can't find other brand BLE module

NRF52840

S140

APP based on ble_app_multilink_central

1 PCA10056 as central, 1 PCA10056 as peripheral, the cantral can find the peripheral and buid connection.

But, failed to find the module from 3rd party, E104-BT52(DA14531 transparent COM module).

Have set with same UUID128,UUIDSVR and characters:

uint8_t uuid128[]   = {0x57,0x49,0x4C,0x44,0x44,0x52,0x41,0x47,0x4F,0x4E,0x43,0x4C,0x99,0x44,0x50,0xFF};
uint8_t uuidsvr[]   = {0x99,0x44};

And set the UUID filter:

 void scan_init(void)
{
    ret_code_t          err_code;
    nrf_ble_scan_init_t init_scan;

    memset(&init_scan, 0, sizeof(init_scan));
    
	  //auto connect the found BLE client
    init_scan.connect_if_match = true;
    init_scan.conn_cfg_tag     = APP_BLE_CONN_CFG_TAG;

    err_code = nrf_ble_scan_init(&m_scan, &init_scan, scan_evt_handler);
    APP_ERROR_CHECK(err_code);

    //err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_NAME_FILTER, m_target_periph_name);
	  ble_uuid_t uuid;
	  ble_uuid128_t gateway_base_uuid = {GATEWAY_UUID_BASE};  
    err_code = sd_ble_uuid_decode(16,(uint8_t*)&gateway_base_uuid,&uuid);
	
		APP_ERROR_CHECK(err_code);

	  err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_UUID_FILTER, &uuid);
    APP_ERROR_CHECK(err_code);

    //err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_NAME_FILTER, false);
    err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_UUID_FILTER, false);
    APP_ERROR_CHECK(err_code);
		
		UNUSED_VARIABLE(uuid);
		UNUSED_VARIABLE(err_code);
		//UNUSED_VARIABLE(gateway_base_uuid);
		UNUSED_VARIABLE(init_scan);
		
}

I have check with mobile app, the very noticeable difference is : the UUID of PCA10056(peripheral) is 128bit format, but UUID for E104-BT52(peripheral) is 16bit.

But, it looks like I can do nothing for E104-BT52(according to their guidebook).

Can I do something in central to deal with this problem?

Thank you.

Parents
  • updated: I did not set base UUID128 for E104-BT52 before,it showed 128bit service UUID and characters after I set it, but the advertised service UUID still be 16bit service UUID.and the central can't find the E104-BT52 module.

  • UPDATE:I followed into scan code of S140, it looks like the advData from E104-BT52 is not what S140 wanted.It defined like this:

    020106  < Len(1 byte) >  FF  < customized data(26 Bytes) >

    according the logic in ble_advData.c:

    uint16_t ble_advdata_search(uint8_t const * p_encoded_data,
                                uint16_t        data_len,
                                uint16_t      * p_offset,
                                uint8_t         ad_type)
    {
        if ((p_encoded_data == NULL) || (p_offset == NULL))
        {
            return 0;
        }
    
        uint16_t i = 0;
    
        while ((i + 1 < data_len) && ((i < *p_offset) || (p_encoded_data[i + 1] != ad_type)))
        {
            // Jump to next data.
            i += (p_encoded_data[i] + 1);
        }
    
        if (i >= data_len)
        {
            return 0;
        }
        else
        {
            uint16_t offset = i + 2;
            uint16_t len    = p_encoded_data[i] ? (p_encoded_data[i] - 1) : 0;
            if (!len || ((offset + len) > data_len))
            {
                // Malformed. Zero length or extends beyond provided data.
                return 0;
            }
            *p_offset = offset;
            return len;
        }
    }

    It can't find what I have set in < customized data(26 Bytes) > :

    0x11 0x07 <uuid128>

    So, it can find the BLE peripheral.

    According to decription of sd_ble_gap_scan_start:

    Events generated
    BLE_GAP_EVT_ADV_REPORT	An advertising or scan response packet has been received.
    BLE_GAP_EVT_TIMEOUT	Scanner has timed out.

    The event handle:

    void nrf_ble_scan_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_contex)
    {
        nrf_ble_scan_t                 * p_scan_data  = (nrf_ble_scan_t *)p_contex;
        ble_gap_evt_adv_report_t const * p_adv_report = &p_ble_evt->evt.gap_evt.params.adv_report;
        ble_gap_evt_t const            * p_gap_evt    = &p_ble_evt->evt.gap_evt;
    
        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_ADV_REPORT:
                nrf_ble_scan_on_adv_report(p_scan_data, p_adv_report);
                break;
    
            case BLE_GAP_EVT_TIMEOUT:
                nrf_ble_scan_on_timeout(p_scan_data, p_gap_evt);
                break;
    
            case BLE_GAP_EVT_CONNECTED:
                nrf_ble_scan_on_connected_evt(p_scan_data, p_gap_evt);
                break;
    
            default:
                break;
        }
    }

    It assigned in the Macro definition:

    /**@brief Macro for defining a nrf_ble_scan instance.
     *
     * @param   _name   Name of the instance.
     * @hideinitializer
     */
    #define NRF_BLE_SCAN_DEF(_name)                            \
        static nrf_ble_scan_t _name;                           \
        NRF_SDH_BLE_OBSERVER(_name ## _ble_obs,                \
                             NRF_BLE_SCAN_OBSERVER_PRIO,       \
                             nrf_ble_scan_on_ble_evt, &_name); \
    
    

    So, I have to modify the ble_advdata_search() function? Or I can write some event handle instead of modify SD functions?

