Method: Meshtastic::StreamInterface#connect

Defined in:
lib/meshtastic/stream_interface.rb

#connect(opts = {}) ⇒ Object

Supported Method Parameters

packet_id = Meshtastic.generate_packet_id(

last_packet_id: 'optional - Last Packet ID (Default: 0)'

)



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/meshtastic/stream_interface.rb', line 52

def connect(opts = {})
  # Send some bogus UART characters to force a sleeping device to wake, and
  # if the reading statemachine was parsing a bad packet make sure we write enough start bytes to force it to resync (we don't use START1 because we want to ensure it is looking for START1)
  p = [START2] * 32
  self._write_bytes(p)

  sleep(0.1) # wait 100ms to give device time to start running

  @rx_thread.start
  mui = Meshtastic::MeshInterface.new
  mui.start_config
rescue StandardError => e
  raise e
end