99#include <zephyr/bluetooth/audio/bap.h>
1010#include <zephyr/logging/log.h>
1111#include <zephyr/sys/byteorder.h>
12+ #include <zephyr/drivers/gpio.h>
1213
1314#include "webusb.h"
1415#include "message_handler.h"
@@ -80,6 +81,9 @@ static uint32_t ba_source_broadcast_id;
8081static uint8_t ba_source_id ; /* Source ID of the receive state */
8182static struct bt_bap_scan_delegator_recv_state recv_state = {0 };
8283
84+ const struct gpio_dt_spec connLed = GPIO_DT_SPEC_GET (DT_ALIAS (led0 ), gpios );
85+ const struct gpio_dt_spec sinkLed = GPIO_DT_SPEC_GET (DT_ALIAS (led1 ), gpios );
86+
8387/*
8488 * Private functions
8589 */
@@ -250,6 +254,8 @@ static void broadcast_assistant_add_src_cb(struct bt_conn *conn, int err)
250254 net_buf_add_le32 (evt_msg , err );
251255
252256 send_net_buf_event (MESSAGE_SUBTYPE_SOURCE_ADDED , evt_msg );
257+
258+ gpio_pin_set (sinkLed .port , sinkLed .pin , 1 );
253259}
254260
255261static void broadcast_assistant_mod_src_cb (struct bt_conn * conn , int err )
@@ -271,6 +277,7 @@ static void broadcast_assistant_rem_src_cb(struct bt_conn *conn, int err)
271277{
272278 LOG_INF ("BASS remove source (err: %d)" , err );
273279 ba_source_id = 0 ;
280+ gpio_pin_set (sinkLed .port , sinkLed .pin , 0 );
274281}
275282
276283static void connected (struct bt_conn * conn , uint8_t err )
@@ -311,6 +318,8 @@ static void connected(struct bt_conn *conn, uint8_t err)
311318 LOG_ERR ("Setting security failed (err %d)" , err );
312319 }
313320
321+ gpio_pin_set (connLed .port , connLed .pin , 1 );
322+
314323}
315324
316325static void disconnected (struct bt_conn * conn , uint8_t reason )
@@ -879,6 +888,22 @@ int broadcast_assistant_init(void)
879888 bt_bap_broadcast_assistant_register_cb (& broadcast_assistant_callbacks );
880889 LOG_INF ("Bluetooth scan callback registered" );
881890
891+ if (!device_is_ready (connLed .port ) ||
892+ !device_is_ready (sinkLed .port )) {
893+ return -1 ;
894+ }
895+ err = gpio_pin_configure_dt (& connLed , GPIO_OUTPUT_INACTIVE );
896+ if (err < 0 ) {
897+ return err ;
898+ }
899+ err = gpio_pin_configure_dt (& sinkLed , GPIO_OUTPUT_INACTIVE );
900+ if (err < 0 ) {
901+ return err ;
902+ }
903+ gpio_pin_set (connLed .port , connLed .pin , 0 );
904+ gpio_pin_set (sinkLed .port , sinkLed .pin , 0 );
905+ LOG_INF ("LED's initialzed" );
906+
882907 ba_scan_target = 0 ;
883908
884909 return 0 ;
0 commit comments