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);
    }
  • I don't quite understand what you mean with "monitor the beacon but not range it with the current situation".

    It is possible to scan at the same time that you are connected, but nRF Connect for mobile does not do this at this point in time. What do you want your application to do?

    You advertise with the BLE uart service, and when you connect to it, you start advertising as a beacon. Is this new advertising because you want to measure the distance to the beacon?

    Best regards,

    Edvin

  • Edvin,

    By being able to monitor and not range the beacon I’m referring to the ability of the device to only having the ability to monitor whether the beacon is in the particular region (monitor) as opposed to being able to also determine its exact distance. I’m also having trouble determining how to send data such as the weight readings that are being fed through the A1 port of the nRF device over uart (rx).

    -Hudson

  • Ok. So you need to be able to pick up the beacon advertising packs from another device than the mobile phone when you are connected, then?

    Regarding sending weight readings:

    Could you describe what the problem is? Do you have difficulties getting the readings from the sensor, or do you have problems sending them over the link?

  • Both. I know my sensor works as I have it setup via Arduino but I don’t know where I can access this data on the uart example. Once I get this data, how do I then send it through rx. I’ve been trying to send test strings such as “hello world” just to test this thing out but can’t seem to find where this data should be placed for it to be transferred over rx. 

  • 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

Reply Children
Related