diff --git a/TactilityC/Include/tt_hal_radio.h b/TactilityC/Include/tt_hal_radio.h index 6f60c9ee..ed994c2a 100644 --- a/TactilityC/Include/tt_hal_radio.h +++ b/TactilityC/Include/tt_hal_radio.h @@ -70,8 +70,8 @@ struct RadioTxPacket { }; typedef void (*RadioStateCallback)(DeviceId id, RadioState state, void* ctx); -typedef void (*RadioTxStateCallback)(RadioTxId id, RadioTxState state); -typedef void (*RadioOnReceiveCallback)(DeviceId id, const RadioRxPacket* packet); +typedef void (*RadioTxStateCallback)(RadioTxId id, RadioTxState state, void* ctx); +typedef void (*RadioOnReceiveCallback)(DeviceId id, const RadioRxPacket* packet, void* ctx); /** * 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] 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] ctx context which will be passed to the callback function * @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. * @param[in] handle the radio driver handle * @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 */ -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. diff --git a/TactilityC/Source/tt_hal_radio.cpp b/TactilityC/Source/tt_hal_radio.cpp index 8cf71208..e308b7fa 100644 --- a/TactilityC/Source/tt_hal_radio.cpp +++ b/TactilityC/Source/tt_hal_radio.cpp @@ -39,7 +39,10 @@ extern "C" { RadioHandle tt_hal_radio_alloc(DeviceId 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) { @@ -116,15 +119,15 @@ extern "C" { 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(handle); auto ttPacket = tt::hal::radio::TxPacket{ .data = std::vector(packet.data, packet.data + packet.size), .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) { - 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(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) { auto ttcPacket = RadioRxPacket{ .data = ttPacket.data.data(), @@ -148,7 +151,7 @@ extern "C" { .rssi = ttPacket.rssi, .snr = ttPacket.snr }; - callback(id, &ttcPacket); + callback(id, &ttcPacket, ctx); } }); } diff --git a/TactilityC/Source/tt_init.cpp b/TactilityC/Source/tt_init.cpp index 649876d7..68f1c945 100644 --- a/TactilityC/Source/tt_init.cpp +++ b/TactilityC/Source/tt_init.cpp @@ -62,6 +62,8 @@ const esp_elfsym elf_symbols[] { ESP_ELFSYM_EXPORT(close), // time.h ESP_ELFSYM_EXPORT(clock_gettime), + ESP_ELFSYM_EXPORT(time), + ESP_ELFSYM_EXPORT(localtime), ESP_ELFSYM_EXPORT(strftime), // pthread ESP_ELFSYM_EXPORT(pthread_create), @@ -387,7 +389,9 @@ const esp_elfsym elf_symbols[] { ESP_ELFSYM_EXPORT(lv_event_get_current_target_obj), // lv_color ESP_ELFSYM_EXPORT(lv_color_black), + ESP_ELFSYM_EXPORT(lv_color_darken), ESP_ELFSYM_EXPORT(lv_color_hex), + ESP_ELFSYM_EXPORT(lv_color_lighten), ESP_ELFSYM_EXPORT(lv_color_make), // lv_group 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_height), 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_span), 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_flag), 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_flex_align), ESP_ELFSYM_EXPORT(lv_obj_set_flex_flow),