- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
At device central periphreal Device B, this is what i am following
case CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:
Advreport= *(CYBLE_GAPC_ADV_REPORT_T*) eventParam;
//Checking for peripheral Device A
if(Advreport.peerBdAddr[1]==0xD0 && Advreport.peerBdAddr[2]==0x37 && Advreport.peerBdAddr[3]==0x84 &&
Advreport.peerBdAddr[4]==0x00 && Advreport.peerBdAddr[5]==0x0A)
{
printf(" \r\n device detected \r\n ");
CyBle_GapcStopScan();
CyBle_ProcessEvents();
printf("\r\n Device rssi value is %d",scanreport.rssi); // RSSI of peripheral Device A
buffer[0]=scanreport.rssi; // storing rssi of device A
cyBle_discoveryData.advData[0]=buffer[0];
CyBle_GapUpdateAdvData(&cyBle_discoveryData,&cyBle_scanRspData);
}
break;
At device Central Device C, this is what i am following
case CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:
Advreport= *(CYBLE_GAPC_ADV_REPORT_T*) eventParam;
//Checking for
if(Advreport.peerBdAddr[1]==0xD0 && Advreport.peerBdAddr[2]==0x36 && Advreport.peerBdAddr[3]==0x28 &&
Advreport.peerBdAddr[4]==0x00 && Advreport.peerBdAddr[5]==0x0A) // checking for central periphreal Device B
{
RSSI=Advreport.rssi; // central periphreal Device B rssi value
printf("\r\n RSSI value of device central-peripheral is %d \r\n",RSSI);
val[0]=Advreport.data[0]; //Advreport.data will contains the peripheral Device A rssi value
y = ((int)val[0]) - 255;
printf("\r\n RSSI value of device B %d \r\n",y);
}
break;
for val[0]=Advreport.data[0]; i am obtaining both the rssi values of device B (central -peripheral device)and device A (peripheral device)
How can i get only the device A value?
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Could you please add the below code in your Central project.
At Central Device C,
************************************************
case CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:
Advreport= *(CYBLE_GAPC_ADV_REPORT_T*) eventParam;
//Checking for
if(Advreport.peerBdAddr[1]==0xD0 && Advreport.peerBdAddr[2]==0x36 && Advreport.peerBdAddr[3]==0x28 &&
Advreport.peerBdAddr[4]==0x00 && Advreport.peerBdAddr[5]==0x0A) // checking for central periphreal Device B
{
if(Advreport.dataLen!=0)
{
RSSI=Advreport.rssi; // central periphreal Device B rssi value
printf("\r\n RSSI value of device central-peripheral is %d \r\n",RSSI);
val[0]=Advreport.data[0]; //Advreport.data will contains the peripheral Device A rssi value
y = ((int)val[0]) - 255;
printf("\r\n RSSI value of device B %d \r\n",y);
}
}
break;
************************************************
Thanks,
P Yugandhar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello umg_4380326 ,
At device B when the device is in central mode, you are storing the RSSI value(i.e., the distance between the Device A and Device B) of device A in a buffer and after switching it to peripheral mode, you are sending it through the advertisement data. So, at device C, advertisement report data of Device B (i.e., Advreport.data[0]) will contains the RSSI value of device A and device B. RSSI value of advertisement report(Advreport.rssi of Device B) will give the value of device B and device C. In order to check for different advertising devices RSSI value at device C, in the scan progress event(CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT) you need to check the address of different advertising devices in an advertisement report first and then you can get the RSSI values as shown in below code.
*******************************
case CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:
Advreport= *(CYBLE_GAPC_ADV_REPORT_T*) eventParam;
//Checking for peripheral device 1 with address
if(Advreport.peerBdAddr[1]==0x44 && Advreport.peerBdAddr[2]==0x67 && Advreport.peerBdAddr[3]==0x89 &&
Advreport.peerBdAddr[4]==0x01 && Advreport.peerBdAddr[5]==0x0A)
{
RSSI=Advreport.rssi; // peripheral device 1 rssi value
}
//Checking for peripheral device 2
else if(Advreport.peerBdAddr[1]==0x56 && Advreport.peerBdAddr[2]==0x78 && Advreport.peerBdAddr[3]==0x90 &&
Advreport.peerBdAddr[4]==0x05 && Advreport.peerBdAddr[5]==0x0A)
{
RSSI=Advreport.rssi; // peripheral device 2 rssi value
}
*******************************
Please refer to the Observer project in the GitHub, in this code example, central device scans for the nearby advertising devices continuously and shows the advertising report and scan response data of the advertising devices on the UART terminal (like Tera Term, Hyperterminal).
Please let me know if you have any questions.
Thanks,
P Yugandhar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Yugandhar,
I am not sure you understand what i am trying to ask.
Like you mentioned
- At device B when the device is in central mode, storing the RSSI value of device A in a buffer and after switching it to peripheral mode, sending it through the advertisement data.
- At device C, advertisement report data of Device B (i.e., Advreport.data[0]) will contains the RSSI value of device A. RSSI value of advertisement report, Advreport.rssi of Device B
I am ONLY checking for the advertising device B( having the advertising RSSI data of device A) at device C.
I am not checking for two different advertising devices at device C. I am only checking for device B(because that is the only device i need).
What I am trying to state is At device C when i am trying to receive the RSSI value of device A (Advreport.data[0]) that is stored in buffer, I am getting the values of both device A and device B from the buffer when I am displaying it on Uart Terminal.
Why am i getting the Rssi values of the device B along with device A when i can get advertising device B Rssi value through Advreport.rssi ??
I hope i am clear.Please kindly let me know what am i doing wrong.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Could you please share your peripheral(Device B) and central (Device C) projects so that we can check at our end ?
Thanks,
P Yugandhar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Could you please add the below code in your Central project.
At Central Device C,
************************************************
case CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:
Advreport= *(CYBLE_GAPC_ADV_REPORT_T*) eventParam;
//Checking for
if(Advreport.peerBdAddr[1]==0xD0 && Advreport.peerBdAddr[2]==0x36 && Advreport.peerBdAddr[3]==0x28 &&
Advreport.peerBdAddr[4]==0x00 && Advreport.peerBdAddr[5]==0x0A) // checking for central periphreal Device B
{
if(Advreport.dataLen!=0)
{
RSSI=Advreport.rssi; // central periphreal Device B rssi value
printf("\r\n RSSI value of device central-peripheral is %d \r\n",RSSI);
val[0]=Advreport.data[0]; //Advreport.data will contains the peripheral Device A rssi value
y = ((int)val[0]) - 255;
printf("\r\n RSSI value of device B %d \r\n",y);
}
}
break;
************************************************
Thanks,
P Yugandhar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Worked fine after implementing if(Advreport.dataLen!=0).
Thanks