STATIC void mptask_enter_ap_mode (void) { // append the mac only if it's not the first boot bool add_mac = !PRCMGetSpecialBit(PRCM_FIRST_BOOT_BIT); // enable simplelink in ap mode (use the MAC address to make the ssid unique) wlan_sl_init (ROLE_AP, MICROPY_PORT_WLAN_AP_SSID, strlen(MICROPY_PORT_WLAN_AP_SSID), MICROPY_PORT_WLAN_AP_SECURITY, MICROPY_PORT_WLAN_AP_KEY, strlen(MICROPY_PORT_WLAN_AP_KEY), MICROPY_PORT_WLAN_AP_CHANNEL, ANTENNA_TYPE_INTERNAL, add_mac); }
STATIC mp_obj_t wlan_init_helper(wlan_obj_t *self, const mp_arg_val_t *args) { // get the mode int8_t mode = args[0].u_int; wlan_validate_mode(mode); // get the ssid mp_uint_t ssid_len = 0; const char *ssid = NULL; if (args[1].u_obj != NULL) { ssid = mp_obj_str_get_data(args[1].u_obj, &ssid_len); wlan_validate_ssid_len(ssid_len); } // get the auth config uint8_t auth = SL_SEC_TYPE_OPEN; mp_uint_t key_len = 0; const char *key = NULL; if (args[2].u_obj != mp_const_none) { mp_obj_t *sec; mp_obj_get_array_fixed_n(args[2].u_obj, 2, &sec); auth = mp_obj_get_int(sec[0]); key = mp_obj_str_get_data(sec[1], &key_len); wlan_validate_security(auth, key, key_len); } // get the channel uint8_t channel = args[3].u_int; wlan_validate_channel(channel); // get the antenna type uint8_t antenna = 0; #if MICROPY_HW_ANTENNA_DIVERSITY antenna = args[4].u_int; wlan_validate_antenna(antenna); #endif // initialize the wlan subsystem wlan_sl_init(mode, (const char *)ssid, ssid_len, auth, (const char *)key, key_len, channel, antenna, false); return mp_const_none; }