手機(jī)端發(fā)送讀數(shù)據(jù)時,?Peripheral例程中的哪個函數(shù)被觸發(fā)回調(diào)?修改哪里讓它讀到我指定想返回的數(shù)據(jù),謝謝!
熱門產(chǎn)品 :
CH397: 高集成度、低功耗USB網(wǎng)卡芯片
手機(jī)端發(fā)送讀數(shù)據(jù)時,?Peripheral例程中的哪個函數(shù)被觸發(fā)回調(diào)?修改哪里讓它讀到我指定想返回的數(shù)據(jù),謝謝!
在EVT\EXAM\BLE\Peripheral 的example中,這些讀操作最先會調(diào)用下面這個函數(shù):
文件: EVT\EXAM\BLE\Peripheral\Profile.c 中的部分代碼
static?bStatus_t?simpleProfile_ReadAttrCB(?uint16?connHandle,?gattAttribute_t?*pAttr,? ????????????????????????????uint8?*pValue,?uint16?*pLen,?uint16?offset,?uint16?maxLen,uint8?method??) { ??bStatus_t?status?=?SUCCESS; ??//?If?attribute?permissions?require?authorization?to?read,?return?error ??if?(?gattPermitAuthorRead(?pAttr->permissions?)?) ??{ ????//?Insufficient?authorization ????return?(?ATT_ERR_INSUFFICIENT_AUTHOR?); ??} ?? ??//?Make?sure?it's?not?a?blob?operation?(no?attributes?in?the?profile?are?long) ??if?(?offset?>?0?) ??{ ????return?(?ATT_ERR_ATTR_NOT_LONG?); ??} ? ??if?(?pAttr->type.len?==?ATT_BT_UUID_SIZE?) ??{ ????//?16-bit?UUID ????uint16?uuid?=?BUILD_UINT16(?pAttr->type.uuid[0],?pAttr->type.uuid[1]); ????switch?(?uuid?) ????{ ??????//?No?need?for?"GATT_SERVICE_UUID"?or?"GATT_CLIENT_CHAR_CFG_UUID"?cases; ??????//?gattserverapp?handles?those?reads ??????//?characteristics?1?and?2?have?read?permissions ??????//?characteritisc?3?does?not?have?read?permissions;?therefore?it?is?not ??????//???included?here ??????//?characteristic?4?does?not?have?read?permissions,?but?because?it ??????//???can?be?sent?as?a?notification,?it?is?included?here ??????case?SIMPLEPROFILE_CHAR1_UUID: ????????*pLen?=?SIMPLEPROFILE_CHAR1_LEN; ????????tmos_memcpy(?pValue,?pAttr->pValue,?SIMPLEPROFILE_CHAR1_LEN?); ????????break; ?????? ??????case?SIMPLEPROFILE_CHAR2_UUID: ????????*pLen?=?SIMPLEPROFILE_CHAR2_LEN; ????????tmos_memcpy(?pValue,?pAttr->pValue,?SIMPLEPROFILE_CHAR2_LEN?); ????????break; ?????? ??????case?SIMPLEPROFILE_CHAR4_UUID: ????????*pLen?=?SIMPLEPROFILE_CHAR4_LEN; ????????tmos_memcpy(?pValue,?pAttr->pValue,?SIMPLEPROFILE_CHAR4_LEN?); ????????break; ?????? ??????case?SIMPLEPROFILE_CHAR5_UUID: ????????*pLen?=?SIMPLEPROFILE_CHAR5_LEN; ????????tmos_memcpy(?pValue,?pAttr->pValue,?SIMPLEPROFILE_CHAR5_LEN?); ????????break; ???????? ??????default: ????????//?Should?never?get?here!?(characteristics?3?and?4?do?not?have?read?permissions) ????????*pLen?=?0; ????????status?=?ATT_ERR_ATTR_NOT_FOUND; ????????break; ????}