return PlatformResult{ErrorCode::INVALID_STATE_ERR};
}
- auto ret = bt_gatt_server_foreach_services(handle_, DestroyService, nullptr);
+ auto ret = bt_gatt_server_foreach_services(handle_, BluetoothGATTServerService::DestroyService, nullptr);
if (BT_ERROR_NONE != ret) {
LoggerE("bt_gatt_server_unregister_all_services(): %d (%s)", ret, get_error_message(ret));
return BluetoothErrorToPlatformResult(ret);
*/
}
-bool BluetoothGATTServer::DestroyService(int total, int index, bt_gatt_h handle, void* user_data) {
- ScopeLogger("total: %d, index: %d, handle: %p", total, index, handle);
-
- auto ret = bt_gatt_service_foreach_included_services(handle, DestroyService, nullptr);
- if (BT_ERROR_NONE != ret) {
- LoggerE("bt_gatt_service_foreach_included_servics(): %d (%s)", ret, get_error_message(ret));
- }
- LoggerD("bt_gatt_service_foreach_included_servics(): success");
-
- ret = bt_gatt_service_foreach_characteristics(handle, DestroyCharacteristic, nullptr);
- if (BT_ERROR_NONE != ret) {
- LoggerE("bt_gatt_service_foreach_characteristics(): %d (%s)", ret, get_error_message(ret));
- }
- LoggerD("bt_gatt_service_foreach_characteristics(): success");
-
- ret = bt_gatt_service_destroy(handle);
- if (BT_ERROR_NONE != ret) {
- LoggerE("bt_gatt_service_destroy(): %d (%s)", ret, get_error_message(ret));
- }
-
- return true;
-}
-
-bool BluetoothGATTServer::DestroyCharacteristic(int total, int index, bt_gatt_h handle,
- void* user_data) {
- ScopeLogger("total: %d, index: %d, handle: %p", total, index, handle);
-
- auto ret = bt_gatt_characteristic_foreach_descriptors(handle, DestroyDescriptor, nullptr);
- if (BT_ERROR_NONE != ret) {
- LoggerE("bt_gatt_characteristic_foreach_descriptors(): %d (%s)", ret, get_error_message(ret));
- }
- LoggerD("bt_gatt_characteristic_foreach_descriptors(): success");
-
- ret = bt_gatt_characteristic_destroy(handle);
- if (BT_ERROR_NONE != ret) {
- LoggerE("bt_gatt_characteristic_destroy(): %d (%s)", ret, get_error_message(ret));
- }
-
- return true;
-}
-
-bool BluetoothGATTServer::DestroyDescriptor(int total, int index, bt_gatt_h handle,
- void* user_data) {
- ScopeLogger("total: %d, index: %d, handle: %p", total, index, handle);
-
- auto ret = bt_gatt_descriptor_destroy(handle);
- if (BT_ERROR_NONE != ret) {
- LoggerE("bt_gatt_descriptor_destroy(): %d (%s)", ret, get_error_message(ret));
- }
- return true;
-}
-
void BluetoothGATTServer::PowerStateChangeCb(bool state) {
ScopeLogger();
picojson::value result{picojson::object{}};
PlatformResult SendResponse(const picojson::value& args);
PlatformResult NotifyAboutValueChange(const picojson::value& args);
+ static bool DestroyService(int total, int index, bt_gatt_h handle, void* user_data);
+ static bool DestroyCharacteristic(int total, int index, bt_gatt_h handle, void* user_data);
+ static bool DestroyDescriptor(int total, int index, bt_gatt_h handle, void* user_data);
+
private:
BluetoothInstance& instance_;
std::map<int, bt_gatt_h> gatt_objects_;
std::map<std::pair<bt_gatt_h, std::string>, std::string>& callback_names_map_;
} rw_request_callback_data_;
- static bool DestroyService(int total, int index, bt_gatt_h handle, void* user_data);
- static bool DestroyCharacteristic(int total, int index, bt_gatt_h handle, void* user_data);
- static bool DestroyDescriptor(int total, int index, bt_gatt_h handle, void* user_data);
static void NotifyCallback(int result, const char* remote_address, bt_gatt_server_h server,
bt_gatt_h characteristic, bool completed, void* user_data);