Skip to content

Commit ed56b0b

Browse files
author
Daniel Campora
committed
cc3200: Finally unlock the full wake on WLAN feature set.
1 parent 18030bd commit ed56b0b

13 files changed

Lines changed: 207 additions & 135 deletions

File tree

cc3200/ftp/ftp.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "ftp.h"
4141
#include "simplelink.h"
4242
#include "modwlan.h"
43+
#include "modusocket.h"
4344
#include "debug.h"
4445
#include "serverstask.h"
4546
#include "ff.h"
@@ -50,7 +51,6 @@
5051
#include "updater.h"
5152
#include "timeutils.h"
5253

53-
5454
/******************************************************************************
5555
DEFINE PRIVATE CONSTANTS
5656
******************************************************************************/
@@ -429,6 +429,9 @@ static bool ftp_create_listening_socket (_i16 *sd, _u16 port, _u8 backlog) {
429429
_sd = *sd;
430430

431431
if (_sd > 0) {
432+
// add the new socket to the network administration
433+
modusocket_socket_add(_sd, false);
434+
432435
// Enable non-blocking mode
433436
nonBlockingOption.NonblockingEnabled = 1;
434437
ASSERT (sl_SetSockOpt(_sd, SOL_SOCKET, SL_SO_NONBLOCKING, &nonBlockingOption, sizeof(nonBlockingOption)) == SL_SOC_OK);
@@ -464,6 +467,9 @@ static ftp_result_t ftp_wait_for_connection (_i16 l_sd, _i16 *n_sd) {
464467
return E_FTP_RESULT_FAILED;
465468
}
466469

470+
// add the new socket to the network administration
471+
modusocket_socket_add(_sd, false);
472+
467473
// client connected, so go on
468474
return E_FTP_RESULT_OK;
469475
}

cc3200/mods/modnetwork.c

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,47 +25,22 @@
2525
* THE SOFTWARE.
2626
*/
2727

28-
#include <stdio.h>
29-
#include <stdint.h>
30-
#include <string.h>
28+
#include <std.h>
3129

3230
#include "py/mpstate.h"
3331
#include MICROPY_HAL_H
3432
#include "modnetwork.h"
3533
#include "mpexception.h"
3634
#include "serverstask.h"
35+
#include "simplelink.h"
36+
3737

3838
/// \module network - network configuration
3939
///
4040
/// This module provides network drivers and routing configuration.
4141

4242
void mod_network_init0(void) {
43-
mp_obj_list_init(&MP_STATE_PORT(mod_network_nic_list), 0);
44-
}
45-
46-
void mod_network_register_nic(mp_obj_t nic) {
47-
for (mp_uint_t i = 0; i < MP_STATE_PORT(mod_network_nic_list).len; i++) {
48-
if (MP_STATE_PORT(mod_network_nic_list).items[i] == nic) {
49-
// nic already registered
50-
return;
51-
}
52-
}
53-
// nic not registered so add to list
54-
mp_obj_list_append(&MP_STATE_PORT(mod_network_nic_list), nic);
55-
}
56-
57-
mp_obj_t mod_network_find_nic(void) {
58-
for (mp_uint_t i = 0; i < MP_STATE_PORT(mod_network_nic_list).len; i++) {
59-
mp_obj_t nic = MP_STATE_PORT(mod_network_nic_list).items[i];
60-
return nic;
61-
}
62-
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable));
63-
}
64-
65-
STATIC mp_obj_t network_route(void) {
66-
return &MP_STATE_PORT(mod_network_nic_list);
6743
}
68-
STATIC MP_DEFINE_CONST_FUN_OBJ_0(network_route_obj, network_route);
6944

7045
#if (MICROPY_PORT_HAS_TELNET || MICROPY_PORT_HAS_FTP)
7146
STATIC mp_obj_t network_server_start(void) {
@@ -97,7 +72,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(network_server_login_obj, network_server_login)
9772
STATIC const mp_map_elem_t mp_module_network_globals_table[] = {
9873
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_network) },
9974
{ MP_OBJ_NEW_QSTR(MP_QSTR_WLAN), (mp_obj_t)&mod_network_nic_type_wlan },
100-
{ MP_OBJ_NEW_QSTR(MP_QSTR_route), (mp_obj_t)&network_route_obj },
10175

10276
#if (MICROPY_PORT_HAS_TELNET || MICROPY_PORT_HAS_FTP)
10377
{ MP_OBJ_NEW_QSTR(MP_QSTR_start_server), (mp_obj_t)&network_server_start_obj },

cc3200/mods/modnetwork.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ typedef struct _mod_network_nic_type_t {
3737
mp_obj_type_t base;
3838

3939
// API for non-socket operations
40-
int (*gethostbyname)(mp_obj_t nic, const char *name, mp_uint_t len, uint8_t *ip_out, uint8_t family);
40+
int (*gethostbyname)(const char *name, mp_uint_t len, uint8_t *ip_out, uint8_t family);
4141

4242
// API for socket operations; return -1 on error
4343
int (*socket)(struct _mod_network_socket_obj_t *s, int *_errno);
@@ -57,7 +57,6 @@ typedef struct _mod_network_nic_type_t {
5757

5858
typedef struct _mod_network_socket_obj_t {
5959
mp_obj_base_t base;
60-
mp_obj_t nic;
6160
mod_network_nic_type_t *nic_type;
6261
union {
6362
struct {
@@ -74,7 +73,5 @@ typedef struct _mod_network_socket_obj_t {
7473
extern const mod_network_nic_type_t mod_network_nic_type_wlan;
7574

7675
void mod_network_init0(void);
77-
void mod_network_register_nic(mp_obj_t nic);
78-
mp_obj_t mod_network_find_nic(void);
7976

8077
#endif // MODNETWORK_H_

0 commit comments

Comments
 (0)