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);
    }
  • Edvin,

    I'm having trouble working with the nRF Connect application on my Mac. I have the bluetooth device connected to my Mac via J-Link and the error I am receiving is:

    Error while setting up device 000801001102: No serial port available for device with serial number 000801001102

    -Hudson

  • Hello Hudson,

    Just to clarify a couple of things. The device that you are trying to use with nRF Connect is not the same as the one you try to program your uart + beacon application to, right?

    And the device that you are using with nRF Connect, is that a nRF DK or nRF Dongle?

    -Edvin

  • Edvin,

    No it’s the same device I’ve been using. 

    -Hudson

  • Well. When you program a device with the application used in nRF Connect, it will overwrite everything that is already on there, so you need an extra DK or Dongle in order to use nRF Connect for Desktop. 

    However, you shouldn't need that. If you have two cellphones, this should be possible.

    Program your DK with the application that you wrote, then open nRF Connect on both phones. Connect to the device with one phone, and after that start scanning with the other phone. You should see the beacon advertisements.

    Best regards,

    Edvin

  • Edvin,

    The only issue with doing what you said is that I don’t have two phones, and the requirement for my project is for this to be done on one phone. Correct me if I’m wrong but I’ll be able to monitor the beacon but not range it with the current situation (using one phone) which is all I need to have happen.

    -Hudson

Reply Children
Related