![]() |
Public Member Functions | |
(id) | - initWithPacketSize: |
(id) | - initWithHeader:withHeader: |
(NSDate *) | - timestamp |
(int) | - payloadSize |
(int) | - packetSize |
(byte *) | - payload |
(BOOL) | - isAsyncPacket |
(byte) | - header |
(void) | - setHeader: |
(byte) | - checksum |
(void) | - setChecksum: |
(byte) | - computeChecksum |
(int) | - computePayloadSize |
(void) | - computePayloadSizeAndChecksum |
IDBluePacket represents a command / response for IDBLUE devices. A packet can be between 4 and 256 bytes. An IDBluePacket starts with a header byte, followed by 2 data length bytes, then the payload, and finally a checksum byte (xor of all other bytes).
0 - header byte 1 - data len (MSB) 2 - data len (LSB) 3 - ... - payload [n - 2] - [n - 1] - checksum
An example of the simplest packet would be the NO_OP command [0x00 0x00 0x00 0x00], and the ASYNC packet [0x70 0x00 0x00 0x70]. An example of a packet with a payload would be the beep command: [0x03 0x00 0x01 0x01 0x03]
- (byte) checksum |
Gets the checksum
- (byte) computeChecksum |
Xor all the bytes in the IDBluePacket to compute the checksum and store the results in the last byte of the packet.
- (int) computePayloadSize |
Computes the payload size (i.e. packet size - 4), and stores the payload size in the payload size bytes (index 1 and 2) of the current IDBluePacket.
- (void) computePayloadSizeAndChecksum |
Calls computePayloadSize followed by computeChecksum. This method should be called after modifying the payload.
- (byte) header |
Gets the header byte
- (id) initWithHeader: | (int) | packetSize | |
withHeader: | (byte) | header | |
Initialize an IDBluePacket with the specified number of bytes and the given header byte.
packetSize | the length of the packet, in bytes |
header | the header byte of the IDBluePacket |
- (id) initWithPacketSize: | (int) | packetSize |
Initialize an IDBluePacket with the specified number of bytes
packetSize | the length of the packet, in bytes. |
Reimplemented in SetPropertyCommand.
- (BOOL) isAsyncPacket |
Determine if the current IDBluePacket is the async packet (0x70 0x00 0x00 0x70).
- (int) packetSize |
The total length of the IDBluePacket
- (byte *) payload |
Get a pointer to the payload of the IDBluePacket
- (int) payloadSize |
Get the length of the payload
- (void) setChecksum: | (byte) | checksum |
Sets the checksum
checksum | the checksum to be set |
- (void) setHeader: | (byte) | header |
Sets the header byte
header | the header byte to be set |
- (NSDate *) timestamp |
Get the timestamp of the IDBluePacket