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

Issue: Identifying beacons with 128-bit UUID for nRF9160 DK (PCA 10090)

Hi,

I am currently working on "asset_tracker" application.

Actually, I need to read 128-bit UUID values of the BLE ibeacons present nearby the board (PCA10090)  to be captured in "asset_tracker", application.

Looking forward to your help.

Please guide me the correct way and let me know how to read 128-bit UUID values and implement the same for asset tracker application.

Parents
  • I modified the ble_lte_gateway example in NCS v1.1.0 to scan for beacons, parse the advertising data and store the 128 bit UUID, the major and the minor value. Execute these steps to get the example up and running

    • Follow the steps explained here to build and run the LTE Sensor Gateway example
    • Swap the file <..>\ncs\nrf\samples\nrf9160\lte_ble_gateway\src\ble.c with the file provided below, then rebuild and flash your example.

    /*
     * Copyright (c) 2018 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
     */
    
    #include <zephyr.h>
    
    #include <bluetooth/gatt.h>
    #include <bluetooth/uuid.h>
    #include <bluetooth/gatt_dm.h>
    #include <bluetooth/scan.h>
    
    #include <dk_buttons_and_leds.h>
    #include <misc/byteorder.h>
    
    #include <nrf_cloud.h>
    #include "aggregator.h"
    
    #define BEACON_UUID_START 4
    #define BEACON_UUID_SIZE 16
    
    #define BEACON_MAJOR_START 20
    #define BEACON_MAJOR_SIZE 2
    
    #define BEACON_MINOR_START 22
    #define BEACON_MINOR_SIZE 2
    
    uint8_t beacon_uuid[16];
    uint8_t beacon_major[2];
    uint8_t beacon_minor[2];
    
    static bool adv_data_found(struct bt_data *data, void *user_data)
    {
            int i, index;
    
    	if(data->type== BT_DATA_MANUFACTURER_DATA) {
               printk("--------------\n");
               printk("Manuf. data: ");
    	   for(i=0; i < data->data_len; i++){
                    printk("%x, ", data->data[i]);
               }
               printk("\n");
               printk("Beacon uuid: ");
               for(i=0; i < BEACON_UUID_SIZE; i++){
                    index = i + BEACON_UUID_START;
                    beacon_uuid[i] = (uint8_t)data->data[index];
                    printk("%x,", data->data[index]);
               }
               printk("\n");
    
               printk("Beacon major: ");
               for(i=0; i < BEACON_MAJOR_SIZE; i++){
                    index = i + BEACON_MAJOR_START;
                    beacon_major[i] = (uint8_t)data->data[index];
                    printk("%x,", data->data[index]);
               }
               printk("\n");
                printk("Beacon minor: ");
               for(i=0; i < BEACON_MINOR_SIZE; i++){
                    index = i + BEACON_MINOR_START;
                    beacon_minor[i] = (uint8_t)data->data[index];
                    printk("%x,", data->data[index]);
               }
               printk("\n\n");
    	   return false;
    	}
    
    
    	return true;
    }
    
    static void scan_cb(const bt_addr_le_t *addr, s8_t rssi, u8_t adv_type,
    		    struct net_buf_simple *ad)
    {
            printk("scan callback\n");
            bt_data_parse(ad, adv_data_found, NULL);
    }
    
    void scan_connecting_error(struct bt_scan_device_info *device_info)
    {
    	printk("Connection to peer failed!\n");
    }
    
    //BT_SCAN_CB_INIT(scan_cb, scan_filter_match, NULL, scan_connecting_error, NULL);
    
    static void scan_start(void)
    {
    	int err;
    
            err = bt_le_scan_start(BT_LE_SCAN_ACTIVE, scan_cb);
    	if (err) {
    		printk("Starting scanning failed (err %d)\n", err);
    		return;
            }
    }
    
    static void ble_ready(int err)
    {
    	printk("Bluetooth ready\n");
    
    	//bt_conn_cb_register(&conn_callbacks);
    	scan_start();
    }
    
    void ble_init(void)
    {
    	int err;
    
    	printk("Initializing Bluetooth..\n");
    	err = bt_enable(ble_ready);
    	if (err) {
    		printk("Bluetooth init failed (err %d)\n", err);
    		return;
    	}
    }
    

    Best regards,

    Simon

  • Hi Simon, 

    Thank you for your reply.

    Actually I have migrated the lte_ble_gateway code changes along with the above snippet to asset_tacker application, as per the requirement demand. 

    But unfortunately, I am getting the following errors, while testing the above code to observed the UUID values.  

    /*************************************** Logs **************************************/

    Initializing Bluetooth..

    <err> bt_driver: Unknown H:4 type 0x01

    [00:00:00.365,905] <wrn> bt_hci_core: opcode 0x0000 pool id 5 pool 0x20030ea4 != &hci_cmd_pool 0x20030e80

    [00:00:18.555,236] <wrn> bt_driver: Discarding event 0x3e
    [00:00:18.561,920] <wrn> bt_driver: Discarding event 0x3e


    [00:00:00.368,011] <err> bt_driver: Not enough space in buffer
    [00:00:00.374,511] <err> bt_driver: Unknown H:4 type 0x00
    [00:00:00.380,584] <err> bt_driver: Unknown H:4 type 0x00
    ASSERTION FAIL [err == 0] @ C:/ncs/zephyr/subsys/bluetooth/host/hci_core.c:340
    k_sem_take failed with err -11

    [00:00:00.581,085] <wrn> bt_driver: Discarding event 0x3e
    [00:00:00.587,188] <err> bt_driver: Unknown H:4 type 0x01
    [00:00:00.593,322] <err> bt_driver: Not enough space in buffer
    [00:00:00.599,822] <err> bt_driver: Unknown H:4 type 0xee
    [00:00:00.605,926] <err> bt_driver: Unknown H:4 type 0x2a
    [00:00:00.611,999] <err> bt_driver: Unknown H:4 type 0x72
    [00:00:00.618,072] <err> bt_driver: Unknown H:4 type 0x22
    [00:00:00.624,176] <err> bt_driver: Unknown H:4 type 0x69
    [00:00:00.630,249] <err> bt_driver: Unknown H:4 type 0x00
    [00:00:00.636,352] <err> bt_driver: Unknown H:4 type 0xd4

    /**************************   End of Logs  ***********************************/

    NOTE: I have ported the all required code changes needed by the lte_ble_gateway in the asset_tracker application. 

    And observed the NO warnings and NO errors, while compiling the code. 

    Please help me with the above issue, whether I am missing anything, apart from code changes. 

    HW Tested: nRF9160 DK (PCA10090)

    SW Used: V1.1.0 branch

    Thank you. 

