WIP
This commit is contained in:
parent
bd69212a19
commit
ee8119779e
@ -37,9 +37,6 @@
|
|||||||
#include "shared-module/bleio/AdvertisementData.h"
|
#include "shared-module/bleio/AdvertisementData.h"
|
||||||
#include "shared-module/bleio/ScanEntry.h"
|
#include "shared-module/bleio/ScanEntry.h"
|
||||||
|
|
||||||
// Work-in-progress: orphaned for now.
|
|
||||||
//| :orphan:
|
|
||||||
//|
|
|
||||||
//| .. currentmodule:: bleio
|
//| .. currentmodule:: bleio
|
||||||
//|
|
//|
|
||||||
//| :class:`ScanEntry` -- BLE scan response entry
|
//| :class:`ScanEntry` -- BLE scan response entry
|
||||||
@ -63,7 +60,7 @@
|
|||||||
//| .. attribute:: name
|
//| .. attribute:: name
|
||||||
//|
|
//|
|
||||||
//| The name of the device. (read-only)
|
//| 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
|
//| .. attribute:: raw_data
|
||||||
@ -87,7 +84,7 @@
|
|||||||
//| .. attribute:: tx_power_level
|
//| .. attribute:: tx_power_level
|
||||||
//|
|
//|
|
||||||
//| The transmit power level of the device. (read-only)
|
//| 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) {
|
static uint8_t find_data_item(mp_obj_array_t *data_in, uint8_t type, uint8_t **data_out) {
|
||||||
uint16_t i = 0;
|
uint16_t i = 0;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
*
|
*
|
||||||
* The MIT License (MIT)
|
* The MIT License (MIT)
|
||||||
*
|
*
|
||||||
|
* Copyright (c) 2019 Dan Halbert for Adafruit Industries
|
||||||
* Copyright (c) 2018 Artur Pacholec
|
* Copyright (c) 2018 Artur Pacholec
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -32,9 +33,6 @@
|
|||||||
#define DEFAULT_INTERVAL 100
|
#define DEFAULT_INTERVAL 100
|
||||||
#define DEFAULT_WINDOW 100
|
#define DEFAULT_WINDOW 100
|
||||||
|
|
||||||
// Work-in-progress: orphaned for now.
|
|
||||||
//| :orphan:
|
|
||||||
//|
|
|
||||||
//| .. currentmodule:: bleio
|
//| .. currentmodule:: bleio
|
||||||
//|
|
//|
|
||||||
//| :class:`Scanner` -- scan for nearby BLE devices
|
//| :class:`Scanner` -- scan for nearby BLE devices
|
||||||
@ -46,7 +44,7 @@
|
|||||||
//|
|
//|
|
||||||
//| import bleio
|
//| import bleio
|
||||||
//| scanner = bleio.Scanner()
|
//| scanner = bleio.Scanner()
|
||||||
//| entries = scanner.scan(2500)
|
//| entries = scanner.scan(2.5) # Scan for 2.5 seconds
|
||||||
//| print(entries)
|
//| print(entries)
|
||||||
//|
|
//|
|
||||||
|
|
||||||
@ -57,33 +55,28 @@
|
|||||||
|
|
||||||
//| .. attribute:: interval
|
//| .. attribute:: interval
|
||||||
//|
|
//|
|
||||||
//| The interval (in ms) between the start of two consecutive scan windows.
|
//| The interval (in seconds) between the start of two consecutive scan windows.
|
||||||
//| Allowed values are between 10ms and 10.24 sec.
|
//| Allowed values are between 0.010 and 10.24 sec.
|
||||||
//|
|
//|
|
||||||
|
|
||||||
//| .. attribute:: window
|
//| .. attribute:: window
|
||||||
//|
|
//|
|
||||||
//| The duration (in ms) in which a single BLE channel is scanned.
|
//| The duration (in seconds) in which a single BLE channel is scanned.
|
||||||
//| Allowed values are between 10ms and 10.24 sec.
|
//| Allowed values are between 0.010 and 10.24 sec.
|
||||||
//|
|
//|
|
||||||
|
|
||||||
//| .. method:: scan(timeout)
|
//| .. method:: scan(timeout)
|
||||||
//|
|
//|
|
||||||
//| Performs a BLE scan.
|
//| Performs a BLE scan.
|
||||||
//|
|
//|
|
||||||
//| :param int timeout: the scan timeout in ms
|
//| :param float timeout: the scan timeout in seconds
|
||||||
//| :returns: advertising packets found
|
//| :returns: advertising packets found
|
||||||
//| :rtype: list of :py:class:`bleio.ScanEntry`
|
//| :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) {
|
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);
|
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;
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* The MIT License (MIT)
|
* The MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2017 Glenn Ruben Bakke
|
* Copyright (c) 2019 Dan Halbert for Adafruit Industries
|
||||||
* Copyright (c) 2018 Artur Pacholec
|
* Copyright (c) 2018 Artur Pacholec
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
Loading…
Reference in New Issue
Block a user