Skip to content

Commit

Permalink
Add more function names and bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
maxikrie committed Feb 7, 2025
1 parent 4ab2ba5 commit 69c2b6e
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 4 deletions.
47 changes: 44 additions & 3 deletions examples/nimble_blecent/nimble_blecent_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ void ble_hci_sock_set_device(int dev);

static int blecent_gap_event(FAR struct ble_gap_event *event, FAR void *arg);

/****************************************************************************
* Private Data
****************************************************************************/

/****************************************************************************
* Name: blecent_on_read
****************************************************************************/

static int
blecent_on_read(uint16_t conn_handle,
FAR const struct ble_gatt_error *error,
Expand All @@ -86,6 +94,10 @@ blecent_on_read(uint16_t conn_handle,
return 0;
}

/****************************************************************************
* Name: blecent_on_write
****************************************************************************/

static int
blecent_on_write(uint16_t conn_handle,
FAR const struct ble_gatt_error *error,
Expand Down Expand Up @@ -117,6 +129,10 @@ blecent_on_subscribe(uint16_t conn_handle,
return 0;
}

/****************************************************************************
* Name: blecent_read_write_subscribe
****************************************************************************/

static void
blecent_read_write_subscribe(FAR const struct peer *peer)
{
Expand Down Expand Up @@ -207,8 +223,13 @@ blecent_read_write_subscribe(FAR const struct peer *peer)
ble_gap_terminate(peer->conn_handle, BLE_ERR_REM_USER_CONN_TERM);
}

/****************************************************************************
* Name: blecent_on_disc_complete
****************************************************************************/

static void
blecent_on_disc_complete(FAR const struct peer *peer, int status,FAR void *arg)
blecent_on_disc_complete(FAR const struct peer *peer, int status,
FAR void *arg)
{
if (status != 0)
{
Expand Down Expand Up @@ -237,8 +258,11 @@ blecent_on_disc_complete(FAR const struct peer *peer, int status,FAR void *arg)
blecent_read_write_subscribe(peer);
}

static void
blecent_scan(void)
/****************************************************************************
* Name: blecent_scan
****************************************************************************/

static void blecent_scan(void)
{
uint8_t own_addr_type;
struct ble_gap_disc_params disc_params;
Expand Down Expand Up @@ -282,6 +306,10 @@ blecent_scan(void)
}
}

/****************************************************************************
* Name: blecent_should_connect
****************************************************************************/

static int
blecent_should_connect(const struct ble_gap_disc_desc *disc)
{
Expand Down Expand Up @@ -318,6 +346,10 @@ blecent_should_connect(const struct ble_gap_disc_desc *disc)
return 0;
}

/****************************************************************************
* Name: blecent_connect_if_interesting
****************************************************************************/

static void
blecent_connect_if_interesting(FAR const struct ble_gap_disc_desc *disc)
{
Expand Down Expand Up @@ -362,6 +394,11 @@ blecent_connect_if_interesting(FAR const struct ble_gap_disc_desc *disc)
disc->addr.type, addr_str(disc->addr.val), rc);
return;
}
}

/****************************************************************************
* Name: blecent_gap_event
****************************************************************************/

static int
blecent_gap_event(FAR struct ble_gap_event *event, FAR void *arg)
Expand Down Expand Up @@ -531,6 +568,10 @@ blecent_on_reset(int reason)
printf("Resetting state; reason=%d\n", reason);
}

/****************************************************************************
* Name: blecent_on_sync
****************************************************************************/

static void
blecent_on_sync(void)
{
Expand Down
22 changes: 21 additions & 1 deletion examples/nimble_bleprph/nimble_bleprph_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ static int bleprph_gap_event(FAR struct ble_gap_event *event, FAR void *arg);
* Private Data
****************************************************************************/

/****************************************************************************
* Name: bleprph_print_conn_desc
****************************************************************************/

static void
bleprph_print_conn_desc(FAR struct ble_gap_conn_desc *desc)
{
Expand All @@ -95,6 +99,10 @@ bleprph_print_conn_desc(FAR struct ble_gap_conn_desc *desc)
desc->sec_state.bonded);
}

/****************************************************************************
* Name: bleprph_advertise
****************************************************************************/

static void bleprph_advertise(void)
{
uint8_t own_addr_type;
Expand Down Expand Up @@ -171,6 +179,10 @@ static void bleprph_advertise(void)
}
}

/****************************************************************************
* Name: bleprph_gap_event
****************************************************************************/

static int
bleprph_gap_event(FAR struct ble_gap_event *event, FAR void *arg)
{
Expand Down Expand Up @@ -283,12 +295,20 @@ bleprph_gap_event(FAR struct ble_gap_event *event, FAR void *arg)
return 0;
}

/****************************************************************************
* Name: bleprph_on_reset
****************************************************************************/

static void
bleprph_on_reset(int reason)
{
printf("Resetting state; reason=%d\n", reason);
}

/****************************************************************************
* Name: bleprph_on_sync
****************************************************************************/

static void
bleprph_on_sync(void)
{
Expand Down Expand Up @@ -413,7 +433,7 @@ int main(int argc, FAR char *argv[])
}

ble_svc_bas_battery_level_set(batt_level);
sleep(1);
usleep(100000);
}

return 0;
Expand Down

0 comments on commit 69c2b6e

Please sign in to comment.