2020-12-10 14:25:20 +00:00
|
|
|
#include "bt_i.h"
|
|
|
|
|
2021-03-11 09:31:07 +00:00
|
|
|
uint32_t bt_view_exit(void* context) {
|
|
|
|
(void)context;
|
|
|
|
return VIEW_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void bt_update_statusbar(void* arg) {
|
|
|
|
furi_assert(arg);
|
|
|
|
Bt* bt = arg;
|
|
|
|
BtMessage m = {.type = BtMessageTypeUpdateStatusbar};
|
|
|
|
furi_check(osMessageQueuePut(bt->message_queue, &m, 0, osWaitForever) == osOK);
|
|
|
|
}
|
|
|
|
|
2021-06-02 14:09:02 +00:00
|
|
|
void bt_update_param(void* arg) {
|
2021-03-11 09:31:07 +00:00
|
|
|
furi_assert(arg);
|
|
|
|
Bt* bt = arg;
|
2021-06-02 14:09:02 +00:00
|
|
|
BtMessage m;
|
|
|
|
if(bt->state.type == BtStateHoppingTx || bt->state.type == BtStateCarrierRxRunning) {
|
|
|
|
m.type = BtMessageTypeStartTestCarrier;
|
|
|
|
} else if(bt->state.type == BtStatePacketRunning) {
|
|
|
|
m.type = BtMessageTypeStartTestPacketRx;
|
|
|
|
}
|
2021-03-11 09:31:07 +00:00
|
|
|
furi_check(osMessageQueuePut(bt->message_queue, &m, 0, osWaitForever) == osOK);
|
|
|
|
}
|
|
|
|
|
2020-12-10 14:25:20 +00:00
|
|
|
Bt* bt_alloc() {
|
|
|
|
Bt* bt = furi_alloc(sizeof(Bt));
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 16:09:26 +00:00
|
|
|
|
2021-03-11 09:31:07 +00:00
|
|
|
bt->message_queue = osMessageQueueNew(8, sizeof(BtMessage), NULL);
|
|
|
|
bt->update_status_timer = osTimerNew(bt_update_statusbar, osTimerPeriodic, bt, NULL);
|
|
|
|
osTimerStart(bt->update_status_timer, 4000);
|
2021-06-02 14:09:02 +00:00
|
|
|
bt->update_param_timer = osTimerNew(bt_update_param, osTimerPeriodic, bt, NULL);
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 16:09:26 +00:00
|
|
|
bt->gui = furi_record_open("gui");
|
|
|
|
bt->menu = furi_record_open("menu");
|
2020-12-10 14:25:20 +00:00
|
|
|
|
2021-06-02 14:09:02 +00:00
|
|
|
bt->state.type = BtStateReady;
|
2021-03-11 09:31:07 +00:00
|
|
|
bt->state.param.channel = BtChannel2402;
|
|
|
|
bt->state.param.power = BtPower0dB;
|
2021-06-02 14:09:02 +00:00
|
|
|
bt->state.param.datarate = BtDataRate1M;
|
2021-03-11 09:31:07 +00:00
|
|
|
|
2021-01-29 13:52:16 +00:00
|
|
|
bt->statusbar_view_port = view_port_alloc();
|
2021-02-25 10:22:46 +00:00
|
|
|
view_port_set_width(bt->statusbar_view_port, 5);
|
2021-01-29 13:52:16 +00:00
|
|
|
view_port_draw_callback_set(bt->statusbar_view_port, bt_draw_statusbar_callback, bt);
|
|
|
|
view_port_enabled_set(bt->statusbar_view_port, false);
|
|
|
|
gui_add_view_port(bt->gui, bt->statusbar_view_port, GuiLayerStatusBarLeft);
|
2020-12-10 14:25:20 +00:00
|
|
|
|
2021-07-07 08:57:49 +00:00
|
|
|
bt->menu_icon = icon_animation_alloc(&A_Bluetooth_14);
|
2020-12-14 10:50:32 +00:00
|
|
|
bt->menu_item = menu_item_alloc_menu("Bluetooth", bt->menu_icon);
|
2021-03-11 09:31:07 +00:00
|
|
|
menu_item_subitem_add(
|
2021-06-02 14:09:02 +00:00
|
|
|
bt->menu_item, menu_item_alloc_function("Carrier test", NULL, bt_menu_test_carrier, bt));
|
2021-03-11 09:31:07 +00:00
|
|
|
menu_item_subitem_add(
|
|
|
|
bt->menu_item,
|
|
|
|
menu_item_alloc_function("Test packet TX", NULL, bt_menu_test_packet_tx, bt));
|
|
|
|
menu_item_subitem_add(
|
|
|
|
bt->menu_item, menu_item_alloc_function("Start app", NULL, bt_menu_start_app, bt));
|
2021-06-02 14:09:02 +00:00
|
|
|
menu_item_subitem_add(
|
|
|
|
bt->menu_item,
|
|
|
|
menu_item_alloc_function("Test packet RX", NULL, bt_menu_test_packet_rx, bt));
|
2021-03-11 09:31:07 +00:00
|
|
|
|
2021-06-02 14:09:02 +00:00
|
|
|
// Carrier test
|
|
|
|
bt->view_test_carrier = view_alloc();
|
|
|
|
view_set_context(bt->view_test_carrier, bt);
|
|
|
|
view_set_draw_callback(bt->view_test_carrier, bt_view_test_carrier_draw);
|
2021-03-11 09:31:07 +00:00
|
|
|
view_allocate_model(
|
2021-06-02 14:09:02 +00:00
|
|
|
bt->view_test_carrier, ViewModelTypeLocking, sizeof(BtViewTestCarrierModel));
|
|
|
|
view_set_input_callback(bt->view_test_carrier, bt_view_test_carrier_input);
|
|
|
|
|
|
|
|
// Packet TX test
|
2021-03-11 09:31:07 +00:00
|
|
|
bt->view_test_packet_tx = view_alloc();
|
|
|
|
view_set_context(bt->view_test_packet_tx, bt);
|
|
|
|
view_set_draw_callback(bt->view_test_packet_tx, bt_view_test_packet_tx_draw);
|
|
|
|
view_allocate_model(
|
|
|
|
bt->view_test_packet_tx, ViewModelTypeLocking, sizeof(BtViewTestPacketTxModel));
|
|
|
|
view_set_input_callback(bt->view_test_packet_tx, bt_view_test_packet_tx_input);
|
2021-06-02 14:09:02 +00:00
|
|
|
|
|
|
|
// Packet RX test
|
|
|
|
bt->view_test_packet_rx = view_alloc();
|
|
|
|
view_set_context(bt->view_test_packet_rx, bt);
|
|
|
|
view_set_draw_callback(bt->view_test_packet_rx, bt_view_test_packet_rx_draw);
|
|
|
|
view_allocate_model(
|
|
|
|
bt->view_test_packet_rx, ViewModelTypeLocking, sizeof(BtViewTestPacketRxModel));
|
|
|
|
view_set_input_callback(bt->view_test_packet_rx, bt_view_test_packet_rx_input);
|
|
|
|
|
|
|
|
// Start app
|
2021-03-11 09:31:07 +00:00
|
|
|
bt->view_start_app = view_alloc();
|
|
|
|
view_set_context(bt->view_start_app, bt);
|
|
|
|
view_set_draw_callback(bt->view_start_app, bt_view_app_draw);
|
|
|
|
view_set_previous_callback(bt->view_start_app, bt_view_exit);
|
2021-06-02 14:09:02 +00:00
|
|
|
|
|
|
|
// View dispatcher
|
2021-03-11 09:31:07 +00:00
|
|
|
bt->view_dispatcher = view_dispatcher_alloc();
|
2021-06-02 14:09:02 +00:00
|
|
|
view_dispatcher_add_view(bt->view_dispatcher, BtViewTestCarrier, bt->view_test_carrier);
|
2021-03-11 09:31:07 +00:00
|
|
|
view_dispatcher_add_view(bt->view_dispatcher, BtViewTestPacketTx, bt->view_test_packet_tx);
|
2021-06-02 14:09:02 +00:00
|
|
|
view_dispatcher_add_view(bt->view_dispatcher, BtViewTestPacketRx, bt->view_test_packet_rx);
|
2021-03-11 09:31:07 +00:00
|
|
|
view_dispatcher_add_view(bt->view_dispatcher, BtViewStartApp, bt->view_start_app);
|
|
|
|
|
|
|
|
Gui* gui = furi_record_open("gui");
|
|
|
|
view_dispatcher_attach_to_gui(bt->view_dispatcher, gui, ViewDispatcherTypeFullscreen);
|
|
|
|
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 16:09:26 +00:00
|
|
|
with_value_mutex(
|
|
|
|
bt->menu, (Menu * menu) { menu_item_add(menu, bt->menu_item); });
|
2020-12-10 14:25:20 +00:00
|
|
|
return bt;
|
|
|
|
}
|
|
|
|
|
2020-12-14 10:50:32 +00:00
|
|
|
void bt_draw_statusbar_callback(Canvas* canvas, void* context) {
|
2021-07-07 08:57:49 +00:00
|
|
|
canvas_draw_icon(canvas, 0, 0, &I_Bluetooth_5x8);
|
2020-12-10 14:25:20 +00:00
|
|
|
}
|
|
|
|
|
2021-06-02 14:09:02 +00:00
|
|
|
void bt_menu_test_carrier(void* context) {
|
2021-03-11 09:31:07 +00:00
|
|
|
furi_assert(context);
|
|
|
|
Bt* bt = context;
|
2021-06-02 14:09:02 +00:00
|
|
|
bt->state.type = BtStateCarrierTx;
|
2021-03-11 09:31:07 +00:00
|
|
|
BtMessage message = {
|
2021-06-02 14:09:02 +00:00
|
|
|
.type = BtMessageTypeStartTestCarrier,
|
2021-03-11 09:31:07 +00:00
|
|
|
.param.channel = bt->state.param.channel,
|
|
|
|
.param.power = bt->state.param.power};
|
|
|
|
furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
|
|
|
|
}
|
|
|
|
|
|
|
|
void bt_menu_test_packet_tx(void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
Bt* bt = context;
|
2021-06-02 14:09:02 +00:00
|
|
|
bt->state.type = BtStatePacketSetup;
|
2021-03-11 09:31:07 +00:00
|
|
|
BtMessage message = {
|
|
|
|
.type = BtMessageTypeSetupTestPacketTx,
|
|
|
|
.param.channel = bt->state.param.channel,
|
|
|
|
.param.datarate = bt->state.param.datarate};
|
|
|
|
furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
|
|
|
|
}
|
|
|
|
|
2021-06-02 14:09:02 +00:00
|
|
|
void bt_menu_test_packet_rx(void* context) {
|
2021-03-11 09:31:07 +00:00
|
|
|
furi_assert(context);
|
|
|
|
Bt* bt = context;
|
2021-06-02 14:09:02 +00:00
|
|
|
bt->state.type = BtStatePacketSetup;
|
2021-03-11 09:31:07 +00:00
|
|
|
BtMessage message = {
|
2021-06-02 14:09:02 +00:00
|
|
|
.type = BtMessageTypeSetupTestPacketRx,
|
2021-03-11 09:31:07 +00:00
|
|
|
.param.channel = bt->state.param.channel,
|
2021-06-02 14:09:02 +00:00
|
|
|
.param.datarate = bt->state.param.datarate};
|
2021-03-11 09:31:07 +00:00
|
|
|
furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
|
|
|
|
}
|
|
|
|
|
|
|
|
void bt_menu_start_app(void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
Bt* bt = context;
|
2021-06-02 14:09:02 +00:00
|
|
|
bt->state.type = BtStateStartedApp;
|
2021-03-11 09:31:07 +00:00
|
|
|
BtMessage message = {.type = BtMessageTypeStartApp};
|
|
|
|
furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
|
|
|
|
}
|
|
|
|
|
2021-08-07 16:54:42 +00:00
|
|
|
int32_t bt_srv() {
|
2020-12-10 14:25:20 +00:00
|
|
|
Bt* bt = bt_alloc();
|
|
|
|
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 16:09:26 +00:00
|
|
|
furi_record_create("bt", bt);
|
2020-12-10 14:25:20 +00:00
|
|
|
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_bt_init();
|
2021-03-11 09:31:07 +00:00
|
|
|
BtMessage message;
|
2020-12-10 14:25:20 +00:00
|
|
|
while(1) {
|
2021-03-11 09:31:07 +00:00
|
|
|
furi_check(osMessageQueueGet(bt->message_queue, &message, NULL, osWaitForever) == osOK);
|
2021-06-02 14:09:02 +00:00
|
|
|
if(message.type == BtMessageTypeStartTestCarrier) {
|
|
|
|
// Start carrier test
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_bt_stop_tone_tx();
|
2021-06-02 14:09:02 +00:00
|
|
|
if(bt->state.type == BtStateCarrierTx) {
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_bt_start_tone_tx(message.param.channel, message.param.power);
|
2021-06-02 14:09:02 +00:00
|
|
|
} else if(bt->state.type == BtStateHoppingTx) {
|
2021-03-11 09:31:07 +00:00
|
|
|
bt->state.param.channel =
|
|
|
|
bt_switch_channel(InputKeyRight, bt->state.param.channel);
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_bt_start_tone_tx(bt->state.param.channel, bt->state.param.power);
|
2021-06-02 14:09:02 +00:00
|
|
|
} else if(bt->state.type == BtStateCarrierRxStart) {
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_bt_start_packet_rx(bt->state.param.channel, bt->state.param.datarate);
|
2021-06-02 14:09:02 +00:00
|
|
|
bt->state.type = BtStateCarrierRxRunning;
|
|
|
|
} else if(bt->state.type == BtStateCarrierRxRunning) {
|
2021-08-08 18:03:25 +00:00
|
|
|
bt->state.param.rssi = furi_hal_bt_get_rssi();
|
2021-03-11 09:31:07 +00:00
|
|
|
}
|
|
|
|
with_view_model(
|
2021-06-02 14:09:02 +00:00
|
|
|
bt->view_test_carrier, (BtViewTestCarrierModel * model) {
|
2021-03-11 09:31:07 +00:00
|
|
|
model->type = bt->state.type;
|
|
|
|
model->channel = bt->state.param.channel;
|
|
|
|
model->power = bt->state.param.power;
|
2021-06-02 14:09:02 +00:00
|
|
|
model->rssi = bt->state.param.rssi;
|
2021-03-11 09:31:07 +00:00
|
|
|
return true;
|
|
|
|
});
|
2021-06-02 14:09:02 +00:00
|
|
|
view_dispatcher_switch_to_view(bt->view_dispatcher, BtViewTestCarrier);
|
|
|
|
} else if(message.type == BtMessageTypeStopTestCarrier) {
|
|
|
|
if(bt->state.type == BtStateCarrierRxRunning) {
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_bt_stop_packet_test();
|
2021-06-02 14:09:02 +00:00
|
|
|
} else {
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_bt_stop_tone_tx();
|
2021-06-02 14:09:02 +00:00
|
|
|
}
|
|
|
|
bt->state.type = BtStateReady;
|
2021-03-11 09:31:07 +00:00
|
|
|
} else if(message.type == BtMessageTypeSetupTestPacketTx) {
|
|
|
|
// Update packet test setup
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_bt_stop_packet_test();
|
2021-03-11 09:31:07 +00:00
|
|
|
with_view_model(
|
|
|
|
bt->view_test_packet_tx, (BtViewTestPacketTxModel * model) {
|
|
|
|
model->type = bt->state.type;
|
|
|
|
model->channel = bt->state.param.channel;
|
|
|
|
model->datarate = bt->state.param.datarate;
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
view_dispatcher_switch_to_view(bt->view_dispatcher, BtViewTestPacketTx);
|
|
|
|
} else if(message.type == BtMessageTypeStartTestPacketTx) {
|
|
|
|
// Start sending packets
|
2021-06-02 14:09:02 +00:00
|
|
|
if(bt->state.type == BtStatePacketStart) {
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_bt_start_packet_tx(message.param.channel, 1, message.param.datarate);
|
2021-06-02 14:09:02 +00:00
|
|
|
} else if(bt->state.type == BtStatePacketSetup) {
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_bt_stop_packet_test();
|
|
|
|
bt->state.param.packets_sent = furi_hal_bt_get_transmitted_packets();
|
2021-06-02 14:09:02 +00:00
|
|
|
}
|
2021-03-11 09:31:07 +00:00
|
|
|
with_view_model(
|
|
|
|
bt->view_test_packet_tx, (BtViewTestPacketTxModel * model) {
|
|
|
|
model->type = bt->state.type;
|
|
|
|
model->channel = bt->state.param.channel;
|
|
|
|
model->datarate = bt->state.param.datarate;
|
2021-06-02 14:09:02 +00:00
|
|
|
model->packets_sent = bt->state.param.packets_sent;
|
2021-03-11 09:31:07 +00:00
|
|
|
return true;
|
|
|
|
});
|
|
|
|
view_dispatcher_switch_to_view(bt->view_dispatcher, BtViewTestPacketTx);
|
2021-06-02 14:09:02 +00:00
|
|
|
} else if(message.type == BtMessageTypeSetupTestPacketRx) {
|
|
|
|
// Update packet test setup
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_bt_stop_packet_test();
|
2021-06-02 14:09:02 +00:00
|
|
|
with_view_model(
|
|
|
|
bt->view_test_packet_rx, (BtViewTestPacketRxModel * model) {
|
|
|
|
model->type = bt->state.type;
|
|
|
|
model->channel = bt->state.param.channel;
|
|
|
|
model->datarate = bt->state.param.datarate;
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
view_dispatcher_switch_to_view(bt->view_dispatcher, BtViewTestPacketRx);
|
|
|
|
} else if(message.type == BtMessageTypeStartTestPacketRx) {
|
2021-03-11 09:31:07 +00:00
|
|
|
// Start test rx
|
2021-06-02 14:09:02 +00:00
|
|
|
if(bt->state.type == BtStatePacketStart) {
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_bt_start_packet_rx(message.param.channel, message.param.datarate);
|
2021-06-02 14:09:02 +00:00
|
|
|
bt->state.type = BtStatePacketRunning;
|
|
|
|
} else if(bt->state.type == BtStatePacketRunning) {
|
2021-08-08 18:03:25 +00:00
|
|
|
bt->state.param.rssi = furi_hal_bt_get_rssi();
|
2021-06-02 14:09:02 +00:00
|
|
|
} else if(bt->state.type == BtStatePacketSetup) {
|
2021-08-08 18:03:25 +00:00
|
|
|
bt->state.param.packets_received = furi_hal_bt_stop_packet_test();
|
2021-06-02 14:09:02 +00:00
|
|
|
}
|
2021-03-11 09:31:07 +00:00
|
|
|
with_view_model(
|
2021-06-02 14:09:02 +00:00
|
|
|
bt->view_test_packet_rx, (BtViewTestPacketRxModel * model) {
|
|
|
|
model->type = bt->state.type;
|
2021-03-11 09:31:07 +00:00
|
|
|
model->channel = bt->state.param.channel;
|
2021-06-02 14:09:02 +00:00
|
|
|
model->datarate = bt->state.param.datarate;
|
|
|
|
model->packets_received = bt->state.param.packets_received;
|
|
|
|
model->rssi = bt->state.param.rssi;
|
2021-03-11 09:31:07 +00:00
|
|
|
return true;
|
|
|
|
});
|
2021-06-02 14:09:02 +00:00
|
|
|
view_dispatcher_switch_to_view(bt->view_dispatcher, BtViewTestPacketRx);
|
|
|
|
} else if(message.type == BtMessageTypeStopTestPacket) {
|
|
|
|
// Stop test packet tx
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_bt_stop_packet_test();
|
2021-06-02 14:09:02 +00:00
|
|
|
bt->state.type = BtStateReady;
|
2021-03-11 09:31:07 +00:00
|
|
|
} else if(message.type == BtMessageTypeStartApp) {
|
|
|
|
// Start app
|
|
|
|
view_dispatcher_switch_to_view(bt->view_dispatcher, BtViewStartApp);
|
2021-08-08 18:03:25 +00:00
|
|
|
if(furi_hal_bt_start_app()) {
|
2021-06-02 14:09:02 +00:00
|
|
|
bt->state.type = BtStateStartedApp;
|
2021-03-11 09:31:07 +00:00
|
|
|
}
|
|
|
|
} else if(message.type == BtMessageTypeUpdateStatusbar) {
|
|
|
|
// Update statusbar
|
2021-08-08 18:03:25 +00:00
|
|
|
view_port_enabled_set(bt->statusbar_view_port, furi_hal_bt_is_alive());
|
2021-03-11 09:31:07 +00:00
|
|
|
}
|
2020-12-10 14:25:20 +00:00
|
|
|
}
|
2021-02-12 17:24:34 +00:00
|
|
|
return 0;
|
2020-12-10 14:25:20 +00:00
|
|
|
}
|