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

Periperal + Broadcaster role

hello ,

i want to know if there an example available that has both peripheral + Broadcaster role running at the same time , Broadcaster advertise the service in the peripheral and its rssi ?

Thanks

Parents
  • I'm actually not aware of any example, but there are several questions about this on DevZone.

    It should be simply to set the advertising data with sd_ble_gap_adv_data_set() (through ble_advdata_set()) and call sd_ble_gap_adv_start(). See this MSC.

    Please be aware that you per spec only can do non-connectable advertising while in a connection.

    Putting in an UUID (service) shouldn't be too hard. I'm not sure what RSSI you would be putting in? What received signal strength would you be putting in?

    Edit1:

    Q1) Yes. Something like this:

    ble_gap_adv_params_t m_adv_params;
    
    m_adv_params.type        = BLE_GAP_ADV_TYPE_ADV_NONCONN_IND;
    m_adv_params.p_peer_addr = NULL;
    m_adv_params.fp          = BLE_GAP_ADV_FP_ANY;
    m_adv_params.interval    = NON_CONNECTABLE_ADV_INTERVAL;
    m_adv_params.timeout     = APP_CFG_NON_CONN_ADV_TIMEOUT;
    
    err_code = sd_ble_gap_adv_start(&m_adv_params);
    APP_ERROR_CHECK(err_code);
    

    Q2) You need to add your UUID to the ble_advdata_t struct that you give to ble_advdata_set(). You can have a look at how this is populated in one of our examples.

    Q3) Both

    Edit2:

    int main(void)
    {
        uint32_t err_code;
        ble_stack_init();
        
        ble_uuid_t    ble_uuid;
        ble_uuid128_t base_uuid = {{0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x00, 0x00, 0x40, 0x6E}};
        
        err_code = sd_ble_uuid_vs_add(&base_uuid, &ble_uuid.type);
        APP_ERROR_CHECK(err_code);
    
        ble_uuid.uuid = 0x0001;
        
        ble_gap_conn_sec_mode_t sec_mode;
    
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
                  
        err_code = sd_ble_gap_device_name_set(&sec_mode, "propUUID", 8);
        APP_ERROR_CHECK(err_code);
        
        ble_advdata_t advdata;
        memset(&advdata, 0, sizeof(advdata));
        
        advdata.name_type          = BLE_ADVDATA_FULL_NAME;
        advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
        
        advdata.uuids_complete.p_uuids = &ble_uuid;
        advdata.uuids_complete.uuid_cnt = 1;
    
        err_code = ble_advdata_set(&advdata, NULL);
        APP_ERROR_CHECK(err_code);
                                              
        ble_gap_adv_params_t adv_params;
        memset(&adv_params, 0, sizeof(adv_params));
    
        adv_params.type        = BLE_GAP_ADV_TYPE_ADV_NONCONN_IND;
        adv_params.interval    = 200;
        adv_params.timeout     = 0;
    
        err_code = sd_ble_gap_adv_start(&adv_params);
        APP_ERROR_CHECK(err_code);
        
        // Enter main loop.
        for (;;)
        {
            power_manage();
        }
    }
    
  • @Petter , hi thanks for the reply.

    Q1) if i understand correctly once my periperal role is connected to a central device , i can call sd_ble_gap_adv_start() to do non-connectable advertising ? , can you show me sudo code for this as there is no example for this ?

    Q2) the other thing is while am in non-connectable advertising mode how can i adversise we my service ?

    Q3) to read this non connectable service , which role does the other ble device has to be observer or central or both are possible ?

Reply
  • @Petter , hi thanks for the reply.

    Q1) if i understand correctly once my periperal role is connected to a central device , i can call sd_ble_gap_adv_start() to do non-connectable advertising ? , can you show me sudo code for this as there is no example for this ?

    Q2) the other thing is while am in non-connectable advertising mode how can i adversise we my service ?

    Q3) to read this non connectable service , which role does the other ble device has to be observer or central or both are possible ?

Children
No Data
Related