Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added cellular.answer() function in modcellular.c #129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ports/gprs_a9/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ The purpose of this module is to have an access to high-level networking (SMS, G
* `on_call(callback: Callable)`: sets a callback `function(number_or_hangup)` on call events (incoming, hangup, etc.);
* ~~`network_status_changed()` (bool): indicates whether the network status changed since the last check~~ use `on_status_event` instead;
* ~~`call()` (list[str], [str, None]): calls missed (1st output) and the incoming call number or `None` if no incoming calls at the moment (2nd output)~~ use `on_call` instead;
* `answer()`: answers incoming calls;

### `usocket` ###

Expand Down
22 changes: 22 additions & 0 deletions ports/gprs_a9/modcellular.c
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,26 @@ STATIC mp_obj_t modcellular_get_imsi(void) {

STATIC MP_DEFINE_CONST_FUN_OBJ_0(modcellular_get_imsi_obj, modcellular_get_imsi);


STATIC mp_obj_t modcellular_answer(void) {
// ========================================
// Answer incoming calls.
//
// ========================================
if (!CALL_Answer()) {
mp_raise_RuntimeError("Failed to answer the call");
return mp_const_none;
}
return mp_const_none;
}

STATIC MP_DEFINE_CONST_FUN_OBJ_0(modcellular_answer_obj, modcellular_answer);






bool get_flight_mode(void) {
// Polls flight mode
bool flag;
Expand Down Expand Up @@ -1328,6 +1348,8 @@ STATIC const mp_map_elem_t mp_module_cellular_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_on_sms), (mp_obj_t)&modcellular_on_sms_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_on_call), (mp_obj_t)&modcellular_on_call_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_on_ussd), (mp_obj_t)&modcellular_on_ussd_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_answer), (mp_obj_t)&modcellular_answer_obj },


{ MP_ROM_QSTR(MP_QSTR_NETWORK_FREQ_BAND_GSM_900P), MP_ROM_INT(NETWORK_FREQ_BAND_GSM_900P) },
{ MP_ROM_QSTR(MP_QSTR_NETWORK_FREQ_BAND_GSM_900E), MP_ROM_INT(NETWORK_FREQ_BAND_GSM_900E) },
Expand Down
Loading