fixup m0 and nrf

This commit is contained in:
Scott Shawcroft 2019-01-14 18:08:45 -08:00
parent 12c8b00556
commit bd3c36ce6d
No known key found for this signature in database
GPG Key ID: FD0EDC4B6C53CA59
12 changed files with 58 additions and 90 deletions

View File

@ -69,22 +69,18 @@ STATIC uint8_t xdigit_8b_value(byte nibble1, byte nibble2) {
//| - `bleio.AddressType.RANDOM_PRIVATE_RESOLVABLE` //| - `bleio.AddressType.RANDOM_PRIVATE_RESOLVABLE`
//| - `bleio.AddressType.RANDOM_PRIVATE_NON_RESOLVABLE` //| - `bleio.AddressType.RANDOM_PRIVATE_NON_RESOLVABLE`
//| //|
STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
mp_arg_check_num(n_args, n_kw, 1, 1, true);
bleio_address_obj_t *self = m_new_obj(bleio_address_obj_t);
self->base.type = &bleio_address_type;
self->type = ADDRESS_PUBLIC;
mp_map_t kw_args;
mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args);
enum { ARG_address }; enum { ARG_address };
static const mp_arg_t allowed_args[] = { static const mp_arg_t allowed_args[] = {
{ MP_QSTR_address, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, { MP_QSTR_address, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
}; };
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
bleio_address_obj_t *self = m_new_obj(bleio_address_obj_t);
self->base.type = &bleio_address_type;
self->type = ADDRESS_PUBLIC;
const mp_obj_t address = args[ARG_address].u_obj; const mp_obj_t address = args[ARG_address].u_obj;

View File

@ -59,24 +59,19 @@
//| :param float interval: how often to broadcast //| :param float interval: how often to broadcast
//| //|
STATIC mp_obj_t bleio_broadcaster_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { STATIC mp_obj_t bleio_broadcaster_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
mp_arg_check_num(n_args, n_kw, 0, 1, true);
bleio_broadcaster_obj_t *self = m_new_obj(bleio_broadcaster_obj_t);
self->base.type = &bleio_broadcaster_type;
mp_map_t kw_args;
mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args);
enum { ARG_interval }; enum { ARG_interval };
static const mp_arg_t allowed_args[] = { static const mp_arg_t allowed_args[] = {
{ MP_QSTR_interval, MP_ARG_OBJ, {.u_obj = MP_OBJ_NEW_SMALL_INT(1)} }, { MP_QSTR_interval, MP_ARG_OBJ, {.u_obj = MP_OBJ_NEW_SMALL_INT(1)} },
}; };
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
mp_float_t interval = mp_obj_get_float(args[ARG_interval].u_obj); mp_float_t interval = mp_obj_get_float(args[ARG_interval].u_obj);
bleio_broadcaster_obj_t *self = m_new_obj(bleio_broadcaster_obj_t);
self->base.type = &bleio_broadcaster_type;
// Do port-specific initialization. interval will be validated. // Do port-specific initialization. interval will be validated.
common_hal_bleio_broadcaster_construct(self, interval); common_hal_bleio_broadcaster_construct(self, interval);

View File

@ -51,14 +51,7 @@
//| :param bool write: Clients may write this characteristic; a response will be sent back //| :param bool write: Clients may write this characteristic; a response will be sent back
//| :param bool write_no_response: Clients may write this characteristic; no response will be sent back //| :param bool write_no_response: Clients may write this characteristic; no response will be sent back
//| //|
STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
mp_arg_check_num(n_args, n_kw, 1, 1, true);
bleio_characteristic_obj_t *self = m_new_obj(bleio_characteristic_obj_t);
self->base.type = &bleio_characteristic_type;
mp_map_t kw_args;
mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args);
enum { enum {
ARG_uuid, ARG_broadcast, ARG_indicate, ARG_notify, ARG_read, ARG_write, ARG_write_no_response, ARG_uuid, ARG_broadcast, ARG_indicate, ARG_notify, ARG_read, ARG_write, ARG_write_no_response,
}; };
@ -73,7 +66,7 @@ STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t
}; };
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mp_obj_t uuid = args[ARG_uuid].u_obj; const mp_obj_t uuid = args[ARG_uuid].u_obj;
@ -81,6 +74,8 @@ STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t
mp_raise_ValueError(translate("Expected a UUID")); mp_raise_ValueError(translate("Expected a UUID"));
} }
bleio_characteristic_obj_t *self = m_new_obj(bleio_characteristic_obj_t);
self->base.type = &bleio_characteristic_type;
self->uuid = MP_OBJ_TO_PTR(uuid); self->uuid = MP_OBJ_TO_PTR(uuid);
bleio_characteristic_properties_t properties; bleio_characteristic_properties_t properties;

