module Meshtastic::SerialInterface
def self.subscribe(opts = {})
def self.subscribe(opts = {}) :serial_obj] :root_topic] ||= 'msh' ion] ||= 'US' ts[:channel_topic] ||= '2/e/LongFast/#' ray of PSKs and attempt each until decrypted OiApB1nwvP+rz05pAQ==' ||= { LongFast: public_psk } parameter must be a hash of :channel_id => psk key value pairs' unless psks.is_a?(Hash) public_psk if psks[:LongFast] == 'AQ==' MeshInterface.new her_keys(psks: psks) |= 0 ||= false clude] clude] s[:gps_metadata] ||= false [:include_raw] ||= false xplorer for topic discovery ot_topic}/#{region}/#{channel_topic}" ot_topic}/#{region}" if region == '#' to: #{full_topic}" be(full_topic, qos) ception: No Ping Response received for 23 seconds (MQTT::ProtocolException) ude.to_s.split(',').map(&:strip) ude.to_s.split(',').map(&:strip) ket do |packet_bytes| ket_bytes.to_s if include_raw et_bytes.topic ||= '' cket_bytes.payload ||= '' d_hash = {} = '' oad_hash = JSON.parse(raw_payload, symbolize_names: true) yload = Meshtastic::ToRadio.decode(raw_payload) oad = Meshtastic::FromRadio.decode(raw_payload) oad_hash = decoded_payload.to_h coded_payload_hash[:packet].is_a?(Hash) ded_payload_hash[:packet] if decoded_payload_hash.keys.include?(:packet) ] = raw_topic id_from] = "!#{message[:from].to_i.to_s(16)}" id_to] = "!#{message[:to].to_i.to_s(16)}" s.include?(:rx_time) = message[:rx_time] nt.is_a?(Integer) c = Time.at(rx_time_int).utc.to_s x_time_utc] = rx_time_utc s.include?(:public_key) ey = message[:public_key] lic_key] = Base64.strict_encode64(raw_public_key) _message is not nil, then decrypt prior to decoding. age = message[:encrypted] essage.to_s.length.positive? && pic] [:pki_encrypted] Display Decrypted PKI Message ey = message[:public_key] ic_key = Base64.strict_decode64(public_key) message[:id] = message[:from] _id = [packet_id].pack('V').ljust(8, "\x00") ode = [packet_from].pack('V').ljust(8, "\x00") once_packet_id}#{nonce_from_node}" LongFast] el = message[:topic].split('/')[-2].to_sym arget_channel] if psks.keys.include?(target_channel) se64.strict_decode64(psk) nSSL::Cipher.new('AES-128-CTR') nSSL::Cipher.new('AES-256-CTR') if dec_psk.length == 32 pt dec_psk nonce cipher.update(encrypted_message) + cipher.final oded] = Meshtastic::Data.decode(decrypted).to_h rypted] = :decrypted coded] Meshtastic::Data.decode(message[:decoded][:payload]).to_h ssage[:decoded][:payload] essage[:decoded][:portnum] stic::MeshInterface.new oded][:payload] = mui.decode_payload( ayload, msg_type, ta: gps_metadata acket] = raw_packet if include_raw d_hash[:packet] = message iven? out] = 'pretty' ge = JSON.pretty_generate(decoded_payload_hash) :CompatibilityError, rotobuf::ParseError, eratorError, rror => e (Encoding::CompatibilityError) rypted] = e.message if e.message.include?('key must be') rypted] = 'unable to decrypt - psk?' if e.message.include?('occurred during parsing') oad_hash[:packet] = message _given? ING: #{e.inspect} - MSG IS >>>" acktrace tdout] = 'inspect' sage = decoded_payload_hash.inspect [message[:id].to_s] if include_arr.empty? a?(Hash) = message.values.join(' ') if exclude_arr.none? { |exclude| flat_message.include?(exclude) } && ( include_arr.first == message[:id] || include_arr.all? { |include| flat_message.include?(include) } ) iven? coded_payload_hash " * 80 G:' out_message * 80 \n\n" ' ected. Exiting..." nnect(serial_obj: serial_obj) unless serial_obj.nil? => e nnect(serial_obj: serial_obj) unless serial_obj.nil?