From ee8119779e22c21fe7771a054e4cf6ee921b4352 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 17 May 2019 15:47:12 -0400 Subject: [PATCH] WIP --- shared-bindings/bleio/ScanEntry.c | 7 ++----- shared-bindings/bleio/Scanner.c | 23 ++++++++--------------- shared-bindings/bleio/Scanner.h | 2 +- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/shared-bindings/bleio/ScanEntry.c b/shared-bindings/bleio/ScanEntry.c index e6b9550780..67e4a38c02 100644 --- a/shared-bindings/bleio/ScanEntry.c +++ b/shared-bindings/bleio/ScanEntry.c @@ -37,9 +37,6 @@ #include "shared-module/bleio/AdvertisementData.h" #include "shared-module/bleio/ScanEntry.h" -// Work-in-progress: orphaned for now. -//| :orphan: -//| //| .. currentmodule:: bleio //| //| :class:`ScanEntry` -- BLE scan response entry @@ -63,7 +60,7 @@ //| .. attribute:: name //| //| The name of the device. (read-only) -//| This attribute might be `None` if the data was missing from the advertisement packet. +//| Will be be `None` if the data was missing from the advertisement packet. //| //| .. attribute:: raw_data @@ -87,7 +84,7 @@ //| .. attribute:: tx_power_level //| //| The transmit power level of the device. (read-only) -//| This attribute might be `None` if the data was missing from the advertisement packet. +//| Will be `None` if the data was missing from the advertisement packet. //| static uint8_t find_data_item(mp_obj_array_t *data_in, uint8_t type, uint8_t **data_out) { uint16_t i = 0; diff --git a/shared-bindings/bleio/Scanner.c b/shared-bindings/bleio/Scanner.c index f5424f706c..73b6e6a0b2 100644 --- a/shared-bindings/bleio/Scanner.c +++ b/shared-bindings/bleio/Scanner.c @@ -3,6 +3,7 @@ * * The MIT License (MIT) * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -32,9 +33,6 @@ #define DEFAULT_INTERVAL 100 #define DEFAULT_WINDOW 100 -// Work-in-progress: orphaned for now. -//| :orphan: -//| //| .. currentmodule:: bleio //| //| :class:`Scanner` -- scan for nearby BLE devices @@ -46,7 +44,7 @@ //| //| import bleio //| scanner = bleio.Scanner() -//| entries = scanner.scan(2500) +//| entries = scanner.scan(2.5) # Scan for 2.5 seconds //| print(entries) //| @@ -57,33 +55,28 @@ //| .. attribute:: interval //| -//| The interval (in ms) between the start of two consecutive scan windows. -//| Allowed values are between 10ms and 10.24 sec. +//| The interval (in seconds) between the start of two consecutive scan windows. +//| Allowed values are between 0.010 and 10.24 sec. //| //| .. attribute:: window //| -//| The duration (in ms) in which a single BLE channel is scanned. -//| Allowed values are between 10ms and 10.24 sec. +//| The duration (in seconds) in which a single BLE channel is scanned. +//| Allowed values are between 0.010 and 10.24 sec. //| //| .. method:: scan(timeout) //| //| Performs a BLE scan. //| -//| :param int timeout: the scan timeout in ms +//| :param float timeout: the scan timeout in seconds //| :returns: advertising packets found //| :rtype: list of :py:class:`bleio.ScanEntry` //| -STATIC void bleio_scanner_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - bleio_scanner_obj_t *self = MP_OBJ_TO_PTR(self_in); - - 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, 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); self->base.type = type; diff --git a/shared-bindings/bleio/Scanner.h b/shared-bindings/bleio/Scanner.h index 9bd0717476..c72136389b 100644 --- a/shared-bindings/bleio/Scanner.h +++ b/shared-bindings/bleio/Scanner.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2017 Glenn Ruben Bakke + * Copyright (c) 2019 Dan Halbert for Adafruit Industries * Copyright (c) 2018 Artur Pacholec * * Permission is hereby granted, free of charge, to any person obtaining a copy