How to set channel + URL from Python only?

For those of us with iOS instead of Android: is there a simple HowTo, explaining how to configure channels and URLs, including setting new cryptographic keys, channels names, channel options such as “Very long range (but slower)” etc. using Python?
(Essentially everything that one can do with the Android app, but using Python.)

It’s probably all implemented, but I cannot find any documentation on how to start.

1 Like

As per

meshtastic -h

I’m aware of two arguments for the meshtastic command:

--setch-longslow      Change to the standard long-range (but slow) channel
--setch-shortfast     Change to the standard fast (but short range) channel

Alas, I’m not sure how to set the other two intermediate channel data-rates.

There’s also

  --setchan SETCHAN SETCHAN
                    Set a channel parameter

which I presume accepts as arguments those detailed here, but I’ve yet to try them out.

Thanks, but there is, for example, no option for “Very long range (but slower)” in that meshtastic Python script. :upside_down_face:
Also, at least to my understanding, the URL depends on all these channel parameters, doesn’t it? Is the URL updated when I change a channel parameter? What’s the format of that URL, or how do I construct my own URL? :thinking:

Yep, that’s why I wrote I have no idea how to set all data-rates :grin:

I really hope someone in the know will step in!

I’ll try to help. The URL is constructed automatically based off of the current channel settings. So if you want to customize a channel you could do something like:

meshtastic --setchan name mychan --setchan channel_num 4 --info

This will change some channel params and then show device info (which will include the current channel URL)

I’ll try to update the docs tonight to add some more examples

ok thanks for asking this, because while trying to make an example of setting the psk from the python command line I found a bug. I’ve just released 1.1.33 of the python tool to fix this. I’ve also updated the docs to include an example of setting the PSK. Also if setting PSK to a custom value be very careful to make sure it has 0, 128 or 256 bits (no encryption, aes128, aes256). Because the device code currently requires that.

btw - the reason for my warning about being careful to use the right # of bytes for the psk is a bug in the device code. Which will be fixed in the next release:

Thanks for clarification, that’s very helpful.

The following script:

import meshtastic

interface = meshtastic.SerialInterface()
print (interface.radioConfig.channel_settings.coding_rate)

outputs “0”. Is that expected?

By the way, if you want to ease settings keys, why not use a standard cryptographic routine such as PBKDF2. The following code computes a 256 bit key out of password “SuperSecret” and salt “salt”.

import hashlib
key = hashlib.pbkdf2_hmac(‘sha256’, b’SuperSecret’, b’salt’, 100000)
print (key.hex())

How about adding meshtastic parameter “–setPassword SuperSecret:salt” to make this easier for people?