IDBLUE logo
Public Member Functions
IDBluePacket Class Reference
Inheritance diagram for IDBluePacket:
CByteArray IDBlueCommand ByteArrayCommand ByteCommand EpcReadTagCommand EpcWriteTagCommand GetTagInfoCommand ReadBlockCommand ReadBlocksCommand SetPropertyCommand SimpleCommand StringCommand UShortCommand WriteBlockCommand WriteBlocksCommand

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

Detailed Description

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]


Member Function Documentation

- (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.

Returns:
the computed checksum.

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.

Returns:
the payload size

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.

Parameters:
packetSizethe length of the packet, in bytes
headerthe header byte of the IDBluePacket
Returns:
the initialized packet if successful, nil otherwise
- (id) initWithPacketSize: (int)  packetSize

Initialize an IDBluePacket with the specified number of bytes

Parameters:
packetSizethe length of the packet, in bytes.
Returns:
the initialized packet if successful, nil otherwise

Reimplemented in SetPropertyCommand.

- (BOOL) isAsyncPacket

Determine if the current IDBluePacket is the async packet (0x70 0x00 0x00 0x70).

Returns:
TRUE if the current IDBluePacket is the async packet, FALSE otherwise.
- (int) packetSize

The total length of the IDBluePacket

Returns:
the number of bytes contained in the IDBluePacket, including the header byte, 2 payload size bytes, payload size and checksum.
- (byte *) payload

Get a pointer to the payload of the IDBluePacket

Returns:
the pointer to the start byte of the payload. Modifying the data stored in payload will modify the data in the IDBluePacket.
- (int) payloadSize

Get the length of the payload

Returns:
the number of bytes that can be stored in the payload of the IDBluePacket
- (void) setChecksum: (byte)  checksum

Sets the checksum

Parameters:
checksumthe checksum to be set
- (void) setHeader: (byte)  header

Sets the header byte

Parameters:
headerthe header byte to be set
- (NSDate *) timestamp

Get the timestamp of the IDBluePacket

Returns:
the date / time the IDBluePacket was created

The documentation for this class was generated from the following files:

 

Generated on Mon Jan 19 2015 15:47:39
Copyright © 2015 Cathexis Innovations Inc. All Rights Reserved.