module MaxCube::Messages::TCP::Serializer::MessageZ

Wakeup command. Acknowledgement (A) follows.

Constants

KEYS

Mandatory hash keys.

OPT_KEYS

Optional hash keys.

Private Instance Methods

serialize_tcp_z(hash) click to toggle source
# File lib/maxcube/messages/tcp/type/z.rb, line 16
def serialize_tcp_z(hash)
  time = format('%02x', to_int(0, 'time', hash[:time]))
  scope = hash[:scope].to_sym
  scope = case scope
          when :group, :room
            'G'
          when :all
            'A'
          when :device
            'D'
          else
            raise InvalidMessageBody.new(@msg_type,
                                         "invalid scope: #{scope}")
          end
  args = [time, scope]
  args << format('%02x', to_int(0, 'ID', hash[:id])) if hash.key?(:id)
  args.join(',')
end