Skip to content

Commit

Permalink
first scan/connect to sink
Browse files Browse the repository at this point in the history
  • Loading branch information
ldab committed Jul 8, 2024
1 parent 9c6746e commit 5c002ed
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions app/src/applications/lea_assistant/lea_assistant_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,39 +42,39 @@ static void close_app(void)
zsw_app_manager_app_close_request(&app);
}

static void on_sink_selected(lea_assistant_device_t *device)
static void on_source_selected(lea_assistant_device_t *device)
{
LOG_DBG("Sink %s selected", device->name);
LOG_DBG("Source %s selected", device->name);

// Could use `MESSAGE_SUBTYPE_CONNECT_SINK`, but calling it directly so don't need to fill buffer and parse LTV
connect_to_sink(&device->addr);
// Could use `MESSAGE_SUBTYPE_ADD_SOURCE`, but calling it directly so don't need to fill buffer and parse LTV
add_source(device->sid, device->pa_interval, device->broadcast_id, &device->addr);
close_app();
}

static void on_source_selected(lea_assistant_device_t *device)
static void on_sink_selected(lea_assistant_device_t *device)
{
LOG_DBG("Source %s selected", device->name);
LOG_DBG("Sink %s selected", device->name);

message_handler(&(struct webusb_message ) {
.sub_type = MESSAGE_SUBTYPE_STOP_SCAN
}, 0);

message_handler(&(struct webusb_message ) {
.sub_type = MESSAGE_SUBTYPE_START_SINK_SCAN
.sub_type = MESSAGE_SUBTYPE_START_SOURCE_SCAN
}, 0);

// Could use `MESSAGE_SUBTYPE_ADD_SOURCE`, but calling it directly so don't need to fill buffer and parse LTV
add_source(device->sid, device->pa_interval, device->broadcast_id, &device->addr);
lea_assistant_ui_show_sink(on_sink_selected);
// Could use `MESSAGE_SUBTYPE_CONNECT_SINK`, but calling it directly so don't need to fill buffer and parse LTV
connect_to_sink(&device->addr);
lea_assistant_ui_show_source(on_source_selected);
}

static void lea_assistant_app_start(lv_obj_t *root, lv_group_t *group)
{
LOG_DBG("LEA Assistant app start");
message_handler(&(struct webusb_message ) {
.sub_type = MESSAGE_SUBTYPE_START_SOURCE_SCAN
.sub_type = MESSAGE_SUBTYPE_START_SINK_SCAN
}, 0);
lea_assistant_ui_show(root, on_source_selected, close_app);
lea_assistant_ui_show(root, on_sink_selected, close_app);
}

static void lea_assistant_app_stop(void)
Expand Down
2 changes: 1 addition & 1 deletion app/src/applications/lea_assistant/lea_assistant_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void lea_assistant_ui_show(lv_obj_t *root, on_button_press_cb_t on_button_click_
page_init(root, "Audio source:");
}

void lea_assistant_ui_show_sink(on_button_press_cb_t on_button_click_cb)
void lea_assistant_ui_show_source(on_button_press_cb_t on_button_click_cb)
{
if (root_page != NULL) {
lv_obj_del(root_page);
Expand Down
2 changes: 1 addition & 1 deletion app/src/applications/lea_assistant/lea_assistant_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ typedef void(*on_close_cb_t)(void);

void lea_assistant_ui_show(lv_obj_t *root, on_button_press_cb_t on_button_click_cb, on_close_cb_t close_cb);

void lea_assistant_ui_show_sink(on_button_press_cb_t on_button_click_cb);
void lea_assistant_ui_show_source(on_button_press_cb_t on_button_click_cb);

void lea_assistant_ui_add_list_entry(lea_assistant_device_t *device);

Expand Down

0 comments on commit 5c002ed

Please sign in to comment.