This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2540 串口透传 charHdl 和 Char value的设置

Other Parts Discussed in Thread: CC2540

最近在研究cc2540串口透传的案例,里面有一段是 central 发 “DISCON” 来断开和peripheral 的链接, 具体代码如下。

请问 (1) 为何要用charHdl[4]  (2) 为何要给char_reset.value [0] 到 char_reset.value [3] 置零?

非常感谢!

if(length>=1 && str_cmp(pBuffer,"DISCON",6)==0){
      // disconnect
    Flag_Device_Disconnect_Final = 1; 
    attWriteReq_t char_reset;  
        char_reset.handle = charHdl[4];
        char_reset.len = 4;     
        char_reset.value[0] = 0;     
        char_reset.value[1] = 0;  
        char_reset.value[2] = 0;  
        char_reset.value[3] = 0;  
        char_reset.sig = 0;     
        char_reset.cmd = 0;          
   GATT_WriteCharValue( simpleBLEConnHandle, &char_reset, simpleBLETaskId );   
      
   simpleBLEState = BLE_STATE_DISCONNECTING;
   gStatus = GAPCentralRole_TerminateLink( simpleBLEConnHandle );            
   return ; 
  }

 

x 出现错误。请重试或与管理员联系。