Files
MuditaOS/module-bluetooth/lib/Bluetopia/profiles/CSCS/source/CSCSAPI.h

602 lines
32 KiB
C

/*
* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
* All Rights Reserved.
* Author: Dan Horowitz
*** MODIFICATION HISTORY ****************************************************
*
* mm/dd/yy F. Lastname Description of Modification
* -------- ----------- ------------------------------------------------
* 11/28/11 D. Horowitz Initial creation.
****************************************************************************
*/
/**
* @file CSCSAPI.h
*
* @brief Bluetooth Stack Cycle Speed and Cadence Service (GATT based)
* API Type Definitions, Constants, and Prototypes.
* To use any of the following API's,
* include the following declaration in your application.
*
* @code
* #include "SS1BTCSCS.h"
* @endcode
*
* The Cycling Speed and Cadence Service, CSCS, programming interface defines
* the protocols and procedures to be used to implement CSCS capabilities for both Server and Client services.
* ============================================================================
*/
#ifndef __CSCSAPIH__
#define __CSCSAPIH__
#include "SS1BTPS.h" /*! Bluetooth Stack API Prototypes/Constants. */
#include "SS1BTGAT.h" /*! Bluetooth Stack GATT API Prototypes/Constants. */
#include "CSCSTypes.h" /*! Cycling Speed and Cadence Service Types/Constants. */
/*! Error Return Codes.
* Error Codes that are smaller than these (less than -1000) are
* related to the Bluetooth Protocol Stack itself (see BTERRORS.H).
*/
#define CSCS_ERROR_INVALID_PARAMETER (-1000)
#define CSCS_ERROR_INVALID_BLUETOOTH_STACK_ID (-1001)
#define CSCS_ERROR_INSUFFICIENT_RESOURCES (-1002)
#define CSCS_ERROR_SERVICE_ALREADY_REGISTERED (-1003)
#define CSCS_ERROR_INVALID_INSTANCE_ID (-1004)
#define CSCS_ERROR_MALFORMATTED_DATA (-1005)
#define CSCS_ERROR_INDICATION_IN_PROGRESS (-1006)
#define CSCS_ERROR_UNKNOWN_ERROR (-1007)
#define CSCS_ERROR_WHEEL_NOT_SUPPORTED (-1008)
#define CSCS_ERROR_CRANK_NOT_SUPPORTED (-1009)
#define CSCS_ERROR_MULTIPLE_LOCATION_NOT_SUPPORTED (-1010)
#define CSCS_ERROR_WHEEL_AND_CRANK_NOT_SUPPORTED (-1011)
#define CSCS_ERROR_WHEEL_AND_MULTIPLE_LOCATION_NOT_SUPPORTED (-1012)
#define CSCS_ERROR_CRANK_AND_MULTIPLE_LOCATION_NOT_SUPPORTED (-1013)
#define CSCS_ERROR_WHEEL_AND_CRANK_AND_MULTIPLE_LOCATION_NOT_SUPPORTED (-1014)
#define CSCS_ERROR_LOCATION_LIST_IS_GREATER_THEN_MAXIMUM_SIZE (-1015)
/*! The following defines the valid CSC Feature Bit masks that
* specifies the supported features of the Server
*/
#define CSCS_CSC_SUPPORTED_FEATURE_WHEEL_REVOLUTION_DATA 0x01
#define CSCS_CSC_SUPPORTED_FEATURE_CRANK_REVOLUTION_DATA 0x02
#define CSCS_CSC_SUPPORTED_FEATURE_MULTIPLE_SENSOR_LOCATION 0x04
/*! The following enumeration covers all the client configuration
* descriptor that are available in the CSCS Service. These are used
* to determine which CCD is in use.
*/
typedef enum
{
ctCyclingSpeedandCadenceMeasurement,
ctSCControlPoint
} CSCS_Characteristic_Type_t;
/*! The following enumeration covers all the events generated by the
* CSCS Profile. These are used to determine the type of each event
* generated, and to ensure the proper union element is accessed for
* the CSCS_Event_Data_t structure.
*/
typedef enum
{
etCSCS_Server_Read_Client_Configuration_Request, /*!< Dispatched to a CSCS Server when a CSCS Client is attempting to read a descriptor. */
etCSCS_Server_Client_Configuration_Update, /*!< Dispatched to a CSCS Server when a CSCS Client has written a Client Configuration descriptor. */
etCSCS_Confirmation_Response, /*!< Dispatched to a CSCS Server when a CSCS client sends a confirmation in response to SC Control Point Indication. */
etCSCS_Server_SC_Control_Point_Command /*!< Dispatched to a CSCS Server when a CSCS client sends a request to write SC Control Point data. */
} CSCS_Event_Type_t;
/*! The following structure contains the Handles that will need to be
* cached by a CSCS client in order to only do service discovery once
*/
typedef struct _tagCSCS_Client_Information_t
{
Word_t CSC_Measurement;
Word_t CSC_Measurement_Client_Configuration;
Word_t CSC_Features;
Word_t CSC_Sensor_Location;
Word_t SC_Control_Point;
Word_t SC_Control_Point_Client_Configuration;
} CSCS_Client_Information_t;
#define CSCS_CLIENT_INFORMATION_DATA_SIZE (sizeof(CSCS_Client_Information_t))
/*! The following structure contains all of the per Client data that
* will need to be stored by a CSCS Server.
*/
typedef struct _tagCSCS_Server_Information_t
{
Word_t CSC_Measurement_Client_Configuration;
Word_t SC_Control_Point_Client_Configuration;
} CSCS_Server_Information_t;
#define CSCS_SERVER_INFORMATION_DATA_SIZE (sizeof(CSCS_Server_Information_t))
/*! The following structure defines the structure of the values that
* Wheel Revolution Data Present enables.
*/
typedef struct _tagCSCS_Wheel_Data_t
{
DWord_t Cumulative_Wheel_Revolutions;
Word_t Last_Wheel_Event_Time;
} CSCS_Wheel_Data_t;
/*! The following structure defines the structure of the values that
* Crank Revolution Data Present enables.
*/
typedef struct _tagCSCS_Crank_Data_t
{
Word_t Cumulative_Crank_Revolutions;
Word_t Last_Crank_Event_Time;
} CSCS_Crank_Data_t;
/*! The following represents to the structure of a Measurement. This
* is used to notify a remote CSCS Client of a Measurement in a
* specified category.
* \note The Flags Member Indicate if Data exists in Wheel_Data or
* Crank_Data members
* \note The Wheel_Data member and Crank_Data are optional and may
* be set to NULL.
*/
typedef struct _tagCSCS_Measurements_Data_t
{
Byte_t Flags;
CSCS_Wheel_Data_t *Wheel_Data;
CSCS_Crank_Data_t *Crank_Data;
} CSCS_Measurements_Data_t;
#define CSCS_MEASUREMENTS_DATA (sizeof(CSCS_Wheel_Data_t) + sizeof(CSCS_Crank_Data_t) + BYTE_SIZE)
/*! The following CSCS Profile Event is dispatched to a CSCS Server
* when a CSCS Client has written a Client Configuration
* descriptor. The ConnectionID, ConnectionType, and RemoteDevice
* specifiy the Client that is making the update. The Descriptor
* Type specifies the Descriptor that the Client is writing.
*/
typedef struct _tagCSCS_Connection_Header_Data_t
{
unsigned int InstanceID;
unsigned int ConnectionID;
GATT_Connection_Type_t ConnectionType;
BD_ADDR_t RemoteDevice;
} CSCS_Connection_Header_Data_t;
#define CSCS_CONNECTION_HEADER_DATA_SIZE (sizeof(CSCS_Connection_Header_Data_t))
/*! The following CSCS Profile Event is dispatched to a CSCS Server
* when a CSCS Client is attempting to read a descriptor. The
* ConnectionHeader specify the Client that is making the request.
* The ClientConfigurationType specifies the Descriptor that the
* Client is attempting to read. The TransactionID specifies the
* TransactionID of the request, this can be used when responding to
* the request using the CSCS_Client_Configuration_Read_Response()
* API function.
*/
typedef struct _tagCSCS_Read_Client_Configuration_Data_t
{
CSCS_Connection_Header_Data_t ConnectionHeader;
unsigned int TransactionID;
CSCS_Characteristic_Type_t ClientConfigurationType;
} CSCS_Read_Client_Configuration_Data_t;
#define CSCS_READ_CLIENT_CONFIGURATION_DATA_SIZE (sizeof(CSCS_Read_Client_Configuration_Data_t))
/*! The following CSCS Profile Event is dispatched to a CSCS Server
* when a CSCS Client has written a Client Configuration descriptor.
* The ConnectionHeader specify the Client that is making the update.
* The ClientConfigurationType specifies theDescriptor that the
* Client is writing.
*/
typedef struct _tagCSCS_Client_Configuration_Update_Data_t
{
CSCS_Connection_Header_Data_t ConnectionHeader;
CSCS_Characteristic_Type_t ClientConfigurationType;
Word_t ClientConfiguration;
} CSCS_Client_Configuration_Update_Data_t;
#define CSCS_CLIENT_CONFIGURATION_UPDATE_DATA_SIZE (sizeof(CSCS_Client_Configuration_Update_Data_t))
/*! The following Structure is a part of CSCS Profile Event is
* dispatched to a CSCS Server when a CSCS Server has indicate a
* response to the Client. The Response_Value specifies the response
* value that server will return to the client Number_of_parameters
* specifies the number of available sensor locations,
* Response_Parameter specifies the value of the available locations.
*/
typedef struct _tagCSCS_Control_Point_Indication_Data_t
{
Byte_t Request_Op_Code;
unsigned int Response_Value;
Byte_t Number_Of_Parameters;
Byte_t Response_Parameter[1];
} CSCS_Control_Point_Indication_Data_t;
#define CSCS_INDICATION_DATA_SIZE(_x) (BTPS_STRUCTURE_OFFSET(CSCS_Control_Point_Indication_Data_t, Response_Parameter[0]) + ((_x)*BYTE_SIZE))
#define CSCS_INDICATION_LIST_DATE_SIZE (BTPS_STRUCTURE_OFFSET(CSCS_Control_Point_Indication_Data_t, Response_Parameter[0]) + (BYTE_SIZE))
/*! The following CSCS Profile Event is dispatched to a CSCS Server
* when a CSCS Client has written a command to the CSCS Control
* Point or when the Server indicate a response to the client. The
* ConnectionHeader specify the Client that is making the update and
* how to response. The Op_Code specifies the Op_Code that the
* Client is sending and the Category specifies the category that the
* command applies to. Cumulative_Value specifies the cumulative
* value that the client want to update in the server, The
* Sensor_Location_Value is the value that the client want to update
* in the server, Response specifies the response structure that the
* server will return to the client.
*/
typedef struct _tagCSCS_Control_Point_Data_t
{
CSCS_Connection_Header_Data_t ConnectionHeader;
unsigned int TransactionID;
Word_t AttributeOffset;
Byte_t Op_Code;
union _tagCommand_data_Buffer
{
DWord_t Cumulative_Value;
Byte_t Sensor_Location_Value;
CSCS_Control_Point_Indication_Data_t Indication;
} Command_data_Buffer;
} CSCS_Control_Point_Data_t;
#define CSCS_CONTROL_POINT_DATA_SIZE (sizeof(CSCS_Control_Point_Data_t))
#define CSCS_CONTROL_POINT_WITH_INDICATION_DATA_SIZE(_x) ((sizeof(CSCS_Control_Point_Data_t)) + ((_x)*BYTE_SIZE))
#define CSCS_CONTROL_POINT_SET_CUMULATIVE_DATA_SIZE (CSCS_CONFIRMATION_DATA_SIZE + BYTE_SIZE + DWORD_SIZE)
#define CSCS_CONTROL_POINT_UPDATE_SENSOR_LOCATION_DATA_SIZE (CSCS_CONFIRMATION_DATA_SIZE + BYTE_SIZE + BYTE_SIZE)
#define CSCS_CONTROL_POINT_LIST_REQUEST_DATA_SIZE (CSCS_CONFIRMATION_DATA_SIZE + BYTE_SIZE)
#define CSCS_CONTROL_POINT_RESPONSE_DATA_SIZE (CSCS_CONFIRMATION_DATA_SIZE + BYTE_SIZE + CSCS_INDICATION_LIST_SIZE)
#define CSCS_CONTROL_POINT_INDICATION_LIST_DATA_SIZE(_x) (CSCS_CONFIRMATION_DATA_SIZE + BYTE_SIZE + CSCS_INDICATION_DATA_SIZE(_x))
#define CSCS_CONTROL_POINT_MINIMUM_DATA_SIZE (CSCS_CONTROL_POINT_LIST_REQUEST_DATA_SIZE)
/*! The following CSCS Profile Event is dispatched to a CSCS Server
* when a CSCS Client has sent confirmation data. The
* ConnectionHeader specify the Client that is making the update. The
* Characteristic_Type specifies the Descriptor that the Client
* confirmation for.
*/
typedef struct _tagCSCS_Confirmation_Data_t
{
CSCS_Connection_Header_Data_t ConnectionHeader;
CSCS_Characteristic_Type_t Characteristic_Type;
Byte_t Status;
} CSCS_Confirmation_Data_t;
#define CSCS_CONFIRMATION_DATA_SIZE (sizeof(CSCS_Confirmation_Data_t))
/*! The following structure represents the container structure for
* holding all CSCS Profile Event Data. This structure is received
* for each event generated. The Event_Data_Type member is used to
* determine the appropriate union member element to access the
* contained data. The Event_Data_Size member contains the total
* size of the data contained in this event.
*/
typedef struct _tagCSCS_Event_Data_t
{
CSCS_Event_Type_t Event_Data_Type;
Word_t Event_Data_Size;
union _tagEvent_Data
{
CSCS_Read_Client_Configuration_Data_t *CSCS_Read_Client_Configuration_Data;
CSCS_Client_Configuration_Update_Data_t *CSCS_Client_Configuration_Update_Data;
CSCS_Control_Point_Data_t *CSCS_Control_Point_Data;
CSCS_Confirmation_Data_t *CSCS_Confirmation_Data;
} Event_Data;
} CSCS_Event_Data_t;
#define CSCS_EVENT_DATA_SIZE (sizeof(CSCS_Event_Data_t))
/*! The following declared type represents the Prototype Function for
* a CSCS Profile Event Receive Data Callback. This function will be
* called whenever an CSCS Profile Event occurs that is associated
* with the specified Bluetooth Stack ID.
* @param BluetoothStackID This function passes to
* the caller the Bluetooth Stack ID.
* @param CSCS_Event_Data The CSCS Event Data that
* occurred.
* @param CallbackParameter The CSCS Profile Event Callback Parameter that was
* specified when this Callback was installed. The caller is free to
* use the contents of the CSCS Profile Event Data ONLY in the
* context of this callback. If the caller requires the Data for a
* longer period of time, then the callback function MUST copy the
* data into another Data Buffer This function is guaranteed NOT to
* be invoked more than once simultaneously for the specified
* installed callback (i.e. this function DOES NOT have be re-
* entered). It needs to be noted however, that if the same Callback
* is installed more than once, then the callbacks will be called
* serially. Because of this, the processing in this function should
* be as efficient as possible. It should also be noted that this
* function is called in the Thread Context of a Thread that the User
* does NOT own. Therefore, processing in this function should be as
* efficient as possible (this argument holds anyway because another
* CSCS Profile Event will not be processed while this function call
* is outstanding).
* \note This function MUST NOT Block and wait for events that
* can only be satisfied by Receiving CSCS Profile Event
* Packets. A Deadlock WILL occur because NO CSCS Event
* Callbacks will be issued while this function is
* currently outstanding.
*/
typedef void (BTPSAPI *CSCS_Event_Callback_t)(unsigned int BluetoothStackID, CSCS_Event_Data_t *CSCS_Event_Data, unsigned long CallbackParameter);
/*! @brief The following function is responsible for opening a CSCS Server.
* @param BluetoothStackID The first parameter is the Bluetooth Stack ID on which to open the
* server. @param EventCallback The second parameter is the Callback function to call
* when an event occurs on this Server Port. @param CallbackParameter The third parameter is
* a user-defined callback parameter that will be passed to the
* callback function with each event. @param ServiceID The first parameter is a
* pointer to store the GATT Service ID of the registered CSCS
* service. This can be used to include the service registered by
* this call. @return This function returns the positive, non-zero, Instance
* ID or a negative error code.
* \note Only 1 CSCS Server may be open at a time, per Bluetooth
* Stack ID.
* \note All Client Requests will be dispatch to the EventCallback
* function that is specified by the second parameter to
* this function.
*/
BTPSAPI_DECLARATION int BTPSAPI CSCS_Initialize_Service(unsigned int BluetoothStackID, CSCS_Event_Callback_t EventCallback, unsigned long CallbackParameter, unsigned int *ServiceID);
#ifdef INCLUDE_BLUETOOTH_API_PROTOTYPES
typedef int (BTPSAPI *PFN_CSCS_Initialize_Service_t)(unsigned int BluetoothStackID, CSCS_Event_Callback_t EventCallback, unsigned long CallbackParameter, unsigned int *ServiceID);
#endif
/*! @brief The following function is responsible for opening a CSCS Server.
* @param BluetoothStackID The first parameter is the Bluetooth Stack ID on which to open the
* server. @param EventCallback The second parameter is the Callback function to call
* when an event occurs on this Server Port. @param CallbackParameter The third parameter is
* a user-defined callback parameter that will be passed to the
* callback function with each event. @param ServiceID The fourth parameter is a
* pointer to store the GATT Service ID of the registered CSCS
* service. This can be used to include the service registered by
* this call. @param ServiceHandleRange The final parameter is a pointer, that on input can be
* used to control the location of the service in the GATT database,
* and on ouput to store the service handle range.
* @return This function returns the positive, non-zero, Instance ID or a negative error
* code.
* \note Only 1 CSCS Server may be open at a time, per Bluetooth
* Stack ID.
* \note All Client Requests will be dispatch to the EventCallback
* function that is specified by the second parameter to
* this function.
*/
BTPSAPI_DECLARATION int BTPSAPI CSCS_Initialize_Service_Handle_Range(unsigned int BluetoothStackID, CSCS_Event_Callback_t EventCallback, unsigned long CallbackParameter, unsigned int *ServiceID, GATT_Attribute_Handle_Group_t *ServiceHandleRange);
#ifdef INCLUDE_BLUETOOTH_API_PROTOTYPES
typedef int (BTPSAPI *PFN_CSCS_Initialize_Service_Handle_Range_t)(unsigned int BluetoothStackID, CSCS_Event_Callback_t EventCallback, unsigned long CallbackParameter, unsigned int *ServiceID, GATT_Attribute_Handle_Group_t *ServiceHandleRange);
#endif
/*! @brief The following function is responsible for closing a previously
* CSCS Server. @param BluetoothStackID The first parameter is the Bluetooth Stack ID on
* which to close the server. @param InstanceID The second parameter is the InstanceID
* that was returned from a successful call to
* CSCS_Initialize_Service(). @return This function returns a zero if
* successful or a negative returnerror code if an error occurs.
*/
BTPSAPI_DECLARATION int BTPSAPI CSCS_Cleanup_Service(unsigned int BluetoothStackID, unsigned int InstanceID);
#ifdef INCLUDE_BLUETOOTH_API_PROTOTYPES
typedef int (BTPSAPI *PFN_CSCS_Cleanup_Service_t)(unsigned int BluetoothStackID, unsigned int InstanceID);
#endif
/*! @brief The following function is responsible for querying the number of
* attributes that are contained in the CSCS Service that is
* registered with a call to CSCS_Initialize_Service().
* @return This function returns the non-zero number of attributes that are
* contained in an CSCS Server or zero on failure.
*/
BTPSAPI_DECLARATION unsigned int BTPSAPI CSCS_Query_Number_Attributes(void);
#ifdef INCLUDE_BLUETOOTH_API_PROTOTYPES
typedef unsigned int (BTPSAPI *PFN_CSCS_Query_Number_Attributes_t)(void);
#endif
/*! @brief The following function is responsible for querying the current
* Location of the sensor on the specified CSCS Instance.
* @param BluetoothStackID The first parameter is the Bluetooth Stack ID of the Bluetooth Device.
* @param InstanceID The second parameter is the InstanceID returned from a successful call
* to CSCS_Initialize_Server(). @param Sensor_Location The final parameter is a pointer to
* return the current Sensor Location for the specified CSCS
* Instance. @return This function returns a zero if successful or a
* negative return error code if an error occurs.
*/
BTPSAPI_DECLARATION int BTPSAPI CSCS_Query_Sensor_Location(unsigned int BluetoothStackID, unsigned int InstanceID, Byte_t *Sensor_Location);
#ifdef INCLUDE_BLUETOOTH_API_PROTOTYPES
typedef int (BTPSAPI *PFN_CSCS_Query_Sensor_Location_t)(unsigned int BluetoothStackID, unsigned int InstanceID, Byte_t *Sensor_Location);
#endif
/*! @brief The following function is responsible for responding to a CSCS
* Read Client Configuration Request. @param BluetoothStackID The first parameter is the
* Bluetooth Stack ID of the Bluetooth Device. @param InstanceID The second parameter
* is the InstanceID returned from a successful call to
* CSCS_Initialize_Server(). @param TransactionID The third parameter is the Transaction ID of the
* request. @param Client_Configuration The final parameter contains the Client Configuration to
* send to the remote device. @return This function returns a zero if
* successful or a negative return error code if an error occurs.
*/
BTPSAPI_DECLARATION int BTPSAPI CSCS_Read_Response_For_Read_Client_Configuration(unsigned int BluetoothStackID, unsigned int InstanceID, unsigned int TransactionID, Word_t Client_Configuration);
#ifdef INCLUDE_BLUETOOTH_API_PROTOTYPES
typedef int (BTPSAPI *PFN_CSCS_Read_Response_For_Read_Client_Configuration_t)(unsigned int BluetoothStackID, unsigned int InstanceID, unsigned int TransactionID, Word_t Client_Configuration);
#endif
/*! @brief The following function is responsible for sending a Measurement
* notification to a specified remote device.
* @param BluetoothStackID The first parameter is
* the Bluetooth Stack ID of the Bluetooth Device.
* @param InstanceID The second parameter is the InstanceID returned from a successful call to
* CSCS_Initialize_Server(). @param ConnectionID The third parameter is the ConnectionID
* of the remote device to send the notification to.
* @param Measurements The final parameter is the measurement data to notify.
* @return This function returns a zero if successful or a negative return error code if an
* error occurs.
* \note At least one flag needs to be set in order to send the
* Notification, otherwise an error will be returend to the caller.
* When flag WHEEL_REVOLUTION_DATA_PRESENT is set in the flags of
* the CSCS_Measurements parameter, then Cumulative Wheel Revolutoins
* and Last Wheel Event Time fields are present
* When flag CRANK_REVOLUTION_DATA_PRESENT is set in the flags of
* the CSCS_Measurements parameter, then Cumulative Crank Revolutoins
* and Last Crank Event Time fields are present
*/
BTPSAPI_DECLARATION int BTPSAPI CSCS_Measurements_Notification(unsigned int BluetoothStackID, unsigned int InstanceID, unsigned int ConnectionID, CSCS_Measurements_Data_t *Measurements);
#ifdef INCLUDE_BLUETOOTH_API_PROTOTYPES
typedef int (BTPSAPI *PFN_CSCS_Measurements_Notification_t)(unsigned int BluetoothStackID, unsigned int InstanceID, unsigned int ConnectionID, CSCS_Measurements_Data_t *Measurements);
#endif
/*! @brief The following function is responsible for setting Supported
* features on the specified CSCS Instance. @param BluetoothStackID The first parameter is
* the Bluetooth Stack ID of the Bluetooth Device.
* @param InstanceID The second parameter is the InstanceID returned from a successful call to
* CSCS_Initialize_Server(). @param SupportedFeaturesMask The final parameter is the Supported
* Feature bit mask to set the supported Features for the specified
* CSCS Instance. @return This function returns a zero if successful or a
* negative return error code if an error occurs.
* \note The SupportedFeaturesMask is a bit mask that is made up
* of bit masks of the form CSCS_CSC_FEATURE_BIT_MASK_XXX.
*/
BTPSAPI_DECLARATION int BTPSAPI CSCS_Set_Supported_Features(unsigned int BluetoothStackID, unsigned int InstanceID, Word_t SupportedFeaturesMask);
#ifdef INCLUDE_BLUETOOTH_API_PROTOTYPES
typedef int (BTPSAPI *PFN_CSCS_Set_Supported_Features_t)(unsigned int BluetoothStackID, unsigned int InstanceID, Word_t SupportedFeaturesMask);
#endif
/*! @brief The following function is responsible for querying Supported
* features on the specified CSCS Instance.
* @param BluetoothStackID The first parameter is
* the Bluetooth Stack ID of the Bluetooth Device.
* @param InstanceID The second parameter is the InstanceID returned from a successful call to
* CSCS_Initialize_Server(). @param Features The final parameter is a pointer to
* store the Feature bit mask for the specified CSCS Instance.
* @return This function returns the BitMask of the supported Features if
* successful or a negative return error code if an error occurs.
* \note The Features is a pointer to a bit mask that will
* be made up of bit masks of the form
* CSCS_CSC_FEATURE_BIT_MASK_XXX, if @return This function returns
* success.
*/
BTPSAPI_DECLARATION int BTPSAPI CSCS_Query_Supported_Features(unsigned int BluetoothStackID, unsigned int InstanceID, Word_t *Features);
#ifdef INCLUDE_BLUETOOTH_API_PROTOTYPES
typedef int (BTPSAPI *PFN_CSCS_Query_Supported_Features_t)(unsigned int BluetoothStackID, unsigned int InstanceID, Word_t *Features);
#endif
/*! @brief The following function is responsible for sending a SC Control
* Point indication to a specified remote device. @param BluetoothStackID The first
* parameter is the Bluetooth Stack ID of the Bluetooth Device.
* @param InstanceID The second parameter is the InstanceID returned from a successful call to
* CSCS_Initialize_Server(). @param ConnectionID The third parameter is the ConnectionID
* of the remote device to send the indication to.
* @param Op_Code_Response The fourth parameter is the Op_Code_Response, the structure who store the
* data for the indication.
* @return This function returns a zero if successful or a negative return
* error code if an error occurs.
*/
BTPSAPI_DECLARATION int BTPSAPI CSCS_SC_Control_Point_Indication(unsigned int BluetoothStackID, unsigned int InstanceID, unsigned int ConnectionID, CSCS_Control_Point_Data_t *Op_Code_Response);
#ifdef INCLUDE_BLUETOOTH_API_PROTOTYPES
typedef int (BTPSAPI *PFN_CSCS_CS_Control_Point_Indication_t)(unsigned int BluetoothStackID, unsigned int InstanceID, unsigned int ConnectionID, CSCS_Control_Point_Data_t *Op_Code_Response);
#endif
/*! @brief The following function is responsible for setting the supported
* sensor location list on the Sensor. @param BluetoothStackID The first parameter is the
* Bluetooth Stack ID of the Bluetooth Device. @param InstanceID The second parameter
* is the InstanceID returned from a successful call to
* CSCS_Initialize_Server(). @param SensorListBitMask The final parameter is the Supported
* sensor location list bit mask to set on the sensor.
* @return This function returns a zero if successful or a
* negative return error code if an error occurs.
* \note The SensorListBitMask is a bit mask that is made up
* of bit masks that needs to be smaller then 0x7fff.
*/
int BTPSAPI CSCS_Set_Sensor_Location_List(unsigned int BluetoothStackID, unsigned int InstanceID, Word_t SensorListBitMask);
#ifdef INCLUDE_BLUETOOTH_API_PROTOTYPES
typedef int (BTPSAPI *PFN_CSCS_Set_Sensor_Location_List_t)(unsigned int BluetoothStackID, unsigned int InstanceID, Word_t SensorListBitMask);
#endif
/* CSCS Client API Utils function.
* @brief The following function is responsible for formatting a Cycling
* Speed and Cadence SC Control Point Command into a user specified
* buffer.
* @param BufferLength The first parameter is the length of the buffer.
* @param Buffer The second parameter is a pointer to the buffer to format the command into.
* @param CSCS_Control_Point The final parameter is the control point data.
* @return This function returns a zero if
* successful or a negative return error code if an error occurs.
* \note The BufferLength and Buffer parameter must point to a
* buffer of at least CSCS_CONTROL_POINT_MINIMUM_VALUE_SIZE
* in size.
*/
BTPSAPI_DECLARATION int BTPSAPI CSCS_Format_Control_Point_Command_Util(unsigned int BufferLength, Byte_t *Buffer, CSCS_Control_Point_Data_t *CSCS_Control_Point);
#ifdef INCLUDE_BLUETOOTH_API_PROTOTYPES
typedef int (BTPSAPI *PFN_CSCS_Format_Control_Point_Command_Util_t)(unsigned int BufferLength, Byte_t *Buffer, CSCS_Control_Point_Data_t *CSCS_Control_Point);
#endif
/*! @brief The following function is responsible for parsing a measurement
* notification received from a remote CSCS Server.
* @param ValueLength The first parameter is the length of the value returned by the remote CSCS
* Server. @param Value The second parameter is a pointer to the data returned by
* the remote CSCS Server.
* @param CSCS_Measurement The final parameter is a pointer to the measurement data.
* @return This function returns a pointer to the
* decode measurement data or NULL if an error occurred.
*/
BTPSAPI_DECLARATION int BTPSAPI CSCS_Decode_Cycle_Speed_and_Cadence_Measurements_Util(unsigned int ValueLength, Byte_t *Value, CSCS_Measurements_Data_t *CSCS_Measurement);
#ifdef INCLUDE_BLUETOOTH_API_PROTOTYPES
typedef int (BTPSAPI *PFN_CSCS_Decode_Cycle_Speed_and_Cadence_Measurements_Util_t)(unsigned int ValueLength, Byte_t *Value, CSCS_Measurements_Data_t *CSCS_Measurement);
#endif
/*! @brief The following function is responsible for parsing a value received
* from a remote CSCS Server interpreting it as a SC Control point
* response characteristic. @param ValueLength The first parameter is the length of
* the value returned by the remote CSCS Server.
* @param Value The second parameter is a pointer to the data returned by the remote CSCS
* Server.
* @param CSCS_Control_Point The third parameter is a pointer to the control point data.
* @param LocationList The final parameter is a pointer to store the parsed
* Response value. @return This function returns a zero if successful or
* a negative return error code if an error occurs.
* \note On INPUT the Number_Of_Parameters member of the
* CSCS_Control_Point parameter must contain number of
* entries if it is greater then one, and the opcode is
* REQUEST_SUPPORTED_SENSOR_LOCATION, it represent the size
* of the Response_Parameter array. On RETURN this
* will contain the Op code, value, and the actual number of
* Sensor locations available if asked.
*/
BTPSAPI_DECLARATION int BTPSAPI CSCS_Decode_SC_Control_Point_Indication_Util(Word_t ValueLength, Byte_t *Value, CSCS_Control_Point_Data_t *CSCS_Control_Point, Byte_t * LocationList);
#ifdef INCLUDE_BLUETOOTH_API_PROTOTYPES
typedef int (BTPSAPI *PFN_CSCS_Decode_SC_Control_Point_Indication_Util_t)(Word_t ValueLength, Byte_t *Value, CSCS_Control_Point_Data_t *CSCS_Control_Point, Byte_t * LocationList);
#endif
#endif