/********************************************************************* * @fn sensor_HandleConnStatusCB * * @brief Sensor Profile link status change handler function. * * @param connHandle - connection handle * @param changeType - type of change * * @return none */ static void sensor_HandleConnStatusCB( uint16 connHandle, uint8 changeType ) { // Make sure this is not loopback connection if ( connHandle != LOOPBACK_CONNHANDLE ) { // Reset Client Char Config if connection has dropped if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) || ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) && ( !linkDB_Up( connHandle ) ) ) ) { GATTServApp_InitCharCfg( connHandle, sensorDataConfig ); GATTServApp_InitCharCfg( connHandle, sensorData1Config ); GATTServApp_InitCharCfg( connHandle, sensorData2Config ); GATTServApp_InitCharCfg( connHandle, sensorData3Config ); } if ( changeType == LINKDB_STATUS_UPDATE_NEW ) { GATTServApp_WriteCharCfg(connHandle,sensorDataConfig,GATT_CLIENT_CFG_NOTIFY); GATTServApp_WriteCharCfg(connHandle,sensorData1Config,GATT_CLIENT_CFG_NOTIFY); GATTServApp_WriteCharCfg(connHandle,sensorData2Config,GATT_CLIENT_CFG_NOTIFY); GATTServApp_WriteCharCfg(connHandle,sensorData3Config,GATT_CLIENT_CFG_NOTIFY); } } }
/********************************************************************* * @fn GATTServApp_ProcessCCCWriteReq * * @brief Process the client characteristic configuration * write request for a given client. * * @param connHandle - connection message was received on * @param pAttr - pointer to attribute * @param pValue - pointer to data to be written * @param len - length of data * @param offset - offset of the first octet to be written * @param validCfg - valid configuration * * @return Success or Failure */ bStatus_t GATTServApp_ProcessCCCWriteReq( uint16 connHandle, gattAttribute_t *pAttr, uint8 *pValue, uint16 len, uint16 offset, uint16 validCfg ) { bStatus_t status = SUCCESS; // Validate the value if ( offset == 0 ) { if ( len == 2 ) { uint16 value = BUILD_UINT16( pValue[0], pValue[1] ); // Validate characteristic configuration bit field if ( ( value & ~validCfg ) == 0 ) // indicate and/or notify { // Write the value if it's changed if ( GATTServApp_ReadCharCfg( connHandle, GATT_CCC_TBL(pAttr->pValue) ) != value ) { status = GATTServApp_WriteCharCfg( connHandle, GATT_CCC_TBL(pAttr->pValue), value ); } } else { status = ATT_ERR_INVALID_VALUE; } } else { status = ATT_ERR_INVALID_VALUE_SIZE; } } else { status = ATT_ERR_ATTR_NOT_LONG; } return ( status ); }