I forgot to mention, after a power cycle the functions appear. No problem for debugging, but I want to deploy this firmware to the field and I do not have physical access to the devices.
Can you run particle serial inspect (in Listening Mode) to see whether the upgrade actually completed successfully?
Can you also re-flash your application (with a very minor alteration) and run particle serial inspect again to compare the app hash between the two logs?
Since I couldn’t see anything wrong with your code snippets I’m inclinde to think you are not successfully flashing your application.
More questions
What IDE are you using?
How are you flashing?
Have you marked that device as developer device?
Is it maybe firmware locked?
How does that code behave on a non-product device?
Can you flash a minimal test application (e.g. Blink an LED with your Particle.function() block) to that device to see if anything works?
Besides what @ScruffR asked for, you may have an object creation problem as the order of creation and initialization of classes is not necessarily sequential. The reference to board may not be correct when you define locks[]. This is why it is usually recommended that classes have a begin() method that is called in setup() to avoid this problem.
@ScruffR I can verify the flash was successful because after a power cycle the new functions appear and are working as expected. Therefore I’ve tried @peekay123 fix. It looks like this is the problem. The functions do appear after a flash. But after a few tests it didn’t happened less, but it sometimes still boots up without registering the functions.
And another thing I’m noticing right now is my firmware v1 (my previous version, which ran in 0.7.0) is also missing the functions after a downgrade of the firmware (v5 -> v1), . I’m thinking something has changed in the Device OS bootup sequence.
I’ve added the SYSTEM_MODE(SEMI_AUTOMATIC); and the Particle.connect(); after the Particle.function calls and I can not break it anymore.
Cloud flash from VS code and by installing firmwares in a product
Tried it with and without
I locked different firmwares to simulate upgrading (where it fails)
Have not tried it yet
Have not tried it yet
One thing I’ve noticed during the OTA-flashing of a firmware is that the green blinking phase is completely skipped. So I’m thinking that the Electron is sometimes so fast in connecting to the Particle cloud that it is already connected before the setup() function is called. Therefore skipping the Particle.function() calls? Is that even possible?