summaryrefslogtreecommitdiff
path: root/ports/cc3200
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2018-07-11 16:45:30 -0400
committerDan Halbert <halbert@halwitz.org>2018-07-11 16:45:30 -0400
commit7c219600a246d8956d0b23ea3f5d125a820e6b6a (patch)
tree4cf793a66284322d48a8f430815c31cd1c9ffa1d /ports/cc3200
parent4962468ffffac9ec4e36b2b1fc3f132516df3127 (diff)
parent25ae98f07cb3c4488cb955403dfe56b8bb8db6f0 (diff)
WIP: after merge; before testing
Diffstat (limited to 'ports/cc3200')
-rw-r--r--ports/cc3200/mods/modusocket.c15
-rw-r--r--ports/cc3200/mods/modusocket.h2
-rw-r--r--ports/cc3200/mods/modwlan.c10
-rw-r--r--ports/cc3200/mpconfigport.h4
4 files changed, 14 insertions, 17 deletions
diff --git a/ports/cc3200/mods/modusocket.c b/ports/cc3200/mods/modusocket.c
index f587e765a..286b1fb02 100644
--- a/ports/cc3200/mods/modusocket.c
+++ b/ports/cc3200/mods/modusocket.c
@@ -336,6 +336,9 @@ STATIC int wlan_socket_ioctl (mod_network_socket_obj_t *s, mp_uint_t request, mp
if (SL_FD_ISSET(sd, &xfds)) {
ret |= MP_STREAM_POLL_HUP;
}
+ } else if (request == MP_STREAM_CLOSE) {
+ wlan_socket_close(s);
+ ret = 0;
} else {
*_errno = MP_EINVAL;
ret = MP_STREAM_ERROR;
@@ -466,14 +469,6 @@ STATIC mp_obj_t socket_make_new(const mp_obj_type_t *type, size_t n_args, size_t
return s;
}
-// method socket.close()
-STATIC mp_obj_t socket_close(mp_obj_t self_in) {
- mod_network_socket_obj_t *self = self_in;
- wlan_socket_close(self);
- return mp_const_none;
-}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(socket_close_obj, socket_close);
-
// method socket.bind(address)
STATIC mp_obj_t socket_bind(mp_obj_t self_in, mp_obj_t addr_in) {
mod_network_socket_obj_t *self = self_in;
@@ -704,8 +699,8 @@ STATIC mp_obj_t socket_makefile(size_t n_args, const mp_obj_t *args) {
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_makefile_obj, 1, 6, socket_makefile);
STATIC const mp_rom_map_elem_t socket_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&socket_close_obj) },
- { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&socket_close_obj) },
+ { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&mp_stream_close_obj) },
+ { MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&mp_stream_close_obj) },
{ MP_ROM_QSTR(MP_QSTR_bind), MP_ROM_PTR(&socket_bind_obj) },
{ MP_ROM_QSTR(MP_QSTR_listen), MP_ROM_PTR(&socket_listen_obj) },
{ MP_ROM_QSTR(MP_QSTR_accept), MP_ROM_PTR(&socket_accept_obj) },
diff --git a/ports/cc3200/mods/modusocket.h b/ports/cc3200/mods/modusocket.h
index 6e7758662..aaee04ce1 100644
--- a/ports/cc3200/mods/modusocket.h
+++ b/ports/cc3200/mods/modusocket.h
@@ -26,6 +26,8 @@
#ifndef MICROPY_INCLUDED_CC3200_MODS_MODUSOCKET_H
#define MICROPY_INCLUDED_CC3200_MODS_MODUSOCKET_H
+#include "py/stream.h"
+
extern const mp_obj_dict_t socket_locals_dict;
extern const mp_stream_p_t socket_stream_p;
diff --git a/ports/cc3200/mods/modwlan.c b/ports/cc3200/mods/modwlan.c
index 005334a79..c27e993bc 100644
--- a/ports/cc3200/mods/modwlan.c
+++ b/ports/cc3200/mods/modwlan.c
@@ -886,7 +886,7 @@ STATIC mp_obj_t wlan_scan(mp_obj_t self_in) {
}
mp_obj_t tuple[5];
- tuple[0] = mp_obj_new_str((const char *)wlanEntry.ssid, wlanEntry.ssid_len, false);
+ tuple[0] = mp_obj_new_str((const char *)wlanEntry.ssid, wlanEntry.ssid_len);
tuple[1] = mp_obj_new_bytes((const byte *)wlanEntry.bssid, SL_BSSID_LENGTH);
// 'normalize' the security type
if (wlanEntry.sec_type > 2) {
@@ -1076,7 +1076,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(wlan_mode_obj, 1, 2, wlan_mode);
STATIC mp_obj_t wlan_ssid(size_t n_args, const mp_obj_t *args) {
wlan_obj_t *self = args[0];
if (n_args == 1) {
- return mp_obj_new_str((const char *)self->ssid, strlen((const char *)self->ssid), false);
+ return mp_obj_new_str((const char *)self->ssid, strlen((const char *)self->ssid));
} else {
size_t len;
const char *ssid = mp_obj_str_get_data(args[1], &len);
@@ -1096,7 +1096,7 @@ STATIC mp_obj_t wlan_auth(size_t n_args, const mp_obj_t *args) {
} else {
mp_obj_t security[2];
security[0] = mp_obj_new_int(self->auth);
- security[1] = mp_obj_new_str((const char *)self->key, strlen((const char *)self->key), false);
+ security[1] = mp_obj_new_str((const char *)self->key, strlen((const char *)self->key));
return mp_obj_new_tuple(2, security);
}
} else {
@@ -1200,7 +1200,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(wlan_irq_obj, 1, wlan_irq);
// mp_obj_t connections = mp_obj_new_list(0, NULL);
//
// if (wlan_is_connected()) {
-// device[0] = mp_obj_new_str((const char *)wlan_obj.ssid_o, strlen((const char *)wlan_obj.ssid_o), false);
+// device[0] = mp_obj_new_str((const char *)wlan_obj.ssid_o, strlen((const char *)wlan_obj.ssid_o));
// device[1] = mp_obj_new_bytes((const byte *)wlan_obj.bssid, SL_BSSID_LENGTH);
// // add the device to the list
// mp_obj_list_append(connections, mp_obj_new_tuple(MP_ARRAY_SIZE(device), device));
@@ -1233,7 +1233,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(wlan_irq_obj, 1, wlan_irq);
// if (sl_NetAppGet(SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, &len, (uint8_t *)urn) < 0) {
// mp_raise_OSError(MP_EIO);
// }
-// return mp_obj_new_str(urn, (len - 1), false);
+// return mp_obj_new_str(urn, (len - 1));
// }
//
// return mp_const_none;
diff --git a/ports/cc3200/mpconfigport.h b/ports/cc3200/mpconfigport.h
index 29ae9092b..ee9a226e5 100644
--- a/ports/cc3200/mpconfigport.h
+++ b/ports/cc3200/mpconfigport.h
@@ -131,8 +131,8 @@
X(ETIMEDOUT) \
// TODO these should be generic, not bound to fatfs
-#define mp_type_fileio fatfs_type_fileio
-#define mp_type_textio fatfs_type_textio
+#define mp_type_fileio mp_type_vfs_fat_fileio
+#define mp_type_textio mp_type_vfs_fat_textio
// use vfs's functions for import stat and builtin open
#define mp_import_stat mp_vfs_import_stat