Skip to content

Commit

Permalink
cc3200: Finally unlock the full wake on WLAN feature set.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Campora committed May 22, 2015
1 parent 18030bd commit ed56b0b
Show file tree
Hide file tree
Showing 13 changed files with 207 additions and 135 deletions.
8 changes: 7 additions & 1 deletion cc3200/ftp/ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "ftp.h"
#include "simplelink.h"
#include "modwlan.h"
#include "modusocket.h"
#include "debug.h"
#include "serverstask.h"
#include "ff.h"
Expand All @@ -50,7 +51,6 @@
#include "updater.h"
#include "timeutils.h"


/******************************************************************************
DEFINE PRIVATE CONSTANTS
******************************************************************************/
Expand Down Expand Up @@ -429,6 +429,9 @@ static bool ftp_create_listening_socket (_i16 *sd, _u16 port, _u8 backlog) {
_sd = *sd;

if (_sd > 0) {
// add the new socket to the network administration
modusocket_socket_add(_sd, false);

// Enable non-blocking mode
nonBlockingOption.NonblockingEnabled = 1;
ASSERT (sl_SetSockOpt(_sd, SOL_SOCKET, SL_SO_NONBLOCKING, &nonBlockingOption, sizeof(nonBlockingOption)) == SL_SOC_OK);
Expand Down Expand Up @@ -464,6 +467,9 @@ static ftp_result_t ftp_wait_for_connection (_i16 l_sd, _i16 *n_sd) {
return E_FTP_RESULT_FAILED;
}

// add the new socket to the network administration
modusocket_socket_add(_sd, false);

// client connected, so go on
return E_FTP_RESULT_OK;
}
Expand Down
32 changes: 3 additions & 29 deletions cc3200/mods/modnetwork.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,22 @@
* THE SOFTWARE.
*/

#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <std.h>

#include "py/mpstate.h"
#include MICROPY_HAL_H
#include "modnetwork.h"
#include "mpexception.h"
#include "serverstask.h"
#include "simplelink.h"


/// \module network - network configuration
///
/// This module provides network drivers and routing configuration.

void mod_network_init0(void) {
mp_obj_list_init(&MP_STATE_PORT(mod_network_nic_list), 0);
}

void mod_network_register_nic(mp_obj_t nic) {
for (mp_uint_t i = 0; i < MP_STATE_PORT(mod_network_nic_list).len; i++) {
if (MP_STATE_PORT(mod_network_nic_list).items[i] == nic) {
// nic already registered
return;
}
}
// nic not registered so add to list
mp_obj_list_append(&MP_STATE_PORT(mod_network_nic_list), nic);
}

mp_obj_t mod_network_find_nic(void) {
for (mp_uint_t i = 0; i < MP_STATE_PORT(mod_network_nic_list).len; i++) {
mp_obj_t nic = MP_STATE_PORT(mod_network_nic_list).items[i];
return nic;
}
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable));
}

STATIC mp_obj_t network_route(void) {
return &MP_STATE_PORT(mod_network_nic_list);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(network_route_obj, network_route);

#if (MICROPY_PORT_HAS_TELNET || MICROPY_PORT_HAS_FTP)
STATIC mp_obj_t network_server_start(void) {
Expand Down Expand Up @@ -97,7 +72,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(network_server_login_obj, network_server_login)
STATIC const mp_map_elem_t mp_module_network_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_network) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_WLAN), (mp_obj_t)&mod_network_nic_type_wlan },
{ MP_OBJ_NEW_QSTR(MP_QSTR_route), (mp_obj_t)&network_route_obj },

#if (MICROPY_PORT_HAS_TELNET || MICROPY_PORT_HAS_FTP)
{ MP_OBJ_NEW_QSTR(MP_QSTR_start_server), (mp_obj_t)&network_server_start_obj },
Expand Down
5 changes: 1 addition & 4 deletions cc3200/mods/modnetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ typedef struct _mod_network_nic_type_t {
mp_obj_type_t base;

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

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

typedef struct _mod_network_socket_obj_t {
mp_obj_base_t base;
mp_obj_t nic;
mod_network_nic_type_t *nic_type;
union {
struct {
Expand All @@ -74,7 +73,5 @@ typedef struct _mod_network_socket_obj_t {
extern const mod_network_nic_type_t mod_network_nic_type_wlan;

void mod_network_init0(void);
void mod_network_register_nic(mp_obj_t nic);
mp_obj_t mod_network_find_nic(void);

#endif // MODNETWORK_H_

0 comments on commit ed56b0b

Please sign in to comment.