Class: BuildWatcher::ZigbeeDevice

Inherits:
Object
  • Object
show all
Defined in:
lib/build_watcher/zigbee_device.rb

Instance Method Summary collapse

Constructor Details

#initialize(device) ⇒ ZigbeeDevice

Returns a new instance of ZigbeeDevice.



3
4
5
6
7
# File 'lib/build_watcher/zigbee_device.rb', line 3

def initialize(device)
  @device = device
  @connection = "USE #serial_device INSTEAD OF CONNECTION DIRECTLY"
  Struct.new("ProjectInfo", :public_key, :private_key) unless defined?(Struct::ProjectInfo)
end

Instance Method Details

#broadcast_status(public_key, status) ⇒ Object



25
26
27
28
29
# File 'lib/build_watcher/zigbee_device.rb', line 25

def broadcast_status(public_key, status)
  serial_device do |connection|
    connection.puts(Message.project_status(public_key, status))
  end
end

#project_info(project_index) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/build_watcher/zigbee_device.rb', line 17

def project_info(project_index)
  serial_device do
    request_project_info(project_index)
    sleep(0.5)
    read_project_info
  end
end

#project_quantityObject



9
10
11
12
13
14
15
# File 'lib/build_watcher/zigbee_device.rb', line 9

def project_quantity
  serial_device do
    request_project_count
    sleep(0.5)
    read_project_count
  end
end