View File

@ -44,14 +44,7 @@
//| :param int buffer_size: Size of ring buffer that stores incoming data coming from client. //| :param int buffer_size: Size of ring buffer that stores incoming data coming from client.
//| Must be >= 1. //| Must be >= 1.
//| //|
STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
mp_arg_check_num(n_args, n_kw, 1, 2, true);
bleio_characteristic_buffer_obj_t *self = m_new_obj(bleio_characteristic_buffer_obj_t);
self->base.type = &bleio_characteristic_buffer_type;
mp_map_t kw_args;
mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args);
enum { ARG_characteristic, ARG_buffer_size, }; enum { ARG_characteristic, ARG_buffer_size, };
static const mp_arg_t allowed_args[] = { static const mp_arg_t allowed_args[] = {
{ MP_QSTR_characteristic, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_characteristic, MP_ARG_REQUIRED | MP_ARG_OBJ },
@ -59,7 +52,7 @@ STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type,
}; };
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mp_obj_t characteristic = args[ARG_characteristic].u_obj; const mp_obj_t characteristic = args[ARG_characteristic].u_obj;
const int buffer_size = args[ARG_buffer_size].u_int; const int buffer_size = args[ARG_buffer_size].u_int;
@ -72,6 +65,8 @@ STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type,
mp_raise_ValueError(translate("Expected a Characteristic")); mp_raise_ValueError(translate("Expected a Characteristic"));
} }
bleio_characteristic_buffer_obj_t *self = m_new_obj(bleio_characteristic_buffer_obj_t);
self->base.type = &bleio_characteristic_buffer_type;
self->characteristic = MP_OBJ_TO_PTR(characteristic); self->characteristic = MP_OBJ_TO_PTR(characteristic);
common_hal_bleio_characteristic_buffer_construct(self, self->characteristic, buffer_size); common_hal_bleio_characteristic_buffer_construct(self, self->characteristic, buffer_size);

View File

@ -71,21 +71,14 @@ enum {
//| //|
//| The descriptor uuid. (read-only) //| The descriptor uuid. (read-only)
//| //|
STATIC mp_obj_t bleio_descriptor_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { STATIC mp_obj_t bleio_descriptor_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
mp_arg_check_num(n_args, n_kw, 0, 1, true);
bleio_descriptor_obj_t *self = m_new_obj(bleio_descriptor_obj_t);
self->base.type = type;
mp_map_t kw_args;
mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args);
enum { ARG_uuid }; enum { ARG_uuid };
static const mp_arg_t allowed_args[] = { static const mp_arg_t allowed_args[] = {
{ MP_QSTR_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, { MP_QSTR_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
}; };
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mp_obj_t uuid_arg = args[ARG_uuid].u_obj; const mp_obj_t uuid_arg = args[ARG_uuid].u_obj;
@ -93,6 +86,8 @@ STATIC mp_obj_t bleio_descriptor_make_new(const mp_obj_type_t *type, size_t n_ar
mp_raise_ValueError(translate("Expected a UUID")); mp_raise_ValueError(translate("Expected a UUID"));
} }
bleio_descriptor_obj_t *self = m_new_obj(bleio_descriptor_obj_t);
self->base.type = type;
bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_arg); bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_arg);
common_hal_bleio_descriptor_construct(self, uuid); common_hal_bleio_descriptor_construct(self, uuid);

View File

