diff options
| author | Scott Shawcroft <scott@adafruit.com> | 2019-08-29 21:48:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-29 21:48:31 -0700 |
| commit | b954b2f5df08a2674726fe70023adbe743280426 (patch) | |
| tree | dbf77764a909b6b36c40f1a66daa3ef323ab9593 /py | |
| parent | 2b5ce666be90de7738ed434ba1dde13f67fc30de (diff) | |
| parent | 318d704887cba04587657c75a8fa9862e22e41aa (diff) | |
Merge pull request #2092 from dhalbert/bleio-api-revamp5.0.0-alpha.1
Bleio attribute api revamp
Diffstat (limited to 'py')
| -rw-r--r-- | py/circuitpy_defns.mk | 36 | ||||
| -rw-r--r-- | py/circuitpy_mpconfig.h | 2 | ||||
| -rw-r--r-- | py/circuitpy_mpconfig.mk | 2 | ||||
| -rw-r--r-- | py/obj.h | 1 | ||||
| -rw-r--r-- | py/objstr.c | 8 |
5 files changed, 29 insertions, 20 deletions
diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 3f593416e..b17c312f7 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -122,7 +122,7 @@ ifeq ($(CIRCUITPY_BITBANG_APA102),1) SRC_PATTERNS += bitbangio/SPI% endif ifeq ($(CIRCUITPY_BLEIO),1) -SRC_PATTERNS += bleio/% +SRC_PATTERNS += _bleio/% endif ifeq ($(CIRCUITPY_BOARD),1) SRC_PATTERNS += board/% @@ -223,6 +223,17 @@ endif # All possible sources are listed here, and are filtered by SRC_PATTERNS in SRC_COMMON_HAL SRC_COMMON_HAL_ALL = \ + _bleio/__init__.c \ + _bleio/Adapter.c \ + _bleio/Attribute.c \ + _bleio/Central.c \ + _bleio/Characteristic.c \ + _bleio/CharacteristicBuffer.c \ + _bleio/Descriptor.c \ + _bleio/Peripheral.c \ + _bleio/Scanner.c \ + _bleio/Service.c \ + _bleio/UUID.c \ analogio/AnalogIn.c \ analogio/AnalogOut.c \ analogio/__init__.c \ @@ -233,17 +244,6 @@ SRC_COMMON_HAL_ALL = \ audiopwmio/PWMAudioOut.c \ audioio/__init__.c \ audioio/AudioOut.c \ - bleio/__init__.c \ - bleio/Adapter.c \ - bleio/Attribute.c \ - bleio/Central.c \ - bleio/Characteristic.c \ - bleio/CharacteristicBuffer.c \ - bleio/Descriptor.c \ - bleio/Peripheral.c \ - bleio/Scanner.c \ - bleio/Service.c \ - bleio/UUID.c \ board/__init__.c \ busio/I2C.c \ busio/SPI.c \ @@ -284,9 +284,9 @@ SRC_COMMON_HAL = $(filter $(SRC_PATTERNS), $(SRC_COMMON_HAL_ALL)) # All possible sources are listed here, and are filtered by SRC_PATTERNS. SRC_BINDINGS_ENUMS = \ $(filter $(SRC_PATTERNS), \ - bleio/Address.c \ - bleio/Attribute.c \ - bleio/ScanEntry.c \ + _bleio/Address.c \ + _bleio/Attribute.c \ + _bleio/ScanEntry.c \ digitalio/Direction.c \ digitalio/DriveMode.c \ digitalio/Pull.c \ @@ -301,6 +301,9 @@ SRC_BINDINGS_ENUMS += \ util.c SRC_SHARED_MODULE_ALL = \ + _bleio/Address.c \ + _bleio/Attribute.c \ + _bleio/ScanEntry.c \ _pixelbuf/PixelBuf.c \ _pixelbuf/__init__.c \ _stage/Layer.c \ @@ -317,9 +320,6 @@ SRC_SHARED_MODULE_ALL = \ bitbangio/SPI.c \ bitbangio/__init__.c \ board/__init__.c \ - bleio/Address.c \ - bleio/Attribute.c \ - bleio/ScanEntry.c \ busio/OneWire.c \ displayio/Bitmap.c \ displayio/ColorConverter.c \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index c2e2e2d02..5ac66665a 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -259,7 +259,7 @@ extern const struct _mp_obj_module_t bitbangio_module; #endif #if CIRCUITPY_BLEIO -#define BLEIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_bleio), (mp_obj_t)&bleio_module }, +#define BLEIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR__bleio), (mp_obj_t)&bleio_module }, extern const struct _mp_obj_module_t bleio_module; #else #define BLEIO_MODULE diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 356a8f95d..1af71a416 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -99,7 +99,7 @@ CIRCUITPY_BITBANGIO = $(CIRCUITPY_FULL_BUILD) endif CFLAGS += -DCIRCUITPY_BITBANGIO=$(CIRCUITPY_BITBANGIO) -# Explicitly enabled for boards that support bleio. +# Explicitly enabled for boards that support _bleio. ifndef CIRCUITPY_BLEIO CIRCUITPY_BLEIO = 0 endif @@ -647,6 +647,7 @@ mp_obj_t mp_obj_new_str(const char* data, size_t len); mp_obj_t mp_obj_new_str_via_qstr(const char* data, size_t len); mp_obj_t mp_obj_new_str_from_vstr(const mp_obj_type_t *type, vstr_t *vstr); mp_obj_t mp_obj_new_bytes(const byte* data, size_t len); +mp_obj_t mp_obj_new_bytes_of_zeros(size_t len); mp_obj_t mp_obj_new_bytearray(size_t n, void *items); mp_obj_t mp_obj_new_bytearray_of_zeros(size_t n); mp_obj_t mp_obj_new_bytearray_by_ref(size_t n, void *items); diff --git a/py/objstr.c b/py/objstr.c index afe11f00f..6ef9a15b5 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -2094,6 +2094,14 @@ mp_obj_t mp_obj_new_bytes(const byte* data, size_t len) { return mp_obj_new_str_copy(&mp_type_bytes, data, len); } +mp_obj_t mp_obj_new_bytes_of_zeros(size_t len) { + vstr_t vstr; + vstr_init_len(&vstr, len); + memset(vstr.buf, 0, len); + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} + + bool mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2) { if (MP_OBJ_IS_QSTR(s1) && MP_OBJ_IS_QSTR(s2)) { return s1 == s2; |
