OAD update GATT write timeout
时间:10-02
整理:3721RD
点击:
Hi:
器件信息:
CC2541, BLE Stack v1.3.2, android app(based on sensortag source code),
connect interval: 50ms
我们遇到的问题
我们的使用OAD升级CC2541 的固件时,andorid app 会报错: GATT write timeout
问题描述:
我们每隔50ms写一次数据.
当我们一次写1块数据(16字节)时,OAD正常。
但是当我们一次写4块数据时, OAD 报错: GATT write timeout
我们的问题:
1: 据我所知:BLE GATT 每CONNECT event可以发送4个包(每个包数据长度不超过20个字节), 应此
应该能及时发送出去。
2: 数据写选择的是 WRITE_TYPE_NO_RESPONSE, 应该写入即可,即无需等待server返回,
andorid app 如何会超时呢?
mCharBlock.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE);
代码片段:
while (mProgramming) { try {Thread.sleep(SEND_INTERVAL); } catch (InterruptedException e) {e.printStackTrace(); } for (int i = 0; i < BLOCKS_PER_CONNECTION & mProgramming; i++) {programBlock(); } if ((mProgInfo.iBlocks % 100) == 0) {// Display statistics each 100th blockFwUpdateActivity.this.runOnUiThread(new Runnable() { public void run() { displayStats(); }}); }}
private void programBlock() { if (!mProgramming)return; if (mProgInfo.iBlocks < mProgInfo.nBlocks) { ......// Send blockmCharBlock.setValue(mOadBuffer);boolean success = mLeService.writeCharacteristic(mCharBlock); if (success) { // Update stats mProgInfo.iBlocks++; mProgInfo.iBytes += OAD_BLOCK_SIZE; mProgressBar.setProgress((mProgInfo.iBlocks * 100) / mProgInfo.nBlocks); // if (mProgInfo.iBlocks > 362) { if (!mLeService.waitIdle(GATT_WRITE_TIMEOUT)) {//mProgramming = false;//success = false;mLeService.mBusy=false; msg = "GATT write timeout :"+mProgInfo.iBlocks+"\n";FwUpdateActivity.this.runOnUiThread(new Runnable() { public void run() { mLog.append(msg); }}); } } else { mProgramming = false; msg = "GATT writeCharacteristic failed\n";}...... } else {mProgramming = false; } ......... }
感谢各位的回复与解答!
首先建议您升级到最新的协议栈1.4.1
其次请问您是使用BTOOL还是Device Monitor作为主端操作OAD升级的呢?
如果是以上两种之一,PC端可以看到log的,请问现象是什么?
如果是手机操作的建议您sniffer抓空口数据分析一下失败原因