This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf52840 BLE peripheral connection for data transfer managing

Hello Nordic

 

I am using nrf52840, SDK 16.0,

I wish to implement Ble peripheral that advertise a connection request (if no response from central after x seconds then I go to sleep and try few minutes later). After connection has established I need to manage data transfer to the central gateway (also nrf52840)

  1. Is there an example that I can learn from as for how to manage a connection (only connection, not pairing etc.) ?
  2. Also since most examples are written in an event driven way which is great but really hard to flow the code since breakpoints tend to crash the app, is there some explanation somewhere or guide/tutorials for peripheral connection for data of various sizes ?
  3. Starting to play with the peripheral ble_app_blinky I saw that if I try to change the advertise timeout I stop seeing the advertise in the nrf connect cellphone application, why is that ?

 

#define APP_ADV_DURATION                30//BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED   /**< The advertising time-out (in units of seconds). When set to 0, we will never time out. */

hope to read from you soon

best regards

Ziv

Parents
  • Hi Ziv, 

    1. I would suggest to have a look at the ble_app_uart example. In the example we show cased how you can handle a BLE connection without using peer_manager library. However I would strongly suggest you to use peer_manager in your application. You can choose not to support pairing with peer_manager if you want. 

    2. Base your application on ble_app_uart would be the best option for you. 

    3. When you change APP_ADV_DURATION to 30 it will advertise in only 300ms. The   adv_params.duration  unit is 10ms not 1s as in the comment (please have a look at the ble_gap_adv_params_t struct in ble_gap.h) . I have reported this bug earlier but we haven't got it fixed yet. 

  • hi Hung

    When you change APP_ADV_DURATION to 30 it will advertise in only 300ms.

    i also tried with 3000 instead of 30 cause i thought there might be an issue there, it also did not work 

    In the example we show cased how you can handle a BLE connection without using peer_manager library.

    when reading the explanation for that example it is written "peer" all the time so i don't really understand,

    also there is something more basic that i don't get from the example: 

    to my understanding, if i am the peripheral, then first i broadcast myself, then the central can respond to my broadcast and we initiate a connection.

    in which function i get indication that a connection was established, is the broadcast timeout includes the time it takes to establish the connection, or there is a different timeout for that ?

    who enables the Notifications which to my understanding enables data transfer, is it the central or the peripheral ? 

    if the central is the one who enables the notification, how do i know that the notification is enabled, and what happens if i try to send data via "ble_nus_data_send(...)" (if this is indeed the right function to use?) when the notifications is not enabled ?

    hope to read from you soon

    best regards

    Ziv

Reply
  • hi Hung

    When you change APP_ADV_DURATION to 30 it will advertise in only 300ms.

    i also tried with 3000 instead of 30 cause i thought there might be an issue there, it also did not work 

    In the example we show cased how you can handle a BLE connection without using peer_manager library.

    when reading the explanation for that example it is written "peer" all the time so i don't really understand,

    also there is something more basic that i don't get from the example: 

    to my understanding, if i am the peripheral, then first i broadcast myself, then the central can respond to my broadcast and we initiate a connection.

    in which function i get indication that a connection was established, is the broadcast timeout includes the time it takes to establish the connection, or there is a different timeout for that ?

    who enables the Notifications which to my understanding enables data transfer, is it the central or the peripheral ? 

    if the central is the one who enables the notification, how do i know that the notification is enabled, and what happens if i try to send data via "ble_nus_data_send(...)" (if this is indeed the right function to use?) when the notifications is not enabled ?

    hope to read from you soon

    best regards

    Ziv

Children
No Data
Related