Skip to content

Commit 57fa14b

Browse files
author
Daniel Campora
committed
cc3200: New WLAN API including test.
1 parent dbdcb58 commit 57fa14b

File tree

14 files changed

+764
-418
lines changed

14 files changed

+764
-418
lines changed

cc3200/mods/modussl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ STATIC mp_obj_t mod_ssl_wrap_socket(mp_uint_t n_args, const mp_obj_t *pos_args,
130130
arg_error:
131131
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
132132
}
133-
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ssl_wrap_socket_obj, 1, mod_ssl_wrap_socket);
133+
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ssl_wrap_socket_obj, 0, mod_ssl_wrap_socket);
134134

135135
STATIC const mp_map_elem_t mp_module_ussl_globals_table[] = {
136136
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_ussl) },

cc3200/mods/modwlan.c

Lines changed: 501 additions & 379 deletions
Large diffs are not rendered by default.

cc3200/mods/modwlan.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737

3838
#define MODWLAN_WIFI_EVENT_ANY 0x01
3939

40+
#define MODWLAN_SSID_LEN_MAX 32
41+
4042
/******************************************************************************
4143
DEFINE TYPES
4244
******************************************************************************/
@@ -55,12 +57,12 @@ typedef struct _wlan_obj_t {
5557
uint32_t ip;
5658

5759
int8_t mode;
58-
uint8_t security;
60+
uint8_t auth;
5961
uint8_t channel;
6062
uint8_t antenna;
6163

6264
// my own ssid, key and mac
63-
uint8_t ssid[33];
65+
uint8_t ssid[(MODWLAN_SSID_LEN_MAX + 1)];
6466
uint8_t key[65];
6567
uint8_t mac[SL_MAC_ADDR_LEN];
6668

@@ -84,12 +86,11 @@ extern _SlLockObj_t wlan_LockObj;
8486
DECLARE PUBLIC FUNCTIONS
8587
******************************************************************************/
8688
extern void wlan_pre_init (void);
87-
extern void wlan_sl_enable (int8_t mode, const char *ssid, uint8_t ssid_len, uint8_t sec,
88-
const char *key, uint8_t key_len, uint8_t channel, bool append_mac);
89+
extern void wlan_sl_init (int8_t mode, const char *ssid, uint8_t ssid_len, uint8_t auth, const char *key, uint8_t key_len,
90+
uint8_t channel, uint8_t antenna, bool add_mac);
8991
extern void wlan_first_start (void);
9092
extern void wlan_update(void);
9193
extern void wlan_stop (uint32_t timeout);
92-
extern void wlan_start (void);
9394
extern void wlan_get_mac (uint8_t *macAddress);
9495
extern void wlan_get_ip (uint32_t *ip);
9596
extern bool wlan_is_connected (void);

cc3200/mods/pybi2c.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@ STATIC mp_obj_t pyb_i2c_init_helper(pyb_i2c_obj_t *self, const mp_arg_val_t *arg
320320
STATIC const mp_arg_t pyb_i2c_init_args[] = {
321321
{ MP_QSTR_id, MP_ARG_INT, {.u_int = 0} },
322322
{ MP_QSTR_mode, MP_ARG_INT, {.u_int = PYBI2C_MASTER} },
323-
{ MP_QSTR_baudrate, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 100000} },
324-
{ MP_QSTR_pins, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
323+
{ MP_QSTR_baudrate, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 100000} },
324+
{ MP_QSTR_pins, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
325325
};
326326
STATIC mp_obj_t pyb_i2c_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *all_args) {
327327
// parse args
@@ -414,7 +414,7 @@ STATIC mp_obj_t pyb_i2c_readfrom_into(mp_uint_t n_args, const mp_obj_t *pos_args
414414
// return the number of bytes received
415415
return mp_obj_new_int(vstr.len);
416416
}
417-
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_readfrom_into_obj, 3, pyb_i2c_readfrom_into);
417+
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_readfrom_into_obj, 1, pyb_i2c_readfrom_into);
418418

419419
STATIC mp_obj_t pyb_i2c_writeto(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
420420
STATIC const mp_arg_t pyb_i2c_writeto_args[] = {
@@ -442,7 +442,7 @@ STATIC mp_obj_t pyb_i2c_writeto(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m
442442
// return the number of bytes written
443443
return mp_obj_new_int(bufinfo.len);
444444
}
445-
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_writeto_obj, 3, pyb_i2c_writeto);
445+
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_writeto_obj, 1, pyb_i2c_writeto);
446446