@ -82,16 +82,7 @@ static const char default_name[] = "CIRCUITPY";
//| :param str name: The name used when advertising this peripheral //| :param str name: The name used when advertising this peripheral
//| //|
STATIC mp_obj_t bleio_peripheral_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { STATIC mp_obj_t bleio_peripheral_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
mp_arg_check_num(n_args, n_kw, 0, 1, true);
bleio_peripheral_obj_t *self = m_new_obj(bleio_peripheral_obj_t);
self->base.type = &bleio_peripheral_type;
self->service_list = mp_obj_new_list(0, NULL);
self->notif_handler = mp_const_none;
mp_map_t kw_args;
mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args);
enum { ARG_services, ARG_name }; enum { ARG_services, ARG_name };
static const mp_arg_t allowed_args[] = { static const mp_arg_t allowed_args[] = {
{ MP_QSTR_services, MP_ARG_OBJ, {.u_obj = mp_const_none} }, { MP_QSTR_services, MP_ARG_OBJ, {.u_obj = mp_const_none} },
@ -99,13 +90,17 @@ STATIC mp_obj_t bleio_peripheral_make_new(const mp_obj_type_t *type, size_t n_ar
}; };
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
// If services is not an iterable, an exception will be thrown. // If services is not an iterable, an exception will be thrown.
mp_obj_iter_buf_t iter_buf; mp_obj_iter_buf_t iter_buf;
mp_obj_t iterable = mp_getiter(args[ARG_services].u_obj, &iter_buf); mp_obj_t iterable = mp_getiter(args[ARG_services].u_obj, &iter_buf);
mp_obj_t service; mp_obj_t service;
bleio_peripheral_obj_t *self = m_new_obj(bleio_peripheral_obj_t);
self->base.type = &bleio_peripheral_type;
self->service_list = mp_obj_new_list(0, NULL);
self->notif_handler = mp_const_none;
while ((service = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { while ((service = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
if (!MP_OBJ_IS_TYPE(service, &bleio_service_type)) { if (!MP_OBJ_IS_TYPE(service, &bleio_service_type)) {
mp_raise_ValueError(translate("services includes an object that is not a Service")); mp_raise_ValueError(translate("services includes an object that is not a Service"));

View File

@ -248,7 +248,7 @@ STATIC mp_obj_t scanentry_get_service_uuids(mp_obj_t self_in) {
mp_obj_t entries = mp_obj_new_list(0, NULL); mp_obj_t entries = mp_obj_new_list(0, NULL);
for (size_t i = 0; i < uuids_len / sizeof(uint16_t); ++i) { for (size_t i = 0; i < uuids_len / sizeof(uint16_t); ++i) {
const mp_obj_t uuid_int = mp_obj_new_int(uuids[sizeof(uint16_t) * i] | (uuids[sizeof(uint16_t) * i + 1] << 8)); const mp_obj_t uuid_int = mp_obj_new_int(uuids[sizeof(uint16_t) * i] | (uuids[sizeof(uint16_t) * i + 1] << 8));
const mp_obj_t uuid_obj = bleio_uuid_type.make_new(&bleio_uuid_type, 1, 0, &uuid_int); const mp_obj_t uuid_obj = bleio_uuid_type.make_new(&bleio_uuid_type, 1, &uuid_int, NULL);
mp_obj_list_append(entries, uuid_obj); mp_obj_list_append(entries, uuid_obj);
} }

View File

@ -25,6 +25,7 @@
*/ */
#include "py/objproperty.h" #include "py/objproperty.h"
#include "py/runtime.h"
#include "shared-bindings/bleio/ScanEntry.h" #include "shared-bindings/bleio/ScanEntry.h"
#include "shared-bindings/bleio/Scanner.h" #include "shared-bindings/bleio/Scanner.h"
@ -77,7 +78,9 @@ STATIC void bleio_scanner_print(const mp_print_t *print, mp_obj_t self_in, mp_pr
mp_printf(print, "Scanner(interval: %d window: %d)", self->interval, self->window); mp_printf(print, "Scanner(interval: %d window: %d)", self->interval, self->window);
} }
STATIC mp_obj_t bleio_scanner_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { STATIC mp_obj_t bleio_scanner_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *all_args, mp_map_t *kw_args) {
mp_arg_check_num(n_args, kw_args, 0, 0, false);
bleio_scanner_obj_t *self = m_new_obj(bleio_scanner_obj_t); bleio_scanner_obj_t *self = m_new_obj(bleio_scanner_obj_t);
self->base.type = type; self->base.type = type;

View File

@ -49,17 +49,7 @@
//| :param bool secondary: If the service is a secondary one //| :param bool secondary: If the service is a secondary one
//| //|
STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
mp_arg_check_num(n_args, n_kw, 2, 3, true);
bleio_service_obj_t *self = m_new_obj(bleio_service_obj_t);
self->char_list = mp_obj_new_list(0, NULL);
self->base.type = &bleio_service_type;
self->device = mp_const_none;
self->handle = 0xFFFF;
mp_map_t kw_args;
mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args);
enum { ARG_uuid, ARG_characteristics, ARG_secondary }; enum { ARG_uuid, ARG_characteristics, ARG_secondary };
static const mp_arg_t allowed_args[] = { static const mp_arg_t allowed_args[] = {
{ MP_QSTR_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = mp_const_none} }, { MP_QSTR_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = mp_const_none} },
@ -68,9 +58,7 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args,
}; };
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
self->is_secondary = args[ARG_secondary].u_bool;
const mp_obj_t uuid = args[ARG_uuid].u_obj; const mp_obj_t uuid = args[ARG_uuid].u_obj;
@ -78,6 +66,12 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args,
mp_raise_ValueError(translate("Expected a UUID")); mp_raise_ValueError(translate("Expected a UUID"));
} }
bleio_service_obj_t *self = m_new_obj(bleio_service_obj_t);
self->char_list = mp_obj_new_list(0, NULL);
self->base.type = &bleio_service_type;
self->device = mp_const_none;
self->handle = 0xFFFF;
self->is_secondary = args[ARG_secondary].u_bool;
self->uuid = MP_OBJ_TO_PTR(uuid); self->uuid = MP_OBJ_TO_PTR(uuid);
// If characteristics is not an iterable, an exception will be thrown. // If characteristics is not an iterable, an exception will be thrown.

View File

@ -51,8 +51,8 @@
//| //|
//| :param int/buffer value: The uuid value to encapsulate //| :param int/buffer value: The uuid value to encapsulate
//| //|
STATIC mp_obj_t bleio_uuid_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { STATIC mp_obj_t bleio_uuid_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
mp_arg_check_num(n_args, n_kw, 1, 1, false); mp_arg_check_num(n_args, kw_args, 1, 1, false);
bleio_uuid_obj_t *self = m_new_obj(bleio_uuid_obj_t); bleio_uuid_obj_t *self = m_new_obj(bleio_uuid_obj_t);
self->base.type = type; self->base.type = type;

View File

@ -39,20 +39,20 @@
//| :mod:`socket` --- TCP, UDP and RAW socket support //| :mod:`socket` --- TCP, UDP and RAW socket support
//| ================================================= //| =================================================
//| //|
//| .. module:: socket //| .. module:: socket
//| :synopsis: TCP, UDP and RAW sockets //| :synopsis: TCP, UDP and RAW sockets
//| :platform: SAMD21, SAMD51 //| :platform: SAMD21, SAMD51
//| //|
//| Create TCP, UDP and RAW sockets for communicating over the Internet. //| Create TCP, UDP and RAW sockets for communicating over the Internet.
//| //|
STATIC const mp_obj_type_t socket_type; STATIC const mp_obj_type_t socket_type;
//| .. currentmodule:: socket //| .. currentmodule:: socket
//| //|
//| .. class:: socket(family, type, proto, ...) //| .. class:: socket(family, type, proto, ...)
//| //|
//| Create a new socket //| Create a new socket
//| //|
//| :param ~int family: AF_INET or AF_INET6 //| :param ~int family: AF_INET or AF_INET6
@ -60,8 +60,8 @@ STATIC const mp_obj_type_t socket_type;
//| :param ~int proto: IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW (ignored) //| :param ~int proto: IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW (ignored)
//| //|
STATIC mp_obj_t socket_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { STATIC mp_obj_t socket_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
mp_arg_check_num(n_args, n_kw, 0, 4, false); mp_arg_check_num(n_args, kw_args, 0, 4, false);
// create socket object (not bound to any NIC yet) // create socket object (not bound to any NIC yet)
mod_network_socket_obj_t *s = m_new_obj_with_finaliser(mod_network_socket_obj_t); mod_network_socket_obj_t *s = m_new_obj_with_finaliser(mod_network_socket_obj_t);
@ -245,8 +245,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_send_obj, socket_send);
//| Reads some bytes from the connected remote address. //| Reads some bytes from the connected remote address.
//| Suits sockets of type SOCK_STREAM //| Suits sockets of type SOCK_STREAM
//| Returns a bytes() of length <= bufsize //| Returns a bytes() of length <= bufsize
//| //|
//| :param ~int bufsize: maximum number of bytes to receive //| :param ~int bufsize: maximum number of bytes to receive
STATIC mp_obj_t socket_recv(mp_obj_t self_in, mp_obj_t len_in) { STATIC mp_obj_t socket_recv(mp_obj_t self_in, mp_obj_t len_in) {
mod_network_socket_obj_t *self = MP_OBJ_TO_PTR(self_in); mod_network_socket_obj_t *self = MP_OBJ_TO_PTR(self_in);
@ -313,7 +313,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(socket_sendto_obj, socket_sendto);
//| * a bytes() of length <= bufsize //| * a bytes() of length <= bufsize
//| * a remote_address, which is a tuple of ip address and port number //| * a remote_address, which is a tuple of ip address and port number
//| //|
//| :param ~int bufsize: maximum number of bytes to receive //| :param ~int bufsize: maximum number of bytes to receive
//| //|
STATIC mp_obj_t socket_recvfrom(mp_obj_t self_in, mp_obj_t len_in) { STATIC mp_obj_t socket_recvfrom(mp_obj_t self_in, mp_obj_t len_in) {
@ -469,10 +469,10 @@ STATIC const mp_obj_type_t socket_type = {
}; };
//| .. function:: getaddrinfo(host, port) //| .. function:: getaddrinfo(host, port)
//| //|
//| Gets the address information for a hostname and port //| Gets the address information for a hostname and port
//| //|
//| Returns the appropriate family, socket type, socket protocol and //| Returns the appropriate family, socket type, socket protocol and
//| address information to call socket.socket() and socket.connect() with, //| address information to call socket.socket() and socket.connect() with,
//| as a tuple. //| as a tuple.
//| //|

View File

@ -46,22 +46,22 @@
#include "shared-module/wiznet/wiznet5k.h" #include "shared-module/wiznet/wiznet5k.h"
//| .. currentmodule:: wiznet //| .. currentmodule:: wiznet
//| //|
//| :class:`WIZNET5K` -- wrapper for Wiznet 5500 Ethernet interface //| :class:`WIZNET5K` -- wrapper for Wiznet 5500 Ethernet interface
//| =============================================================== //| ===============================================================
//| //|
//| .. class:: WIZNET5K(spi, cs, rst) //| .. class:: WIZNET5K(spi, cs, rst)
//| //|
//| Create a new WIZNET5500 interface using the specified pins //| Create a new WIZNET5500 interface using the specified pins
//| //|
//| :param spi: spi bus to use //| :param spi: spi bus to use
//| :param cs: pin to use for Chip Select //| :param cs: pin to use for Chip Select
//| :param rst: pin to sue for Reset //| :param rst: pin to sue for Reset
//| //|
STATIC mp_obj_t wiznet5k_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { STATIC mp_obj_t wiznet5k_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
// check arguments // check arguments
mp_arg_check_num(n_args, n_kw, 3, 3, false); mp_arg_check_num(n_args, kw_args, 3, 3, false);
return wiznet5k_create(args[0], args[1], args[2]); return wiznet5k_create(args[0], args[1], args[2]);
} }