Configuring Channel Via Python API

Is there a way to configure/ set / join a channel using the python API? When I do my tests on new versions of the meshtastic firmware I have to use a phone to connect to each node and then use the web URL that was used to initially create my channel.

Is there a way to use the API to reassign each node to the Lora network (channel) mesh without having to use a cell phone?

1 Like

yes

import meshtastic
interface = meshtastic.SerialInterface()
interface.channelURL
‘Meshtastic URL | Meshtastic’
interface.setURL(‘Meshtastic URL | Meshtastic’)

3 Likes

Thank you so much that’s perfect.

2 Likes

I’ve been reading about this Python API quite a bit but can’t seem to grasp what it is and how to use it. Is someone willing to explain a few basic things?

What is Python API? Is that what I installed on my Raspberry Pi running Linux when entered ‘sudo pip3 install --upgrade meshtastic’ in terminal window? I apologize, I know so little about programming or Linux, I don’t even know how to properly ask these questions. But I bet some people reading this will get a good laugh :laughing:

Then I was able to enter ’meshtastic -h’ in the terminal and that revealed a list of commands. I was even able to send text message into my mesh by typing ‘meshtastic —sendtext ‘my_text_message’. So far, I’m not able to figure out how to read messages from the mesh.

How do you run these Python scripts? Does it have to be saved as some type of file and then it gets executed for terminal?

Thanks

1 Like

Yes, the api it’s a little program to interact whit the radio.

I think you can use “meshtastic --seriallog”

On linux, I think, you can create a .py file and run on the terminal.
On windows I’m using a python editor and run the program in terminal.

I think the best way to deal whit some configuration and to send/recive text it’s to use the web ui.

2 Likes

Okay, thanks for the clarifications. I will play some more with this and try to figure it out. It is like learning a foreign language. This all got me looking at some beginner tutorials on Linux terminal…it was a rough weekend, trying to catch up to my 30 years of computer ignorance.

I looked a bit at this meshtastic-web, very interesting. Three questions (okay four really);

  1. Web server files are not included with latest Meshtastic firmware, they have to be manually uploaded?
  2. Best to use Chrome browser, or Edge, will not work on iOS Safari?
  3. I use Meshtastic Python API to provision T-Beam for my WiFi network? Or can enable WiFi access point on device and access this web interface by navigating to IP address displayed on device?

Can’t wait to try this after work…

Thanks

1 Like

Yes, the file can be uploaded on the board in 2/3 way, this is the easier.

I think you can use all, I have tried Chrome and work, even on safari mobile, the only problem it’s the scaling of the site for small screen.

The newest firmware have the ability to enable the wifi access point simply power it up whit the user button press and hold for 2 second, (the user button it’s the middle one on the t-beam).

Also the python api provide all the command to do from there:

This is for connecting on an existing wifi network:

meshtastic --set wifi_ap_mode false --setstr wifi_ssid mywifissid --setstr wifi_password mywifipsw

This for the accesspoint:

meshtastic --set wifi_ap_mode true --setstr wifi_ssid mywifissid --setstr wifi_password mywifipsw

I’m learning, thanks for clarifying some of this. I was able to set up one of the t-beams to log onto my WiFi. I even managed to run Meshtastic on windows machine, it’s a big deal, I have been trying to figure this one out from yesterday evening.

Now for the meshtastic-web, I am not able to upload the three required files into static folder, gives me an error and says write aborted and then displays this;

image

What am I doing wrong?

Thanks

The amount of free space is very low. What hardware do you have this installed on?

This is on T-Beam V1.1 Meshtastic firmware 1.1.32. I have couple of them and they both do the same thing.

I’ve been reading one of the wikis on this and found this;

image

Is this what I’m missing? I installed VS Code and Platform.io extension but have no clue what to do next. I’ll get this by next week LOL

How did you initially flash your device? The preferred way is to use the device-install script that came with the firmware.

