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.

2441主机无法向从机写数据



2441主机通过GATT_DiscCharsByUUID()获取到特性值的handl后,无法对该特性值写数据,返回的状态是error 3,请问是什么原因导致的呢

  • 读写主要使用GATT_WriteCharValue()和GATT_ReadCharValue().可参考协议栈中例程

        // If procedure complete
        if ( ( pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP  && 
               pMsg->hdr.status == bleProcedureComplete ) ||
             ( pMsg->method == ATT_ERROR_RSP ) )
        {
          if ( simpleBLESvcStartHdl != 0 )
          {
            // Discover characteristic
            simpleBLEDiscState = BLE_DISC_STATE_CHAR;
            
            req.startHandle = simpleBLESvcStartHdl;
            req.endHandle = simpleBLESvcEndHdl;
            req.type.len = ATT_BT_UUID_SIZE;
            req.type.uuid[0] = LO_UINT16(SIMPLEPROFILE_CHAR1_UUID);
            req.type.uuid[1] = HI_UINT16(SIMPLEPROFILE_CHAR1_UUID);

            GATT_ReadUsingCharUUID( simpleBLEConnHandle, &req, simpleBLETaskId );
          }
        }
      }
      else if ( simpleBLEDiscState == BLE_DISC_STATE_CHAR )
      {
        // Characteristic found, store handle
        if ( pMsg->method == ATT_READ_BY_TYPE_RSP && 
             pMsg->msg.readByTypeRsp.numPairs > 0 )
        {
          simpleBLECharHdl = BUILD_UINT16( pMsg->msg.readByTypeRsp.dataList[0],
                                           pMsg->msg.readByTypeRsp.dataList[1] );
          
          LCD_WRITE_STRING( "Simple Svc Found", HAL_LCD_LINE_1 );
          simpleBLEProcedureInProgress = FALSE;
        }
        
        simpleBLEDiscState = BLE_DISC_STATE_IDLE;

        
      }