mirror of
https://github.com/isometimes/rpi4-osdev
synced 2024-11-22 10:10:45 +00:00
Modifying part7-bluetooth to show full/friendly device names
This commit is contained in:
parent
db9b058ea9
commit
10ecd8ca76
2 changed files with 27 additions and 16 deletions
|
@ -124,7 +124,7 @@ If you look in _kernel.c_, you'll see the main bulk of our scanning code. Exactl
|
||||||
|
|
||||||
There may be one or more **ad report** in each event, and each contains the 48-bit Bluetooth address of the associated device e.g. `AA:BB:CC:DD:EE:FF` (bd_addr) as well as the data. I found a great article on the [Advertising Data Format from Silicon Labs](https://www.silabs.com/community/wireless/bluetooth/knowledge-base.entry.html/2017/02/10/bluetooth_advertisin-hGsf). Reading this will help you interpret my decode routines.
|
There may be one or more **ad report** in each event, and each contains the 48-bit Bluetooth address of the associated device e.g. `AA:BB:CC:DD:EE:FF` (bd_addr) as well as the data. I found a great article on the [Advertising Data Format from Silicon Labs](https://www.silabs.com/community/wireless/bluetooth/knowledge-base.entry.html/2017/02/10/bluetooth_advertisin-hGsf). Reading this will help you interpret my decode routines.
|
||||||
|
|
||||||
Right now, I'm just printing the bd_addr (using the convenient `uart_hex` routine added to _io.c_), RSSI (an indicator of signal strength), the ad report type & length, and the manufacturer code if received (`ad_type == 0xff`).
|
Right now, I'm just printing the bd_addr (using the convenient `uart_hex` routine added to _io.c_), the ad report type & length, and the friendly/full device name if received (ad_type 0x08 & 0x08 respectively).
|
||||||
|
|
||||||
Proof of life!
|
Proof of life!
|
||||||
--------------
|
--------------
|
||||||
|
|
|
@ -67,9 +67,10 @@ void bt_update()
|
||||||
while ( (buf = poll()) ) {
|
while ( (buf = poll()) ) {
|
||||||
if (data_len >= 2 && buf[0] == LE_ADREPORT_CODE) {
|
if (data_len >= 2 && buf[0] == LE_ADREPORT_CODE) {
|
||||||
unsigned char numreports = buf[1];
|
unsigned char numreports = buf[1];
|
||||||
|
unsigned int c=0;
|
||||||
|
|
||||||
if (numreports == 1 && data_len >= 11) {
|
if (numreports > 0 && data_len >= 11) {
|
||||||
uart_writeText("a(");
|
uart_writeText("\ra(");
|
||||||
for (int c=9;c>=4;c--) {
|
for (int c=9;c>=4;c--) {
|
||||||
if (c != 9) uart_writeText(":");
|
if (c != 9) uart_writeText(":");
|
||||||
uart_hex(buf[c]);
|
uart_hex(buf[c]);
|
||||||
|
@ -78,23 +79,33 @@ void bt_update()
|
||||||
|
|
||||||
unsigned char buf_len = buf[10];
|
unsigned char buf_len = buf[10];
|
||||||
|
|
||||||
if ((buf_len + 11) == data_len - 1) {
|
if ((buf_len + 11) <= data_len - 1) {
|
||||||
buf += 11;
|
buf += 11;
|
||||||
unsigned char rssi = buf[buf_len];
|
|
||||||
uart_writeText(" -> rssi("); uart_hex(rssi); uart_writeText(")");
|
|
||||||
|
|
||||||
|
while (c < numreports) {
|
||||||
unsigned char ad_len = buf[0];
|
unsigned char ad_len = buf[0];
|
||||||
unsigned char ad_type = buf[1];
|
unsigned char ad_type = buf[1];
|
||||||
buf += 2;
|
buf += 2;
|
||||||
uart_writeText(" -> adtype("); uart_hex(ad_type); uart_writeText(":"); uart_hex(ad_len); uart_writeText(")");
|
|
||||||
|
|
||||||
if (ad_len > 2) {
|
if (ad_len > 2) {
|
||||||
if (ad_type == 0xff) {
|
uart_writeText(" -> adtype("); uart_hex(ad_type); uart_writeText(":"); uart_hex(ad_len); uart_writeText(")");
|
||||||
uart_writeText(" -> "); uart_hex(buf[1] << 8); uart_writeText(":"); uart_hex(buf[0]); uart_writeText("\n");
|
|
||||||
|
if (ad_type == 0x09 || ad_type == 0x08) {
|
||||||
|
unsigned int d=0;
|
||||||
|
|
||||||
|
uart_writeText(" -> ");
|
||||||
|
while (d<ad_len - 1) {
|
||||||
|
uart_writeByteBlockingActual(buf[d]);
|
||||||
|
d++;
|
||||||
|
}
|
||||||
|
uart_writeText("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf += ad_len - 1;
|
||||||
|
c++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
uart_writeText("\r");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue