meshtastic-go icon indicating copy to clipboard operation
meshtastic-go copied to clipboard

bugfixes, cleanups, spelling fixes, and node list output in json format

Open sneak opened this issue 1 year ago • 6 comments

This is going to be a big PR.

  • added LICENSE
  • renamed "recv" to "receive" (to match "send" which is not abbreviated)
  • json output is done with serialization now instead of string interpolation
  • all CLI code is moved out of main module into gmtcli module
  • link-time variables are added to main and passed into CLI for version/build information
  • formatting and linting
  • updated dependencies

new feature:

  • node list output in json format now available, e.g.:
  {
    "node_id": "!9c048d2a",
    "node_number": 2617543978,
    "longname": "PalaceStation",
    "shortname": "PlcS",
    "latitude_degrees": 36.175872,
    "longitude_degrees": -115.2385024,
    "mac_address": "d5:0c:9c:04:8d:2a",
    "is_licensed": false,
    "role": "CLIENT",
    "hardware_model": "RAK4631",
    "battery_level_percent": 100,
    "battery_volts": 4.202000141143799,
    "channel_utilization_percentage": 18.366666793823242,
    "air_utilization_transmit_percentage": 2.9119999408721924,
    "last_heard": "2025-03-28T08:28:01Z",
    "last_heard_seconds_ago": 1381,
    "last_heard_human": "23m1s"
  },
  {
    "node_id": "!15f12ed7",
    "node_number": 368127703,
    "longname": "Mojave Hills Base [Lokakyn]",
    "shortname": "MHB",
    "altitude_meters": 750,
    "latitude_degrees": 35.997413,
    "longitude_degrees": -115.284239,
    "mac_address": "c5:09:15:f1:2e:d7",
    "is_licensed": false,
    "role": "CLIENT_MUTE",
    "hardware_model": "RAK4631",
    "battery_level_percent": 101,
    "battery_volts": 4.297999858856201,
    "channel_utilization_percentage": 7.2166666984558105,
    "air_utilization_transmit_percentage": 0.08166667073965073,
    "last_heard": "2025-03-28T08:12:23Z",
    "last_heard_seconds_ago": 2319,
    "last_heard_human": "38m39s"
  },
  {
    "node_id": "!75679905",
    "node_number": 1969723653,
    "longname": "Tad_Pole",
    "shortname": "TD_P",
    "mac_address": "c2:31:75:67:99:05",
    "is_licensed": false,
    "role": "CLIENT",
    "hardware_model": "RAK4631",
    "battery_level_percent": 95,
    "battery_volts": 4.123000144958496,
    "channel_utilization_percentage": 22.518333435058594,
    "air_utilization_transmit_percentage": 1.8046666383743286,
    "last_heard": "2025-03-28T08:35:55Z",
    "last_heard_seconds_ago": 907,
    "last_heard_human": "15m7s"
  },
  {
    "node_id": "!c98f689e",
    "node_number": 3381618846,
    "longname": "LASmesh Base 03 NLV",
    "shortname": "LAS3",
    "mac_address": "cf:ac:c9:8f:68:9e",
    "is_licensed": false,
    "role": "CLIENT",
    "hardware_model": "RAK4631",
    "battery_level_percent": 95,
    "battery_volts": 4.126999855041504,
    "channel_utilization_percentage": 14.891666412353516,
    "air_utilization_transmit_percentage": 3.3212223052978516,
    "last_heard": "2025-03-27T23:45:44Z",
    "last_heard_seconds_ago": 32718,
    "last_heard_human": "9h5m18s"
  }

sneak avatar Mar 28 '25 07:03 sneak

I know I didn't reach out first to check with you @lmatte7 before doing this work - I needed this output myself, and I was scratching an itch. No hard feelings if you're not interested in upstreaming it, I'm happy to fork the goMesh library and meshtastic-go if you don't want to.

sneak avatar Mar 28 '25 08:03 sneak

I know I didn't reach out first to check with you @lmatte7 before doing this work - I needed this output myself, and I was scratching an itch. No hard feelings if you're not interested in upstreaming it, I'm happy to fork the goMesh library and meshtastic-go if you don't want to.

No I always appreciate pull requests! I'll take a look and merge if things look good or leave feedback if anything needs tweaked

lmatte7 avatar Mar 28 '25 14:03 lmatte7

Happy to incorporate feedback. (I just noticed I am using “percent” and “percentage” and need to be consistent.)

Looking forward to more eyeballs on it. I’ll proceed with the channel list json output.

sneak avatar Mar 28 '25 17:03 sneak

FYI: My end goal is that “message receive” spits out json for each message that includes full detail for each message about sender and channel, so that a consumer doesn’t need to keep track of the channel and node list.

sneak avatar Mar 28 '25 17:03 sneak

I will also probably add support for sending webhooks, so that “message receive” can generate HTTP requests for each inbound message (with complete channel/sender metadata in each POST).

sneak avatar Mar 28 '25 17:03 sneak

Hello! I wanted to check in and mention again I appreciate the PR, and apologize for the delay. Things have been busy 😂

I'm going to pull this down locally and test things out sometime in the next week and wanted to give you a heads up. I'll put any feedback in the files as I review the changes. I'm also planning on cutting a new release of the goMesh repo to include new protobufs, so I'll merge this and put out a new release once that is updated as well.

lmatte7 avatar Apr 16 '25 22:04 lmatte7