コード例 #1
0
    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);
        }
    }
コード例 #2
0
    void HandleOnBleDidConnectEvent()
    {
        searchBleDevicesButton.GetComponent <Button>().enabled = true;

        byte[] resetSignal = new byte[] { 0xfe, 0xfe, 0xfe };

        BLEController.SendData(resetSignal);
    }
コード例 #3
0
    IEnumerator SendUpdateDataCommand(int delay)
    {
        yield return(new WaitForSeconds(delay));

        BLEController.SendData(updateDataCommand);
    }
コード例 #4
0
 public void StopMeteoUpdates()
 {
     BLEController.SendData(stopCommand);
 }
コード例 #5
0
 void HandleConnectionEstablishedEvent()
 {
     isTrasmissionActive = true;
     BLEController.SendData(resetCommand);
 }
コード例 #6
0
 public void StopRobot()
 {
     isTrasmissionActive = false;
     BLEController.SendData(resetCommand);
 }
コード例 #7
0
    IEnumerator SendLastCommandAfterDelay(int delay)
    {
        yield return(new WaitForSeconds(delay));

        BLEController.SendData(lastCommand);
    }