CGM Simulator  0.1.3
A CGM simulator to demonstrate the BLE CGM profile v1.1
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
cgmservice.c File Reference

This file contains the CGM sample service for use with the CGM sample application. More...

#include "bcomdef.h"
#include "OSAL.h"
#include "linkdb.h"
#include "att.h"
#include "gatt.h"
#include "gatt_uuid.h"
#include "gatt_profile_uuid.h"
#include "gattservapp.h"
#include "gapbondmgr.h"
#include "cgmservice.h"
Include dependency graph for cgmservice.c:

Macros

#define CGM_MEAS_VALUE_POS   2
 The position of the value of the CGM measurement charateristic in the attribute array. More...
 
#define CGM_MEAS_CONFIG_POS   3
 The position of the Client Configuration of the CGM measurement charateristic in the attribute array. More...
 
#define CGM_FEATURE_VALUE_POS   5
 The position of the value of the CGM feature charateristic in the attribute array. More...
 
#define CGM_STATUS_VALUE_POS   7
 The position of the value of the CGM status charateristic in the attribute array. More...
 
#define CGM_SESSION_START_TIME_VALUE_POS   9
 The position of the value of the session start time charateristic in the attribute array. More...
 
#define CGM_SESSION_RUN_TIME_VALUE_POS   11
 The position of the value of the session run time charateristic in the attribute array. More...
 
#define CGM_RACP_VALUE_POS   13
 The position of the value of the RACP charateristic in the attribute array. More...
 
#define CGM_RACP_CONFIG_POS   14
 The position of the Client Configuration of the RACP charateristic in the attribute array. More...
 
#define CGM_CGM_OPCP_VALUE_POS   16
 The position of the value of the CGM Specific Operation Control Point (OPCP) charateristic in the attribute array. More...
 
#define CGM_CGM_OPCP_CONFIG_POS   17
 

Functions

static uint8 CGM_ReadAttrCB (uint16 connHandle, gattAttribute_t *pAttr, uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen)
 The callback function when an attribute is being read by a collector. More...
 
static bStatus_t CGM_WriteAttrCB (uint16 connHandle, gattAttribute_t *pAttr, uint8 *pValue, uint8 len, uint16 offset)
 The CGM service layer callback function when an attribute is being written to by the collector. More...
 
static void CGM_HandleConnStatusCB (uint16 connHandle, uint8 changeType)
 Simple Profile link status change handler function. More...
 
bStatus_t CGM_RACPIndicate (uint16 connHandle, attHandleValueInd_t *pInd, uint8 taskId)
 Send an indication to the RACP characteristic. More...
 
bStatus_t CGM_AddService (uint32 services)
 Initializes the CGM service by registering GATT attributes with the GATT server. More...
 
void CGM_Register (CGMServiceCB_t pfnServiceCB)
 Register a callback function with the CGM Service. More...
 
bStatus_t CGM_MeasSend (uint16 connHandle, attHandleValueNoti_t *pNoti, uint8 taskId)
 Send a CGM measurement via the CGM measurement notification. More...
 
bStatus_t CGM_CtlPntIndicate (uint16 connHandle, attHandleValueInd_t *pInd, uint8 taskId)
 Send an indication containing a CGM measurement. More...
 
bool CGM_SetSendState (bool input)
 Set the state of the CGM database transmission indicator. More...
 

Variables

CONST uint8 CGMServiceUUID [ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_SERV_UUID), HI_UINT16(CGM_SERV_UUID)}
 CGM service UUID Stored as a constant variable. More...
 
CONST uint8 CGMMeasUUID [ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_MEAS_UUID), HI_UINT16(CGM_MEAS_UUID)}
 CGM Measurement characteristic UUID stored as a constant variable. More...
 
CONST uint8 CGMFeatureUUID [ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_FEATURE_UUID), HI_UINT16(CGM_FEATURE_UUID)}
 CGM Feature UUID stored as a constant. More...
 
CONST uint8 CGMStatusUUID [ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_STATUS_UUID), HI_UINT16(CGM_STATUS_UUID)}
 CGM Status UUID stored as a constant. More...
 
CONST uint8 CGMSessionStartTimeUUID [ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_SES_START_TIME_UUID), HI_UINT16(CGM_SES_START_TIME_UUID)}
 CGM Session Start stored as a constant. More...
 
CONST uint8 CGMSessionRunTimeUUID [ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_SES_RUN_TIME_UUID), HI_UINT16(CGM_SES_RUN_TIME_UUID)}
 CGM Session Run stored as a constant. More...
 
CONST uint8 recordControlPointUUID [ATT_BT_UUID_SIZE] = {LO_UINT16(REC_ACCESS_CTRL_PT_UUID), HI_UINT16(REC_ACCESS_CTRL_PT_UUID)}
 Record Control Point stored as a constant. More...
 
CONST uint8 CGMSpecificOpsControlPointUUID [ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_SPEC_OPS_CTRL_PT_UUID), HI_UINT16(CGM_SPEC_OPS_CTRL_PT_UUID)}
 
