From 5f00e49eab2104261ab7c60fa30ac8d181d364e2 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Thu, 29 May 2025 15:19:48 +0200 Subject: [PATCH] Wrap various bluetooth service API with extern "C" Make service API usable in C++ code without the need of explicit include statements wrapping. --- .../host/services/ans/include/services/ans/ble_svc_ans.h | 7 +++++++ .../host/services/bas/include/services/bas/ble_svc_bas.h | 8 ++++++++ .../host/services/cte/include/services/cte/ble_svc_cte.h | 7 +++++++ .../host/services/cts/include/services/cts/ble_svc_cts.h | 8 ++++++++ .../host/services/dis/include/services/dis/ble_svc_dis.h | 8 ++++++++ .../host/services/hid/include/services/hid/ble_svc_hid.h | 8 ++++++++ nimble/host/services/hr/include/services/hr/ble_svc_hr.h | 8 ++++++++ .../host/services/htp/include/services/htp/ble_svc_htp.h | 8 ++++++++ .../host/services/ias/include/services/ias/ble_svc_ias.h | 7 +++++++ .../services/prox/include/services/prox/ble_svc_prox.h | 8 ++++++++ .../host/services/sps/include/services/sps/ble_svc_sps.h | 8 ++++++++ .../host/services/tps/include/services/tps/ble_svc_tps.h | 7 +++++++ 12 files changed, 92 insertions(+) diff --git a/nimble/host/services/ans/include/services/ans/ble_svc_ans.h b/nimble/host/services/ans/include/services/ans/ble_svc_ans.h index 435e9e11c2..1a5ce0a45b 100644 --- a/nimble/host/services/ans/include/services/ans/ble_svc_ans.h +++ b/nimble/host/services/ans/include/services/ans/ble_svc_ans.h @@ -20,6 +20,10 @@ #ifndef H_BLE_SVC_ANS_ #define H_BLE_SVC_ANS_ +#ifdef __cplusplus +extern "C" { +#endif + struct ble_hs_cfg; /* 16 Bit Alert Notification Service UUID */ @@ -81,5 +85,8 @@ int ble_svc_ans_unr_alert_add(uint8_t cat_id); void ble_svc_ans_init(void); +#ifdef __cplusplus +} #endif +#endif diff --git a/nimble/host/services/bas/include/services/bas/ble_svc_bas.h b/nimble/host/services/bas/include/services/bas/ble_svc_bas.h index 24b9a26c13..88675b4093 100644 --- a/nimble/host/services/bas/include/services/bas/ble_svc_bas.h +++ b/nimble/host/services/bas/include/services/bas/ble_svc_bas.h @@ -20,6 +20,10 @@ #ifndef H_BLE_SVC_BAS_ #define H_BLE_SVC_BAS_ +#ifdef __cplusplus +extern "C" { +#endif + /* 16 Bit Battery Service UUID */ #define BLE_SVC_BAS_UUID16 0x180F @@ -30,4 +34,8 @@ int ble_svc_bas_battery_level_set(uint8_t level); void ble_svc_bas_init(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/nimble/host/services/cte/include/services/cte/ble_svc_cte.h b/nimble/host/services/cte/include/services/cte/ble_svc_cte.h index 9118c6c8f9..b32e650e0c 100644 --- a/nimble/host/services/cte/include/services/cte/ble_svc_cte.h +++ b/nimble/host/services/cte/include/services/cte/ble_svc_cte.h @@ -20,6 +20,10 @@ #ifndef H_BLE_SVC_CTE_ #define H_BLE_SVC_CTE_ +#ifdef __cplusplus +extern "C" { +#endif + struct ble_hs_cfg; #define BLE_SVC_CTE_UUID16 0x184A @@ -33,5 +37,8 @@ struct ble_hs_cfg; void ble_svc_cte_init(void); +#ifdef __cplusplus +} #endif +#endif diff --git a/nimble/host/services/cts/include/services/cts/ble_svc_cts.h b/nimble/host/services/cts/include/services/cts/ble_svc_cts.h index cf62f912d9..57df3ecc69 100644 --- a/nimble/host/services/cts/include/services/cts/ble_svc_cts.h +++ b/nimble/host/services/cts/include/services/cts/ble_svc_cts.h @@ -20,6 +20,10 @@ #ifndef H_BLE_SVC_CTS_ #define H_BLE_SVC_CTS_ +#ifdef __cplusplus +extern "C" { +#endif + #define BLE_SVC_CTS_ERR_DATA_FIELD_IGNORED 0x80 /* 16 Bit Current Time Service UUID */ #define BLE_SVC_CTS_UUID16 0x1805 @@ -157,4 +161,8 @@ ble_svc_cts_init(struct ble_svc_cts_cfg cfg); void ble_svc_cts_time_updated(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/nimble/host/services/dis/include/services/dis/ble_svc_dis.h b/nimble/host/services/dis/include/services/dis/ble_svc_dis.h index b4fa3bced1..749c439f10 100644 --- a/nimble/host/services/dis/include/services/dis/ble_svc_dis.h +++ b/nimble/host/services/dis/include/services/dis/ble_svc_dis.h @@ -20,6 +20,10 @@ #ifndef H_BLE_SVC_DIS_ #define H_BLE_SVC_DIS_ +#ifdef __cplusplus +extern "C" { +#endif + /** * Example: * @@ -145,4 +149,8 @@ int ble_svc_dis_system_id_set(const char *value); int ble_svc_dis_pnp_id_set(const char *value); const char *ble_svc_dis_pnp_id(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/nimble/host/services/hid/include/services/hid/ble_svc_hid.h b/nimble/host/services/hid/include/services/hid/ble_svc_hid.h index 1916695bcf..50c6e5322d 100644 --- a/nimble/host/services/hid/include/services/hid/ble_svc_hid.h +++ b/nimble/host/services/hid/include/services/hid/ble_svc_hid.h @@ -21,6 +21,10 @@ #ifndef H_BLE_SVC_HID_ #define H_BLE_SVC_HID_ +#ifdef __cplusplus +extern "C" { +#endif + /* 16 Bit Battery Service UUID */ #define BLE_SVC_HID_UUID16 0x1812 @@ -110,5 +114,9 @@ void ble_svc_hid_init(void); int ble_svc_hid_add(struct ble_svc_hid_params params); void ble_svc_hid_reset(void); +#ifdef __cplusplus +} +#endif + #endif #endif // CONFIG_BT_NIMBLE_HID_SERVICE diff --git a/nimble/host/services/hr/include/services/hr/ble_svc_hr.h b/nimble/host/services/hr/include/services/hr/ble_svc_hr.h index 9ed8b21f5e..2f8eaa50ef 100644 --- a/nimble/host/services/hr/include/services/hr/ble_svc_hr.h +++ b/nimble/host/services/hr/include/services/hr/ble_svc_hr.h @@ -7,6 +7,10 @@ #ifndef H_BLE_SVC_HR_ #define H_BLE_SVC_HR_ +#ifdef __cplusplus +extern "C" { +#endif + struct ble_hs_cfg; /* 16 Bit Heart Rate Service UUID */ @@ -26,4 +30,8 @@ void ble_svc_hr_on_gap_disconnect(uint16_t conn_handle); void ble_svc_hr_init(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/nimble/host/services/htp/include/services/htp/ble_svc_htp.h b/nimble/host/services/htp/include/services/htp/ble_svc_htp.h index 9b7fbac9d2..97c40451fd 100644 --- a/nimble/host/services/htp/include/services/htp/ble_svc_htp.h +++ b/nimble/host/services/htp/include/services/htp/ble_svc_htp.h @@ -7,6 +7,10 @@ #ifndef H_BLE_SVC_HTP_ #define H_BLE_SVC_HTP_ +#ifdef __cplusplus +extern "C" { +#endif + struct ble_hs_cfg; /* 16 Bit Health Thermometer Service UUID */ @@ -47,4 +51,8 @@ int ble_svc_htp_notify(uint16_t conn_handle, float temp, bool temp_unit); void ble_svc_htp_init(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/nimble/host/services/ias/include/services/ias/ble_svc_ias.h b/nimble/host/services/ias/include/services/ias/ble_svc_ias.h index 26c18d01f1..3bce343b52 100644 --- a/nimble/host/services/ias/include/services/ias/ble_svc_ias.h +++ b/nimble/host/services/ias/include/services/ias/ble_svc_ias.h @@ -20,6 +20,10 @@ #ifndef H_BLE_IAS_TPS_ #define H_BLE_IAS_TPS_ +#ifdef __cplusplus +extern "C" { +#endif + #define BLE_SVC_IAS_UUID16 0x1802 #define BLE_SVC_IAS_CHR_UUID16_ALERT_LEVEL 0x2a06 @@ -33,6 +37,9 @@ typedef int ble_svc_ias_event_fn(uint8_t alert_level); void ble_svc_ias_set_cb(ble_svc_ias_event_fn *cb); void ble_svc_ias_init(void); +#ifdef __cplusplus +} #endif +#endif diff --git a/nimble/host/services/prox/include/services/prox/ble_svc_prox.h b/nimble/host/services/prox/include/services/prox/ble_svc_prox.h index b34fbb951e..8b1e4c62a4 100644 --- a/nimble/host/services/prox/include/services/prox/ble_svc_prox.h +++ b/nimble/host/services/prox/include/services/prox/ble_svc_prox.h @@ -7,6 +7,10 @@ #ifndef H_BLE_SVC_PROX_ #define H_BLE_SVC_PROX_ +#ifdef __cplusplus +extern "C" { +#endif + struct ble_hs_cfg; /* 16 Bit Proximity Sensor Service UUID */ @@ -29,4 +33,8 @@ struct ble_hs_cfg; */ void ble_svc_prox_init(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/nimble/host/services/sps/include/services/sps/ble_svc_sps.h b/nimble/host/services/sps/include/services/sps/ble_svc_sps.h index 0ff9580f74..5daa96ef45 100644 --- a/nimble/host/services/sps/include/services/sps/ble_svc_sps.h +++ b/nimble/host/services/sps/include/services/sps/ble_svc_sps.h @@ -22,6 +22,9 @@ #ifndef H_BLE_SVC_SPS_ #define H_BLE_SVC_SPS_ +#ifdef __cplusplus +extern "C" { +#endif #define BLE_SVC_SPS_UUID16 0x1813 #define BLE_SVC_SPS_CHR_UUID16_SCAN_ITVL_WINDOW 0x2A4F @@ -32,4 +35,9 @@ typedef int ble_svc_sps_event_fn(uint16_t scan_interval, uint16_t scan_window); void ble_svc_sps_scan_refresh(void); void ble_svc_sps_init(uint16_t scan_itvl, uint16_t scan_window); void ble_svc_sps_set_cb(ble_svc_sps_event_fn *cb); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/nimble/host/services/tps/include/services/tps/ble_svc_tps.h b/nimble/host/services/tps/include/services/tps/ble_svc_tps.h index ec4cd790a0..446cc37c48 100644 --- a/nimble/host/services/tps/include/services/tps/ble_svc_tps.h +++ b/nimble/host/services/tps/include/services/tps/ble_svc_tps.h @@ -20,6 +20,10 @@ #ifndef H_BLE_SVC_TPS_ #define H_BLE_SVC_TPS_ +#ifdef __cplusplus +extern "C" { +#endif + struct ble_hs_cfg; #define BLE_SVC_TPS_UUID16 0x1804 @@ -27,5 +31,8 @@ struct ble_hs_cfg; void ble_svc_tps_init(void); +#ifdef __cplusplus +} #endif +#endif