I flashed it with esphome-flasher, which I’m guessing is the issue according to Wiki How-to-use-“Meshtastic-Web”-over-WiFi.

I just created new project in Platform.io, created ‘data’ folder, pasted the three files at Mashtastic-web Git page into this data folder. Then I clicked ‘Build filesystem image’, followed by ‘Upload Filesystem Image’. Both times there was SUCCESS message in terminal.

Now I get this on meshtastic.local/static page, but still cannot upload files;

image

Thanks for trying to flash it both in esphome flasher and from within platform io. That’s what I would have asked you to try. :slight_smile:

I have not seen this problem before. Looks like either the filesystem partitioning didn’t work or the flash chip on your board is not what it was made out to be.

Has anyone else seen this? There should be no reason to have just ~50kb of total space on a newly flashed device.

I just tried a third T-Beam V1.1, same issue.

I tried to use install script that comes with firmware zip file, no success;

I’m grasping at straws here. If anyone has other ideas, please chime in.

Could you open your device in a web browser and point to /json/report ? I’m looking for something that looks like this:

image

If you could, could you also post your debug log starting from the reboot? There may be something about the SPIFFS in there.

I’m still playing with Platform.io, this is what I see for this board;

image

This leads me to believe board is okay, it may be just how I flashed it? These boards originally came with SoftRF preloaded, when I flashed them with esphome-flasher does it erase everything prior to installing Meshtastic?

I’m still trying to figure out how to use device-install.sh, doesn’t work on windows. I enabled Windows Subsystem for Linux and installed Ubuntu terminal but still doesn’t work…cannot install pip for some reason

I have to figure out how to post debug log, I’ll post it once I find out how to do this.

Ah ha! Thanks for sharing about SoftRF.

I just went through the SoftRF source and found that they use the minimal spiffs partition scheme. This gets us in the right direction.

This means that we need to figure out how to change the partition table of your board.

I think you mentioned you were able to get platform io running. Could you try running 'erase flash" and then re-upload the firmware? I don’t know if this will update the partition table, but it’s worth a shot.

image

Also, since you’re in platform io, to get the serial / debug console:

image

/json/report

I erased flash using Platform.io, then I loaded Meshtastic again using esphome-flasher tool on windows. After setting wifi credentials, I can connect to meshtastic.local/static but there is no change in amount of memory;

image

I’m still working on how to run this serial/debug console in platform.io. When I click on that little ‘cord end’ icon you indicated I get a terminal open with this;

This does not look right does it? I don’t really know what I’m doing in Platform.io, have to play with this a bit more…

Helo. I have the same bug. The difference is that i’m using ttgo lora 32 not the t-beam version. On my device fabric was installed pax counter, then i installed my sondy go software. After that i was installed myshtastic 0.9.7 using espflasher, afther that i updated via bluetooth from app on my phone to version 1.1.32.

Trying 3 diffrent browsers and always get the same msg “write aborted”.

Mayby that give you some thoughts.
I will look further for solutions.

I had the same problem with two Tbeams, but managed to erase the flash through the command line allowing me to upload a fresh build and get a proper amount of space.

When in the root directory for the project I used:
pio run --target erase --environment tbeam

One of my tbeams (sx1262 & M8N) now runs perfectly, has uploaded he files and the webpage works well. The other (6M) is still misbehaving somewhat. It uploads the two smaller files without issue, but when trying to upload the app.js.gz file, it gets stuck in a loop with the following debug code.

00:02:23 [WebServerThread] File Length 4163
[HTTPS:E] Multipart incomplete
00:02:23 [WebServerThread] File Length 4163
[HTTPS:E] Multipart incomplete
00:02:23 [WebServerThread] File Length 4163
[HTTPS:E] Multipart incomplete
00:02:23 [WebServerThread] File Length 4163
[HTTPS:E] Multipart incomplete
00:02:23 [WebServerThread] File Length 4163