static CGMServiceCB_t CGMServiceCB
 The variable to register the CGM service callback function. More...
 
static bool cgmMeasDBSendInProgress
 An variable to indicate whether the RACP transmission is in progress. More...
 
static CONST gattAttrType_t CGMService = {ATT_BT_UUID_SIZE, CGMServiceUUID }
 CGM GATT service declaration data structure. More...
 
static uint8 CGMMeasProps = GATT_PROP_NOTIFY
 Variable storing the CGM Measurement Characteristic property. More...
 
static gattCharCfg_t CGMMeasConfig [GATT_MAX_NUM_CONN]
 Variable for storing the client configuration for CGM Measurement Characteristic. More...
 
static uint8 CGMMeassurementDummy =0
 This is a dummy variable to register the CGM Measurement characteristic to the ATT server. The actual variable for receiving the CGM measurement is defined in cgm.c. More...
 
static uint8 CGMFeatureProps = GATT_PROP_READ
 Variable storing the CGM Feature Characteristic property. More...
 
static uint8 CGMFeatureDummy = 0
 This is a dummy variable to register the CGM Feature characteristic to the ATT server. The actual variable for receiving the CGM feature value is defined in cgm.c. More...
 
static uint8 CGMStatusProps = GATT_PROP_READ
 Variable storing the CGM Status Characteristic property. More...
 
static uint8 CGMStatusDummy =0
 This is a dummy variable to register the CGM Status characteristic to the ATT server. The actual variable for receiving the CGM measurement is defined in cgm.c. More...
 
static uint8 CGMSessionStartTimeProps = GATT_PROP_WRITE|GATT_PROP_READ
 Variable storing the CGM Start Time Characteristic property. More...
 
static uint8 CGMSessionStartTimeDummy =0
 This is a dummy variable to register the CGM Start Time characteristic to the ATT server. The actual variable for receiving the CGM measurement is defined in cgm.c. More...
 
static uint8 CGMSessionRunTimeProps = GATT_PROP_READ
 Variable storing the CGM Run Time Characteristic property. More...
 
static uint16 CGMSessionRunTimeDummy =2
 This is a dummy variable to register the CGM Run time characteristic to the ATT server. The actual variable for receiving the CGM measurement is defined in cgm.c. More...
 
static uint8 CGMRacpProps = GATT_PROP_WRITE|GATT_PROP_INDICATE
 Variable storing the CGM RACP Characteristic property. More...
 
static gattCharCfg_t CGMRacpConfig [GATT_MAX_NUM_CONN]
 Variable for storing the client configuration for RACP Characteristic. More...
 
static uint8 CGMRacpDummy =0
 This is a dummy variable to register the CGM RACP characteristic to the ATT server. The actual variable for receiving the CGM measurement is defined in cgm.c. More...
 
static uint8 CGMControlProps = GATT_PROP_WRITE|GATT_PROP_INDICATE
 Variable storing the CGM OPCP Characteristic property. More...
 
static gattCharCfg_t CGMControlConfig [GATT_MAX_NUM_CONN]
 Variable for storing the client configuration OPCP Characteristic. More...
 
static uint8 CGMControlDummy =0
 This is a dummy variable to register the CGM OPCP characteristic to the ATT server. The actual variable for receiving the CGM measurement is defined in cgm.c. More...
 
static gattAttribute_t CGMAttrTbl []
 
CONST gattServiceCBs_t CGMCBs
 

Detailed Description

This file contains the CGM sample service for use with the CGM sample application.

Date
2015-Feb-3
Version
2

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Macro Definition Documentation

#define CGM_CGM_OPCP_CONFIG_POS   17

The position of the Client Configuration of the CGM Specific Operation Control Point OPCP) charateristic in the attribute array

#define CGM_CGM_OPCP_VALUE_POS   16

The position of the value of the CGM Specific Operation Control Point (OPCP) charateristic in the attribute array.

#define CGM_FEATURE_VALUE_POS   5

The position of the value of the CGM feature charateristic in the attribute array.

#define CGM_MEAS_CONFIG_POS   3

The position of the Client Configuration of the CGM measurement charateristic in the attribute array.

#define CGM_MEAS_VALUE_POS   2

The position of the value of the CGM measurement charateristic in the attribute array.

#define CGM_RACP_CONFIG_POS   14

The position of the Client Configuration of the RACP charateristic in the attribute array.

#define CGM_RACP_VALUE_POS   13

The position of the value of the RACP charateristic in the attribute array.

#define CGM_SESSION_RUN_TIME_VALUE_POS   11

The position of the value of the session run time charateristic in the attribute array.

#define CGM_SESSION_START_TIME_VALUE_POS   9

The position of the value of the session start time charateristic in the attribute array.

#define CGM_STATUS_VALUE_POS   7

The position of the value of the CGM status charateristic in the attribute array.

Function Documentation

