Class: Rex::Post::HWBridge::Extensions::Zigbee::Zigbee
- Inherits:
-
Rex::Post::HWBridge::Extension
- Object
- Rex::Post::HWBridge::Extension
- Rex::Post::HWBridge::Extensions::Zigbee::Zigbee
- Defined in:
- lib/rex/post/hwbridge/extensions/zigbee/zigbee.rb
Overview
Zigbee extension - set of commands to be executed on zigbee compatible hw bridges
Instance Attribute Summary collapse
-
#target_device ⇒ Object
Returns the value of attribute target_device.
Attributes inherited from Rex::Post::HWBridge::Extension
Instance Method Summary collapse
-
#get_target_device ⇒ String
Retrieves the default zigbee device ID.
-
#initialize(client) ⇒ Zigbee
constructor
A new instance of Zigbee.
-
#inject(dev, data) ⇒ Object
Injects a raw packet.
-
#recv(dev) ⇒ Hash
Receives data from transceiver.
-
#set_channel(dev, channel) ⇒ Object
Sets the channel.
-
#set_target_device(device) ⇒ Object
Sets the default target device.
-
#sniffer_off(dev) ⇒ Object
Disables sniffer and puts the device in a state that can be changed (like adujsting channel).
-
#sniffer_on(dev) ⇒ Object
Enables sniffer receive mode.
-
#supported_devices ⇒ Array
Gets supported Zigbee Devices.
Constructor Details
#initialize(client) ⇒ Zigbee
Returns a new instance of Zigbee.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rex/post/hwbridge/extensions/zigbee/zigbee.rb', line 17 def initialize(client) super(client, 'zigbee') # Alias the following things on the client object so that they # can be directly referenced client.register_extension_aliases( [ { 'name' => 'zigbee', 'ext' => self } ]) end |
Instance Attribute Details
#target_device ⇒ Object
Returns the value of attribute target_device.
87 88 89 |
# File 'lib/rex/post/hwbridge/extensions/zigbee/zigbee.rb', line 87 def target_device @target_device end |
Instance Method Details
#get_target_device ⇒ String
Retrieves the default zigbee device ID
39 40 41 |
# File 'lib/rex/post/hwbridge/extensions/zigbee/zigbee.rb', line 39 def get_target_device self.target_device end |
#inject(dev, data) ⇒ Object
Injects a raw packet
59 60 61 62 |
# File 'lib/rex/post/hwbridge/extensions/zigbee/zigbee.rb', line 59 def inject(dev, data) data = Base64.urlsafe_encode64(data) client.send_request("/zigbee/#{dev}/inject?data=#{data}") end |
#recv(dev) ⇒ Hash
Receives data from transceiver
67 68 69 70 71 72 73 |
# File 'lib/rex/post/hwbridge/extensions/zigbee/zigbee.rb', line 67 def recv(dev) data = client.send_request("/zigbee/#{dev}/recv") if data.size > 0 data["data"] = Base64.urlsafe_decode64(data["data"]) if data.has_key? "data" end data end |
#set_channel(dev, channel) ⇒ Object
Sets the channel
52 53 54 |
# File 'lib/rex/post/hwbridge/extensions/zigbee/zigbee.rb', line 52 def set_channel(dev, channel) client.send_request("/zigbee/#{dev}/set_channel?chan=#{channel}") end |
#set_target_device(device) ⇒ Object
Sets the default target device
33 34 35 |
# File 'lib/rex/post/hwbridge/extensions/zigbee/zigbee.rb', line 33 def set_target_device(device) self.target_device = device end |
#sniffer_off(dev) ⇒ Object
Disables sniffer and puts the device in a state that can be changed (like adujsting channel)
77 78 79 |
# File 'lib/rex/post/hwbridge/extensions/zigbee/zigbee.rb', line 77 def sniffer_off(dev) client.send_request("/zigbee/#{dev}/sniffer_off") end |
#sniffer_on(dev) ⇒ Object
Enables sniffer receive mode. Not necessary to call before calling recv
83 84 85 |
# File 'lib/rex/post/hwbridge/extensions/zigbee/zigbee.rb', line 83 def sniffer_on(dev) client.send_request("/zigbee/#{dev}/sniffer_on") end |
#supported_devices ⇒ Array
Gets supported Zigbee Devices
45 46 47 |
# File 'lib/rex/post/hwbridge/extensions/zigbee/zigbee.rb', line 45 def supported_devices client.send_request("/zigbee/supported_devices") end |