Class: XBee::Frame::ExplicitAddressingCommand

Inherits:
Base
  • Object
show all
Defined in:
lib/ruxbee/frame/explicit_addressing_command.rb

Overview

Explicit Addressing ZigBee Command Frame (0x11)

This frame allows ZigBee Application Layer fields to be specified for a data transmission. This frame is similar to Zigbee Transmit Request (0x10) but requires the ZigBee application layer addressing fields to be set.

This frame is also used for triggering Programmable XBee (S2B) module Over-the-Air firmware upgrade process.

Instance Attribute Summary collapse

Attributes inherited from Base

#frame_id

Instance Method Summary collapse

Methods inherited from Base

#_dump, #data, #length

Constructor Details

#initialize(frame_id = nil, destination_address = 0x000000000000ffff, destination_network = 0x0000fffe, source_endpoint = nil, destination_endpoint = nil, cluster_id = nil, profile_id = nil, broadcast_radius = 0x00, transmit_options = 0x00, payload = nil, payload_pack_string = "a*") ⇒ ExplicitAddressingCommand

Returns a new instance of ExplicitAddressingCommand.



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ruxbee/frame/explicit_addressing_command.rb', line 18

def initialize(frame_id = nil, destination_address = 0x000000000000ffff, destination_network = 0x0000fffe, source_endpoint = nil, destination_endpoint = nil, cluster_id = nil, profile_id = nil, broadcast_radius = 0x00, transmit_options = 0x00, payload = nil, payload_pack_string = "a*")
  self.frame_id = frame_id
  self.destination_address = destination_address
  self.destination_network = destination_network
  self.source_endpoint = source_endpoint
  self.destination_endpoint = destination_endpoint
  self.cluster_id = cluster_id
  self.profile_id = profile_id
  self.broadcast_radius = broadcast_radius
  self.transmit_options = transmit_options
  self.payload = payload
  self.payload_pack_string = payload_pack_string
end

Instance Attribute Details

#broadcast_radiusObject

Returns the value of attribute broadcast_radius.



16
17
18
# File 'lib/ruxbee/frame/explicit_addressing_command.rb', line 16

def broadcast_radius
  @broadcast_radius
end

#cluster_idObject

Returns the value of attribute cluster_id.



16
17
18
# File 'lib/ruxbee/frame/explicit_addressing_command.rb', line 16

def cluster_id
  @cluster_id
end

#destination_addressObject

Returns the value of attribute destination_address.



16
17
18
# File 'lib/ruxbee/frame/explicit_addressing_command.rb', line 16

def destination_address
  @destination_address
end

#destination_endpointObject

Returns the value of attribute destination_endpoint.



16
17
18
# File 'lib/ruxbee/frame/explicit_addressing_command.rb', line 16

def destination_endpoint
  @destination_endpoint
end

#destination_networkObject

Returns the value of attribute destination_network.



16
17
18
# File 'lib/ruxbee/frame/explicit_addressing_command.rb', line 16

def destination_network
  @destination_network
end

#payloadObject

Returns the value of attribute payload.



16
17
18
# File 'lib/ruxbee/frame/explicit_addressing_command.rb', line 16

def payload
  @payload
end

#payload_pack_stringObject

Returns the value of attribute payload_pack_string.



16
17
18
# File 'lib/ruxbee/frame/explicit_addressing_command.rb', line 16

def payload_pack_string
  @payload_pack_string
end

#profile_idObject

Returns the value of attribute profile_id.



16
17
18
# File 'lib/ruxbee/frame/explicit_addressing_command.rb', line 16

def profile_id
  @profile_id
end

#source_endpointObject

Returns the value of attribute source_endpoint.



16
17
18
# File 'lib/ruxbee/frame/explicit_addressing_command.rb', line 16

def source_endpoint
  @source_endpoint
end

#transmit_optionsObject

Returns the value of attribute transmit_options.



16
17
18
# File 'lib/ruxbee/frame/explicit_addressing_command.rb', line 16

def transmit_options
  @transmit_options
end

Instance Method Details

#api_identifierObject



14
# File 'lib/ruxbee/frame/explicit_addressing_command.rb', line 14

def  api_identifier ; 0x11 ; end

#cmd_dataObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ruxbee/frame/explicit_addressing_command.rb', line 39

def cmd_data
  # We need to pack the 64-bit destination_address in two 32-bit parts.
  dest_high = (self.destination_address >> 32) & 0xFFFFFFFF
  dest_low = self.destination_address & 0xFFFFFFFF
  if payload.nil?
    # By default we send a null-byte payload \0
    [self.frame_id, dest_high, dest_low, self.destination_network, self.source_endpoint, self.destination_endpoint, self.cluster_id, self.profile_id, self.broadcast_radius, self.transmit_options, self.payload].pack("CNNnCCnnCCx")
  else
    [self.frame_id, dest_high, dest_low, self.destination_network, self.source_endpoint, self.destination_endpoint, self.cluster_id, self.profile_id, self.broadcast_radius, self.transmit_options, self.payload].pack("CNNnCCnnCC#{payload_pack_string}")
  end
end

#cmd_data=(data_string) ⇒ Object



32
33
34
35
36
37
# File 'lib/ruxbee/frame/explicit_addressing_command.rb', line 32

def cmd_data=(data_string)
  # We need to read in the 64-bit destination_address in two 32-bit parts.
  dest_high = dest_low = 0
  self.frame_id, dest_high, dest_low, self.destination_network, self.source_endpoint, self.destination_endpoint, self.cluster_id, self.profile_id, self.broadcast_radius, self.transmit_options, self.payload = data_string.unpack("CNNnCCnnCC#{payload_pack_string}")
  self.destination_address = dest_high << 32 | dest_low
end