Class: Flic::Protocol::Primitives::BluetoothAddress
- Inherits:
-
BinData::Primitive
- Object
- BinData::Primitive
- Flic::Protocol::Primitives::BluetoothAddress
- Defined in:
- lib/flic/protocol/primitives/bluetooth_address.rb
Overview
A bluetooth address (bdaddr_t) is encoded in little endan, 6 bytes in total. When such an address is written as a string, it is normally written in big endian, where each byte is encoded in hex and colon as separator for each byte. For example, the address 08:09:0a:0b:0c:0d is encoded as the bytes 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08.
Constant Summary collapse
- PRINTF_FORMAT_STRING =
'%.2X:%.2X:%.2X:%.2X:%.2X:%.2X'.freeze
- SCANF_FORMAT_STRING =
'%X:%X:%X:%X:%X:%X'.freeze
Instance Method Summary collapse
Instance Method Details
#get ⇒ Object
16 17 18 |
# File 'lib/flic/protocol/primitives/bluetooth_address.rb', line 16 def get sprintf(PRINTF_FORMAT_STRING, *big_endian_octets) end |
#set(value) ⇒ Object
20 21 22 |
# File 'lib/flic/protocol/primitives/bluetooth_address.rb', line 20 def set(value) self.big_endian_octets = value.scanf(SCANF_FORMAT_STRING) end |