Part Number:CC2640R2F
如题,SDK版本是SimpleLink CC2640R2 SDK – 4.30.00.08.
我在程序中添加了看门狗,发现调用GapScan_enable后过一段时间程序就复位了。
可以确定硬件是没有问题的,我有一个老的工程SDK版本是simplelink_cc2640r2_sdk_1_40_00_45工作正常。
我初始化了串口,通过串口接收一个指令后调用SimpleCentral_doDiscoverDevices开始扫描,程序执行到GapScan_enable就死了
我已经附上了代码。simple_central.csimple_central.h
SerialInterface.c
/***********************************************************************//** * @fileSerialInterface.c * @brief* @details* @authorNick ( Nick.yao@justec.cn ) * @version* @date2023-02-23 14:08:25 * @pre* @copyright Copyright <span style="font-family:Microsoft Sans Serif;">© </span>Nick ( Nick.yao@justec.cn ). All rights reserved. */ #include "SerialInterface.h" #include "Att.h" //#include "Protocol.h" //#include "Crc.h" //#include "peripheral.h" //#include "devinfoservice.h" //#include "simpleGATTprofile.h" //#include "simpleBLEPeripheral.h" #include "hci.h" #include <ti/drivers/UART.H> #include <ti/sysbios/knl/Task.h> #include <ti/sysbios/knl/Semaphore.h> #include <ti/sysbios/BIOS.h> #include <ti/sysbios/knl/Clock.h> #include "Board.h" #include "OSAL.h" #include <stdio.h> #include <string.h> //2018-4-10 #include "gatt.h" //#include "simpleGATTprofile.h" #include "simple_gatt_profile.h" //2018-5-17 #include "simple_central.h" #include "LinkList.h" //2018-5-17 extern uint8 simpleBLEState; static UART_HandlehUART; static Semaphore_Handle hUARTSem; static Semaphore_Struct sUARTSem; static Task_StructsUARTTask; #define UART_TASK_STACK_SIZE(512u) #define UART_TASK_PRIORITY(1u) Char UART_TaskStack[UART_TASK_STACK_SIZE]; //2018-4-24 static uint8_trxBuf[256]; //static uint8_trxBuf[5000]; static uint16_t rxWRAddr = 0; static uint16_t rxRDAddr = 0; static uint8_trxBuf2[256]; _transMode transMode = eCTRL_MODE; void SerialReadCallback( UART_Handle handle, void *buf, size_t count ); void SerialWriteCallback( UART_Handle handle, void *buf, size_t count ); int SerialSend( UART_Handle handle, void *buf, size_t count ); int SerialRead( UART_Handle handle, void *buf, size_t count ); void SerialTaskFxn( UArg a0, UArg a1 ); void ProtocolForBulk(); void ProtocolForCTRL(); void BluetoothSwitch( bool val ); extern void SerialBulkEvent( _transMode mode ); //2018-3-23 //void Uart_SendMsg(uint8 cmd,uint8 data); //2018-3-26 static uint8 sendMsgTo_TaskID; uint8 timeoutFlag; uint8 disconnectFlag; //2018-5-11 #include <xdc/runtime/Assert.h> #include <xdc/runtime/Types.h> #include <xdc/runtime/Log.h> #include <ti/sysbios/BIOS.h> #include "board.h" #include <ti/drivers/power/PowerCC26XX.h> #include <ti/drivers/UART.h> #include <ti/drivers/uart/UARTCC26XX.h> /*********************�궨��************************/ #if defined(CC2640R2DK_7ID) #define GUA_UART_RX IOID_1 //�������� #define GUA_UART_TX IOID_2 //�������� #else #define GUA_UART_RX IOID_0 //�������� #define GUA_UART_TX IOID_1 //�������� #endif //#define CC2640R2DK_4XS_UART_RXIOID_0 /* P1.7 */ //#define CC2640R2DK_4XS_UART_TXIOID_1 /* P1.9 */ /*********************�ڲ�����************************/ //���ں� typedef enum{ GUA_UART0 = 0, GUA_UARTCOUNT }GUA_UARTName; //��������������� const UARTCC26XX_HWAttrsV2 GUA_UART_CC26XXHWAttrs[GUA_UARTCOUNT] = { { .baseAddr = UART0_BASE, .powerMngrId = PowerCC26XX_PERIPH_UART0, .intNum = INT_UART0_COMB, .intPriority = ~0, .swiPriority = 0, .txPin = GUA_UART_TX, .rxPin = GUA_UART_RX, .ctsPin = PIN_UNASSIGNED, .rtsPin = PIN_UNASSIGNED } }; //����Ŀ�� static UARTCC26XX_Object GUA_UART_CC26XXObjects[GUA_UARTCOUNT]; static const UART_Config GUA_UART_Config[GUA_UARTCOUNT] = { { .fxnTablePtr = &UARTCC26XX_fxnTable, .object = &GUA_UART_CC26XXObjects[GUA_UART0], .hwAttrs = &GUA_UART_CC26XXHWAttrs[GUA_UART0] }, }; //���ھ�� static UART_Handle stGUA_UART_Handle; //���ڲ��� static UART_Params stGUA_UART_Params; #define GUA_UART_MAX_NUM_RX_BYTES 60 //�������ֽ� #define GUA_UART_MAX_NUM_TX_BYTES 60 //������ֽ� /*********************�ⲿ����************************/ uint8 gaGUA_UART_RxBuf[GUA_UART_MAX_NUM_RX_BYTES] = {0}; uint8 gaGUA_UART_TxBuf[GUA_UART_MAX_NUM_TX_BYTES] = {0}; uint32 gGUA_UART_WantedRxBytes; uint8 gGUA_UART_Size; /////////////////////////////////////////////////////// #define USE_LINK_LIST 1 #if (USE_LINK_LIST == 1) typedef struct _ts_voc_data{ LinkListNode next; uint16_t voc; uint16_t temp; uint16_t humi; uint8_t status; uint8_t rev; }TS_VOC_DATA; #else typedef struct _ts_voc_data{ uint16_t voc; uint16_t temp; uint16_t humi; uint8_t status; uint8_t rev; }TS_VOC_DATA; #endif #define VOC_BUF_LEN 90 TS_VOC_DATA voc_data[VOC_BUF_LEN]; LinkList *idle_list,*data_list; static float HexToFloat(uint8_t *buf) { union{ float t; uint8_tndata[4]; }tmp; tmp.ndata[3] = buf[0]; tmp.ndata[2] = buf[1]; tmp.ndata[1] = buf[2]; tmp.ndata[0] = buf[3]; return tmp.t; } static uint16_t U16LittleToBig(uint16_t val) { union{ uint16_t t; uint8_t ndata[2]; }tmp,ret; tmp.t = val; ret.ndata[0] = tmp.ndata[1]; ret.ndata[1] = tmp.ndata[0]; return ret.t; } static void set_up_link_list(void) { int i; idle_list = LinkList_Creat(); data_list = LinkList_Creat(); for(i=0; i<VOC_BUF_LEN; i++){ LinkList_Insert(idle_list,(LinkListNode*)&voc_data[i],0); } } #if (USE_LINK_LIST == 1) void voc_data_puts(uint8_t* dataflow) { TS_VOC_DATA *p; float t; if(LinkList_Length(idle_list) > 0){ p = (TS_VOC_DATA *)LinkList_Delete(idle_list, 0);//�ӿ�������õ�һ��buf }else{ p = (TS_VOC_DATA *)LinkList_Delete(data_list, 0);//�����������н���ɵ�����ɾ�� } memcpy((uint8_t*)&(p->voc), dataflow, 2); t = HexToFloat(dataflow+2); p->temp = U16LittleToBig((uint16_t)(t*10)); t = HexToFloat(dataflow+6); p->humi = U16LittleToBig((uint16_t)(t*10)); p->status = dataflow[10]; LinkList_Insert(data_list, (LinkListNode *)p, LinkList_Length(data_list));//������������β�� } static uint8_t voc_datas_output(TS_VOC_DATA* p) { uint8_t ret = 0; TS_VOC_DATA *pdata; if(LinkList_Length(data_list) > 0){ pdata = (TS_VOC_DATA *)LinkList_Delete(data_list, 0);//�����������н���ɵ������ͳ� p->voc = pdata->voc; p->temp = pdata->temp; p->humi = pdata->humi; p->status = pdata->status; LinkList_Insert(idle_list,(LinkListNode*)pdata,0);//�����нڵ���� ret = 1; } return ret; } #else static uint16_t voc_read = 0, voc_write = 0; void voc_data_puts(uint8_t* dataflow) { float t; memcpy((uint8_t*)&(voc_data[voc_write].voc), dataflow, 2); t = HexToFloat(dataflow+2); voc_data[voc_write].temp = U16LittleToBig((uint16_t)(t*10)); t = HexToFloat(dataflow+6); voc_data[voc_write].humi = U16LittleToBig((uint16_t)(t*10)); voc_data[voc_write].status = dataflow[10]; voc_write++; if(voc_write >= VOC_BUF_LEN) voc_write = 0; } static uint8_t voc_datas_output(TS_VOC_DATA* p) { uint8_t ret = 0; if(voc_read != voc_write){ p->voc = voc_data[voc_read].voc; p->temp = voc_data[voc_read].temp; p->humi = voc_data[voc_read].humi; p->status = voc_data[voc_read].status; voc_read++; if(voc_read >= VOC_BUF_LEN) voc_read = 0; ret = 1; } return ret; } #endif //2018-5-7 //���ھ�� //���������ݳ��� /* #define GUA_UART_MAX_NUM_RX_BYTES 60 //�������ֽ� #define GUA_UART_MAX_NUM_TX_BYTES 60 //������ֽ� static UART_Handle stGUA_UART_Handle; uint8 gaGUA_UART_RxBuf[GUA_UART_MAX_NUM_RX_BYTES] = {0}; uint8 gaGUA_UART_TxBuf[GUA_UART_MAX_NUM_TX_BYTES] = {0}; uint32 gGUA_UART_WantedRxBytes; uint8 gGUA_UART_Size; */ //void SerialInit() void SerialInit(__UART_Callback SerialReadCallback) {UART_Paramsparams;Semaphore_Params sParams;Task_ParamsTaskParams; set_up_link_list();HCI_EXT_SetTxPowerCmd( HCI_EXT_TX_POWER_5_DBM );/* io config in Board.c *//* uart config */UART_Params_init(¶ms);/* 57600, N, 8, 1 */params.baudRate = 115200; //params.baudRate = 230400;params.parityType = UART_PAR_NONE;params.dataLength = UART_LEN_8;params.stopBits = UART_STOP_ONE;params.readMode = UART_MODE_CALLBACK;params.readCallback = SerialReadCallback;params.writeMode = UART_MODE_BLOCKING;params.writeCallback = NULL;params.writeDataMode = UART_DATA_BINARY;params.readDataMode = UART_DATA_BINARY;params.readReturnMode = UART_RETURN_FULL;params.readEcho = UART_ECHO_OFF;/* Initialize the UART driver */UART_init(); //2018-4-4 //hUART = UART_open( CC2650_UART0, ¶ms ); // hUART = UART_open( Board_UART0, ¶ms ); stGUA_UART_Handle = GUA_UART_Config[0].fxnTablePtr->openFxn((UART_Handle)&GUA_UART_Config[0], ¶ms); //������ھֲ����ع��� GUA_UART_Config[0].fxnTablePtr->controlFxn(stGUA_UART_Handle, UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE, NULL);/*Semaphore_Params_init( &sParams );sParams.mode = Semaphore_Mode_BINARY;Semaphore_construct( &sUARTSem, 0, &sParams );hUARTSem = Semaphore_handle( &sUARTSem );Task_Params_init( &TaskParams );TaskParams.stack= UART_TaskStack;TaskParams.stackSize = UART_TASK_STACK_SIZE;TaskParams.priority= UART_TASK_PRIORITY;Task_construct( &sUARTTask, SerialTaskFxn, &TaskParams, NULL ); */ gGUA_UART_WantedRxBytes = GUA_UART_MAX_NUM_RX_BYTES; // GUA_UART_Config[0].fxnTablePtr->readFxn(stGUA_UART_Handle,gaGUA_UART_RxBuf, gGUA_UART_WantedRxBytes); //SerialRead( hUART, &rxBuf2[0], 1); SerialRead(stGUA_UART_Handle,gaGUA_UART_RxBuf, gGUA_UART_WantedRxBytes); } void SerialDeinit() {if( NULL != hUART ){UART_readCancel( hUART );UART_close( hUART );Task_destruct( &sUARTTask );} } int SerialSend( UART_Handle handle, void *buf, size_t count ) {int ret;ret = UART_write( handle, buf, count );return ret; } int SerialRead( UART_Handle handle, void *buf, size_t count ) {int ret;// ret = UART_read( handle, buf, count );ret = GUA_UART_Config[0].fxnTablePtr->readFxn(handle,buf, count);return ret; } //2018-4-24 //int SerialSendSimple( void *buf, size_t count ) int SerialSendSimple( void *buf, uint16_t count ) {int ret;//2018-5-11if( NULL != stGUA_UART_Handle )ret = GUA_UART_Config[0].fxnTablePtr->writeFxn(stGUA_UART_Handle,buf, count ); //if( NULL != hUART ) //ret = UART_write( hUART, buf, count );return ret; } int DBG_Print(void *buf, uint16_t count) { // return SerialSendSimple(buf,count); return 0; } void SerialReadCallback( UART_Handle handle, void *buf, size_t count ) {size_t i;for( i = 0; i < count; i ++ ){rxBuf[ rxWRAddr ++ ] = ( ( uint8_t * )buf )[ i ];if( sizeof( rxBuf ) <= rxWRAddr )rxWRAddr = 0;} // Semaphore_post( hUARTSem ); GUA_UART_Config[0].fxnTablePtr->readFxn(stGUA_UART_Handle,gaGUA_UART_RxBuf, gGUA_UART_WantedRxBytes); } //void SerialWriteCallback( UART_Handle handle, void *buf, size_t count ) //{ // //} uint8_t SerialGetRxData() {uint8_t ret;if( rxRDAddr != rxWRAddr ){ret = rxBuf[ rxRDAddr ++ ];}else{} //!< equalif( sizeof( rxBuf ) <= rxRDAddr )rxRDAddr = 0;return ret; } void SerialGetRxBuf(uint8 *buf, uint16 len) {uint8_t i;for(i=0;i<len;i++) *buf++ = SerialGetRxData(); } //2018-4-24 //uint8_t SerialGetRxLen() uint16_t SerialGetRxLen() {if( rxRDAddr != rxWRAddr ){return ( ( rxWRAddr > rxRDAddr ) ? ( rxWRAddr - rxRDAddr ) : ( sizeof( rxBuf ) - rxRDAddr + rxWRAddr ) );}return 0; } void SerialReceiveProcess() {switch( transMode ){case eCTRL_MODE:ProtocolForCTRL();break;case eBULK_MODE:ProtocolForBulk();break;default:break;} } void SerialTaskFxn( UArg a0, UArg a1 ) {/* init task */for (;;){ //2018-5-11 //SerialRead( hUART, &rxBuf2[0], 1 ); GUA_UART_Config[0].fxnTablePtr->readFxn(stGUA_UART_Handle,gaGUA_UART_RxBuf, gGUA_UART_WantedRxBytes);Semaphore_pend( hUARTSem, BIOS_WAIT_FOREVER );//2018-4-11// receive process //SerialReceiveProcess();} } void ProtocolForBulk() { // if( 20 <= SerialGetRxLen() ) //SerialBulkEvent( transMode ); } typedef struct {uint8_t u8DatNo;uint8_t u8Data[26]; }_AlcoPrint_Data; _AlcoPrint_Data *pAlcoPrint_Data; void ProtocolForCTRL() {static uint8_t lastDat = 0;static uint8_t frameBeginFlag = FALSE;static uint8_t frameLength = 0;static uint8_t tmpBuf[64];static uint8_t tmpBufCnt;uint8_t curDat;uint8_t checksum[2]; //2018-3-19 /*curDat = SerialGetRxData();if( TRUE == frameBeginFlag ){if( 0 != frameLength ){tmpBuf[tmpBufCnt ++] = curDat;frameLength --;if(frameLength == 0) //receive all data complete{frameBeginFlag = FALSE;GenerateChecksum( checksum, 0, tmpBuf, tmpBuf[2] - 2 );if( ( tmpBuf[tmpBuf[2] - 1] == checksum[1] ) &&( tmpBuf[tmpBuf[2] - 2] == checksum[0] ) ){switch( tmpBuf[3] ){case 0x14: //!< ready or not?if( ( 0x07 == tmpBuf[2] ) && ( 0x01 == tmpBuf[4] ) ){}break;case 0x88: //!< modeif( 0x07 == tmpBuf[2] ){BluetoothSwitch( ON ); //transMode = ( _transMode )tmpBuf[4];GenerateChecksum( tmpBuf, tmpBuf[2] - 2, tmpBuf, tmpBuf[2] - 2 );SerialSendSimple( tmpBuf, tmpBuf[2] );}break;case 0x04: //!< swverif( ( 0x07 == tmpBuf[2] ) && ( 0x05 == tmpBuf[4] ) ){DevInfo_GetParameter( DEVINFO_SOFTWARE_REV, tmpBuf + 5 );tmpBuf[2] = 0x0F;GenerateChecksum( tmpBuf, tmpBuf[2] - 2, tmpBuf, tmpBuf[2] - 2 );SerialSendSimple( tmpBuf, tmpBuf[2] );}break;default:break;}}}}else{if( curDat > 5 ) //length of frame{frameLength = curDat - 3;tmpBufCnt = 0;tmpBuf[tmpBufCnt ++] = 0xfa;tmpBuf[tmpBufCnt ++] = 0xf5;tmpBuf[tmpBufCnt ++] = curDat;}else{frameBeginFlag = FALSE;}}}else{if( ( 0xFA == lastDat ) && ( 0xF5 == curDat ) ){frameBeginFlag = TRUE;}}lastDat = curDat;*/attWriteReq_t AttReq;curDat = SerialGetRxData(); // tmpBuf[tmpBufCnt++] = curDat; AttReq.pValue[tmpBufCnt++] = curDat;if(tmpBufCnt>=20){ //2018-4-10 // memcpy(&AttReq.pValue,tmpBuf,tmpBufCnt); AttReq.handle = charHdl +1 ;// 0x0035;//0xFFE9;//simpleBLECharHdl; AttReq.len =tmpBufCnt;//20;// SIMPLEPROFILE_CHAR6_LEN; AttReq.sig = 0; AttReq.cmd = 0; GATT_WriteNoRsp( simpleBLEConnHandle, &AttReq ); /***************************/ // SerialSendSimple(tmpBuf,tmpBufCnt); tmpBufCnt = 0;} } //static uint8 beginFlag = 0; uint8 beginFlag = 0; void ProtocolForCTRL2() {static uint8 frameStart;static uint8 frameCount;if( beginFlag ){ //attHandleValueNoti_t nData; //attWriteReq_t AttReq;uint16 recLen = SerialGetRxLen();uint16 len = 0; if(recLen) { /* len = ( recLen > SIMPLEPROFILE_CHAR6_LEN ) ? SIMPLEPROFILE_CHAR6_LEN : recLen; // AttReq.value[0] = len; HalUARTRead (port, AttReq.value, len); // if(strstr(AttReq.value,Ptinter_FrameEnd)==NULL) { AttReq.handle = simpleBLECharHdl +1;// 0x0035;//0xFFE9;//simpleBLECharHdl; // AttReq.len =SIMPLEPROFILE_CHAR6_LEN;//20;// SIMPLEPROFILE_CHAR6_LEN; AttReq.len =len;//20;// SIMPLEPROFILE_CHAR6_LEN; AttReq.sig = 0; AttReq.cmd = 0; // osal_memcpy(&AttReq.value[1],nData.value,nData.len); // osal_memcpy(AttReq.value,nData.value,nData.len); GATT_WriteCharValue( 0, &AttReq, simpleBLETaskId ); // HalUARTWrite(HAL_UART_PORT_1,AttReq.value, len); } */ }}else{if ( SerialGetRxLen() >= 8 ){ //(void)SerialRead (port, pAlcoPrint_Data->u8Data, 1);SerialRead( hUART, pAlcoPrint_Data->u8Data, 1); //(void)HalUARTRead (port, pAlcoPrint_Data->u8Data, 26);if( pAlcoPrint_Data->u8Data[0] == 0x1b ){ //(void)HalUARTRead (port, pAlcoPrint_Data->u8Data + 1, 25);SerialRead( hUART, pAlcoPrint_Data->u8Data+ 1, 7);if((pAlcoPrint_Data->u8Data[6] == 0x0d) && (pAlcoPrint_Data->u8Data[7] == 0x0a)){if((pAlcoPrint_Data->u8Data[0] == 0x1b) && (pAlcoPrint_Data->u8Data[1] == 0x40) &&(pAlcoPrint_Data->u8Data[4] == 0x1b) && (pAlcoPrint_Data->u8Data[5] == 0x40)){beginFlag = 1; //Uart_SendMsg(UART_Conn,0);pAlcoPrint_Data->u8DatNo = 0; //timeoutFlag = TRUE; //osal_start_timerEx( sendMsgTo_TaskID, 4, 1 );}}}else{return;}}} } /* //void Uart_SendMsg(uint8 cmd,uint8 data) void Uart_SendMsg(uint8_t event, uint8_t state) { // sappPacket_t *msgPkt;msgPkt = (sappPacket_t *)osal_msg_allocate( sizeof(sappPacket_t) );if ( msgPkt ){msgPkt->hdr.event = UART_MESSAGE;msgPkt->cmd = cmd;msgPkt->data = data;osal_msg_send( sendMsgTo_TaskID, (uint8 *)msgPkt );} // // sbpEvt_t *pMsg;// Create dynamic pointer to message.if ((pMsg = ICall_malloc(sizeof(sbpEvt_t)))){pMsg->hdr.event = event;pMsg->hdr.state = state;// Enqueue the message.Util_enqueueMsg(appMsgQueue, sem, (uint8*)pMsg);} // } */ /* void BluetoothSwitch( bool val ) {uint8_t advertising;gaprole_States_t gapRole_state;GAPRole_GetParameter( GAPROLE_STATE, &gapRole_state );GAPRole_GetParameter( GAPROLE_ADVERT_ENABLED, &advertising );// terminates the existing connectionif( OFF == val ){if( gapRole_state == GAPROLE_CONNECTED ){GAPRole_TerminateConnection();}if( OFF != advertising ){advertising = OFF;// turn off advertisingGAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8_t ), &advertising );}}else{if( ( gapRole_state != GAPROLE_CONNECTED ) && ( ON != advertising ) ){advertising = ON;// turn on advertisingGAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8_t ), &advertising );}} } */ uint8 EstablishLink_Idx,EstablishLink_Flag; uint8 Scan_Flg ; #define TOTAL_COMMAND 4 char arCommand[TOTAL_COMMAND][10] = {"SCAN0","SCAN1","DISCONNET","CONNET"}; int FindCommand(uint8 *szCommand) {char *p;uint8 command;uint8 offset;for( int i = 0 ; i < TOTAL_COMMAND ; i ++){p = strstr(szCommand,&arCommand[i][0]) ;if(p!= NULL ){switch(i){ case 0 ://SCAN0 //Uart_SendMsg(UART_Disconn); SimpleCentral_doStopDiscovering(0); break; case 1 ://SCAN1//Uart_SendMsg(UART_Start);//SerialSendSimple("start discovery\r\n",17);SimpleCentral_doDiscoverDevices(0);break; case 2 ://DISCONNETbeginFlag = 0;Uart_SendMsg(UART_Terminate); break; case 3 ://CONNET if (simpleBLEState != BLE_STATE_CONNECTED) {command =(p[6]-0x30)*10; command += (p[7]-0x30); if(command<=scanRes) { EstablishLink_Idx = command; Uart_SendMsg(UART_Conn); EstablishLink_Flag = 1; } else { } } break; default: break;}break;}} } char tttxBuf[64]; void BLEProcessBulkEvent( ) {uint8_t txBuf[64];uint16_t txBufLen, i;uint16_t rxBufLen = SerialGetRxLen();uint16 timeOut;char* command;uint8_t status; //2018-6-1 if(rxBufLen>0) { if( rxBufLen > 20 ) txBufLen = 20; elsetxBufLen = rxBufLen; SerialGetRxBuf (txBuf, txBufLen); command=strstr(txBuf,"AT+"); if(command != NULL) { FindCommand(command+3); return; } } if( beginFlag ) {if( rxBufLen ){ attWriteReq_t AttReq; //FA F5 00 14 90 // if(txBuf[0] == 0xfa && txBuf[1] == 0xf5 && txBuf[4] == 0x90){ // uint8_t title_end[4] = {0x1b,0x40,0x1b,0x40}; // uint8_t send_temp[7]; // TS_VOC_DATA p; // SerialSendSimple(title_end,4); // while(voc_datas_output(&p)){ // memcpy(send_temp, (uint8_t*)&(p.voc), 7); // SerialSendSimple(send_temp,7); // } // SerialSendSimple(title_end,4); // } // else { AttReq.pValue = GATT_bm_alloc(simpleBLEConnHandle, ATT_WRITE_REQ, txBufLen, NULL); if ( AttReq.pValue != NULL ) { AttReq.handle = charHdl+1; AttReq.len = txBufLen; AttReq.sig = 0; //2018-4-24 //AttReq.cmd = 0; AttReq.cmd = 1; //SerialGetRxBuf(AttReq.pValue,txBufLen); memcpy(AttReq.pValue,txBuf,txBufLen); //2018-4-24 //status = GATT_WriteCharValue(simpleBLEConnHandle, &AttReq, selfEntity); status = GATT_WriteNoRsp(simpleBLEConnHandle, &AttReq); char pbuf[30]; sprintf(pbuf,"Send tick:%d\r\n",Clock_getTicks()); DBG_Print(pbuf,strlen(pbuf)); if ( status != SUCCESS ) { GATT_bm_free((gattMsg_t *)&AttReq, ATT_WRITE_REQ); } } } } } } /*if( rxBufLen ){if( rxBufLen > 20 ) txBufLen = 20;elsetxBufLen = rxBufLen;for( i = 0; i < txBufLen; i ++ )txBuf[i] = SerialGetRxData();timeOut = 0; //IS_READY( timeOut, ( SimpleProfile_SetParameter( CUSTOM_NOTIFICATION, txBufLen, &txBuf[0] ) != SUCCESS ) ); memcpy(&AttReq.pValue,txBuf,txBufLen); AttReq.handle = charHdl +1;// 0x0035;//0xFFE9;//simpleBLECharHdl; AttReq.len =txBufLen;//20;// SIMPLEPROFILE_CHAR6_LEN; AttReq.sig = 0; AttReq.cmd = 0; GATT_WriteCharValue( 0, &AttReq, selfEntity );} */ //2018-4-8 /* if( beginFlag ) {if( rxBufLen ){ attWriteReq_t AttReq;if( rxBufLen > CUSTOM_DATA_TRANSFER_LEN ) txBufLen = CUSTOM_DATA_TRANSFER_LEN;elsetxBufLen = rxBufLen; AttReq.pValue = GATT_bm_alloc(simpleBLEConnHandle, ATT_WRITE_REQ, txBufLen, NULL); // SerialGetRxBuf(txBuf, txBufLen); // command=strstr(txBuf,"AT+"); SerialGetRxBuf(AttReq.pValue,txBufLen); command=strstr(AttReq.pValue,"AT+"); if(command!=NULL) { FindCommand(command+3); } else {if ( AttReq.pValue != NULL ){AttReq.handle = charHdl+1;AttReq.len = txBufLen; //memcpy(AttReq.pValue,txBuf,txBufLen);AttReq.sig = 0; //2018-4-24 //AttReq.cmd = 0;AttReq.cmd = 1; //2018-4-24 //status = GATT_WriteCharValue(simpleBLEConnHandle, &AttReq, selfEntity);status = GATT_WriteNoRsp(simpleBLEConnHandle, &AttReq);if ( status != SUCCESS ){GATT_bm_free((gattMsg_t *)&AttReq, ATT_WRITE_REQ);}} }} } else { if(rxBufLen>0) { SerialGetRxBuf (txBuf, rxBufLen); command=strstr(txBuf,"AT+"); if(command!=NULL) { FindCommand(command+3); } } } } */
SerialInterface.h
Katherine Wang:
已为您联系TI工程师,稍后给您回复
,
Katherine Wang:
这种类型的问题通常是由于内存问题。我建议您参考此设备的调试并监视可用堆内存以确认这一点。
要解决此问题,我建议您过滤掉广告结果、缩短扫描时间等。