diff --git a/epicardium/ble/epic_ble_api.c b/epicardium/ble/epic_ble_api.c index bc50a72b6660bf69cfb7255ff059665c203507cc..cf27adc0f237f650c3acabeaa38e4aab6df53f34 100644 --- a/epicardium/ble/epic_ble_api.c +++ b/epicardium/ble/epic_ble_api.c @@ -158,3 +158,9 @@ int epic_ble_advertise( } return 0; } + +int epic_ble_advertise_stop(void) +{ + ble_adv_stop(); + return 0; +} diff --git a/epicardium/epicardium.h b/epicardium/epicardium.h index 62d7d01e6cb1d4acaa0e6eb5261e81e4f948d7c3..75901978e91b0c8104bd4d70a3c4c21f5669a585 100644 --- a/epicardium/epicardium.h +++ b/epicardium/epicardium.h @@ -181,6 +181,7 @@ typedef _Bool bool; #define API_BLE_GET_DEVICE_NAME 0x183 #define API_BLE_GET_ADDRESS 0x184 #define API_BLE_ADVERTISE 0x185 +#define API_BLE_ADVERTISE_STOP 0x186 /* clang-format on */ @@ -2663,6 +2664,7 @@ API(API_BLE_GET_DEVICE_NAME, int epic_ble_get_device_name(uint8_t **buf, uint16_ API(API_BLE_GET_ADDRESS, void epic_ble_get_address(uint8_t *addr)); API(API_BLE_ADVERTISE, int epic_ble_advertise(int interval_us, const uint8_t *adv_data, size_t adv_data_len, const uint8_t *sr_data, size_t sr_data_len, bool connectable)); +API(API_BLE_ADVERTISE_STOP, int epic_ble_advertise_stop(void)); #endif /* _EPICARDIUM_H */ diff --git a/pycardium/modules/modbluetooth_card10.c b/pycardium/modules/modbluetooth_card10.c index 3c3bbdbc833cac533b1df52c477fb7034a756b5f..4a659f93d42fa430af82e18d5ed8bc2c7b08248d 100644 --- a/pycardium/modules/modbluetooth_card10.c +++ b/pycardium/modules/modbluetooth_card10.c @@ -12,9 +12,6 @@ enum notification_status { NOTIFICATION_STATUS_OVERFLOW }; -const char *const not_implemented_message = - "Not (yet) implemented on card10. See https://git.card10.badge.events.ccc.de/card10/firmware/-/issues/8"; - typedef struct _mp_bluetooth_card10_root_pointers_t { // Characteristic (and descriptor) value storage. mp_gatts_db_t gatts_db; @@ -54,11 +51,6 @@ gatts_status_lookup(mp_gatts_db_t db, uint16_t handle) return MP_OBJ_TO_PTR(elem->value); } -static void raise(void) -{ - mp_raise_NotImplementedError(not_implemented_message); -} - static void clear_events(void) { struct epic_ble_event ble_event; @@ -238,7 +230,7 @@ int mp_bluetooth_gap_advertise_start( // Stop advertisement. No-op when already stopped. void mp_bluetooth_gap_advertise_stop(void) { - raise(); + epic_ble_advertise_stop(); } // Start adding services. Must be called before mp_bluetooth_register_service. @@ -506,6 +498,14 @@ int mp_bluetooth_gap_disconnect(uint16_t conn_handle) } #if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE +const char *const not_implemented_message = + "Not (yet) implemented on card10. See https://git.card10.badge.events.ccc.de/card10/firmware/-/issues/8"; + +static void raise(void) +{ + mp_raise_NotImplementedError(not_implemented_message); +} + // Start a discovery (scan). Set duration to zero to run continuously. int mp_bluetooth_gap_scan_start( int32_t duration_ms, int32_t interval_us, int32_t window_us