summaryrefslogtreecommitdiff
path: root/shared-module
diff options
context:
space:
mode:
Diffstat (limited to 'shared-module')
-rw-r--r--shared-module/bleio/Address.c8
-rw-r--r--shared-module/bleio/Address.h2
-rw-r--r--shared-module/bleio/ScanEntry.c8
-rw-r--r--shared-module/bleio/ScanEntry.h2
4 files changed, 8 insertions, 12 deletions
diff --git a/shared-module/bleio/Address.c b/shared-module/bleio/Address.c
index e26bbe2ac..6bc458b7c 100644
--- a/shared-module/bleio/Address.c
+++ b/shared-module/bleio/Address.c
@@ -27,17 +27,17 @@
#include <string.h>
-#include "py/objproperty.h"
+#include "py/objstr.h"
#include "shared-bindings/bleio/Address.h"
#include "shared-module/bleio/Address.h"
-void common_hal_bleio_address_construct(bleio_address_obj_t *self, uint8_t *bytes, size_t bytes_length, uint8_t address_type) {
- memcpy(self->bytes, bytes, bytes_length);
+void common_hal_bleio_address_construct(bleio_address_obj_t *self, uint8_t *bytes, uint8_t address_type) {
+ self->bytes = mp_obj_new_bytes(bytes, NUM_BLEIO_ADDRESS_BYTES);
self->type = address_type;
}
mp_obj_t common_hal_bleio_address_get_address_bytes(bleio_address_obj_t *self) {
- return mp_obj_new_bytes(self->bytes, NUM_BLEIO_ADDRESS_BYTES);
+ return self->bytes;
}
uint8_t common_hal_bleio_address_get_type(bleio_address_obj_t *self) {
diff --git a/shared-module/bleio/Address.h b/shared-module/bleio/Address.h
index eb1aab258..39789842f 100644
--- a/shared-module/bleio/Address.h
+++ b/shared-module/bleio/Address.h
@@ -35,7 +35,7 @@
typedef struct {
mp_obj_base_t base;
uint8_t type;
- uint8_t bytes[NUM_BLEIO_ADDRESS_BYTES];
+ mp_obj_t bytes; // a bytes() object
} bleio_address_obj_t;
#endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_ADDRESS_H
diff --git a/shared-module/bleio/ScanEntry.c b/shared-module/bleio/ScanEntry.c
index 44b50a4ce..306ac33c5 100644
--- a/shared-module/bleio/ScanEntry.c
+++ b/shared-module/bleio/ScanEntry.c
@@ -33,14 +33,10 @@
#include "shared-module/bleio/ScanEntry.h"
mp_obj_t common_hal_bleio_scanentry_get_address(bleio_scanentry_obj_t *self) {
- bleio_address_obj_t *address = m_new_obj(bleio_address_obj_t);
- address->base.type = &bleio_address_type;
- memcpy(address->bytes, self->address.bytes, NUM_BLEIO_ADDRESS_BYTES);
- address->type = self->address.type;
- return MP_OBJ_TO_PTR(address);
+ return MP_OBJ_FROM_PTR(self->address);
}
-mp_obj_t common_hal_bleio_scanentry_get_raw_data(bleio_scanentry_obj_t *self) {
+mp_obj_t common_hal_bleio_scanentry_get_advertisement_bytes(bleio_scanentry_obj_t *self) {
return self->data;
}
diff --git a/shared-module/bleio/ScanEntry.h b/shared-module/bleio/ScanEntry.h
index 4e7028ba2..b302460e6 100644
--- a/shared-module/bleio/ScanEntry.h
+++ b/shared-module/bleio/ScanEntry.h
@@ -35,7 +35,7 @@ typedef struct {
mp_obj_base_t base;
bool connectable;
int8_t rssi;
- bleio_address_obj_t address;
+ bleio_address_obj_t *address;
mp_obj_t data;
} bleio_scanentry_obj_t;