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

nRF9160 DK lte_ble_gateway sample to get beacon UUID

Hi,
       I am working on nRF9160DK lte_ble_gateway sample, in that I want to scan for beacons UUID and major, minor value.
       nRF52 device is programmed with bluetooth HCI (UART). I dont want to use BLE scan filters.

      Could someone please provide me a sample or hint on how to get it.

Parents
  • You need to somehow filter the advertising data. This is because beacon data usually is in the form of manufacturer-specific data (see this link), and you need to check all incoming advertising packets and check if it contains a manufacturer-specific AD type (check the bottom of this link). I am not too familiar with the Zephyr BLE libraries, and I am not sure what the proper way of going about this is, but here is one approach:

    • Make a copy of the lte_ble_gateway example, which you can modify
    • Inside <..>\ncs\nrf\samples\nrf9160\lte_ble_gateway\src\ble.c do the following
      • Change scan_start() to the following:

    static void scan_start(void){
            int err;
          
          	err = bt_le_scan_start(&scan_param, scan_cb);
    	if (err) {
    		printk("Starting scanning failed (err %d)\n", err);
    		return;
    	}
    }

      • Change scan_cb to the following:

    static void scan_cb(const bt_addr_le_t *addr, s8_t rssi, u8_t adv_type,
    		    struct net_buf_simple *buf)
    {
            bt_data_parse(ad, adv_data_found, NULL);
    }

    • Create adv_data_found:

    static bool adv_data_found(struct bt_data *data, void *user_data)
    {
    	struct bt_scan_control *scan_control =
    			(struct bt_scan_control *)user_data;
    
    	if(data->type== BT_DATA_MANUFACTURER_DATA) {
    	   //process the "data" variable
    	   //Get minor and major values, uuid etc. from data
    	   return false
    	}
    
    
    	return true;
    }

    • Then delete everything from <..>\ncs\nrf\samples\nrf9160\lte_ble_gateway\src\ble.c that you don't need, e.g. functionality for connecting to a device.

    I have not tested this myself, and my approach my contain errors/mistakes. Please ask if this approach doesn't work, or if you want me to elaborate more on anything.

    Best regards,

    Simon

  • Check out this ticket where I have provided the complete code to get this working.

    Best regards,

    Simon

  • I got expected UUID, major and minor values.

    Thanks Simon..

Reply Children
No Data
Related