Missing Symbols in Firmware?

Hi,

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).

Hi,
You can use native APIs on IDE Eclipse for Xadow GSM (2502 SDK 2.0.46),
Power Management http://labs.mediatek.com/site/global/developer_tools/mediatek_linkit_assist_2502/api_references/C_FW_POWER.gsp
GSM Management
http://labs.mediatek.com/site/global/developer_tools/mediatek_linkit_assist_2502/api_references/C_GSM.gsp

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.

I Think I figured something out, here is my example code:

[code]#include “vmsystem.h”
#include “vmthread.h”
#include “ResID.h”
#include “vmpwr.h”
#include “vmlog.h”

#include “vmgsm_sim.h”

VM_THREAD_HANDLE main_handle;

VMINT32 main_thread(VM_THREAD_HANDLE thread_handle, void *user_data)
{
vm_thread_sleep(2000);

vm_log_debug("Value: %i, %i",  vm_gsm_sim_has_card(), vm_pwr_get_battery_level());
while(1)
{
	vm_thread_sleep(1000);
}

return 0;

}

void handle_system_event(VMINT message, VMINT param)
{
switch (message)
{
case VM_EVENT_CREATE:
vm_log_debug(“Value: %i, %i”, vm_gsm_sim_has_card(), vm_pwr_get_battery_level());
main_handle = vm_thread_create(main_thread, NULL, 200);
break;
case VM_EVENT_QUIT:
break;
}
}

void vm_main(void)
{
vm_pmng_register_system_event_callback(handle_system_event);
}
[/code]

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”…

Its little bit strange!?!??!

[code]#include “vmsystem.h”
#include “vmtype.h”
#include “vmlog.h”
#include “vmtimer.h”
#include “ResID.h”
#include “hello-world.h”
#include “vmpwr.h”

VM_TIMER_ID_PRECISE sys_timer_id = 0;

void sys_timer_callback(VM_TIMER_ID_PRECISE sys_timer_id, void* user_data)
{
VMINT bat_level;
bat_level=vm_pwr_get_battery_level();
vm_log_info(“уровень батареи: =%d,%d”,bat_level,vm_pwr_is_charging());

}

void handle_sysevt(VMINT message, VMINT param)
{
switch (message)
{
case VM_EVENT_CREATE:
sys_timer_id = vm_timer_create_non_precise(1000, sys_timer_callback, NULL);
break;
case VM_EVENT_PAINT:
break;
case VM_EVENT_QUIT:
break;
}
}

void vm_main(void)
{
vm_pmng_register_system_event_callback(handle_sysevt);
}
[/code]

Use this code

I don’t wan’t to use a timer function, my question ist why the function can’t be called out of a thread?!?

Read documentation http://labs.mediatek.com/fileMedia/download/22008eac-3fdc-4f19-b2d7-1b6aad86ea67

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.

Ah okay, thanks for your answer… is somewhere a list which API’s can only be called from the main thread?

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.