/********************************************************************* * @brief Set/clear the service change indication in a bond record. * * Public function defined in gapperiphbondmgr.h. */ bStatus_t GAPBondMgr_ServiceChangeInd( uint16 connectionHandle, uint8 setParam ) { bStatus_t ret = bleNoResources; // return value if ( connectionHandle == 0xFFFF ) { uint8 idx; // loop counter // Run through the bond database and update the Service Change indication for ( idx = 0; idx < GAP_BONDINGS_MAX; idx++ ) { if ( gapBondMgrChangeState( idx, GAP_BONDED_STATE_SERVICE_CHANGED, setParam ) ) { ret = SUCCESS; } } // If the service change indication is TRUE, tell the connected devices if ( setParam ) { // Run connected database linkDB_PerformFunc( gapBondMgrSendServiceChange ); } } else { // Find connection information linkDBItem_t *pLinkItem = linkDB_Find( connectionHandle ); if ( pLinkItem ) { uint8 idx; // loop counter idx = GAPBondMgr_ResolveAddr( pLinkItem->addrType, pLinkItem->addr, NULL ); if ( idx < GAP_BONDINGS_MAX ) { // Bond found, update it. VOID gapBondMgrChangeState( idx, GAP_BONDED_STATE_SERVICE_CHANGED, setParam ); ret = SUCCESS; } // If the service change indication is TRUE, tell the connected device if ( setParam ) { gapBondMgrSendServiceChange( pLinkItem ); } } else { ret = bleNotConnected; } } return ( ret ); }
/********************************************************************* * @fn battNotifyLevelState * * @brief Send a notification of the battery level state * characteristic if a connection is established. * * @return None. */ static void battNotifyLevel( void ) { // Execute linkDB callback to send notification linkDB_PerformFunc( battNotifyCB ); }
/********************************************************************* * @fn SimpleProfile_SetParameter * * @brief Set a Simple Profile parameter. * * @param param - Profile parameter ID * @param len - length of data to right * @param value - pointer to data to write. This is dependent on * the parameter ID and WILL be cast to the appropriate * data type (example: data type of uint16 will be cast to * uint16 pointer). * * @return bStatus_t */ bStatus_t ExampleService_SetParameter( uint8 param, uint8 len, void *value ) { bStatus_t ret = SUCCESS; switch ( param ) { case SIMPLEPROFILE_CHAR1:{ if ( len == SIMPLEPROFILE_CHAR1_ATCLEN ) { VOID osal_memcpy( simpleProfileChar1, value, SIMPLEPROFILE_CHAR1_ATCLEN ); } else ret = bleInvalidRange; break; } case SIMPLEPROFILE_CHAR2:{ if ( len == SIMPLEPROFILE_CHAR2_ATCLEN ) { VOID osal_memcpy( simpleProfileChar2, value, SIMPLEPROFILE_CHAR2_ATCLEN ); linkDB_PerformFunc( ServerNotificationCallBack); // See if Notification has been enabled // GATTServApp_ProcessCharCfg( simpleProfileChar2Config, simpleProfileChar2, FALSE, // simpleProfileAttrTbl, GATT_NUM_ATTRS( simpleProfileAttrTbl ),INVALID_TASK_ID ); } else ret = bleInvalidRange; break; } /* case SIMPLEPROFILE_CHAR2: if ( len == sizeof ( uint8 ) ) { simpleProfileChar2 = *((uint8*)value); } else { ret = bleInvalidRange; } break; case SIMPLEPROFILE_CHAR3: if ( len == sizeof ( uint8 ) ) { simpleProfileChar3 = *((uint8*)value); } else { ret = bleInvalidRange; } break; case SIMPLEPROFILE_CHAR4:{ if ( len == sizeof ( uint8 )){ simpleProfileChar4 = *((uint8*)value); // See if Notification has been enabled GATTServApp_ProcessCharCfg( simpleProfileChar4Config, &simpleProfileChar4, FALSE, simpleProfileAttrTbl, GATT_NUM_ATTRS( simpleProfileAttrTbl ), INVALID_TASK_ID ); } else ret = bleInvalidRange; break; } case SIMPLEPROFILE_CHAR5: if ( len == SIMPLEPROFILE_CHAR5_LEN ) { VOID osal_memcpy( simpleProfileChar5, value, SIMPLEPROFILE_CHAR5_LEN ); } else { ret = bleInvalidRange; } break; default: ret = INVALIDPARAMETER; break; */ } return ( ret ); }