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

UART + non-connectable advertisement

I am trying to broadcast a non-connectable advertisement (such as a beacon) while I am connected to a device that I am transferring data via TX. I am working with a nRF52840 on Segger Embedded Studio v3.4 with the nRF5_SDK_15 as the base for my code manipulation. More specifically I'm going off the ble_app_uart example for pca10040 s132. I don't care about receiving data through RX from the device I am connected to. By the way, I have tried using the Time Slot API where I try to initiate the advertising of the beacon when the device connects through UART. It is my understanding from projects such as the nRF51-multi-role-protocol-conn-observer-advertiser example on github but this is for nrf51 devices. I have tried to mimick this project as well as articles showing how the time slot api can be used to implement non-connectable advertising during a connection as a peripheral. I have also tried doing this without the Time Slot API but to no avail. My thinking is that the buffer transferring data out of the device can only handle 31 bytes of data per interval, but both the advertising and uart protocols take up 31 bytes so its not possible to do at the same time. There must be a way to switch between the two protocols (uart and advertisement) when the radio interrupt occurs. Please help.

Parents
  • Hello,

    When you say: "while I am connected to a device that I am transferring data via TX". Do you mean a physical UART, or UART over BLE (Nordic Uart Service/NUS)?

     

    Either way, I don't think you have to use the Timeslot API. You can connect to a device, and start advertising again. You can also start advertising non-connectable while in a connection. All you need to do is to wait for the connected event, set up a non-connectable advertising set (like it is done in the beacon examples), and start advertising again. However, you can't advertise with two advertising sets at the same time. If you want to advertise with the non-connectable advertising at the same time as regular/connectable advertising (for the NUS service), you must manually swap between these, but that is absolutely doable.

     

    So do you want to advertise with the non-connectable advertisements while in a BLE connection, or while connected to the physical UART?

     

    Best regards,

    Edvin

  • Thanks for getting back Edvin,

    I am referring to UART over BLE such as with the ble_app_uart example. What I tried that is pretty much what you are saying. I took the advertising_init and advertising_start methods from the ble_app_uart example and changed their names (advertising_init_beacon and advertising_start_beacon), brought them into the the ble_app_uart example, and when the gap_evt signals that a connection has been initiated, I call the advertising_init_beacon and advertising_start_beacon methods for the beacon in that order. It's failing after I'm calling this method:

    sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);

    which is at the end of the advertising_init_beacon method. This is the entire method:

    static void advertising_init_beacon(void)
    {
    uint32_t err_code; ble_advdata_t advdata; uint8_t flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED; ble_advdata_manuf_data_t manuf_specific_data; manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER; manuf_specific_data.data.p_data = (uint8_t *) m_beacon_info; manuf_specific_data.data.size = APP_BEACON_INFO_LENGTH; // Build and set advertising data. memset(&advdata, 0, sizeof(advdata)); advdata.name_type = BLE_ADVDATA_NO_NAME; advdata.flags = flags; advdata.p_manuf_specific_data = &manuf_specific_data; // Initialize advertising parameters (used when starting advertising). memset(&m_adv_params, 0, sizeof(m_adv_params)); m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED; m_adv_params.p_peer_addr = NULL; // Undirected advertisement. m_adv_params.filter_policy = BLE_GAP_ADV_FP_ANY; m_adv_params.interval = NON_CONNECTABLE_ADV_INTERVAL; m_adv_params.duration = 0; // Never time out. err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len); APP_ERROR_CHECK(err_code);
        err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
        APP_ERROR_CHECK(err_code);
    }
  • Look at the test guide for the ble_app_uart example:

    http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.0.0%2Fble_sdk_app_nus_eval.html&anchor=project_uart_nus_eval_test

    You can use a terminal, like Termite to send strings to the nRF. Then use nRF Toolbox or nRF Connect for mobile to receive the data. You need to enable notifications if you use nRF Connect for mobile to see the data. See the guide on how to do that.

    BR,

    Edvin

  • I’ve read through the tutorial and performed it fine, but my problem is doing the transfer of data over rx from within the code. This is because I will have a weight and temp sensor connected to my nRF52 device and will be sending the data it is receiving to send over UART to the iPhone.

  • I’ve read through the tutorial and performed it fine, but my problem is doing the transfer of data over rx from within the code. This is because I will have a weight and temp sensor connected to my nRF52 device and will be sending the data it is receiving to send over UART to the iPhone.

  • And the problem is... ?

    Are you getting values from your sensor, which are transferred? You don't want that? You want to process the sensor data before sending it? I am only guessing here. It would be easier if you describe the issue.

  • The problem is that I don't know how to read the data from the sensors, and even if I were able to get this data, I don't know how I could send this data over UART. I know the sensors are setup properly and the device is capable of doing this because I have successfully done this through the Arduino IDE. 

Reply Children
Related