447447
STATIC mp_obj_t pyb_i2c_readfrom_mem(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
448448
STATIC const mp_arg_t pyb_i2c_readfrom_mem_args[] = {
@@ -460,7 +460,7 @@ STATIC mp_obj_t pyb_i2c_readfrom_mem(mp_uint_t n_args, const mp_obj_t *pos_args,
460460
pyb_i2c_readmem_into (args, &vstr);
461461
return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr);
462462
}
463-
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_readfrom_mem_obj, 4, pyb_i2c_readfrom_mem);
463+
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_readfrom_mem_obj, 1, pyb_i2c_readfrom_mem);
464464

465465
STATIC const mp_arg_t pyb_i2c_readfrom_mem_into_args[] = {
466466
{ MP_QSTR_addr, MP_ARG_REQUIRED | MP_ARG_INT, },
@@ -479,7 +479,7 @@ STATIC mp_obj_t pyb_i2c_readfrom_mem_into(mp_uint_t n_args, const mp_obj_t *pos_
479479
pyb_i2c_readmem_into (args, &vstr);
480480
return mp_obj_new_int(vstr.len);
481481
}
482-
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_readfrom_mem_into_obj, 4, pyb_i2c_readfrom_mem_into);
482+
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_readfrom_mem_into_obj, 1, pyb_i2c_readfrom_mem_into);
483483

484484
STATIC mp_obj_t pyb_i2c_writeto_mem(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
485485
// parse args
@@ -507,7 +507,7 @@ STATIC mp_obj_t pyb_i2c_writeto_mem(mp_uint_t n_args, const mp_obj_t *pos_args,
507507

508508
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
509509
}
510-
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_writeto_mem_obj, 4, pyb_i2c_writeto_mem);
510+
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_writeto_mem_obj, 1, pyb_i2c_writeto_mem);
511511

