Scan Local Name

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
LUAB_4724786
Level 4
Level 4
25 replies posted 10 likes received 10 replies posted

Hi there,

I have a question on how to retrieve the Local Name after scanning BLE and retrieved its Adv Data. Currently I am using CYBT-213043 Mesh Kit and after following lots of information in the forum I manage to get information all scanned devices from mesh_application.c (mesh_adv_report()).

I also have an application in my phone that provides information about nearby devices, see in the attachment picture, there is an information about its local name which is "Amazfit GTR".

So I am adding wiced_bt_ble_check_advertising_data() in the code with BTM_BLE_ADVERT_TYPE_NAME_COMPLETE and also BTM_BLE_ADVERT_TYPE_NAME_SHORT but still, I cant see the in the result of scanned of adv data.

Would you kindly guide me on how to retrieve that local name in my code ? so far I can only see the RSSI, MAC, ble_addr_type, ble_evt_type and p_adv_data (I think its raw data). Below is the usage of the code wiced_bt_ble_check_advertising_data() that I am using, just in case I am doing wrongly in here.

uint8_t* p_name;
uint8_t p_len = 0;

p_name = wiced_bt_ble_check_advertising_data(p_adv_data, BTM_BLE_ADVERT_TYPE_NAME_COMPLETE , &p_len);
if( p_len > 0 )
{
WICED_BT_TRACE(" checked_adv_data: ");
for(int i=0; i<p_len; i++)
{
WICED_BT_TRACE("%02X", p_name[i + 1]);
}
WICED_BT_TRACE("\n");
}

Thanks and Best Regards,

LUTHFI AD

 

0 Likes
1 Solution
DheerajPK_41
Moderator
Moderator
Moderator
750 replies posted 500 likes received 500 replies posted

Hi,

I checked the code example (key_ch04d_ex02_observer_mydev) using CYBT-213043-MESH and I could get the local name. Do you mean, you are not able to get the name using the the same code?

The advertising device should advertise the Local Name. If not, your scanning device will shown NULL as local name of the adv device. 

 

Please try using the below code. (These are written for 20819 platform)

Device_1: program with Program_1 (Observer)

Device_2: Program with Program_2  (Advertiser - Comment our LED, Button, etc. in the code)

 

This is working for me. 

May be you can share your code with us to make us understand the implementation, so that we will be able to give you more accurate answer/help.

Thanks,

-Dheeraj

View solution in original post

0 Likes
6 Replies
DheerajPK_41
Moderator
Moderator
Moderator
750 replies posted 500 likes received 500 replies posted

Hi,

Please refer the below code to understand the usage. Can you try using memcpy and print the name?

https://github.com/cypresssemiconductorco/CypressAcademy_BT101_Files/tree/master/Projects/ch04d/key_... 

 

Thanks,

-Dheeraj

0 Likes
LUAB_4724786
Level 4
Level 4
25 replies posted 10 likes received 10 replies posted

Dear Dheeraj,

Thank you for link and I did follow with memcpy and printing the name, it is still the same actually, still cannot get the Local Name. I did some experiment (to make sure my code alright), I set my bluetooth mouse unpair and let it broadcast at that state and I can see via (wiced_bt_ble_check_advertising_data()) but ... sadly only that mouse among other devices.

So I proceed further, create some dummy project with changes in this code 

wiced_bt_cfg_settings.device_name = (uint8_t *)"Can U See Me";

and I scan it with mesh app (during device registering) and I can see that device, see below :

photo_2021-05-06_16-32-22.jpg

And I also check with the other app (lightblue),  it is detected ... and I can see that name, see below :

photo_2021-05-06_16-32-22 (2).jpg

But unfortunately cannot be detected via code (wiced_bt_ble_check_advertising_data()), no name can be retrieved, could you try my experiment at your end too just to make sure that perhaps I am doing something wrong or different, thanks.

0 Likes
DheerajPK_41
Moderator
Moderator
Moderator
750 replies posted 500 likes received 500 replies posted

Hi,

I checked the code example (key_ch04d_ex02_observer_mydev) using CYBT-213043-MESH and I could get the local name. Do you mean, you are not able to get the name using the the same code?

