class CresIP
For testing 3series device control you can use the reserved joins Analog Joins: 17201 == LCD Brightness Digital Joins: 17229 == LCD Backlight On
17230 == LCD Backlight Off
Device sent: 0d 0002 0000 Controller sent: 0e 0002 0000
server:
0f 0001 02 (request IP ID Register, switch should send IPID)
switch:
0a 000a 00 05 a34240 02 00000000 (IPID: 0x03 to 0xFE === 05) (byte 5) (RESP: 0x02)
server:
02 0004 00000003 (IP ID registry success) failed response: 02 0003 ffff02
- NOTE
-
No example data
Constants
- DefaultPort
- HeartBeatRate
- PacketTypes
- PayloadType
- TLSPort
Public Class Methods
new(callback = nil, &block)
click to toggle source
# File lib/cresip.rb, line 25 def initialize(callback = nil, &block) @callback = callback || block @buffer = String.new end
Public Instance Methods
parse_packet(header, payload)
click to toggle source
# File lib/cresip.rb, line 46 def parse_packet(header, payload) case header.type when :register, :register_response, :register_success @callback.call Register.new(header, payload) when :program_stopping # Should we bother with a callback? when :echo_request, :echo_response @callback.call Echo.new(header, payload) when :action_info action_header = ActionHeader.new action_header.read(payload) @callback.call Action.new(header, action_header) when :serial_data @callback.call SerialData.new(header, payload) end end
read(data)
click to toggle source
# File lib/cresip.rb, line 30 def read(data) @buffer << data while @buffer.length >= 3 do header = PacketHeader.new header.read(@buffer[0..2]) length = header.packet_size + 3 break if @buffer.length < length payload = @buffer[3...length] @buffer = @buffer[length..-1] parse_packet(header, payload) end end