512512
STATIC const mp_map_elem_t pyb_i2c_locals_dict_table[] = {
513513
// instance methods

cc3200/mods/pybsleep.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ void pybsleep_init0 (void) {
164164
MAP_PRCMHibernateWakeupSourceDisable(PRCM_HIB_SLOW_CLK_CTR | PRCM_HIB_GPIO2 | PRCM_HIB_GPIO4 | PRCM_HIB_GPIO13 |
165165
PRCM_HIB_GPIO17 | PRCM_HIB_GPIO11 | PRCM_HIB_GPIO24 | PRCM_HIB_GPIO26);
166166

167-
// store the reset casue (if it's soft reset, leave it as it is)
167+
// check the reset casue (if it's soft reset, leave it as it is)
168168
if (pybsleep_reset_cause != PYB_SLP_SOFT_RESET) {
169169
switch (MAP_PRCMSysResetCauseGet()) {
170170
case PRCM_POWER_ON:
@@ -188,6 +188,7 @@ void pybsleep_init0 (void) {
188188
switch (MAP_PRCMHibernateWakeupCauseGet()) {
189189
case PRCM_HIB_WAKEUP_CAUSE_SLOW_CLOCK:
190190
pybsleep_wake_reason = PYB_SLP_WAKED_BY_RTC;
191+
// TODO repeat the alarm
191192
break;
192193
case PRCM_HIB_WAKEUP_CAUSE_GPIO:
193194
pybsleep_wake_reason = PYB_SLP_WAKED_BY_GPIO;

cc3200/mods/pybuart.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ STATIC mp_obj_t pyb_uart_init_helper(pyb_uart_obj_t *self, const mp_arg_val_t *a
446446
}
447447

448448
STATIC const mp_arg_t pyb_uart_init_args[] = {
449-
{ MP_QSTR_id, MP_ARG_OBJ, {.u_obj = mp_const_none} },
449+
{ MP_QSTR_id, MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
450450
{ MP_QSTR_baudrate, MP_ARG_INT, {.u_int = 9600} },
451451
{ MP_QSTR_bits, MP_ARG_INT, {.u_int = 8} },
452452
{ MP_QSTR_parity, MP_ARG_OBJ, {.u_obj = mp_const_none} },
@@ -462,7 +462,7 @@ STATIC mp_obj_t pyb_uart_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t
462462

463463
// work out the uart id
464464
uint uart_id;
465-
if (args[0].u_obj == mp_const_none) {
465+
if (args[0].u_obj == MP_OBJ_NULL) {
466466
if (args[5].u_obj != MP_OBJ_NULL) {
467467
mp_obj_t *pins;
468468
mp_uint_t n_pins = 2;

cc3200/mpconfigport.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len);
207207
#define MICROPY_HAL_H "cc3200_hal.h"
208208
#define MICROPY_PORT_HAS_TELNET (1)
209209
#define MICROPY_PORT_HAS_FTP (1)
210-
#define MICROPY_PORT_WLAN_URN (0)
211210
#define MICROPY_PY_SYS_PLATFORM "WiPy"
212211

213212
#define MICROPY_PORT_WLAN_AP_SSID "wipy-wlan"

cc3200/mptask.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
#include "mpirq.h"
6969
#include "updater.h"
7070
#include "moduos.h"
71+
#include "antenna.h"
7172

7273
/******************************************************************************
7374
DECLARE PRIVATE CONSTANTS
@@ -360,11 +361,11 @@ STATIC void mptask_init_sflash_filesystem (void) {
360361

361362
STATIC void mptask_enter_ap_mode (void) {
362363
// append the mac only if it's not the first boot
363-
bool append_mac = !PRCMGetSpecialBit(PRCM_FIRST_BOOT_BIT);
364-
364+
bool add_mac = !PRCMGetSpecialBit(PRCM_FIRST_BOOT_BIT);
365365
// enable simplelink in ap mode (use the MAC address to make the ssid unique)
366-
wlan_sl_enable (ROLE_AP, MICROPY_PORT_WLAN_AP_SSID, strlen(MICROPY_PORT_WLAN_AP_SSID), MICROPY_PORT_WLAN_AP_SECURITY,
367-
MICROPY_PORT_WLAN_AP_KEY, strlen(MICROPY_PORT_WLAN_AP_KEY), MICROPY_PORT_WLAN_AP_CHANNEL, append_mac);
366+
wlan_sl_init (ROLE_AP, MICROPY_PORT_WLAN_AP_SSID, strlen(MICROPY_PORT_WLAN_AP_SSID),
367+
MICROPY_PORT_WLAN_AP_SECURITY, MICROPY_PORT_WLAN_AP_KEY, strlen(MICROPY_PORT_WLAN_AP_KEY),
368+
MICROPY_PORT_WLAN_AP_CHANNEL, ANTENNA_TYPE_INTERNAL, add_mac);
368369
}
369370

370371
STATIC void mptask_create_main_py (void) {

cc3200/qstrdefsport.h

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ Q(pins)
176176

177177
// for RTC class
178178
Q(RTC)
179+
Q(id)
179180
Q(init)
180181
Q(alarm)
181182
Q(alarm_left)
@@ -262,38 +263,33 @@ Q(server_timeout)
262263

263264
// for WLAN class
264265
Q(WLAN)
265-
Q(iwconfig)
266+
Q(id)
267+
Q(init)
268+
Q(mode)
266269
Q(key)
267-
Q(security)
270+
Q(auth)
268271
Q(ssid)
269272
Q(bssid)
273+
Q(mac)
274+
Q(antenna)
270275
Q(scan)
271276
Q(connect)
272277
Q(isconnected)
273278
Q(disconnect)
274279
Q(channel)
275280
Q(rssi)
276281
Q(ifconfig)
277-
Q(info)
278-
Q(connections)
279-
#if MICROPY_PORT_WLAN_URN
280-
Q(urn)
281-
#endif
282-
Q(mode)
283-
Q(ip)
284-
Q(subnet)
285-
Q(gateway)
286-
Q(dns)
287-
Q(mac)
288-
Q(antenna)
282+
Q(config)
283+
//Q(connections)
284+
//Q(urn)
289285
Q(STA)
290286
Q(AP)
291287
Q(OPEN)
292288
Q(WEP)
293289
Q(WPA)
294290
Q(WPA2)
295-
Q(INTERNAL)
296-
Q(EXTERNAL)
291+
Q(INT_ANT)
292+
Q(EXT_ANT)
297293
Q(ANY_EVENT)
298294

299295
// for WDT class

cc3200/serverstask.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,15 @@ void TASK_Servers (void *pvParameters) {
144144

145145
void servers_start (void) {
146146
servers_data.do_enable = true;
147-
HAL_Delay (SERVERS_CYCLE_TIME_MS * 5);
147+
HAL_Delay (SERVERS_CYCLE_TIME_MS * 3);
148148
}
149149

150150
void servers_stop (void) {
151151
servers_data.do_disable = true;
152152
do {
153153
HAL_Delay (SERVERS_CYCLE_TIME_MS);
154154
} while (servers_are_enabled());
155-
HAL_Delay (SERVERS_CYCLE_TIME_MS * 5);
155+
HAL_Delay (SERVERS_CYCLE_TIME_MS * 3);
156156
}
157157

158158
void servers_reset (void) {

0 commit comments

Comments
 (0)