Custom port A9G module: help wanted
Posted: Tue Feb 19, 2019 10:55 pm
Hi community,
I am porting micropython to the A9 GSM module (see also: A9G, RDA8955). It usually comes as a part of the board with a charge controller, external antennae, etc.: a very interesting piece of hardware overall from ESP manufacturers. The ongoing work is here: https://github.com/pulkin/micropython
I reserve this thread for my questions and your help with this implementation.
My first question is:
I am implementing a simple callback enabling updates of the GSM signal level in python. This is done through events in the original SDK, something like this (sorry for indents: have no idea how to post it here properly):
case API_EVENT_ID_SIGNAL_QUALITY:
mp_warning("API_EVENT_ID_SIGNAL_QUALITY");
notify_signal(pEvent);
break;
The actual python interface looks like this:
void notify_signal(API_Event_t* event) {
if (signal_callback == mp_const_none) {
return;
}
if (!MP_OBJ_IS_FUN(signal_callback)) {
mp_warning("The GSM signal callback is not a function");
return;
}
nlr_buf_t nlr;
if (nlr_push(&nlr) == 0) {
mp_warning("Calling ...");
mp_obj_t ret = mp_call_function_0(signal_callback);
nlr_pop();
} else {
signal_callback = mp_const_none;
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
}
}
The problem is that this code ends up in nlr_jump_fail when the actual event occurs. The callback is a simple "print" function but the last thing printed is "Calling ...". The question is: how to implement this callback properly?
I am porting micropython to the A9 GSM module (see also: A9G, RDA8955). It usually comes as a part of the board with a charge controller, external antennae, etc.: a very interesting piece of hardware overall from ESP manufacturers. The ongoing work is here: https://github.com/pulkin/micropython
I reserve this thread for my questions and your help with this implementation.
My first question is:
I am implementing a simple callback enabling updates of the GSM signal level in python. This is done through events in the original SDK, something like this (sorry for indents: have no idea how to post it here properly):
case API_EVENT_ID_SIGNAL_QUALITY:
mp_warning("API_EVENT_ID_SIGNAL_QUALITY");
notify_signal(pEvent);
break;
The actual python interface looks like this:
void notify_signal(API_Event_t* event) {
if (signal_callback == mp_const_none) {
return;
}
if (!MP_OBJ_IS_FUN(signal_callback)) {
mp_warning("The GSM signal callback is not a function");
return;
}
nlr_buf_t nlr;
if (nlr_push(&nlr) == 0) {
mp_warning("Calling ...");
mp_obj_t ret = mp_call_function_0(signal_callback);
nlr_pop();
} else {
signal_callback = mp_const_none;
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
}
}
The problem is that this code ends up in nlr_jump_fail when the actual event occurs. The callback is a simple "print" function but the last thing printed is "Calling ...". The question is: how to implement this callback properly?