summaryrefslogtreecommitdiff
path: root/ports/nrf
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2019-06-18 23:46:20 -0400
committerDan Halbert <halbert@halwitz.org>2019-06-18 23:46:20 -0400
commit35b919185747c42e183ccfc41f99fd370acca450 (patch)
tree5c1a383a99c53592c16daed8c61f84a4176d99f0 /ports/nrf
parent1356819de195810da09b5fc051ef5cc9dc21b2f4 (diff)
Don't operate directly on bleio objects in shared-bindings: use common_hal
routines instead. Changes made but not yet tested.
Diffstat (limited to 'ports/nrf')
-rw-r--r--ports/nrf/common-hal/bleio/Broadcaster.h6
-rw-r--r--ports/nrf/common-hal/bleio/Characteristic.c16
-rw-r--r--ports/nrf/common-hal/bleio/Characteristic.h8
-rw-r--r--ports/nrf/common-hal/bleio/CharacteristicBuffer.h6
-rw-r--r--ports/nrf/common-hal/bleio/Device.c14
-rw-r--r--ports/nrf/common-hal/bleio/Peripheral.c18
-rw-r--r--ports/nrf/common-hal/bleio/Peripheral.h12
-rw-r--r--ports/nrf/common-hal/bleio/Scanner.c12
-rw-r--r--ports/nrf/common-hal/bleio/Scanner.h40
-rw-r--r--ports/nrf/common-hal/bleio/Service.c36
-rw-r--r--ports/nrf/common-hal/bleio/Service.h44
-rw-r--r--ports/nrf/common-hal/bleio/__init__.h6
12 files changed, 185 insertions, 33 deletions
diff --git a/ports/nrf/common-hal/bleio/Broadcaster.h b/ports/nrf/common-hal/bleio/Broadcaster.h
index 72f93a443..2d1ae69a1 100644
--- a/ports/nrf/common-hal/bleio/Broadcaster.h
+++ b/ports/nrf/common-hal/bleio/Broadcaster.h
@@ -25,8 +25,8 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_COMMON_HAL_BLEIO_BROADCASTER_H
-#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_BROADCASTER_H
+#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_BROADCASTER_H
+#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_BROADCASTER_H
#include "ble.h"
@@ -44,4 +44,4 @@ typedef struct {
} bleio_broadcaster_obj_t;
-#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_BROADCASTER_H
+#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_BROADCASTER_H
diff --git a/ports/nrf/common-hal/bleio/Characteristic.c b/ports/nrf/common-hal/bleio/Characteristic.c
index 9409b73ce..45fb1d092 100644
--- a/ports/nrf/common-hal/bleio/Characteristic.c
+++ b/ports/nrf/common-hal/bleio/Characteristic.c
@@ -237,7 +237,11 @@ void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self,
}
-void common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self) {
+void common_hal_bleio_characteristic_set_service(bleio_characteristic_obj_t *self, bleio_service_obj_t *service) {
+ self->service = service;
+}
+
+mp_obj_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self) {
switch (common_hal_bleio_device_get_gatt_role(self->service->device)) {
case GATT_ROLE_CLIENT:
gattc_read(self);
@@ -251,6 +255,8 @@ void common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self)
mp_raise_RuntimeError(translate("bad GATT role"));
break;
}
+
+ return self->value_data;
}
void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo) {
@@ -285,3 +291,11 @@ void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self,
break;
}
}
+
+bleio_uuid_obj_t *common_hal_bleio_characteristic_get_uuid(bleio_characteristic_obj_t *self) {
+ return self->uuid;
+}
+
+bleio_characteristic_properties_t common_hal_bleio_characteristic_get_properties(bleio_characteristic_obj_t *self) {
+ return self->props;
+}
diff --git a/ports/nrf/common-hal/bleio/Characteristic.h b/ports/nrf/common-hal/bleio/Characteristic.h
index bce1eec1d..662485bad 100644
--- a/ports/nrf/common-hal/bleio/Characteristic.h
+++ b/ports/nrf/common-hal/bleio/Characteristic.h
@@ -24,11 +24,11 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTIC_H
-#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTIC_H
+#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTIC_H
+#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTIC_H
#include "shared-module/bleio/Characteristic.h"
-#include "shared-module/bleio/Service.h"
+#include "common-hal/bleio/Service.h"
#include "common-hal/bleio/UUID.h"
typedef struct {
@@ -43,4 +43,4 @@ typedef struct {
uint16_t sccd_handle;
} bleio_characteristic_obj_t;
-#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTIC_H
+#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTIC_H
diff --git a/ports/nrf/common-hal/bleio/CharacteristicBuffer.h b/ports/nrf/common-hal/bleio/CharacteristicBuffer.h
index b36f63fec..6a44229f7 100644
--- a/ports/nrf/common-hal/bleio/CharacteristicBuffer.h
+++ b/ports/nrf/common-hal/bleio/CharacteristicBuffer.h
@@ -24,8 +24,8 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H
-#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H
+#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H
+#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H
#include "nrf_soc.h"
@@ -40,4 +40,4 @@ typedef struct {
ringbuf_t ringbuf;
} bleio_characteristic_buffer_obj_t;
-#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H
+#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H
diff --git a/ports/nrf/common-hal/bleio/Device.c b/ports/nrf/common-hal/bleio/Device.c
index 5f625829e..b1ac72e75 100644
--- a/ports/nrf/common-hal/bleio/Device.c
+++ b/ports/nrf/common-hal/bleio/Device.c
@@ -323,7 +323,7 @@ STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *res
bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t);
service->base.type = &bleio_service_type;
service->device = device;
- service->char_list = mp_obj_new_list(0, NULL);
+ service->characteristic_list = mp_obj_new_list(0, NULL);
service->start_handle = gattc_service->handle_range.start_handle;
service->end_handle = gattc_service->handle_range.end_handle;
service->handle = gattc_service->handle_range.start_handle;
@@ -366,7 +366,7 @@ STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio
characteristic->handle = gattc_char->handle_value;
characteristic->service = m_char_discovery_service;
- mp_obj_list_append(m_char_discovery_service->char_list, MP_OBJ_FROM_PTR(characteristic));
+ mp_obj_list_append(m_char_discovery_service->characteristic_list, MP_OBJ_FROM_PTR(characteristic));
}
if (response->count > 0) {
@@ -491,9 +491,9 @@ void common_hal_bleio_device_add_service(bleio_device_obj_t *device, bleio_servi
mp_raise_OSError_msg(translate("Failed to add service"));
}
- const mp_obj_list_t *char_list = MP_OBJ_TO_PTR(service->char_list);
- for (size_t i = 0; i < char_list->len; ++i) {
- bleio_characteristic_obj_t *characteristic = char_list->items[i];
+ const mp_obj_list_t *characteristic_list = MP_OBJ_TO_PTR(service->characteristic_list);
+ for (size_t i = 0; i < characteristic_list->len; ++i) {
+ bleio_characteristic_obj_t *characteristic = characteristic_list->items[i];
common_hal_bleio_service_add_characteristic(service, characteristic);
}
}
@@ -583,8 +583,8 @@ void common_hal_bleio_device_connect(bleio_device_obj_t *device) {
bool found_char = discover_characteristics(device, service, service->start_handle);
while (found_char) {
- const mp_obj_list_t *char_list = MP_OBJ_TO_PTR(service->char_list);
- const bleio_characteristic_obj_t *characteristic = char_list->items[char_list->len - 1];
+ const mp_obj_list_t *characteristic_list = MP_OBJ_TO_PTR(service->characteristic_list);
+ const bleio_characteristic_obj_t *characteristic = characteristic_list->items[characteristic_list->len - 1];
const uint16_t next_handle = characteristic->handle + 1;
if (next_handle >= service->end_handle) {
diff --git a/ports/nrf/common-hal/bleio/Peripheral.c b/ports/nrf/common-hal/bleio/Peripheral.c
index e59676fde..36c20373d 100644
--- a/ports/nrf/common-hal/bleio/Peripheral.c
+++ b/ports/nrf/common-hal/bleio/Peripheral.c
@@ -33,6 +33,7 @@
#include "ble_hci.h"
#include "nrf_soc.h"
#include "py/gc.h"
+#include "py/objlist.h"
#include "py/objstr.h"
#include "py/runtime.h"
#include "shared-bindings/bleio/Adapter.h"
@@ -40,6 +41,7 @@
#include "shared-bindings/bleio/Peripheral.h"
#include "shared-bindings/bleio/Service.h"
#include "shared-bindings/bleio/UUID.h"
+#include "common-hal/bleio/Service.h"
#define BLE_MIN_CONN_INTERVAL MSEC_TO_UNITS(15, UNIT_0_625_MS)
#define BLE_MAX_CONN_INTERVAL MSEC_TO_UNITS(300, UNIT_0_625_MS)
@@ -117,19 +119,23 @@ STATIC void peripheral_on_ble_evt(ble_evt_t *ble_evt, void *self_in) {
}
}
-void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self) {
+void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self, mp_obj_list_t *service_list, mp_obj_t name) {
common_hal_bleio_adapter_set_enabled(true);
+ self->service_list = service_list;
+ self->name = name;
+
self->gatt_role = GATT_ROLE_SERVER;
self->conn_handle = BLE_CONN_HANDLE_INVALID;
self->adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET;
// Add all the services.
- mp_obj_list_t *service_list = MP_OBJ_TO_PTR(self->service_list);
for (size_t service_idx = 0; service_idx < service_list->len; ++service_idx) {
bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[service_idx]);
+ common_hal_bleio_service_set_device(service, MP_OBJ_FROM_PTR(self));
+
ble_uuid_t uuid;
bleio_uuid_convert_to_nrf_ble_uuid(service->uuid, &uuid);
@@ -149,10 +155,18 @@ void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self) {
}
+mp_obj_list_t *common_hal_bleio_peripheral_get_service_list(bleio_peripheral_obj_t *self) {
+ return self->service_list;
+}
+
bool common_hal_bleio_peripheral_get_connected(bleio_peripheral_obj_t *self) {
return self->conn_handle != BLE_CONN_HANDLE_INVALID;
}
+mp_obj_t common_hal_bleio_peripheral_get_name(bleio_peripheral_obj_t *self) {
+ return self->name;
+}
+
void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *self, bool connectable, mp_float_t interval, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo) {
// interval value has already been validated.
diff --git a/ports/nrf/common-hal/bleio/Peripheral.h b/ports/nrf/common-hal/bleio/Peripheral.h
index eb0b0417a..9103fcf94 100644
--- a/ports/nrf/common-hal/bleio/Peripheral.h
+++ b/ports/nrf/common-hal/bleio/Peripheral.h
@@ -25,13 +25,16 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_COMMON_HAL_BLEIO_PERIPHERAL_H
-#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_PERIPHERAL_H
+#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_PERIPHERAL_H
+#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_PERIPHERAL_H
#include <stdbool.h>
#include "ble.h"
+#include "py/obj.h"
+#include "py/objlist.h"
+
#include "shared-module/bleio/__init__.h"
#include "shared-module/bleio/Address.h"
@@ -40,8 +43,7 @@ typedef struct {
mp_obj_t name;
gatt_role_t gatt_role;
volatile uint16_t conn_handle;
- mp_obj_t service_list;
- mp_obj_t notif_handler;
+ mp_obj_list_t *service_list;
mp_obj_t conn_handler;
// The advertising data and scan response buffers are held by us, not by the SD, so we must
// maintain them and not change it. If we need to change the contents during advertising,
@@ -52,4 +54,4 @@ typedef struct {
} bleio_peripheral_obj_t;
-#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_PERIPHERAL_H
+#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_PERIPHERAL_H
diff --git a/ports/nrf/common-hal/bleio/Scanner.c b/ports/nrf/common-hal/bleio/Scanner.c
index 08600bc0a..64f7decad 100644
--- a/ports/nrf/common-hal/bleio/Scanner.c
+++ b/ports/nrf/common-hal/bleio/Scanner.c
@@ -30,6 +30,7 @@
#include "ble_drv.h"
#include "ble_gap.h"
#include "py/mphal.h"
+#include "py/objlist.h"
#include "py/runtime.h"
#include "shared-bindings/bleio/Adapter.h"
#include "shared-bindings/bleio/ScanEntry.h"
@@ -68,6 +69,10 @@ STATIC void on_ble_evt(ble_evt_t *ble_evt, void *scanner_in) {
}
}
+void common_hal_bleio_scanner_construct(bleio_scanner_obj_t *self) {
+ self->adv_reports = mp_obj_new_list(0, NULL);
+}
+
void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout, mp_float_t interval, mp_float_t window) {
common_hal_bleio_adapter_set_enabled(true);
ble_drv_add_event_handler(on_ble_evt, self);
@@ -78,7 +83,8 @@ void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout
.scan_phys = BLE_GAP_PHY_1MBPS,
};
- common_hal_bleio_adapter_set_enabled(true);
+ // Empty the advertising reports list.
+ mp_obj_list_clear(self->adv_reports);
uint32_t err_code;
err_code = sd_ble_gap_scan_start(&scan_params, &m_scan_buffer);
@@ -90,3 +96,7 @@ void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout
mp_hal_delay_ms(timeout * 1000);
sd_ble_gap_scan_stop();
}
+
+mp_obj_t common_hal_bleio_scanner_get_adv_reports(bleio_scanner_obj_t *self) {
+ return self->adv_reports;
+}
diff --git a/ports/nrf/common-hal/bleio/Scanner.h b/ports/nrf/common-hal/bleio/Scanner.h
new file mode 100644
index 000000000..a71066487
--- /dev/null
+++ b/ports/nrf/common-hal/bleio/Scanner.h
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
+ * Copyright (c) 2018 Artur Pacholec
+ *
+ * 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_NRF_COMMON_HAL_BLEIO_SCANNER_H
+#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_SCANNER_H
+
+#include "py/obj.h"
+
+typedef struct {
+ mp_obj_base_t base;
+ mp_obj_t adv_reports; // List of reports.
+ uint16_t interval;
+ uint16_t window;
+} bleio_scanner_obj_t;
+
+#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_SCANNER_H
diff --git a/ports/nrf/common-hal/bleio/Service.c b/ports/nrf/common-hal/bleio/Service.c
index 26a1f1cff..77d3f0259 100644
--- a/ports/nrf/common-hal/bleio/Service.c
+++ b/ports/nrf/common-hal/bleio/Service.c
@@ -29,18 +29,46 @@
#include "py/runtime.h"
#include "common-hal/bleio/__init__.h"
#include "common-hal/bleio/Characteristic.h"
+#include "shared-bindings/bleio/Characteristic.h"
#include "shared-bindings/bleio/Service.h"
#include "shared-bindings/bleio/Adapter.h"
-void common_hal_bleio_service_construct(bleio_service_obj_t *self) {
+void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, mp_obj_list_t *characteristic_list, bool is_secondary) {
+ self->device = mp_const_none;
+ self->handle = 0xFFFF;
+ self->uuid = uuid;
+ self->characteristic_list = characteristic_list;
+ self->is_secondary = is_secondary;
+
+ for (size_t characteristic_idx = 0; characteristic_idx < characteristic_list->len; ++characteristic_idx) {
+ bleio_characteristic_obj_t *characteristic = MP_OBJ_TO_PTR(characteristic_list->items[characteristic_idx]);
+ common_hal_bleio_characteristic_set_service(characteristic, self);
+ }
+
+}
+
+bleio_uuid_obj_t *common_hal_bleio_service_get_uuid(bleio_service_obj_t *self) {
+ return self->uuid;
+}
+
+mp_obj_list_t *common_hal_bleio_service_get_characteristic_list(bleio_service_obj_t *self) {
+ return self->characteristic_list;
+}
+
+bool common_hal_bleio_service_get_is_secondary(bleio_service_obj_t *self) {
+ return self->is_secondary;
+}
+
+void common_hal_bleio_service_set_device(bleio_service_obj_t *self, mp_obj_t device) {
+ self->device = device;
}
// Call this after the Service has been added to the Peripheral.
void common_hal_bleio_service_add_all_characteristics(bleio_service_obj_t *self) {
// Add all the characteristics.
- const mp_obj_list_t *char_list = MP_OBJ_TO_PTR(self->char_list);
- for (size_t char_idx = 0; char_idx < char_list->len; ++char_idx) {
- bleio_characteristic_obj_t *characteristic = char_list->items[char_idx];
+ const mp_obj_list_t *characteristic_list = MP_OBJ_TO_PTR(self->characteristic_list);
+ for (size_t characteristic_idx = 0; characteristic_idx < characteristic_list->len; ++characteristic_idx) {
+ bleio_characteristic_obj_t *characteristic = characteristic_list->items[characteristic_idx];
ble_gatts_char_md_t char_md = {
.char_props.broadcast = characteristic->props.broadcast,
diff --git a/ports/nrf/common-hal/bleio/Service.h b/ports/nrf/common-hal/bleio/Service.h
new file mode 100644
index 000000000..7998cc862
--- /dev/null
+++ b/ports/nrf/common-hal/bleio/Service.h
@@ -0,0 +1,44 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 Artur Pacholec
+ *
+ * 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_NRF_COMMON_HAL_BLEIO_SERVICE_H
+#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_SERVICE_H
+
+#include "common-hal/bleio/UUID.h"
+
+typedef struct {
+ mp_obj_base_t base;
+ uint16_t handle;
+ bool is_secondary;
+ bleio_uuid_obj_t *uuid;
+ // May be a Peripheral, Central, etc.
+ mp_obj_t *device;
+ mp_obj_t characteristic_list;
+ uint16_t start_handle;
+ uint16_t end_handle;
+} bleio_service_obj_t;
+
+#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_SERVICE_H
diff --git a/ports/nrf/common-hal/bleio/__init__.h b/ports/nrf/common-hal/bleio/__init__.h
index 9e044f37c..0c46b631f 100644
--- a/ports/nrf/common-hal/bleio/__init__.h
+++ b/ports/nrf/common-hal/bleio/__init__.h
@@ -24,8 +24,8 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_COMMON_HAL_BLEIO_INIT_H
-#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_INIT_H
+#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_INIT_H
+#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_INIT_H
#include "shared-bindings/bleio/__init__.h"
#include "shared-bindings/bleio/Adapter.h"
@@ -39,4 +39,4 @@
gatt_role_t common_hal_bleio_device_get_gatt_role(mp_obj_t device);
uint16_t common_hal_bleio_device_get_conn_handle(mp_obj_t device);
-#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_INIT_H
+#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_INIT_H