OTA uploads to wrong address

I have several projects in my workspace and a few of them use OTA for programming.
These tend to be ESP8266 or ESP32’s.
I don’t have a problem with the actual OTA upload itself but rather the device the upload goes to.

For example, I have one project with and address of 192.168.1.126 and another with an address of 192.168.1.132, but no matter what I do, when uploading it will always use .126 address and program the wrong device.

Here is the .ini file for the .126 device:
[env:d1_mini_pro]
platform = espressif8266
board = d1
framework = arduino
upload_protocol = espota
upload_port = 192.168.1.126

and this is the .132 device .ini
[env:ttgo-lora32-v1]
board = ttgo-lora32-v1
framework = arduino
platform = espressif32
board_build.flash_mode = qio
monitor_speed = 115200
upload_protocol = espota
upload_port = 192.168.1.132

I have changed the order of the sketches in the workspace which made no difference.
I have removed all open sketches and re-started so nothing is loaded in and then loaded in the correct sketch then re-started again so it starts with the correct sketch (the one to .132) loaded.
It still uploads to .126

Am I doing something wrong or missing something obvious?

Occasionally it does go to .132, but it seems to be pot-luck.

Any help please as I don’t want to have to remove everything from the workspace other than the one that I want as this defeats the object of having a workspace list.

Thanks

Martin

What exact button do you use for uploading? You select the “Upload” button of the explicit environment in the project tasks, right?

I use the compile and upload buttons at the bottom of the screen.
image
However, I have just noticed that it says 'Default (ESP8266 OTA) at the bottom. I never noticed that before so have I accidentally changed something?

I notice that it seems to be uploading the same file no matter which one I am working on.

Executing task in folder ESP8266 OTA: C:\Users\Martin.platformio\penv\Scripts\platformio.exe run <

If you use those, they will perform the upload to the respective environment you have selected.

You can also see there that you’ve selected (or rather, it’s the default that was selected for you), is the “Default” environment of the “ESP8266 OTA” project – default env, that is, the first [env] in the platformio.ini is used, or the one designed by default_envs if the directive exits. And since your upload_port = 192.168.1.126 is the first environment, it will upload to that.

The environment selector is something that was introduced in the latest extension update since yesterday.

If you click on the “Default (ESP8266 OTA)” button, a project and environment selection pops up where you can switch to your desired environment.

grafik

That will also trigger a reload of the Intellisense.

Thus, if you want a quick upload, you should use the PlatofrmIO sidebar and the explicit “Upload” project task of the environment as shown above.

Sorry, was typing this edit during your reply…

Edit-in
I have just clicked on the ‘Default’ icon and it allows me to select the one I want. So just managed to get my central heating back on line after the program had been wiped off.
However, I never noticed that before so I assume I have somehow activated a default setting rather than it using the project I am currently working on.
So, how do I undo that please?

Also, your screenshot is very close to what I have as it is the ‘ttgo-lora32-v1’ I am actualy trying to work on. How did you do that? :slight_smile:

Ok, just read your last message in full, that will explain it then, I wondered why I never saw that before.
Bit naughty though, it took my central heating off line since 8am as it had uploaded an OTA test sketch, luckily the OTA of the test sketch was still accepting OTA uploads otherwise I would have had to start disconnecting things in my central heating cupboard.

Anyway, thank you so much for your help, very fast and got me going again.
Cheers
Martin

Sorry, where is the ‘explicit upload’ button / option please?
This seems a really dumb move, why would they include the default option, surely the default should be to upload the project that you are ‘actually’ working on!
Confusing !

From what I’ve read the VSCode API for detecting the currently opened project has broken and many people had reported that uploading actually resulted in a completetly different project being uploaded, so it’s more explicit now; that’s what I understand at least.

When you click on the PlatformIO (Alien) icon in the left sidebar of VSCode, the project task selection comes up. You can further expand each environment and execute the tasks (like, Building, Uploading and other platform-specific tasks) there.

Looks like that just brings up what is already selected on the bottom task bar rather than allow the current ‘edited’ project to be selected, so will still have to select it at the bottom task bar.

Can I ask one more thing, on the ‘source control’ icon I have a number, selecting it brings up some changes. Now as I thought this was refering to changes I had just made, I committed them. It now seems these are changes made to the ‘git source’ and has completely messed up my configurations for my LoRa Gateway.
As I am only learning, it took me some time to configure it as there are many different files. Is this also a new function or is it coincidence that a change has been made to the source?

Thanks again

Indeed you can’t change the project with it, but you can chosose between all the the environments of a project, even if you have currently selected a different environment.

The Git functionality of VSCode is always built in and is separate from the PlatformIO plugin. The general helper documents for that are at Source Control with Git in Visual Studio Code

Well I have learned the hard way, 2 lessons today.

  • Make sure I select the default file to the one I am working on. (Still cannot understand why they would do this, surely you would want to upload a project that you are currently working on not a completely different on. Who thought that one up?!)
  • Don’t update anything from the source files as this is going to cost me hours if not days to figure out the settings I have lost.

Funny (not really) one of the main reasons I struggled to make the change to PlatformIO was the fact that all libraries etc stayed with each project so even years down the line I could still work on projects, that has just gone with one press of a button.

So, thank you Max (I assume Max), you have been a great help.

Cheers

Martin