Reply
  • UPDATE:I followed into scan code of S140, it looks like the advData from E104-BT52 is not what S140 wanted.It defined like this:

    020106  < Len(1 byte) >  FF  < customized data(26 Bytes) >

    according the logic in ble_advData.c:

    uint16_t ble_advdata_search(uint8_t const * p_encoded_data,
                                uint16_t        data_len,
                                uint16_t      * p_offset,
                                uint8_t         ad_type)
    {
        if ((p_encoded_data == NULL) || (p_offset == NULL))
        {
            return 0;
        }
    
        uint16_t i = 0;
    
        while ((i + 1 < data_len) && ((i < *p_offset) || (p_encoded_data[i + 1] != ad_type)))
        {
            // Jump to next data.
            i += (p_encoded_data[i] + 1);
        }
    
        if (i >= data_len)
        {
            return 0;
        }
        else
        {
            uint16_t offset = i + 2;
            uint16_t len    = p_encoded_data[i] ? (p_encoded_data[i] - 1) : 0;
            if (!len || ((offset + len) > data_len))
            {
                // Malformed. Zero length or extends beyond provided data.
                return 0;
            }
            *p_offset = offset;
            return len;
        }
    }

    It can't find what I have set in < customized data(26 Bytes) > :

    0x11 0x07 <uuid128>

    So, it can find the BLE peripheral.

    According to decription of sd_ble_gap_scan_start:

    Events generated
    BLE_GAP_EVT_ADV_REPORT	An advertising or scan response packet has been received.
    BLE_GAP_EVT_TIMEOUT	Scanner has timed out.

    The event handle:

    void nrf_ble_scan_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_contex)
    {
        nrf_ble_scan_t                 * p_scan_data  = (nrf_ble_scan_t *)p_contex;
        ble_gap_evt_adv_report_t const * p_adv_report = &p_ble_evt->evt.gap_evt.params.adv_report;
        ble_gap_evt_t const            * p_gap_evt    = &p_ble_evt->evt.gap_evt;
    
        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_ADV_REPORT:
                nrf_ble_scan_on_adv_report(p_scan_data, p_adv_report);
                break;
    
            case BLE_GAP_EVT_TIMEOUT:
                nrf_ble_scan_on_timeout(p_scan_data, p_gap_evt);
                break;
    
            case BLE_GAP_EVT_CONNECTED:
                nrf_ble_scan_on_connected_evt(p_scan_data, p_gap_evt);
                break;
    
            default:
                break;
        }
    }

    It assigned in the Macro definition:

    /**@brief Macro for defining a nrf_ble_scan instance.
     *
     * @param   _name   Name of the instance.
     * @hideinitializer
     */
    #define NRF_BLE_SCAN_DEF(_name)                            \
        static nrf_ble_scan_t _name;                           \
        NRF_SDH_BLE_OBSERVER(_name ## _ble_obs,                \
                             NRF_BLE_SCAN_OBSERVER_PRIO,       \
                             nrf_ble_scan_on_ble_evt, &_name); \
    
    

    So, I have to modify the ble_advdata_search() function? Or I can write some event handle instead of modify SD functions?

