private IEnumerator Start()
    {
        yield return(new WaitForSeconds(3));

        BLEService.Initialize(() =>
        {
            Debug.Log("### Initialized");
            BLEService.StartScan(device =>
            {
                if (device.Name.Equals("UARTService"))
                {
                    BLEService.ConnectToDevice(device,
                                               characteristic =>
                    {
                        Debug.Log(characteristic.CharacteristicUuid);
                        if (characteristic.CharacteristicUuid.Equals(CharacteristicUuid))
                        {
                            BLEService.Subscribe(characteristic, OnDataReceived);
                        }
                    },
                                               disconnectedAddress => { Debug.Log($"### Device Disconnected: {disconnectedAddress}"); });
                }
            });
        },
                              error =>
        {
            Debug.Log("### Intialization error");
        });
        // UARTService
    }
示例#2
0
 private void PrintAvailableDevicesList()
 {
     foreach (BLEService.Device device in devices)
     {
         if (GUILayout.Button(device.Name))
         {
             BLEService.ConnectToDevice(device,
                                        characteristic => { characteristics.Add(characteristic); },
                                        disconnectedAddress => { Debug.Log($"Device Disconnected: {disconnectedAddress}"); });
         }
     }
 }