I want to try and use my phone as a beacon for the EFR32BG to scan for. I've set up the scan parameters and included the function to make it scan, as follows.
gecko_cmd_le_gap_set_scan_parameters(80, 400, SCAN_PASSIVE);
gecko_cmd_le_gap_discover(DISCOVER_OBSERVATION);
volatile int8_t advertised_data_rssi[32]; // Just to check variables in debug mode.
volatile uint8_t advertised_pack_type[32];
volatile bd_addr advertised_address[32];
for (int x = 0; x < 32 ; x++){
advertised_data_rssi[x] = 0;
advertised_pack_type[x] = 0;
}
while (1) {
struct gecko_cmd_packet* evt;
// Wait for stack event.
evt = gecko_wait_event();
switch (BGLIB_MSG_ID(evt->header)) {
case gecko_evt_le_gap_scan_response_id:
advertised_data_rssi[i] = evt->data.evt_le_gap_scan_response.rssi;
advertised_pack_type[i] = evt->data.evt_le_gap_scan_response.packet_type;
advertised_address[i] = evt->data.evt_le_gap_scan_response.address;
break;
default:
break;
}
}
Firstly, how do I initialise the variable advertised_address to 0. I know that it's of type bd_addr which is essentially uint8 [6] but treating it as a 2D array doesn't seem to work.
Secondly, the EFR32 doesn't actually seem to be detecting anything, as everything stays 0, however, there definitely are BT devices for it to detect. Is there something wrong in the code? Am I missing something?
Thirdly, because I'm having trouble dealing with the bd_addr type, how do I actually parse it? I want to look for a specific ID, but I can't compare using an if statement, as the beacon ID is way too long.
Thank you!!
Bluetooth Low Energy
Discussion Forums
Bluetooth Classic
Unanswered
Hi,
This is more of a C programming issue rather than Bluetooth.
To initialize an array of bd_addr (which is a struct) you could try the solutions offered here and here.
You're using a variable 'i' to address each of the arrays but I don't see it initialized nor incremented in your code, why do you need arrays, to save multiple devices? You will see the same advertisements multiple times, it could actually be that for example indexes 0 to 2 in your array have the exact same content, it depends on the advertisement interval of the devices scanned by the EFR32.
To parse bd_addr, you can probably find the answer with a quick search over the internet.
Regards,
Tiago
0
Yeah sorry, for some reason I edited the i++; part out of my code. It's there when I run it though, rest assured
Even if the bd_addr variable isn't initialised however, the other variables are, and yet they remain 0 when the program runs. Is the actual Bluetooth setup correct?
Thanks
0
Just for clarity, this is what my entire code looks like:
When I comment out the advertised_address variable, I get the packet_type that I expect. When I leave it in the code, both packet_type and rssi are 0, which is strange.
Look for advertisement using EFR32 - Bluetooth
Hello,
I want to try and use my phone as a beacon for the EFR32BG to scan for. I've set up the scan parameters and included the function to make it scan, as follows.
Firstly, how do I initialise the variable advertised_address to 0. I know that it's of type bd_addr which is essentially uint8 [6] but treating it as a 2D array doesn't seem to work.
Secondly, the EFR32 doesn't actually seem to be detecting anything, as everything stays 0, however, there definitely are BT devices for it to detect. Is there something wrong in the code? Am I missing something?
Thirdly, because I'm having trouble dealing with the bd_addr type, how do I actually parse it? I want to look for a specific ID, but I can't compare using an if statement, as the beacon ID is way too long.
Thank you!!
Hi,
This is more of a C programming issue rather than Bluetooth.
To initialize an array of bd_addr (which is a struct) you could try the solutions offered here and here.
You're using a variable 'i' to address each of the arrays but I don't see it initialized nor incremented in your code, why do you need arrays, to save multiple devices? You will see the same advertisements multiple times, it could actually be that for example indexes 0 to 2 in your array have the exact same content, it depends on the advertisement interval of the devices scanned by the EFR32.
To parse bd_addr, you can probably find the answer with a quick search over the internet.
Regards,
Tiago
Yeah sorry, for some reason I edited the i++; part out of my code. It's there when I run it though, rest assured
Even if the bd_addr variable isn't initialised however, the other variables are, and yet they remain 0 when the program runs. Is the actual Bluetooth setup correct?
Thanks
Just for clarity, this is what my entire code looks like:
When I comment out the advertised_address variable, I get the packet_type that I expect. When I leave it in the code, both packet_type and rssi are 0, which is strange.