From f15c31b547acb43b993c64f35c68601986ae3495 Mon Sep 17 00:00:00 2001 From: Milanka Ringwald Date: Thu, 1 Nov 2018 09:34:24 +0100 Subject: [PATCH] gatt_service: implementation of cycling power and cycling speed and cadence GATT services --- src/ble/gatt-service/Makefile.inc | 5 +++-- .../cycling_power_service_server.c | 18 ++++++------------ .../cycling_speed_and_cadence_service_server.c | 6 +----- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/ble/gatt-service/Makefile.inc b/src/ble/gatt-service/Makefile.inc index 7f0353887..8e38f5f88 100644 --- a/src/ble/gatt-service/Makefile.inc +++ b/src/ble/gatt-service/Makefile.inc @@ -1,11 +1,12 @@ # Makefile to collect all C source files of src/ble/gatt-service -SRC_BLE_GATT-SERVICE_FILES = \ +SRC_BLE_GATT_SERVICE_FILES = \ battery_service_server.c \ + cycling_power_service_server.c \ + cycling_speed_and_cadence_service_server.c \ device_information_service_server.c \ heart_rate_service_server.c \ hids_device.c \ nordic_spp_service_server.c \ - ublox_spp_service_server.c \ diff --git a/src/ble/gatt-service/cycling_power_service_server.c b/src/ble/gatt-service/cycling_power_service_server.c index 2333c687d..976cdd364 100644 --- a/src/ble/gatt-service/cycling_power_service_server.c +++ b/src/ble/gatt-service/cycling_power_service_server.c @@ -52,15 +52,9 @@ #include "ble/gatt-service/cycling_power_service_server.h" -// error codes from cps spec -#define CYCLING_POWER_ERROR_CODE_INAPPROPRIATE_CONNECTION_PARAMETERS 0x80 -#define CYCLING_POWER_MAX_BROACAST_MSG_SIZE 31 - -#define CSC_ERROR_CODE_PROCEDURE_ALREADY_IN_PROGRESS 0xFE -#define CSC_ERROR_CODE_CCC_DESCRIPTOR_IMPROPERLY_CONFIGURED 0xFD - -#define CONTROL_POINT_PROCEDURE_TIMEOUT_MS 30 -#define CYCLING_POWER_MEASUREMENT_FLAGS_CLEARED 0xFFFF +#define CYCLING_POWER_MAX_BROACAST_MSG_SIZE 31 +#define CONTROL_POINT_PROCEDURE_TIMEOUT_MS 30 +#define CYCLING_POWER_MEASUREMENT_FLAGS_CLEARED 0xFFFF typedef enum { CP_MASK_BIT_PEDAL_POWER_BALANCE = 0, @@ -743,7 +737,7 @@ static int cycling_power_service_write_callback(hci_con_handle_t con_handle, uin #ifdef ENABLE_ATT_DELAYED_RESPONSE switch (instance->con_interval_status){ case CP_CONNECTION_INTERVAL_STATUS_REJECTED: - return ATT_ERROR_INAPPROPRIATE_CONNECTION_PARAMETERS; + return CYCLING_POWER_ERROR_CODE_INAPPROPRIATE_CONNECTION_PARAMETERS; case CP_CONNECTION_INTERVAL_STATUS_ACCEPTED: case CP_CONNECTION_INTERVAL_STATUS_RECEIVED: @@ -783,10 +777,10 @@ static int cycling_power_service_write_callback(hci_con_handle_t con_handle, uin } if (attribute_handle == instance->control_point_value_handle){ - if (instance->control_point_client_configuration_descriptor_indicate == 0) return CSC_ERROR_CODE_CCC_DESCRIPTOR_IMPROPERLY_CONFIGURED; + if (instance->control_point_client_configuration_descriptor_indicate == 0) return CYCLING_POWER_ERROR_CODE_CCC_DESCRIPTOR_IMPROPERLY_CONFIGURED; if (instance->w4_indication_complete != 0){ printf("w4_indication_complete not 0 \n"); - return CSC_ERROR_CODE_PROCEDURE_ALREADY_IN_PROGRESS; + return CYCLING_POWER_ERROR_CODE_PROCEDURE_ALREADY_IN_PROGRESS; } printf(" \n"); printf("cycling_power_service_write_callback: w4_indication_complete %d \n", instance->w4_indication_complete); diff --git a/src/ble/gatt-service/cycling_speed_and_cadence_service_server.c b/src/ble/gatt-service/cycling_speed_and_cadence_service_server.c index cfcb8e1b4..cd11381e1 100644 --- a/src/ble/gatt-service/cycling_speed_and_cadence_service_server.c +++ b/src/ble/gatt-service/cycling_speed_and_cadence_service_server.c @@ -49,10 +49,6 @@ #include "ble/gatt-service/cycling_speed_and_cadence_service_server.h" -// error codes from cscs spec -#define CSC_ERROR_CODE_PROCEDURE_ALREADY_IN_PROGRESS 0x80 -#define CSC_ERROR_CODE_CCC_DESCRIPTOR_IMPROPERLY_CONFIGURED 0x81 - typedef enum { CSC_RESPONSE_VALUE_SUCCESS = 1, CSC_RESPONSE_VALUE_OP_CODE_NOT_SUPPORTED, @@ -249,7 +245,7 @@ static int cycling_speed_and_cadence_service_write_callback(hci_con_handle_t con if (attribute_handle == instance->control_point_value_handle){ if (instance->control_point_client_configuration_descriptor_indicate == 0) return CSC_ERROR_CODE_CCC_DESCRIPTOR_IMPROPERLY_CONFIGURED; - if (instance->request_opcode != CSC_OPCODE_IDLE) return CSC_ERROR_CODE_PROCEDURE_ALREADY_IN_PROGRESS; + if (instance->request_opcode != CSC_OPCODE_IDLE) return CSCS_ERROR_CODE_PROCEDURE_ALREADY_IN_PROGRESS; instance->request_opcode = buffer[0]; instance->response_value = CSC_RESPONSE_VALUE_SUCCESS;