void HandleDidReceiveDataEvent(byte[] data, int numOfBytes) { Debug.Log("AppControllerBehavior: HandleOnBleDidReceiveDataEvent: size: " + numOfBytes); if (numOfBytes == 1 && data[0] == 0xfe) { Debug.Log("Command correctly received. Can send next command."); if (currentCommandIndex >= listOfCommands.Length) { currentCommandIndex = 0; } lastCommand = listOfCommands[currentCommandIndex]; currentCommandIndex += 1; //send last command in 3 seconds! if (isTrasmissionActive) { transmissionCoroutine = StartCoroutine(SendLastCommandAfterDelay(3)); } } else if (isTrasmissionActive && numOfBytes == 1 && data[0] == 0xdf) { Debug.Log("There was an error sending the command. Retry to send last command."); BLEController.SendData(lastCommand); } }
void HandleOnBleDidConnectEvent() { searchBleDevicesButton.GetComponent <Button>().enabled = true; byte[] resetSignal = new byte[] { 0xfe, 0xfe, 0xfe }; BLEController.SendData(resetSignal); }
IEnumerator SendUpdateDataCommand(int delay) { yield return(new WaitForSeconds(delay)); BLEController.SendData(updateDataCommand); }
public void StopMeteoUpdates() { BLEController.SendData(stopCommand); }
void HandleConnectionEstablishedEvent() { isTrasmissionActive = true; BLEController.SendData(resetCommand); }
public void StopRobot() { isTrasmissionActive = false; BLEController.SendData(resetCommand); }
IEnumerator SendLastCommandAfterDelay(int delay) { yield return(new WaitForSeconds(delay)); BLEController.SendData(lastCommand); }