diff options
| author | arturo182 <arturo182@tlen.pl> | 2018-07-17 11:44:55 +0200 |
|---|---|---|
| committer | arturo182 <arturo182@tlen.pl> | 2018-10-21 15:43:21 +0200 |
| commit | 345334aaf13dabbbb5fbfc1778fc34ed78907f42 (patch) | |
| tree | 1e9865d95dcd042a2de86f3075c932516c6aa5c6 /ports | |
| parent | d5f942a971f001d0a2fe4655f500beefe96dbd46 (diff) | |
bleio: Add a new Address class
Use the new in the Adapter singleton.
Diffstat (limited to 'ports')
| -rwxr-xr-x | ports/nrf/Makefile | 1 | ||||
| -rw-r--r-- | ports/nrf/common-hal/bleio/Adapter.c | 15 | ||||
| -rw-r--r-- | ports/nrf/modules/ubluepy/modubluepy.h | 2 | ||||
| -rw-r--r-- | ports/nrf/modules/ubluepy/ubluepy_constants.c | 3 |
4 files changed, 8 insertions, 13 deletions
diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index aebd87048..2de7f24bd 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -185,6 +185,7 @@ SRC_BINDINGS_ENUMS = \ ifneq ($(SD), ) SRC_BINDINGS_ENUMS += \ + bleio/Address.c \ bleio/AddressType.c \ bleio/UUIDType.c endif diff --git a/ports/nrf/common-hal/bleio/Adapter.c b/ports/nrf/common-hal/bleio/Adapter.c index 52069e305..f4c35ac69 100644 --- a/ports/nrf/common-hal/bleio/Adapter.c +++ b/ports/nrf/common-hal/bleio/Adapter.c @@ -26,11 +26,12 @@ */ #include <stdio.h> +#include <string.h> #include "ble_drv.h" #include "nrfx.h" #include "nrf_error.h" -#include "py/misc.h" +#include "shared-module/bleio/Address.h" void common_hal_bleio_adapter_set_enabled(bool enabled) { if (enabled) { @@ -49,12 +50,10 @@ bool common_hal_bleio_adapter_get_enabled(void) { return ble_drv_stack_enabled(); } -void common_hal_bleio_adapter_get_address(vstr_t *vstr) { - ble_drv_addr_t address; - ble_drv_address_get(&address); +void common_hal_bleio_adapter_get_address(bleio_address_obj_t *address) { + ble_drv_addr_t drv_addr; + ble_drv_address_get(&drv_addr); - vstr_printf(vstr, ""HEX2_FMT":"HEX2_FMT":"HEX2_FMT":" \ - HEX2_FMT":"HEX2_FMT":"HEX2_FMT"", - address.addr[5], address.addr[4], address.addr[3], - address.addr[2], address.addr[1], address.addr[0]); + address->type = drv_addr.addr_type; + memcpy(address->value, drv_addr.addr, BLEIO_ADDRESS_BYTES); } diff --git a/ports/nrf/modules/ubluepy/modubluepy.h b/ports/nrf/modules/ubluepy/modubluepy.h index 0ca491634..c5fd7b6f8 100644 --- a/ports/nrf/modules/ubluepy/modubluepy.h +++ b/ports/nrf/modules/ubluepy/modubluepy.h @@ -90,10 +90,8 @@ typedef enum { typedef enum { UBLUEPY_ADDR_TYPE_PUBLIC = 0, UBLUEPY_ADDR_TYPE_RANDOM_STATIC = 1, -#if 0 UBLUEPY_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE = 2, UBLUEPY_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE = 3, -#endif } ubluepy_addr_type_t; typedef enum { diff --git a/ports/nrf/modules/ubluepy/ubluepy_constants.c b/ports/nrf/modules/ubluepy/ubluepy_constants.c index 14e433e6e..e53a6f068 100644 --- a/ports/nrf/modules/ubluepy/ubluepy_constants.c +++ b/ports/nrf/modules/ubluepy/ubluepy_constants.c @@ -82,9 +82,6 @@ STATIC const mp_rom_map_elem_t ubluepy_constants_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_EVT_GATTS_WRITE), MP_ROM_INT(80) }, { MP_ROM_QSTR(MP_QSTR_UUID_CCCD), MP_ROM_INT(0x2902) }, - { MP_ROM_QSTR(MP_QSTR_ADDR_TYPE_PUBLIC), MP_ROM_INT(UBLUEPY_ADDR_TYPE_PUBLIC) }, - { MP_ROM_QSTR(MP_QSTR_ADDR_TYPE_RANDOM_STATIC), MP_ROM_INT(UBLUEPY_ADDR_TYPE_RANDOM_STATIC) }, - { MP_ROM_QSTR(MP_QSTR_ad_types), MP_ROM_PTR(&ubluepy_constants_ad_types_type) }, }; |
