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

how to enable bidirectional comunication on my nrf51822

Hi,

I'm using the nrf51822 and I want to merge Server and Client roles in one Peripheral device. I am already able to send a history of temperature and humidity measurements to my phone, but I don't have possibility to set measurement period in my phone and send this parameter to nrf51. It seems to me that only reasonable way to do it is to convert GATT role of nrf51, to be Server and Client in the same time. In other words, besides sending characteristics from nrf51, I also must read them. Unfortunately, I can't find any example or even clues how to do it. Only example that brings up the issue of setting GATT role is that one: devzone.nordicsemi.com/questi... but it relates to other SoftDevice, and purpose of this application is quite different. I use S130 SoftDevice and SDK 11. I would be grateful for any advice.

Parents
  • Hi!

    we also use S130 to act as peripheral and central at the same time.

    You have to start scanning as well as setup advertising. Stack will automatically listen for connects 8=>on_connected event) and you can perform your own connects when you receive an advertising event.

    When you receive a CONNECTED event, you can check your role - e.g.:

    if(p_ble_evt->evt.gap_evt.params.connected.role == BLE_GAP_ROLE_PERIPH) {
    // we are peripheral
    } else {
    // we are central
    }
    

    greetings, Michael

  • That isn't exactly what I want to do. In my application, nrf51 should be peripheral all the time, and smartphone should be central, because smartphone oughts to start the connection. But during the connection I want to enable ability of reading data sending from smartphone by my nrf51. Talking more conventionally, I don't want to change GAP roles in my application, I want to nrf51 can smoothly swap its GATT role from Server to Client and vice-versa or rather simply play both roles simultaneously.

Reply
  • That isn't exactly what I want to do. In my application, nrf51 should be peripheral all the time, and smartphone should be central, because smartphone oughts to start the connection. But during the connection I want to enable ability of reading data sending from smartphone by my nrf51. Talking more conventionally, I don't want to change GAP roles in my application, I want to nrf51 can smoothly swap its GATT role from Server to Client and vice-versa or rather simply play both roles simultaneously.

Children
No Data
Related