bStatus_t CGM_CtlPntIndicate ( uint16  connHandle,
attHandleValueInd_t *  pInd,
uint8  taskId 
)

Send an indication containing a CGM measurement.

Parameters
connHandle- connection handle
pInd- pointer to indication structure
taskId- the taskId of the CGM application
Returns
Success or Failure

Here is the caller graph for this function:

Variable Documentation

gattCharCfg_t CGMControlConfig[GATT_MAX_NUM_CONN]
static

Variable for storing the client configuration OPCP Characteristic.

uint8 CGMControlDummy =0
static

This is a dummy variable to register the CGM OPCP characteristic to the ATT server. The actual variable for receiving the CGM measurement is defined in cgm.c.

uint8 CGMControlProps = GATT_PROP_WRITE|GATT_PROP_INDICATE
static

Variable storing the CGM OPCP Characteristic property.

uint8 CGMFeatureDummy = 0
static

This is a dummy variable to register the CGM Feature characteristic to the ATT server. The actual variable for receiving the CGM feature value is defined in cgm.c.

uint8 CGMFeatureProps = GATT_PROP_READ
static

Variable storing the CGM Feature Characteristic property.

CONST uint8 CGMFeatureUUID[ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_FEATURE_UUID), HI_UINT16(CGM_FEATURE_UUID)}

CGM Feature UUID stored as a constant.

gattCharCfg_t CGMMeasConfig[GATT_MAX_NUM_CONN]
static

Variable for storing the client configuration for CGM Measurement Characteristic.

uint8 CGMMeasProps = GATT_PROP_NOTIFY
static

Variable storing the CGM Measurement Characteristic property.

uint8 CGMMeassurementDummy =0
static

This is a dummy variable to register the CGM Measurement characteristic to the ATT server. The actual variable for receiving the CGM measurement is defined in cgm.c.

CONST uint8 CGMMeasUUID[ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_MEAS_UUID), HI_UINT16(CGM_MEAS_UUID)}

CGM Measurement characteristic UUID stored as a constant variable.

gattCharCfg_t CGMRacpConfig[GATT_MAX_NUM_CONN]
static

Variable for storing the client configuration for RACP Characteristic.

uint8 CGMRacpDummy =0
static

This is a dummy variable to register the CGM RACP characteristic to the ATT server. The actual variable for receiving the CGM measurement is defined in cgm.c.

uint8 CGMRacpProps = GATT_PROP_WRITE|GATT_PROP_INDICATE
static

Variable storing the CGM RACP Characteristic property.

CONST gattAttrType_t CGMService = {ATT_BT_UUID_SIZE, CGMServiceUUID }
static

CGM GATT service declaration data structure.

CONST uint8 CGMServiceUUID[ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_SERV_UUID), HI_UINT16(CGM_SERV_UUID)}

CGM service UUID Stored as a constant variable.

uint16 CGMSessionRunTimeDummy =2
static

This is a dummy variable to register the CGM Run time characteristic to the ATT server. The actual variable for receiving the CGM measurement is defined in cgm.c.

uint8 CGMSessionRunTimeProps = GATT_PROP_READ
static

Variable storing the CGM Run Time Characteristic property.

CONST uint8 CGMSessionRunTimeUUID[ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_SES_RUN_TIME_UUID), HI_UINT16(CGM_SES_RUN_TIME_UUID)}

CGM Session Run stored as a constant.

uint8 CGMSessionStartTimeDummy =0
static

This is a dummy variable to register the CGM Start Time characteristic to the ATT server. The actual variable for receiving the CGM measurement is defined in cgm.c.

uint8 CGMSessionStartTimeProps = GATT_PROP_WRITE|GATT_PROP_READ
static

Variable storing the CGM Start Time Characteristic property.

CONST uint8 CGMSessionStartTimeUUID[ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_SES_START_TIME_UUID), HI_UINT16(CGM_SES_START_TIME_UUID)}

CGM Session Start stored as a constant.

CONST uint8 CGMSpecificOpsControlPointUUID[ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_SPEC_OPS_CTRL_PT_UUID), HI_UINT16(CGM_SPEC_OPS_CTRL_PT_UUID)}

CGM Specific Ops Control Point stored as a constant

uint8 CGMStatusDummy =0
static

This is a dummy variable to register the CGM Status characteristic to the ATT server. The actual variable for receiving the CGM measurement is defined in cgm.c.

uint8 CGMStatusProps = GATT_PROP_READ
static

Variable storing the CGM Status Characteristic property.

CONST uint8 CGMStatusUUID[ATT_BT_UUID_SIZE] = {LO_UINT16(CGM_STATUS_UUID), HI_UINT16(CGM_STATUS_UUID)}

CGM Status UUID stored as a constant.

CONST uint8 recordControlPointUUID[ATT_BT_UUID_SIZE] = {LO_UINT16(REC_ACCESS_CTRL_PT_UUID), HI_UINT16(REC_ACCESS_CTRL_PT_UUID)}

Record Control Point stored as a constant.