Sha256: 3499ed7742ce7493aff57b7ff04efe8bff5f3a5e703f57398f849d89f49c9b00
Contents?: true
Size: 981 Bytes
Versions: 1
Compression:
Stored size: 981 Bytes
Contents
module Gom class SensorPorts < Gom::Remote::Entry Defaults = { :interface => '0.0.0.0', :port => 99123, :mode => :udp, } include OAttr oattr :interface, :port, :mode def initialize path, options = {} @path = path @options = Defaults.merge(gnode @path).merge(options) puts " -- new sensor port: #{self.inspect}" end def listen puts " -- listen: #{self.inspect}" self.send "listen_#{mode}" end def listen_udp socket = UDPSocket.new socket.bind(interface, port) loop do msg, sender = socket.recvfrom(1024) puts "-->#{msg}<-- #{sender.inspect}" end ensure socket.close rescue nil end def status puts @options.inspect #t = Net::Telnet::new( # "Host" => device_ip, "Timeout" => 10, "Prompt" => /[$%#>] \z/n #) #t.login(user, password) { |c| puts c } "not implemented" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gom-sensor-ports-0.0.0 | lib/gom-sensor-ports/sensor-ports.rb |