首先從機(jī)和主機(jī)的gattprofile.h文件中的?SIMPLEPROFILE_CHAR1_LEN均改為了5,但接受時(shí)只有第一個(gè)數(shù)據(jù)正確,請(qǐng)大佬指教!謝謝?。?!
發(fā)送函數(shù):
uint8?BLE_Send_Txt[5]={10,15,32,86,65}; static?uint16?connect0_ProcessEvent(?uint8?task_id,?uint16?events?) { if?(?events?&?START_READ_OR_WRITE_EVT?) {??? if(?centralConnList[CONNECT0_ITEM].procedureInProgress?==?FALSE?) { if(?centralDoWrite?) { //?Do?a?write ??attPrepareWriteReq_t?req; req.handle?=?centralConnList[CONNECT0_ITEM].charHdl; req.len?=?SIMPLEPROFILE_CHAR1_LEN; req.pValue?=?GATT_bm_alloc(centralConnList[CONNECT0_ITEM].connHandle,ATT_WRITE_REQ,req.len,NULL,0); if?(?req.pValue?!=?NULL?) { *req.pValue?=?BLE_Send_Txt[0]; if(?GATT_WriteLongCharValue(centralConnList[CONNECT0_ITEM].connHandle,&req,centralTaskId)?==?SUCCESS?) {?????? centralConnList[CONNECT0_ITEM].procedureInProgress?=?TRUE; centralDoWrite?=?!centralDoWrite; tmos_start_task(?centralConnList[CONNECT0_ITEM].taskID,?START_READ_OR_WRITE_EVT,?DEFAULT_READ_OR_WRITE_DELAY); } else { GATT_bm_free((gattMsg_t?*)&req,?ATT_WRITE_REQ); } }?? }
接收方是這樣的
uint8?txt[SIMPLEPROFILE_CHAR1_LEN]; static?void?simpleProfileChangeCB(?uint8?paramID,?uint8?*pValue,?uint16?len?) { ??switch(?paramID?) ??{ ????case?SIMPLEPROFILE_CHAR1: { ??????tmos_memcpy(?txt,?pValue,?len?); PRINT("profile?ChangeCB?CHAR1..?\n"); ??????break; } ????case?SIMPLEPROFILE_CHAR3: { ??????tmos_memcpy(?txt,?pValue,?len?); PRINT("profile?ChangeCB?CHAR3..\n"); ??????break; } ????default: ??????//?should?not?reach?here! ??????break; ??} }
但調(diào)試結(jié)果是這樣的: