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

How to make a simple unconnected Broadcaster ?

Hello everyone,

I would like to make an unconnected broadcaster to send data to the advertising channels ... I come from a X-NUCLEO-IDB05A1 board and that's has been pretty simple. It is just need to use a function and determine the interval of broadcast and pass the data to this function.

Are there an easy way to do that with the powerful nRF-52840 PDK ?

The "ble_app_alert_notification" example seems to do what I expect. Maybe, it could be a good starting point to understand the Nordic environment.

Thank you,

Sylvain.

Parents
  • Hi,

    If you only want to broadcast information and be non-connectable, I think the beacon example is what you are looking for. Yes, you should be able to implement BLE beacons on the nRF52840. Have a look at this post on devzone, there is also a beacon example attached. It is updated for SDK14.1 and should work with the nRF52840. 

     

  • Yes I have used this example as It's said as in other post. But I have few trouble when I try to modify the payload. I juste want to send a payload like that :

    #define PAYLOAD_LENGTH  0x04
    char payload [PAYLOAD_LENGTH] = {0xFF,0xFF,0xFF,0xFF};

    So I modified this function :
    static void advertising_init(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;
        
        memset(&manuf_specific_data, 0, sizeof(manuf_specific_data));
    
        manuf_specific_data.data.p_data = (char *) payload;
        manuf_specific_data.data.size = PAYLOAD_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;
    
        //Set uniquely the advertising data not the scan response data
        err_code = ble_advdata_set(&advdata, NULL);
        APP_ERROR_CHECK(err_code);
    
        // Initialize advertising parameters (used when starting advertising).
        memset(&m_adv_params, 0, sizeof(m_adv_params));
    
        m_adv_params.type        = BLE_GAP_ADV_TYPE_ADV_NONCONN_IND;
        m_adv_params.p_peer_addr = NULL;    // Undirected advertisement.
        m_adv_params.fp          = BLE_GAP_ADV_FP_ANY;
        m_adv_params.interval    = NON_CONNECTABLE_ADV_INTERVAL;
        m_adv_params.timeout     = 0;       // Never time out.
    }


    I receive the expected data but with other data ... Here's the received data :

    [[0x02,0x01,0x04,0x07,0xFF,0x00,0x00,0xFF,0xFF,0xFF,0xFF]]

    And I don't find where this data is set ...

    Can you help me ?

    Sylvain.
Reply
  • Yes I have used this example as It's said as in other post. But I have few trouble when I try to modify the payload. I juste want to send a payload like that :

    #define PAYLOAD_LENGTH  0x04
    char payload [PAYLOAD_LENGTH] = {0xFF,0xFF,0xFF,0xFF};

    So I modified this function :
    static void advertising_init(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;
        
        memset(&manuf_specific_data, 0, sizeof(manuf_specific_data));
    
        manuf_specific_data.data.p_data = (char *) payload;
        manuf_specific_data.data.size = PAYLOAD_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;
    
        //Set uniquely the advertising data not the scan response data
        err_code = ble_advdata_set(&advdata, NULL);
        APP_ERROR_CHECK(err_code);
    
        // Initialize advertising parameters (used when starting advertising).
        memset(&m_adv_params, 0, sizeof(m_adv_params));
    
        m_adv_params.type        = BLE_GAP_ADV_TYPE_ADV_NONCONN_IND;
        m_adv_params.p_peer_addr = NULL;    // Undirected advertisement.
        m_adv_params.fp          = BLE_GAP_ADV_FP_ANY;
        m_adv_params.interval    = NON_CONNECTABLE_ADV_INTERVAL;
        m_adv_params.timeout     = 0;       // Never time out.
    }


    I receive the expected data but with other data ... Here's the received data :

    [[0x02,0x01,0x04,0x07,0xFF,0x00,0x00,0xFF,0xFF,0xFF,0xFF]]

    And I don't find where this data is set ...

    Can you help me ?

    Sylvain.
Children
Related