Children
  • connected after modified ble_advdata_uuid_find().

    But failed to discovery: 

    0m<info> app: Start scanning for device Service UUID 0x4499.
    0m<debug> ble_scan: Scanning
    0m<debug> ble_scan: Connecting
    0m<debug> ble_scan: Connection status: 0
    0m<info> app: NRF_BLE_SCAN_EVT_FILTER_MATCH 
    0m<debug> nrf_ble_gq: Processing the request queue...
    <debug> nrf_ble_gatt: Requesting to update ATT MTU to 50 bytes on connection
    0m<info> app: NRF_BLE_SCAN_EVT_CONNECTED 
    0m<info> app: Connection 0x1 established, starting DB discovery.
    0m<debug> nrf_ble_gq: Purging request queue with id: 1
    0m<debug> nrf_ble_gq: Registering connection handle: 0x0001
    <debug> ble_db_disc: Starting discovery of service with UUID 0x4499 on conne
    ion handle 0x1.
    0m<debug> nrf_ble_gq: Adding item to the request queue
    0m<debug> nrf_ble_gq: GATTC Primary Services Discovery Request
    <debug> nrf_ble_gq: SD is currently busy. The GATT request procedure will be
    ttempted again later.
    0m<debug> nrf_ble_gq: Processing the request queue...
    0m<debug> nrf_ble_gq: GATTC Primary Service Discovery Request
    <debug> nrf_ble_gq: SD is currently busy. The GATT request procedure will be
    ttempted again later.
    0m<info> app: Start scanning for device Service UUID 0x4499.
    0m<debug> ble_scan: Scanning
    0m<debug> nrf_ble_gq: Processing the request queue...
    0m<info> app: gateway central link 0x1 disconnected (reason: 0x3E)

  • This is not right.

    Actually the connection(0) has been built and the service & characters are discovered.But, there is a 2nd connection(1) created based on the same BLE device, and failed to discover service and characters , and the connections disconnected. and repeat the whole procedure.

    The log file attached. ignore the error on pushing data to buffer.

    I can't attach the file,show parts content here:

    <debug> ble_scan: Connecting
    
    <debug> ble_scan: Connection status: 0
    
    <info> app: NRF_BLE_SCAN_EVT_FILTER_MATCH 
    
    
    
    <debug> nrf_ble_gatt: Requesting to update ATT MTU to 50 bytes on connection 0x0.
    
    <info> app: NRF_BLE_SCAN_EVT_CONNECTED 
    
    
    
    <info> app: Connection 0x0 established, starting DB discovery.
    
    <debug> nrf_ble_gq: Purging request queue with id: 1
    
    <debug> nrf_ble_gq: Purging request queue with id: 0
    
    <debug> nrf_ble_gq: Registering connection handle: 0x0000
    
    <debug> ble_db_disc: Starting discovery of service with UUID 0x4499 on connection handle 0x0.
    
    <debug> nrf_ble_gq: Adding item to the request queue
    
    <debug> nrf_ble_gq: GATTC Primary Services Discovery Request
    
    <debug> nrf_ble_gq: SD is currently busy. The GATT request procedure will be attempted                       again later.
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    <debug> nrf_ble_gq: GATTC Primary Service Discovery Request
    
    <debug> nrf_ble_gq: SD is currently busy. The GATT request procedure will be attempted                           again later.
    
    <info> app: Start scanning for device Service UUID 0x4499.
    
    <debug> ble_scan: Scanning
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    <debug> nrf_ble_gq: GATTC Primary Service Discovery Request
    
    <debug> nrf_ble_gq: SD is currently busy. The GATT request procedure will be attempted                           again later.
    
    <debug> nrf_ble_gatt: Peer on connection 0x0 requested an ATT MTU of 247 bytes.
    
    <debug> nrf_ble_gatt: Updating ATT MTU to 50 bytes (desired: 50) on connection 0x0.
    
    <info> app: BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST.
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    <debug> nrf_ble_gq: GATTC Primary Service Discovery Request
    
    <debug> nrf_ble_gq: SD GATT procedure (2) succeeded on connection handle: 0.
    
    <debug> nrf_ble_gatt: ATT MTU updated to 50 bytes on connection 0x0 (response).
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    <debug> ble_db_disc: Found service UUID 0x4499.
    
    <debug> nrf_ble_gq: Adding item to the request queue
    
    <debug> nrf_ble_gq: GATTC Characteristic Discovery Request
    
    <debug> nrf_ble_gq: SD GATT procedure (3) succeeded on connection handle: 0.
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    <debug> nrf_ble_gq: Adding item to the request queue
    
    <debug> nrf_ble_gq: GATTC Characteristic Discovery Request
    
    <debug> nrf_ble_gq: SD GATT procedure (3) succeeded on connection handle: 0.
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    <debug> nrf_ble_gq: Adding item to the request queue
    
    <debug> nrf_ble_gq: GATTC Characteristic Discovery Request
    
    <debug> nrf_ble_gq: SD GATT procedure (3) succeeded on connection handle: 0.
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    <debug> nrf_ble_gq: Adding item to the request queue
    
    <debug> nrf_ble_gq: GATTC Characteristic Descriptor Request
    
    <debug> nrf_ble_gq: SD GATT procedure (4) succeeded on connection handle: 0.
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    <debug> ble_scan: Connecting
    
    <debug> ble_scan: Connection status: 0
    
    <info> app: NRF_BLE_SCAN_EVT_FILTER_MATCH 
    
    
    
    <debug> nrf_ble_gq: Adding item to the request queue
    
    <debug> nrf_ble_gq: GATTC Characteristic Descriptor Request
    
    <debug> nrf_ble_gq: SD GATT procedure (4) succeeded on connection handle: 0.
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    <debug> nrf_ble_gq: Adding item to the request queue
    
    <debug> nrf_ble_gq: GATTC Characteristic Descriptor Request
    
    <debug> nrf_ble_gq: SD GATT procedure (4) succeeded on connection handle: 0.
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    <debug> ble_db_disc: Discovery of service with UUID 0x4499 completed with success on connection handle 0x0.
    
    <debug> app: call to gateway_on_db_disc_evt for instance 0 and link 0x0!
    
    <debug> ble_gateway_c: gatway Service discovered at peer.
    
    <info> app: Gateway Service discovered on conn_handle 0x0
    
    
    
    <debug> ble_gateway_c: Configuring CCCD. CCCD Handle = 34, Connection Handle = 0
    
    <debug> nrf_ble_gq: Adding item to the request queue
    
    <debug> nrf_ble_gq: GATTC Write Request
    
    <debug> nrf_ble_gq: SD GATT procedure (1) succeeded on connection handle: 0.
    
    <debug> app: call to gateway_on_db_disc_evt for instance 0 and link 0x0!
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    <debug> app: push into buffer failed,ret = 4
    
    <warning> app: Failed to write to buffer_up: buffer_up full. 
    
    
    
    <debug> nrf_ble_gatt: Requesting to update ATT MTU to 50 bytes on connection 0x1.
    
    <info> app: NRF_BLE_SCAN_EVT_CONNECTED 
    
    
    
    
    
    
    
    <info> app: Connection 0x1 established, starting DB discovery.
    
    <debug> nrf_ble_gq: Registering connection handle: 0x0001
    
    <debug> ble_db_disc: Starting discovery of service with UUID 0x4499 on connection handle 0x1.
    
    <debug> nrf_ble_gq: Adding item to the request queue
    
    <debug> nrf_ble_gq: GATTC Primary Services Discovery Request
    
    <debug> nrf_ble_gq: SD is currently busy. The GATT request procedure will be attempted                       again later.
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    <debug> nrf_ble_gq: GATTC Primary Service Discovery Request
    
    <debug> nrf_ble_gq: SD is currently busy. The GATT request procedure will be attempted                           again later.
    
    <info> app: Start scanning for device Service UUID 0x4499.
    
    <debug> ble_scan: Scanning
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    <debug> app: push into buffer failed,ret = 4
    
    <warning> app: Failed to write to buffer_up: buffer_up full. 
    
    
    
    <info> app: gateway central link 0x1 disconnected (reason: 0x3E)
    
    
    
    
    
    
    <info> app: Start scanning for device Service UUID 0x4499.
    
    <debug> ble_scan: Scanning
    
    <debug> ble_scan: Connecting
    
    <debug> ble_scan: Connection status: 0
    
    <info> app: NRF_BLE_SCAN_EVT_FILTER_MATCH 
    
    
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    <debug> app: push into buffer failed,ret = 4
    
    <warning> app: Failed to write to buffer_up: buffer_up full. 
    
    
    
    <debug> nrf_ble_gatt: Requesting to update ATT MTU to 50 bytes on connection 0x1.
    
    <info> app: NRF_BLE_SCAN_EVT_CONNECTED 
    
    
    
    
    
    
    
    <info> app: Connection 0x1 established, starting DB discovery.
    
    <debug> nrf_ble_gq: Purging request queue with id: 1
    
    <debug> nrf_ble_gq: Registering connection handle: 0x0001
    
    <debug> ble_db_disc: Starting discovery of service with UUID 0x4499 on connection handle 0x1.
    
    <debug> nrf_ble_gq: Adding item to the request queue
    
    <debug> nrf_ble_gq: GATTC Primary Services Discovery Request
    
    <debug> nrf_ble_gq: SD is currently busy. The GATT request procedure will be attempted                       again later.
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    <debug> nrf_ble_gq: GATTC Primary Service Discovery Request
    
    <debug> nrf_ble_gq: SD is currently busy. The GATT request procedure will be attempted                           again later.
    
    <info> app: Start scanning for device Service UUID 0x4499.
    
    <debug> ble_scan: Scanning
    
    <info> app: gateway central link 0x1 disconnected (reason: 0x3E)
    
    
    

  • The reason found: The E104-BT52 allowed 2 up links at the same time.so, after 1st connection built,it still send adv, central will try to connect it again, but duplication connection should not permited.

    From E104-BT52 side, they will need modify the firmware,there is no AT cmd to set it yet.

    From central side, how to check it was  connected ? Do I need to maintain BLE address list?

Related