TactilityC: Add context pointers to callbacks, add more symbols to tt_init.cpp
This commit is contained in:
parent
dd0e5bef64
commit
16eba03e49
@ -70,8 +70,8 @@ struct RadioTxPacket {
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef void (*RadioStateCallback)(DeviceId id, RadioState state, void* ctx);
|
typedef void (*RadioStateCallback)(DeviceId id, RadioState state, void* ctx);
|
||||||
typedef void (*RadioTxStateCallback)(RadioTxId id, RadioTxState state);
|
typedef void (*RadioTxStateCallback)(RadioTxId id, RadioTxState state, void* ctx);
|
||||||
typedef void (*RadioOnReceiveCallback)(DeviceId id, const RadioRxPacket* packet);
|
typedef void (*RadioOnReceiveCallback)(DeviceId id, const RadioRxPacket* packet, void* ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate a radio driver object for the specified radioId.
|
* Allocate a radio driver object for the specified radioId.
|
||||||
@ -194,17 +194,19 @@ bool tt_hal_radio_stop(RadioHandle handle);
|
|||||||
* @param[in] handle the radio driver handle
|
* @param[in] handle the radio driver handle
|
||||||
* @param[in] packet packet to send (no special requirement for memory of data)
|
* @param[in] packet packet to send (no special requirement for memory of data)
|
||||||
* @param[in] callback function to call on transmission state change for the packet
|
* @param[in] callback function to call on transmission state change for the packet
|
||||||
|
* @param[in] ctx context which will be passed to the callback function
|
||||||
* @return the identifier for the transmission
|
* @return the identifier for the transmission
|
||||||
*/
|
*/
|
||||||
RadioTxId tt_hal_radio_transmit(RadioHandle handle, RadioTxPacket packet, RadioTxStateCallback callback);
|
RadioTxId tt_hal_radio_transmit(RadioHandle handle, RadioTxPacket packet, RadioTxStateCallback callback, void* ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribe for any received packet that the radio driver object receives.
|
* Subscribe for any received packet that the radio driver object receives.
|
||||||
* @param[in] handle the radio driver handle
|
* @param[in] handle the radio driver handle
|
||||||
* @param[in] callback function to call on reception of a packet
|
* @param[in] callback function to call on reception of a packet
|
||||||
|
* @param[in] ctx context which will be passed to the callback function
|
||||||
* @return the identifier for the subscription
|
* @return the identifier for the subscription
|
||||||
*/
|
*/
|
||||||
RadioRxSubscriptionId tt_hal_radio_subscribe_receive(RadioHandle handle, RadioOnReceiveCallback callback);
|
RadioRxSubscriptionId tt_hal_radio_subscribe_receive(RadioHandle handle, RadioOnReceiveCallback callback, void* ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribe for any state change of the radio driver object.
|
* Subscribe for any state change of the radio driver object.
|
||||||
|
|||||||
@ -39,7 +39,10 @@ extern "C" {
|
|||||||
|
|
||||||
RadioHandle tt_hal_radio_alloc(DeviceId radioId) {
|
RadioHandle tt_hal_radio_alloc(DeviceId radioId) {
|
||||||
auto radio = findValidRadioDevice(radioId);
|
auto radio = findValidRadioDevice(radioId);
|
||||||
return new DeviceWrapper(radio);
|
if (radio != nullptr) {
|
||||||
|
return new DeviceWrapper(radio);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tt_hal_radio_free(RadioHandle handle) {
|
void tt_hal_radio_free(RadioHandle handle) {
|
||||||
@ -116,15 +119,15 @@ extern "C" {
|
|||||||
return wrapper->device->stop();
|
return wrapper->device->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
RadioTxId tt_hal_radio_transmit(RadioHandle handle, RadioTxPacket packet, RadioTxStateCallback callback) {
|
RadioTxId tt_hal_radio_transmit(RadioHandle handle, RadioTxPacket packet, RadioTxStateCallback callback, void* ctx) {
|
||||||
auto wrapper = static_cast<DeviceWrapper*>(handle);
|
auto wrapper = static_cast<DeviceWrapper*>(handle);
|
||||||
auto ttPacket = tt::hal::radio::TxPacket{
|
auto ttPacket = tt::hal::radio::TxPacket{
|
||||||
.data = std::vector<uint8_t>(packet.data, packet.data + packet.size),
|
.data = std::vector<uint8_t>(packet.data, packet.data + packet.size),
|
||||||
.address = packet.address
|
.address = packet.address
|
||||||
};
|
};
|
||||||
return wrapper->device->transmit(ttPacket, [callback](tt::hal::radio::RadioDevice::TxId id, tt::hal::radio::RadioDevice::TransmissionState state) {
|
return wrapper->device->transmit(ttPacket, [callback, ctx](tt::hal::radio::RadioDevice::TxId id, tt::hal::radio::RadioDevice::TransmissionState state) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(id, fromCpp(state));
|
callback(id, fromCpp(state), ctx);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -138,9 +141,9 @@ extern "C" {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
RadioRxSubscriptionId tt_hal_radio_subscribe_receive(RadioHandle handle, RadioOnReceiveCallback callback) {
|
RadioRxSubscriptionId tt_hal_radio_subscribe_receive(RadioHandle handle, RadioOnReceiveCallback callback, void* ctx) {
|
||||||
auto wrapper = static_cast<DeviceWrapper*>(handle);
|
auto wrapper = static_cast<DeviceWrapper*>(handle);
|
||||||
return wrapper->device->subscribeRx([callback](tt::hal::Device::Id id, const tt::hal::radio::RxPacket& ttPacket) {
|
return wrapper->device->subscribeRx([callback, ctx](tt::hal::Device::Id id, const tt::hal::radio::RxPacket& ttPacket) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
auto ttcPacket = RadioRxPacket{
|
auto ttcPacket = RadioRxPacket{
|
||||||
.data = ttPacket.data.data(),
|
.data = ttPacket.data.data(),
|
||||||
@ -148,7 +151,7 @@ extern "C" {
|
|||||||
.rssi = ttPacket.rssi,
|
.rssi = ttPacket.rssi,
|
||||||
.snr = ttPacket.snr
|
.snr = ttPacket.snr
|
||||||
};
|
};
|
||||||
callback(id, &ttcPacket);
|
callback(id, &ttcPacket, ctx);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,6 +62,8 @@ const esp_elfsym elf_symbols[] {
|
|||||||
ESP_ELFSYM_EXPORT(close),
|
ESP_ELFSYM_EXPORT(close),
|
||||||
// time.h
|
// time.h
|
||||||
ESP_ELFSYM_EXPORT(clock_gettime),
|
ESP_ELFSYM_EXPORT(clock_gettime),
|
||||||
|
ESP_ELFSYM_EXPORT(time),
|
||||||
|
ESP_ELFSYM_EXPORT(localtime),
|
||||||
ESP_ELFSYM_EXPORT(strftime),
|
ESP_ELFSYM_EXPORT(strftime),
|
||||||
// pthread
|
// pthread
|
||||||
ESP_ELFSYM_EXPORT(pthread_create),
|
ESP_ELFSYM_EXPORT(pthread_create),
|
||||||
@ -387,7 +389,9 @@ const esp_elfsym elf_symbols[] {
|
|||||||
ESP_ELFSYM_EXPORT(lv_event_get_current_target_obj),
|
ESP_ELFSYM_EXPORT(lv_event_get_current_target_obj),
|
||||||
// lv_color
|
// lv_color
|
||||||
ESP_ELFSYM_EXPORT(lv_color_black),
|
ESP_ELFSYM_EXPORT(lv_color_black),
|
||||||
|
ESP_ELFSYM_EXPORT(lv_color_darken),
|
||||||
ESP_ELFSYM_EXPORT(lv_color_hex),
|
ESP_ELFSYM_EXPORT(lv_color_hex),
|
||||||
|
ESP_ELFSYM_EXPORT(lv_color_lighten),
|
||||||
ESP_ELFSYM_EXPORT(lv_color_make),
|
ESP_ELFSYM_EXPORT(lv_color_make),
|
||||||
// lv_group
|
// lv_group
|
||||||
ESP_ELFSYM_EXPORT(lv_group_add_obj),
|
ESP_ELFSYM_EXPORT(lv_group_add_obj),
|
||||||
@ -413,6 +417,8 @@ const esp_elfsym elf_symbols[] {
|
|||||||
ESP_ELFSYM_EXPORT(lv_obj_get_display),
|
ESP_ELFSYM_EXPORT(lv_obj_get_display),
|
||||||
ESP_ELFSYM_EXPORT(lv_obj_get_height),
|
ESP_ELFSYM_EXPORT(lv_obj_get_height),
|
||||||
ESP_ELFSYM_EXPORT(lv_obj_get_parent),
|
ESP_ELFSYM_EXPORT(lv_obj_get_parent),
|
||||||
|
ESP_ELFSYM_EXPORT(lv_obj_get_scroll_x),
|
||||||
|
ESP_ELFSYM_EXPORT(lv_obj_get_scroll_y),
|
||||||
ESP_ELFSYM_EXPORT(lv_obj_get_style_grid_cell_column_pos),
|
ESP_ELFSYM_EXPORT(lv_obj_get_style_grid_cell_column_pos),
|
||||||
ESP_ELFSYM_EXPORT(lv_obj_get_style_grid_cell_column_span),
|
ESP_ELFSYM_EXPORT(lv_obj_get_style_grid_cell_column_span),
|
||||||
ESP_ELFSYM_EXPORT(lv_obj_get_style_grid_cell_row_pos),
|
ESP_ELFSYM_EXPORT(lv_obj_get_style_grid_cell_row_pos),
|
||||||
@ -431,6 +437,8 @@ const esp_elfsym elf_symbols[] {
|
|||||||
ESP_ELFSYM_EXPORT(lv_obj_remove_event_cb),
|
ESP_ELFSYM_EXPORT(lv_obj_remove_event_cb),
|
||||||
ESP_ELFSYM_EXPORT(lv_obj_remove_flag),
|
ESP_ELFSYM_EXPORT(lv_obj_remove_flag),
|
||||||
ESP_ELFSYM_EXPORT(lv_obj_remove_state),
|
ESP_ELFSYM_EXPORT(lv_obj_remove_state),
|
||||||
|
ESP_ELFSYM_EXPORT(lv_obj_scroll_to_x),
|
||||||
|
ESP_ELFSYM_EXPORT(lv_obj_scroll_to_y),
|
||||||
ESP_ELFSYM_EXPORT(lv_obj_set_align),
|
ESP_ELFSYM_EXPORT(lv_obj_set_align),
|
||||||
ESP_ELFSYM_EXPORT(lv_obj_set_flex_align),
|
ESP_ELFSYM_EXPORT(lv_obj_set_flex_align),
|
||||||
ESP_ELFSYM_EXPORT(lv_obj_set_flex_flow),
|
ESP_ELFSYM_EXPORT(lv_obj_set_flex_flow),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user