Reply
  • Hi Simon, 

    Thank you for your reply.

    Actually I have migrated the lte_ble_gateway code changes along with the above snippet to asset_tacker application, as per the requirement demand. 

    But unfortunately, I am getting the following errors, while testing the above code to observed the UUID values.  

    /*************************************** Logs **************************************/

    Initializing Bluetooth..

    <err> bt_driver: Unknown H:4 type 0x01

    [00:00:00.365,905] <wrn> bt_hci_core: opcode 0x0000 pool id 5 pool 0x20030ea4 != &hci_cmd_pool 0x20030e80

    [00:00:18.555,236] <wrn> bt_driver: Discarding event 0x3e
    [00:00:18.561,920] <wrn> bt_driver: Discarding event 0x3e


    [00:00:00.368,011] <err> bt_driver: Not enough space in buffer
    [00:00:00.374,511] <err> bt_driver: Unknown H:4 type 0x00
    [00:00:00.380,584] <err> bt_driver: Unknown H:4 type 0x00
    ASSERTION FAIL [err == 0] @ C:/ncs/zephyr/subsys/bluetooth/host/hci_core.c:340
    k_sem_take failed with err -11

    [00:00:00.581,085] <wrn> bt_driver: Discarding event 0x3e
    [00:00:00.587,188] <err> bt_driver: Unknown H:4 type 0x01
    [00:00:00.593,322] <err> bt_driver: Not enough space in buffer
    [00:00:00.599,822] <err> bt_driver: Unknown H:4 type 0xee
    [00:00:00.605,926] <err> bt_driver: Unknown H:4 type 0x2a
    [00:00:00.611,999] <err> bt_driver: Unknown H:4 type 0x72
    [00:00:00.618,072] <err> bt_driver: Unknown H:4 type 0x22
    [00:00:00.624,176] <err> bt_driver: Unknown H:4 type 0x69
    [00:00:00.630,249] <err> bt_driver: Unknown H:4 type 0x00
    [00:00:00.636,352] <err> bt_driver: Unknown H:4 type 0xd4

    /**************************   End of Logs  ***********************************/

    NOTE: I have ported the all required code changes needed by the lte_ble_gateway in the asset_tracker application. 

    And observed the NO warnings and NO errors, while compiling the code. 

    Please help me with the above issue, whether I am missing anything, apart from code changes. 

    HW Tested: nRF9160 DK (PCA10090)

    SW Used: V1.1.0 branch

    Thank you. 

Children
Related