diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2019-01-10 19:59:17 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-10 19:59:17 -0800 |
| commit | 573c6d60baedc9c06f6d7f274f45cf73c4b4283a (patch) | |
| tree | 2439849224cc3de1ed1564f31b967b93ca3f9507 /shared-module | |
| parent | 516d7da64173055422230e46173f7d19273a5107 (diff) | |
| parent | c863ad442fe826125fffc93a4077aa13c124c3b5 (diff) | |
Merge pull request #1446 from dhalbert/bleio-rev
Initial rewrite of bleio
Diffstat (limited to 'shared-module')
| -rw-r--r-- | shared-module/bleio/Characteristic.h | 19 | ||||
| -rw-r--r-- | shared-module/bleio/Service.h | 4 | ||||
| -rw-r--r-- | shared-module/bleio/__init__.h | 38 |
3 files changed, 44 insertions, 17 deletions
diff --git a/shared-module/bleio/Characteristic.h b/shared-module/bleio/Characteristic.h index 94c43f81e..958837e64 100644 --- a/shared-module/bleio/Characteristic.h +++ b/shared-module/bleio/Characteristic.h @@ -27,26 +27,15 @@ #ifndef MICROPY_INCLUDED_SHARED_MODULE_BLEIO_CHARACTERISTIC_H #define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_CHARACTERISTIC_H -#include "shared-module/bleio/Service.h" -#include "common-hal/bleio/UUID.h" - +// Flags for each characteristic property. Common across ports. typedef struct { - mp_obj_base_t base; - bleio_service_obj_t *service; - bleio_uuid_obj_t *uuid; - mp_obj_t value_data; - uint16_t handle; - struct { bool broadcast : 1; bool read : 1; - bool write_wo_resp : 1; + bool write_no_response : 1; bool write : 1; bool notify : 1; bool indicate : 1; - } props; - uint16_t user_desc_handle; - uint16_t cccd_handle; - uint16_t sccd_handle; -} bleio_characteristic_obj_t; +} bleio_characteristic_properties_t; + #endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_CHARACTERISTIC_H diff --git a/shared-module/bleio/Service.h b/shared-module/bleio/Service.h index ff506d3f3..828d4cdc8 100644 --- a/shared-module/bleio/Service.h +++ b/shared-module/bleio/Service.h @@ -28,14 +28,14 @@ #define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SERVICE_H #include "common-hal/bleio/UUID.h" -#include "shared-module/bleio/Device.h" typedef struct { mp_obj_base_t base; uint16_t handle; bool is_secondary; bleio_uuid_obj_t *uuid; - bleio_device_obj_t *device; + // May be a Peripheral, Central, etc. + mp_obj_t *device; mp_obj_t char_list; uint16_t start_handle; uint16_t end_handle; diff --git a/shared-module/bleio/__init__.h b/shared-module/bleio/__init__.h new file mode 100644 index 000000000..07d148594 --- /dev/null +++ b/shared-module/bleio/__init__.h @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_MODULE_BLEIO_INIT_H +#define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_INIT_H + +typedef enum { + GATT_ROLE_NONE, + GATT_ROLE_SERVER, + GATT_ROLE_CLIENT, +} gatt_role_t; + +extern void bleio_reset(void); + +#endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_INIT_H |
