Пример #1
0
 private void handleBleConnecting()
 {
     BleApi.Service    service = new BleApi.Service();
     BleApi.ScanStatus status;
     do
     {
         status = BleApi.PollService(out service, false);
         if (status == BleApi.ScanStatus.AVAILABLE)
         {
             Debug.Log("Found service: " + service.uuid);
             string uuid = service.uuid.Replace("{", null).Replace("}", null);
             if (uuid.Equals(SERVICE_UUID, StringComparison.OrdinalIgnoreCase))
             {
                 /* Service found, subscribe to updates from TX char */
                 BleApi.SubscribeCharacteristic(truetouchDevice.id, SERVICE_UUID, TX_CHAR_UUID, false);
                 state = BleState.CONNECTED;
                 Debug.Log("Connected to TrueTouch");
                 return;
             }
         }
         else if (status == BleApi.ScanStatus.FINISHED)
         {
             /* Couldn't find target service on the device */
             errorString = "Could not find NUS service on TrueTouch";
             state       = BleState.ERROR;
         }
     } while (status == BleApi.ScanStatus.AVAILABLE);
 }
Пример #2
0
 public void Subscribe()
 {
     // no error code available in non-blocking mode
     BleApi.SubscribeCharacteristic(selectedDeviceId, selectedServiceId, selectedCharacteristicId, false);
     isSubscribed = true;
 }