Module: Meshtastic
- Defined in:
- lib/meshtastic.rb,
lib/meshtastic/atak.rb,
lib/meshtastic/mesh.rb,
lib/meshtastic/mqtt.rb,
lib/meshtastic/admin.rb,
lib/meshtastic/rtttl.rb,
lib/meshtastic/config.rb,
lib/meshtastic/serial.rb,
lib/meshtastic/xmodem.rb,
lib/meshtastic/apponly.rb,
lib/meshtastic/atak_pb.rb,
lib/meshtastic/channel.rb,
lib/meshtastic/mesh_pb.rb,
lib/meshtastic/mqtt_pb.rb,
lib/meshtastic/version.rb,
lib/meshtastic/admin_pb.rb,
lib/meshtastic/paxcount.rb,
lib/meshtastic/portnums.rb,
lib/meshtastic/rtttl_pb.rb,
lib/meshtastic/config_pb.rb,
lib/meshtastic/localonly.rb,
lib/meshtastic/telemetry.rb,
lib/meshtastic/xmodem_pb.rb,
lib/meshtastic/apponly_pb.rb,
lib/meshtastic/channel_pb.rb,
lib/meshtastic/clientonly.rb,
lib/meshtastic/deviceonly.rb,
lib/meshtastic/paxcount_pb.rb,
lib/meshtastic/portnums_pb.rb,
lib/meshtastic/powermon_pb.rb,
lib/meshtastic/device_ui_pb.rb,
lib/meshtastic/localonly_pb.rb,
lib/meshtastic/storeforward.rb,
lib/meshtastic/telemetry_pb.rb,
lib/meshtastic/clientonly_pb.rb,
lib/meshtastic/deviceonly_pb.rb,
lib/meshtastic/module_config.rb,
lib/meshtastic/cannedmessages.rb,
lib/meshtastic/remote_hardware.rb,
lib/meshtastic/storeforward_pb.rb,
lib/meshtastic/module_config_pb.rb,
lib/meshtastic/cannedmessages_pb.rb,
lib/meshtastic/connection_status.rb,
lib/meshtastic/remote_hardware_pb.rb,
lib/meshtastic/connection_status_pb.rb
Overview
Plugin used to interact with Meshtastic nodes
Defined Under Namespace
Modules: ATAK, Admin, Apponly, Cannedmessages, Channel, Clientonly, Config, ConnectionStatus, Deviceonly, Localonly, MQTT, Mesh, ModuleConfig, Paxcount, Portnums, RTTTL, RemoteHardware, Serial, Storeforward, Telemetry, Xmodem
Constant Summary collapse
- TAKPacket =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.TAKPacket").msgclass
- GeoChat =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.GeoChat").msgclass
- Group =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.Group").msgclass
- Status =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.Status").msgclass
- Contact =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.Contact").msgclass
- PLI =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.PLI").msgclass
- Team =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.Team").enummodule
- MemberRole =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.MemberRole").enummodule
- Position =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.Position").msgclass
- User =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.User").msgclass
- RouteDiscovery =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.RouteDiscovery").msgclass
- Routing =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.Routing").msgclass
- Data =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.Data").msgclass
- Waypoint =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.Waypoint").msgclass
- MqttClientProxyMessage =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.MqttClientProxyMessage").msgclass
- MeshPacket =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.MeshPacket").msgclass
- NodeInfo =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.NodeInfo").msgclass
- MyNodeInfo =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.MyNodeInfo").msgclass
- LogRecord =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.LogRecord").msgclass
- QueueStatus =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.QueueStatus").msgclass
- FromRadio =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.FromRadio").msgclass
- ClientNotification =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.ClientNotification").msgclass
- FileInfo =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.FileInfo").msgclass
- ToRadio =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.ToRadio").msgclass
- Compressed =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.Compressed").msgclass
- NeighborInfo =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.NeighborInfo").msgclass
- Neighbor =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.Neighbor").msgclass
- DeviceMetadata =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.DeviceMetadata").msgclass
- Heartbeat =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.Heartbeat").msgclass
- NodeRemoteHardwarePin =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.NodeRemoteHardwarePin").msgclass
- ChunkedPayload =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.ChunkedPayload").msgclass
- Resend_chunks =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.resend_chunks").msgclass
- ChunkedPayloadResponse =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.ChunkedPayloadResponse").msgclass
- HardwareModel =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.HardwareModel").enummodule
- Constants =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.Constants").enummodule
- CriticalErrorCode =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.CriticalErrorCode").enummodule
- ExcludedModules =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.ExcludedModules").enummodule
- ServiceEnvelope =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.ServiceEnvelope").msgclass
- MapReport =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.MapReport").msgclass
- VERSION =
'0.0.118'- AdminMessage =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.AdminMessage").msgclass
- HamParameters =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.HamParameters").msgclass
- NodeRemoteHardwarePinsResponse =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.NodeRemoteHardwarePinsResponse").msgclass
- RTTTLConfig =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.RTTTLConfig").msgclass
- XModem =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.XModem").msgclass
- ChannelSet =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.ChannelSet").msgclass
- ChannelSettings =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.ChannelSettings").msgclass
- ModuleSettings =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.ModuleSettings").msgclass
- PortNum =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.PortNum").enummodule
- PowerMon =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.PowerMon").msgclass
- PowerStressMessage =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.PowerStressMessage").msgclass
- DeviceUIConfig =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.DeviceUIConfig").msgclass
- NodeFilter =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.NodeFilter").msgclass
- NodeHighlight =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.NodeHighlight").msgclass
- Theme =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.Theme").enummodule
- Language =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.Language").enummodule
- LocalConfig =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.LocalConfig").msgclass
- LocalModuleConfig =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.LocalModuleConfig").msgclass
- DeviceMetrics =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.DeviceMetrics").msgclass
- EnvironmentMetrics =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.EnvironmentMetrics").msgclass
- PowerMetrics =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.PowerMetrics").msgclass
- AirQualityMetrics =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.AirQualityMetrics").msgclass
- LocalStats =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.LocalStats").msgclass
- HealthMetrics =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.HealthMetrics").msgclass
- Nau7802Config =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.Nau7802Config").msgclass
- TelemetrySensorType =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.TelemetrySensorType").enummodule
- DeviceProfile =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.DeviceProfile").msgclass
- PositionLite =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.PositionLite").msgclass
- UserLite =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.UserLite").msgclass
- NodeInfoLite =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.NodeInfoLite").msgclass
- DeviceState =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.DeviceState").msgclass
- ChannelFile =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.ChannelFile").msgclass
- StoreAndForward =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.StoreAndForward").msgclass
- RemoteHardwarePin =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.RemoteHardwarePin").msgclass
- RemoteHardwarePinType =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.RemoteHardwarePinType").enummodule
- CannedMessageModuleConfig =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.CannedMessageModuleConfig").msgclass
- HardwareMessage =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.HardwareMessage").msgclass
- DeviceConnectionStatus =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.DeviceConnectionStatus").msgclass
- WifiConnectionStatus =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.WifiConnectionStatus").msgclass
- EthernetConnectionStatus =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.EthernetConnectionStatus").msgclass
- NetworkConnectionStatus =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.NetworkConnectionStatus").msgclass
- BluetoothConnectionStatus =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.BluetoothConnectionStatus").msgclass
- SerialConnectionStatus =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("meshtastic.SerialConnectionStatus").msgclass
Class Method Summary collapse
-
.authors ⇒ Object
- Author(s)
-
0day Inc.
-
.decode_payload(opts = {}) ⇒ Object
- Supported Method Parameters
-
Meshtastic::MQQT.decode_payload( payload: ‘required - payload to recursively decode’, msg_type: ‘required - message type (e.g. :TEXT_MESSAGE_APP)’, gps_metadata: ‘optional - include GPS metadata in output (default: false)’, ).
-
.generate_packet_id(opts = {}) ⇒ Object
- Supported Method Parameters
-
packet_id = Meshtastic.generate_packet_id( last_packet_id: ‘optional - Last Packet ID (Default: 0)’ ).
-
.get_cipher_keys(opts = {}) ⇒ Object
- Supported Method Parameters
-
Meshtastic.get_cipher_keys( psks: ‘required - hash of channel / pre-shared key value pairs’ ).
-
.gps_search(opts = {}) ⇒ Object
- Supported Method Parameters
-
Meshtastic.gps_search( lat: ‘required - latitude float (e.g. 37.7749)’, lon: ‘required - longitude float (e.g. -122.4194)’ ).
-
.help ⇒ Object
Display a List of Every Meshtastic Module.
-
.send_data(opts = {}) ⇒ Object
- Supported Method Parameters
-
Meshtastic.send_data( from: ‘required - From ID (String or Integer) (Default: “!00000b0b”)’, to: ‘optional - Destination ID (Default: “!ffffffff”)’, last_packet_id: ‘optional - Last Packet ID (Default: 0)’, via: ‘optional - :radio || :mqtt (Default: :radio)’, channel: ‘optional - Channel (Default: 0)’, data: ‘required - Data to Send’, want_ack: ‘optional - Want Acknowledgement (Default: false)’, hop_limit: ‘optional - Hop Limit (Default: 3)’, port_num: ‘optional - (Default: Meshtastic::PortNum::PRIVATE_APP)’, psks: ‘optional - hash of :channel => psk key value pairs (default: { LongFast: “AQ==” })’ ).
-
.send_packet(opts = {}) ⇒ Object
- Supported Method Parameters
-
Meshtastic.send_packet( mesh_packet: ‘required - Mesh Packet to Send’, from: ‘required - From ID (String or Integer) (Default: “!00000b0b”)’, to: ‘optional - Destination ID (Default: “!ffffffff”)’, last_packet_id: ‘optional - Last Packet ID (Default: 0)’, via: ‘optional - :radio || :mqtt (Default: :radio)’, channel: ‘optional - Channel (Default: 0)’, want_ack: ‘optional - Want Acknowledgement (Default: false)’, hop_limit: ‘optional - Hop Limit (Default: 3)’, psks: ‘optional - hash of :channel => psk key value pairs (default: { LongFast: “AQ==” })’ ).
-
.send_text(opts = {}) ⇒ Object
- Supported Method Parameters
-
Meshtastic.send_text( from: ‘required - From ID (String or Integer) (Default: “!00000b0b”)’, to: ‘optional - Destination ID (Default: “!ffffffff”)’, last_packet_id: ‘optional - Last Packet ID (Default: 0)’, via: ‘optional - :radio || :mqtt (Default: :radio)’, channel: ‘optional - Channel (Default: 6)’, text: ‘optional - Text Message (Default: SYN)’, want_ack: ‘optional - Want Acknowledgement (Default: false)’, want_response: ‘optional - Want Response (Default: false)’, hop_limit: ‘optional - Hop Limit (Default: 3)’, on_response: ‘optional - Callback on Response’, psks: ‘optional - hash of :channel => psk key value pairs (default: { LongFast: “AQ==” })’ ).
-
.send_to_mqtt(opts = {}) ⇒ Object
- Supported Method Parameters
-
Meshtastic.send_to_mqtt( service_envelope: ‘required - ServiceEnvelope Message to Send’ ).
-
.send_to_radio(opts = {}) ⇒ Object
- Supported Method Parameters
-
Meshtastic.send_to_radio( to_radio: ‘required - ToRadio Message to Send’ ).
Class Method Details
.authors ⇒ Object
- Author(s)
-
0day Inc. <[email protected]>
477 478 479 480 481 |
# File 'lib/meshtastic.rb', line 477 public_class_method def self. "AUTHOR(S): 0day Inc. <[email protected]> " end |
.decode_payload(opts = {}) ⇒ Object
- Supported Method Parameters
-
Meshtastic::MQQT.decode_payload(
payload: 'required - payload to recursively decode', msg_type: 'required - message type (e.g. :TEXT_MESSAGE_APP)', gps_metadata: 'optional - include GPS metadata in output (default: false)',)
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 |
# File 'lib/meshtastic.rb', line 366 public_class_method def self.decode_payload(opts = {}) payload = opts[:payload] msg_type = opts[:msg_type] = opts[:gps_metadata] case msg_type when :ADMIN_APP decoder = Meshtastic::AdminMessage when :ATAK_FORWARDER, :ATAK_PLUGIN decoder = Meshtastic::TAKPacket # when :AUDIO_APP # decoder = Meshtastic::Audio when :DETECTION_SENSOR_APP decoder = Meshtastic::DeviceState # when :IP_TUNNEL_APP # decoder = Meshtastic::IpTunnel when :MAP_REPORT_APP decoder = Meshtastic::MapReport # when :MAX # decoder = Meshtastic::Max when :NEIGHBORINFO_APP decoder = Meshtastic::NeighborInfo when :NODEINFO_APP decoder = Meshtastic::User when :PAXCOUNTER_APP decoder = Meshtastic::Paxcount when :POSITION_APP decoder = Meshtastic::Position # when :PRIVATE_APP # decoder = Meshtastic::Private when :RANGE_TEST_APP # Unsure if this is the correct protobuf object decoder = Meshtastic::FromRadio when :REMOTE_HARDWARE_APP decoder = Meshtastic::HardwareMessage # when :REPLY_APP # decoder = Meshtastic::Reply when :ROUTING_APP decoder = Meshtastic::Routing when :SERIAL_APP decoder = Meshtastic::SerialConnectionStatus when :SIMULATOR_APP decoder = Meshtastic::Compressed when :STORE_FORWARD_APP decoder = Meshtastic::StoreAndForward when :TELEMETRY_APP decoder = Meshtastic::Telemetry when :TEXT_MESSAGE_APP, :UNKNOWN_APP decoder = Meshtastic::Data when :TRACEROUTE_APP decoder = Meshtastic::RouteDiscovery when :WAYPOINT_APP decoder = Meshtastic::Waypoint # when :ZPS_APP # decoder = Meshtastic::Zps else puts "WARNING: Can't decode\n#{payload.inspect}\nw/ portnum: #{msg_type}" return payload end payload = decoder.decode(payload).to_h if payload.keys.include?(:latitude_i) lat = payload[:latitude_i] * 0.0000001 payload[:latitude] = lat end if payload.keys.include?(:longitude_i) lon = payload[:longitude_i] * 0.0000001 payload[:longitude] = lon end if payload.keys.include?(:macaddr) mac_raw = payload[:macaddr] mac_hex_arr = mac_raw.bytes.map { |byte| byte.to_s(16).rjust(2, '0') } mac_hex_str = mac_hex_arr.join(':') payload[:macaddr] = mac_hex_str end if payload.keys.include?(:public_key) public_key_raw = payload[:public_key] payload[:public_key] = Base64.strict_encode64(public_key_raw) end if payload.keys.include?(:time) time_int = payload[:time] if time_int.is_a?(Integer) time_utc = Time.at(time_int).utc.to_s payload[:time_utc] = time_utc end end if && payload[:latitude] && payload[:longitude] lat = payload[:latitude] lon = payload[:longitude] unless lat.zero? && lon.zero? gps_search_resp = gps_search(lat: lat, lon: lon) payload[:gps_metadata] = gps_search_resp end end payload rescue Encoding::CompatibilityError, Google::Protobuf::ParseError payload rescue StandardError => e raise e end |
.generate_packet_id(opts = {}) ⇒ Object
- Supported Method Parameters
-
packet_id = Meshtastic.generate_packet_id(
last_packet_id: 'optional - Last Packet ID (Default: 0)')
283 284 285 286 287 288 289 290 291 |
# File 'lib/meshtastic.rb', line 283 public_class_method def self.generate_packet_id(opts = {}) last_packet_id = opts[:last_packet_id] ||= 0 last_packet_id = 0 if last_packet_id.negative? packet_id = Random.rand(0xffffffff) if last_packet_id.zero? packet_id = (last_packet_id + 1) & 0xffffffff if last_packet_id.positive? packet_id end |
.get_cipher_keys(opts = {}) ⇒ Object
- Supported Method Parameters
-
Meshtastic.get_cipher_keys(
psks: 'required - hash of channel / pre-shared key value pairs')
298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File 'lib/meshtastic.rb', line 298 public_class_method def self.get_cipher_keys(opts = {}) psks = opts[:psks] psks.each_key do |key| psk = psks[key] padded_psk = psk.ljust(psk.length + ((4 - (psk.length % 4)) % 4), '=') replaced_psk = padded_psk.gsub('-', '+').gsub('_', '/') psks[key] = replaced_psk end psks rescue StandardError => e raise e end |
.gps_search(opts = {}) ⇒ Object
- Supported Method Parameters
-
Meshtastic.gps_search(
lat: 'required - latitude float (e.g. 37.7749)', lon: 'required - longitude float (e.g. -122.4194)')
346 347 348 349 350 351 352 353 354 355 356 357 |
# File 'lib/meshtastic.rb', line 346 public_class_method def self.gps_search(opts = {}) lat = opts[:lat] lon = opts[:lon] raise 'ERROR: Latitude and Longitude are required' unless lat && lon gps_arr = [lat.to_f, lon.to_f] Geocoder.search(gps_arr).first.data rescue StandardError => e raise e end |
.help ⇒ Object
Display a List of Every Meshtastic Module
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 |
# File 'lib/meshtastic.rb', line 485 public_class_method def self.help puts "USAGE: #{self}.send_text( from: 'required - From ID (String or Integer) (Default: \"!00000b0b\")', to: 'optional - Destination ID (Default: \"!ffffffff\")', last_packet_id: 'optional - Last Packet ID (Default: 0)', via: 'optional - :radio || :mqtt (Default: :radio)', channel: 'optional - Channel (Default: 6)', text: 'optional - Text Message (Default: SYN)', want_ack: 'optional - Want Acknowledgement (Default: false)', want_response: 'optional - Want Response (Default: false)', hop_limit: 'optional - Hop Limit (Default: 3)', on_response: 'optional - Callback on Response', psks: 'optional - hash of :channel => psk key value pairs (default: { LongFast: \"AQ==\" })' ) #{self}.send_data( from: 'required - From ID (String or Integer) (Default: \"!00000b0b\")', to: 'optional - Destination ID (Default: \"!ffffffff\")', last_packet_id: 'optional - Last Packet ID (Default: 0)', via: 'optional - :radio || :mqtt (Default: :radio)', channel: 'optional - Channel (Default: 0)', data: 'required - Data to Send', want_ack: 'optional - Want Acknowledgement (Default: false)', hop_limit: 'optional - Hop Limit (Default: 3)', port_num: 'optional - (Default: Meshtastic::PortNum::PRIVATE_APP)', psks: 'optional - hash of :channel => psk key value pairs (default: { LongFast: \"AQ==\" })' ) #{self}.send_packet( mesh_packet: 'required - Mesh Packet to Send', from: 'required - From ID (String or Integer) (Default: \"!00000b0b\")', to: 'optional - Destination ID (Default: \"!ffffffff\")', last_packet_id: 'optional - Last Packet ID (Default: 0)', via: 'optional - :radio || :mqtt (Default: :radio)', channel: 'optional - Channel (Default: 0)', want_ack: 'optional - Want Acknowledgement (Default: false)', hop_limit: 'optional - Hop Limit (Default: 3)', psks: 'optional - hash of :channel => psk key value pairs (default: { LongFast: \"AQ==\" })' ) #{self}.generate_packet_id( last_packet_id: 'optional - Last Packet ID (Default: 0)' ) #{self}.get_cipher_keys( psks: 'required - hash of channel / pre-shared key value pairs' ) #{self}.send_to_radio( to_radio: 'required - ToRadio Message to Send' ) #{self}.send_to_mqtt( service_envelope: 'required - ServiceEnvelope Message to Send' ) #{self}.gps_search( lat: 'required - latitude float (e.g. 37.7749)', lon: 'required - longitude float (e.g. -122.4194)' ) #{self}.decode_payload( payload: 'required - payload to recursively decode', msg_type: 'required - message type (e.g. :TEXT_MESSAGE_APP)', gps_metadata: 'optional - include GPS metadata in output (default: false)', ) #{self}.authors " end |
.send_data(opts = {}) ⇒ Object
- Supported Method Parameters
-
Meshtastic.send_data(
from: 'required - From ID (String or Integer) (Default: "!00000b0b")', to: 'optional - Destination ID (Default: "!ffffffff")', last_packet_id: 'optional - Last Packet ID (Default: 0)', via: 'optional - :radio || :mqtt (Default: :radio)', channel: 'optional - Channel (Default: 0)', data: 'required - Data to Send', want_ack: 'optional - Want Acknowledgement (Default: false)', hop_limit: 'optional - Hop Limit (Default: 3)', port_num: 'optional - (Default: Meshtastic::PortNum::PRIVATE_APP)', psks: 'optional - hash of :channel => psk key value pairs (default: { LongFast: "AQ==" })')
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/meshtastic.rb', line 138 public_class_method def self.send_data(opts = {}) # Send a text message to a node from = opts[:from] ||= '!00000b0b' # from_hex = from.delete('!').bytes.map { |b| b.to_s(16).rjust(2, '0') }.join if from.is_a?(String) from_hex = from.delete('!') if from.is_a?(String) from = from_hex.to_i(16) if from_hex raise 'ERROR: from parameter is required.' unless from to = opts[:to] ||= '!ffffffff' # to_hex = to.delete('!').bytes.map { |b| b.to_s(16).rjust(2, '0') }.join if to.is_a?(String) to_hex = to.delete('!') if to.is_a?(String) to = to_hex.to_i(16) if to_hex last_packet_id = opts[:last_packet_id] ||= 0 via = opts[:via] ||= :radio channel = opts[:channel] ||= 0 data = opts[:data] want_ack = opts[:want_ack] ||= false hop_limit = opts[:hop_limit] ||= 3 port_num = opts[:port_num] ||= Meshtastic::PortNum::PRIVATE_APP max_port_num = Meshtastic::PortNum::MAX raise "ERROR: Invalid port_num" unless port_num.positive? && port_num < max_port_num public_psk = '1PG7OiApB1nwvP+rz05pAQ==' psks = opts[:psks] ||= { LongFast: public_psk } raise 'ERROR: psks parameter must be a hash of :channel => psk key value pairs' unless psks.is_a?(Hash) psks[:LongFast] = public_psk if psks[:LongFast] == 'AQ==' data_len = data.payload.length max_len = Meshtastic::Constants::DATA_PAYLOAD_LEN raise "ERROR: Data Length > #{max_len} Bytes" if data_len > max_len mesh_packet = Meshtastic::MeshPacket.new mesh_packet.decoded = data send_packet( mesh_packet: mesh_packet, from: from, to: to, last_packet_id: last_packet_id, via: via, channel: channel, want_ack: want_ack, hop_limit: hop_limit, psks: psks ) rescue StandardError => e raise e end |
.send_packet(opts = {}) ⇒ Object
- Supported Method Parameters
-
Meshtastic.send_packet(
mesh_packet: 'required - Mesh Packet to Send', from: 'required - From ID (String or Integer) (Default: "!00000b0b")', to: 'optional - Destination ID (Default: "!ffffffff")', last_packet_id: 'optional - Last Packet ID (Default: 0)', via: 'optional - :radio || :mqtt (Default: :radio)', channel: 'optional - Channel (Default: 0)', want_ack: 'optional - Want Acknowledgement (Default: false)', hop_limit: 'optional - Hop Limit (Default: 3)', psks: 'optional - hash of :channel => psk key value pairs (default: { LongFast: "AQ==" })')
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'lib/meshtastic.rb', line 201 public_class_method def self.send_packet(opts = {}) mesh_packet = opts[:mesh_packet] from = opts[:from] ||= '!00000b0b' # from_hex = from.delete('!').bytes.map { |b| b.to_s(16).rjust(2, '0') }.join if from.is_a?(String) from_hex = from.delete('!') if from.is_a?(String) from = from_hex.to_i(16) if from_hex raise 'ERROR: from parameter is required.' unless from to = opts[:to] ||= '!ffffffff' # to_hex = to.delete('!').bytes.map { |b| b.to_s(16).rjust(2, '0') }.join if to.is_a?(String) to_hex = to.delete('!') if to.is_a?(String) to = to_hex.to_i(16) if to_hex last_packet_id = opts[:last_packet_id] ||= 0 via = opts[:via] ||= :radio channel = opts[:channel] ||= 0 want_ack = opts[:want_ack] ||= false hop_limit = opts[:hop_limit] ||= 3 public_psk = '1PG7OiApB1nwvP+rz05pAQ==' psks = opts[:psks] ||= { LongFast: public_psk } raise 'ERROR: psks parameter must be a hash of :channel => psk key value pairs' unless psks.is_a?(Hash) psks[:LongFast] = public_psk if psks[:LongFast] == 'AQ==' # my_info = Meshtastic::FromRadio.my_info # wait_connected if to != my_info.my_node_num && my_info.is_a(Meshtastic::Deviceonly::MyInfo) mesh_packet.from = from mesh_packet.to = to mesh_packet.channel = channel mesh_packet.want_ack = want_ack mesh_packet.hop_limit = hop_limit mesh_packet.id = generate_packet_id(last_packet_id: last_packet_id) if psks nonce_packet_id = [mesh_packet.id].pack('V').ljust(8, "\x00") nonce_from_node = [from].pack('V').ljust(8, "\x00") nonce = "#{nonce_packet_id}#{nonce_from_node}" psk = psks[psks.keys.first] dec_psk = Base64.strict_decode64(psk) cipher = OpenSSL::Cipher.new('AES-128-CTR') cipher = OpenSSL::Cipher.new('AES-256-CTR') if dec_psk.length == 32 cipher.encrypt cipher.key = dec_psk cipher.iv = nonce decrypted_payload = mesh_packet.decoded.to_proto encrypted_payload = cipher.update(decrypted_payload) + cipher.final mesh_packet.encrypted = encrypted_payload end # puts mesh_packet.to_h # puts "Sending Packet via: #{via}" case via when :radio # Sending a to_radio message over mqtt # causes unpredictable behavior # (e.g. disconnecting node(s) from bluetooth) to_radio = Meshtastic::ToRadio.new to_radio.packet = mesh_packet send_to_radio(to_radio: to_radio) when :mqtt service_envelope = Meshtastic::ServiceEnvelope.new service_envelope.packet = mesh_packet # TODO: Add support for multiple PSKs by accepting channel_id service_envelope.channel_id = psks.keys.first service_envelope.gateway_id = "!#{from.to_s(16).downcase}" send_to_mqtt(service_envelope: service_envelope) else raise "ERROR: Invalid via parameter: #{via}" end rescue StandardError => e raise e end |
.send_text(opts = {}) ⇒ Object
- Supported Method Parameters
-
Meshtastic.send_text(
from: 'required - From ID (String or Integer) (Default: "!00000b0b")', to: 'optional - Destination ID (Default: "!ffffffff")', last_packet_id: 'optional - Last Packet ID (Default: 0)', via: 'optional - :radio || :mqtt (Default: :radio)', channel: 'optional - Channel (Default: 6)', text: 'optional - Text Message (Default: SYN)', want_ack: 'optional - Want Acknowledgement (Default: false)', want_response: 'optional - Want Response (Default: false)', hop_limit: 'optional - Hop Limit (Default: 3)', on_response: 'optional - Callback on Response', psks: 'optional - hash of :channel => psk key value pairs (default: { LongFast: "AQ==" })')
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/meshtastic.rb', line 67 public_class_method def self.send_text(opts = {}) # Send a text message to a node from = opts[:from] ||= '!00000b0b' # from_hex = from.delete('!').bytes.map { |b| b.to_s(16).rjust(2, '0') }.join if from.is_a?(String) from_hex = from.delete('!') if from.is_a?(String) from = from_hex.to_i(16) if from_hex raise 'ERROR: from parameter is required.' unless from to = opts[:to] ||= '!ffffffff' # to_hex = to.delete('!').bytes.map { |b| b.to_s(16).rjust(2, '0') }.join if to.is_a?(String) to_hex = to.delete('!') if to.is_a?(String) to = to_hex.to_i(16) if to_hex last_packet_id = opts[:last_packet_id] ||= 0 via = opts[:via] ||= :radio channel = opts[:channel] ||= 6 text = opts[:text] ||= 'SYN' want_ack = opts[:want_ack] ||= false want_response = opts[:want_response] ||= false hop_limit = opts[:hop_limit] ||= 3 on_response = opts[:on_response] public_psk = '1PG7OiApB1nwvP+rz05pAQ==' psks = opts[:psks] ||= { LongFast: public_psk } raise 'ERROR: psks parameter must be a hash of :channel => psk key value pairs' unless psks.is_a?(Hash) psks[:LongFast] = public_psk if psks[:LongFast] == 'AQ==' # TODO: verify text length validity max_txt_len = Meshtastic::Constants::DATA_PAYLOAD_LEN raise "ERROR: Text Length > #{max_txt_len} Bytes" if text.length > max_txt_len port_num = Meshtastic::PortNum::TEXT_MESSAGE_APP data = Meshtastic::Data.new data.payload = text.force_encoding('ASCII-8BIT') data.portnum = port_num data.want_response = want_response # puts data.to_h send_data( from: from, to: to, last_packet_id: last_packet_id, via: via, channel: channel, data: data, want_ack: want_ack, want_response: want_response, hop_limit: hop_limit, port_num: port_num, on_response: on_response, psks: psks ) rescue StandardError => e raise e end |
.send_to_mqtt(opts = {}) ⇒ Object
- Supported Method Parameters
-
Meshtastic.send_to_mqtt(
service_envelope: 'required - ServiceEnvelope Message to Send')
331 332 333 334 335 336 337 338 339 |
# File 'lib/meshtastic.rb', line 331 public_class_method def self.send_to_mqtt(opts = {}) service_envelope = opts[:service_envelope] raise 'ERROR: Invalid ServiceEnvelope Message' unless service_envelope.is_a?(Meshtastic::ServiceEnvelope) service_envelope.to_proto rescue StandardError => e raise e end |
.send_to_radio(opts = {}) ⇒ Object
- Supported Method Parameters
-
Meshtastic.send_to_radio(
to_radio: 'required - ToRadio Message to Send')
317 318 319 320 321 322 323 324 325 |
# File 'lib/meshtastic.rb', line 317 public_class_method def self.send_to_radio(opts = {}) to_radio = opts[:to_radio] raise 'ERROR: Invalid ToRadio Message' unless to_radio.is_a?(Meshtastic::ToRadio) to_radio.to_proto rescue StandardError => e raise e end |