I have been trying to use various of the api calls that are defined in the headers but are not directly exposed as part of the arduino ide - I noticed that a lot of the most interesting ones for me seem to be missing from the firmware.
I plan to use the ones that control the power management to check the battery level and trigger the power-off and restart calls. kaktus.martin over in the SIM-Card thread also found non-included APIs regarding Sim Management.
Is this a problem of the firmware that is used with the Arduino ide? Would switching to the eclipse IDE and the alternative SDK help?
Being able to check the battery level and schedule Wake-ups by time would really help with my project (I would have to externalize that to a second micro otherwise).
So you tried it? I am asking because the headers are there in the arduino ide as well - calls to “vm_pwr_get_battery_level” just return -103 and “vm_pwr_shutdown” or “vm_pwr_reboot” for instance do nothing (I would expect that the module goes off or restarts) - I am asking because I have some Problems with getting the SDK to work correctly with my ecipse setup and i will have to probably reinstall the IDE or do even more.
So I tried it after getting Home from work - seems like the Arduino firmware misses a lot of symbols - probably those that haven’t been directly implemented.
Using the eclipse IDE with the SDK however allows me to access those API calls.
Tried the functions with with Eclipse und the SDK 2.0.46, the reboot function has no effect an I get the return value “-103” from the vm_pwr_get_battery_level() function also…
Both shutdown and reboot work fine here. I used the unmodified demo code for testing - did you flash the SDK version of the firmware with the Firmware updater? Its different from the one with the arduino ide.
So the debug output of the example is in line 29 “Value: 1,100” and in line 15 “Value: 1,100”.
But if I comment out the debug output in line 29 the debug output of line 15 will be: “Value: 0, -103”…
4.4. Threads
As described in 2.1”Environment”, the application is executed in a multi-threaded environment
and the application itself runs in the main thread, and most APIs are only available to the main
thread. The application can create and control a limited number of new threads with the
vm_thread function. Basic inter-thread communication message mechanisms and
synchronization mechanisms are also provided. Refer to 5.5.5, “Threads” for details.
Since I know that not all function can be called out of a sub thread, I wrote my own functions where it doesn’t matter where you call the apis… I uploaded you an example in the attachement.
Maybe the same problem exists in the Arduino IDE (I’m using Eclipse)… because I saw that in the file …/Eclipse\LINKIT_ASSIST_SDK\custom\arduino\main.cpp the loop(); of arduino is also handled with a sub-thread… could this be the reason why the apis in the arduino IDE also not work? example_thread_api.zip (2.87 KB)
This is cool - I haven’t tried it yet but i might even be able to use the scheduled wake-up stuff. Sadly the module still draws 4ma when “off” so really long term monitoring is out of the question.
Thanks for finding out why there were inaccessible API calls.