The advertising device should advertise the Local Name. If not, your scanning device will shown NULL as local name of the adv device. 

 

Please try using the below code. (These are written for 20819 platform)

Device_1: program with Program_1 (Observer)

Device_2: Program with Program_2  (Advertiser - Comment our LED, Button, etc. in the code)

 

This is working for me. 

May be you can share your code with us to make us understand the implementation, so that we will be able to give you more accurate answer/help.

Thanks,

-Dheeraj

0 Likes
LUAB_4724786
Level 4
Level 4
25 replies posted 10 likes received 10 replies posted

Hi Dheeraj,

As I mention before, the way I scan the device is via "mesh_application.c" and adding a bit of logging under function name "mesh_adv_report()", as I told you before it is working loging a lot of devices with its RSSI, Type and MAC and I am using non modified source code, from sample but changes only at "mesh_application.c".

The reason I am not choosing "observer" sample way is because I want mesh functiontionality is still working but I also need to be able to scan surounding device as well, so ... I ended with experimenting with that function (mesh_adv_report) at mesh_application.c.

anyway, I notice that observer sample is scanning other device with "wiced_bt_ble_scan()" but mesh_application.c using "wiced_bt_ble_observe()" ...

  1. Is there any different between wiced_bt_ble_scan vs wiced_bt_ble_observe in term of scanning and having the result ?
  2. Would please help check within mesh_adv_report() under mesh_application.c to check the scanning result ? (you can use any sample project) just in case something wrong with my sample, I am using MTB 2.1.
  3. I just want my mesh functionality working but I also want it to scan other device, is there any way without utilize mesh_adv_report() function in mesh_application.c to achieve this ?
  4. As I mention before ... yes my code is work and the code is just using wiced_bt_ble_check_advertising_data() to get their names, I am using my wireless mouse (unpair mode) and yes it is detected and printed the name well and double check with adv data content, that flag BTM_BLE_ADVERT_TYPE_NAME_COMPLETE is in there ... but why other devices (in my case) like watch, beacon, mesh devices, other phone and tablet cannot see the name ? ... but application phone can scan and get the name ?

Please help me on this and I really not using any custom code actually but only using mesh sample and change a bit (some of the code in first post) in mesh_application.c at mesh_adv_report() function .... that is all, coming from fresh sample.

Thanks

 

0 Likes
LUAB_4724786
Level 4
Level 4
25 replies posted 10 likes received 10 replies posted

Dear Dheeraj,

I am adding the step that I used in my experiment, I hope its clear and can point where should I modify or doing it wrongly.

I create a project from "mesh_vendor_specific_app" sample and change only the device name

Screenshot 2021-05-11 215225.png

load it and leave it unprovisioned and check with mesh app and lightblue app, it is detected ...

photo_2021-05-11_22-17-17.jpgphoto_2021-05-11_22-17-12.jpg

With the same project, now I change the device name with "Vendor Server Obs" just to make it difference with previous device and load it to another device

Screenshot 2021-05-11 215249.png

and do some changes at "mesh_application.c" at the function "mesh_adv_report()"

Screenshot 2021-05-11 220917.png

and load the program and leave it unprovision and read the debug log at com port

Screenshot 2021-05-11 221508.png

as you can see, it is work properly ... meaning some device can be detected is there but, most of other devices is not detected, like my beacon ... other watch or my previously loaded mesh device "Vendor Server Adv". Anyway ... the phone app like Lightblue can see them all, see below

photo_2021-05-11_22-17-04.jpgphoto_2021-05-11_22-17-08.jpg

Is there anything should I do or missing step/code in order to be able to read the rest of the device name ?

 

Thanks Dheeraj.

0 Likes
DheerajPK_41
Moderator
Moderator
Moderator
750 replies posted 500 likes received 500 replies posted

wiced_bt_ble_scan is filter the scan results for conoectable adv, but wiced_bt_ble_observe scan for all (connectable and non-connectable). if you want to list down all adv you have to use wiced_bt_ble_observe .

Thanks,

-Dheeraj

0 Likes