I'm reading a BLE device and my api return me this struct
typedef struct {
LGATTAddress bd_addr;
int32_t rssi;
uint8_t eir_len;
uint8_t eir[256];
} LGATTDeviceInfo;
I try to print some eir_len and eir[256] and this is the result
for(int i = 0; i < 255; i++)
{
Serial.print(info.eir[i], HEX);
}
Serial.println();
Serial.print("Advertising data lenght: ");
Serial.print(info.eir_len);
Serial.println();
21613FF4C0CE8E1B87D83CB43431A739F4496E0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Advertising data lenght: 23
2167FF4C0102B00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Advertising data lenght: 11
216320A0109524543414D3532474A5830313235315125005002A0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Advertising data lenght: 33
I cannot understand the relation between the air and the lenght: in the second example the response is 13 char but the lenght is 11. Why?
According to bluetooth specs..
The data is 240 octets and consists of a significant part and a non-significant part. The significant part contains a sequence of data structures. Each data structure shall have a length field of one octet, which contains the Length value, and a data field of Length octets. The first n octets of the data field contain the extended inquiry response (EIR) data type. The content of the remaining Length - n octets in the data field depends on the value of the EIR data type and is called the EIR data. The non-significant part extends the extended inquiry response to 240 octets and shall contain all-zero octets.
How can I parse the eir to obtain all the data? For example the name of the device and the manufacturer data?
update
Let's take for example this response
[LGATTC ino]dev address : [8:46:be:ca:2c:2] rssi [-63]
2 1 6 9 8 69 53 65 6E 73 6F 72 20 9 FF BE CA 2C 2 46 2 5F 5D 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Advertising data lenght: 23
I try to convert the hex to string and this part 69 53 65 6E 73 6F 72
is the sensor name (iSensor).
This is a bluetooth sensor that change in this way
<be ca 2c 02 46 02 58 56> - > open
<be ca 2c 02 46 00 59 55> - > close
<be ca 2c 02 46 02 5a 58> - > open
<be ca 2c 02 46 00 5b 57> - > close
<be ca 2c 02 46 02 5c 5a> - > open
<be ca 2c 02 46 00 5d 59> - > close
<be ca 2c 02 46 02 5e 5c> - > open
<be ca 2c 02 46 00 5f 5b> - > close
These are the manufacturer data: the first part be ca 2c 02
is the unique identifier of the device, the 02/00
identify the status of the sensor...
By the way I negin to understand... I notice now the match between the lenght and the eir!
I must now extract the name in char, the status and the device code!
edit 2 I found the specs of my sensors...