diff options
| author | Daniel Campora <daniel@wipy.io> | 2015-08-11 11:18:02 +0200 |
|---|---|---|
| committer | Daniel Campora <daniel@wipy.io> | 2015-08-16 20:17:52 +0200 |
| commit | ea5061e409449118ed45ce2956800780631bcf9e (patch) | |
| tree | 107417699e361857372ec07670ae68770cf75832 /cc3200/mods/modwlan.c | |
| parent | 4c5bfe2d10cd8397e970c4c23f6c15b97133fcc0 (diff) | |
cc3200: Improve callback API.
Rename "wakes" param to "wake_from" and make "value" an object
instead of an integer.
Diffstat (limited to 'cc3200/mods/modwlan.c')
| -rw-r--r-- | cc3200/mods/modwlan.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/cc3200/mods/modwlan.c b/cc3200/mods/modwlan.c index b58d4aa24..406b49a39 100644 --- a/cc3200/mods/modwlan.c +++ b/cc3200/mods/modwlan.c @@ -1087,8 +1087,8 @@ STATIC mp_obj_t wlan_scan(mp_obj_t self_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_1(wlan_scan_obj, wlan_scan); /// \method callback(handler, pwrmode) -/// Create a callback object associated with WLAN -/// min num of arguments is 1 (wakes) +/// Create a callback object associated with the WLAN subsystem +/// Only takes one argument (wake_from) STATIC mp_obj_t wlan_callback (mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_arg_val_t args[mpcallback_INIT_NUM_ARGS]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, mpcallback_INIT_NUM_ARGS, mpcallback_init_args, args); @@ -1096,7 +1096,7 @@ STATIC mp_obj_t wlan_callback (mp_uint_t n_args, const mp_obj_t *pos_args, mp_ma wlan_obj_t *self = pos_args[0]; mp_obj_t _callback = mpcallback_find(self); // check if any parameters were passed - if (kw_args->used > 0 || !_callback) { + if (kw_args->used > 0) { // check the power mode if (args[4].u_int != PYB_PWR_MODE_LPDS) { // throw an exception since WLAN only supports LPDS mode @@ -1104,10 +1104,12 @@ STATIC mp_obj_t wlan_callback (mp_uint_t n_args, const mp_obj_t *pos_args, mp_ma } // create the callback - _callback = mpcallback_new (self, args[1].u_obj, &wlan_cb_methods); + _callback = mpcallback_new (self, args[1].u_obj, &wlan_cb_methods, true); // enable network wakeup pybsleep_set_wlan_lpds_callback (_callback); + } else if (!_callback) { + _callback = mpcallback_new (self, mp_const_none, &wlan_cb_methods, false); } return _callback; } |
