mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-25 09:02:30 +00:00
gatt_service: implementation of cycling power and cycling speed and cadence GATT services
This commit is contained in:
parent
adbdd27a95
commit
f15c31b547
@ -1,11 +1,12 @@
|
|||||||
# Makefile to collect all C source files of src/ble/gatt-service
|
# 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 \
|
battery_service_server.c \
|
||||||
|
cycling_power_service_server.c \
|
||||||
|
cycling_speed_and_cadence_service_server.c \
|
||||||
device_information_service_server.c \
|
device_information_service_server.c \
|
||||||
heart_rate_service_server.c \
|
heart_rate_service_server.c \
|
||||||
hids_device.c \
|
hids_device.c \
|
||||||
nordic_spp_service_server.c \
|
nordic_spp_service_server.c \
|
||||||
ublox_spp_service_server.c \
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,13 +52,7 @@
|
|||||||
|
|
||||||
#include "ble/gatt-service/cycling_power_service_server.h"
|
#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 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 CONTROL_POINT_PROCEDURE_TIMEOUT_MS 30
|
||||||
#define CYCLING_POWER_MEASUREMENT_FLAGS_CLEARED 0xFFFF
|
#define CYCLING_POWER_MEASUREMENT_FLAGS_CLEARED 0xFFFF
|
||||||
|
|
||||||
@ -743,7 +737,7 @@ static int cycling_power_service_write_callback(hci_con_handle_t con_handle, uin
|
|||||||
#ifdef ENABLE_ATT_DELAYED_RESPONSE
|
#ifdef ENABLE_ATT_DELAYED_RESPONSE
|
||||||
switch (instance->con_interval_status){
|
switch (instance->con_interval_status){
|
||||||
case CP_CONNECTION_INTERVAL_STATUS_REJECTED:
|
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_ACCEPTED:
|
||||||
case CP_CONNECTION_INTERVAL_STATUS_RECEIVED:
|
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 (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){
|
if (instance->w4_indication_complete != 0){
|
||||||
printf("w4_indication_complete not 0 \n");
|
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(" \n");
|
||||||
printf("cycling_power_service_write_callback: w4_indication_complete %d \n", instance->w4_indication_complete);
|
printf("cycling_power_service_write_callback: w4_indication_complete %d \n", instance->w4_indication_complete);
|
||||||
|
@ -49,10 +49,6 @@
|
|||||||
|
|
||||||
#include "ble/gatt-service/cycling_speed_and_cadence_service_server.h"
|
#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 {
|
typedef enum {
|
||||||
CSC_RESPONSE_VALUE_SUCCESS = 1,
|
CSC_RESPONSE_VALUE_SUCCESS = 1,
|
||||||
CSC_RESPONSE_VALUE_OP_CODE_NOT_SUPPORTED,
|
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 (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 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->request_opcode = buffer[0];
|
||||||
instance->response_value = CSC_RESPONSE_VALUE_SUCCESS;
|
instance->response_value = CSC_RESPONSE_VALUE_SUCCESS;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user