This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Weird definition of access_opcode_t?

When reading about access_opcode_t struct on its infocenter page it stumbled upon this table i don't understand.

access_opcode_t is defined as:

Data Fields
-------------------
uint16_t opcode
uint16_t company_id

And the table i don't understand looks like this:

+-----------+-----------+-----------+-----------------------------------------------------------------+
| Byte 0 	| Byte 1 	| Byte 2 	| Description													  |
+-----------+-----------+-----------+-----------------------------------------------------------------+
|0xxxxxxx 	| 			|			| "1-octet Bluetooth SIG Opcodes (excluding 01111111)"			  |
|01111111 	| 			|			| "Reserved for Future Use"										  |
|10xxxxxx 	| xxxxxxxx 	|			| "2-octet Bluetooth SIG Opcodes"								  |
|11xxxxxx 	| zzzzzzzz	| zzzzzzzz 	| "3-octet Vendor Specific Opcodes. z denotes company identifier" |
+-----------+-----------+-----------+-----------------------------------------------------------------+

I read this table as the company_d value is saved in the opcode attribute. Is this correct? It seems wrong to save a value like this when there is a perfectly fine variable that could be used.

If this is true, why should I do it this way, and not just save the company id in the defined attribute?

  • Hi SørenHN,

    It's not "saved in". The company_id is a separated field. When processing the an access_opcode_t instant, first the access layer will check for the first bit of the first byte of "opcode", if it's "0" then only the first byte of opcode is used as in the first row of the table.

    If it's "1" then next bit is checked, if it's "0" then 2 bytes of "opcode" is used. This is the second row.

    If the second bit is "1", then first byte of opcode and 2 bytes in "company_id" will be used, creating a 3 bytes opcode from this combination.

Related