Improve BLE robot command complete check.

parent fa473b8b
Pipeline #752 passed with stages
in 13 minutes and 42 seconds
......@@ -8,6 +8,8 @@
*/
pm.BLEPhysicalRobotConnector = pm.PhysicalRobotConnector.extend(/** @lends pm.BLEPhysicalRobot# */{
_currentCommand: "",
connect: function()
{
if(pm.btleManager && pm.btleManager.isBTLEAvailable())
......@@ -50,6 +52,7 @@ pm.BLEPhysicalRobotConnector = pm.PhysicalRobotConnector.extend(/** @lends pm.BL
return;
this._runningCommand = true;
this._currentCommand = command;
cc.log("Sending command to BLE Physical robot:" + command);
......@@ -59,6 +62,11 @@ pm.BLEPhysicalRobotConnector = pm.PhysicalRobotConnector.extend(/** @lends pm.BL
_dataReceiveCallback: function(data)
{
cc.log("Received response from BLE Physical robot:" + data);
this._runningCommand = false;
if(this._currentCommand && data.indexOf("ok_" + this._currentCommand ) !== -1)
{
this._currentCommand = "";
this._runningCommand = false;
}
}
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment