Пример #1
0
 public void StartNotifications(Action <byte[]> action)
 {
     Ble.SubscribeCharacteristic(this.deviceAddress, this.serviceUUID, this.characteristicUUID, (address, characteristicUUID, bytes) =>
     {
         action(bytes);
     });
 }
Пример #2
0
 public void Scan(String[] serviceUUIDs, bool rssiOnly, Action <BLEPeripheralInterface> action)
 {
     Ble.StartScan(serviceUUIDs, (device_address, device_name, rssi, bytes) =>
     {
         action(new BLEMobilePeripheral(serviceUUIDs, device_address, device_name, rssi));
     });
 }
Пример #3
0
 public void ReadValue(Action <string, byte[]> action)
 {
     Ble.ReadCharacteristic(this.deviceAddress, this.serviceUUID, this.characteristicUUID, (address, characteristicUUID, bytes) =>
     {
         action(characteristicUUID, bytes);
     });
 }
Пример #4
0
        public async UniTask Disconnect(Action action)
        {
            Ble.DisconnectAllPeripherals();
            Ble.Finalize();
            await UniTask.Delay(500);

            action.Invoke();
        }
 /// <summary>
 /// peripheralに接続
 /// [peripheral:1 - characteristic:多]の関係なので、characteristicActionが複数回呼び出される
 /// </summary>
 public void Connect(Action <BLECharacteristicInterface> characteristicAction)
 {
     Ble.ConnectToPeripheral(this.device_address, OnConnected, null, (address, serviceUUID, characteristicUUID) =>
     {
         //Debug.Log("address=" + address + ". uuid=" + serviceUUID + ". chara=" + characteristicUUID);
         characteristicAction(new BLEMobileCharacteristic(this.device_address, serviceUUID, characteristicUUID));
     }, this.OnDisconnected);
 }
Пример #6
0
        public async UniTask Enable(bool enable, Action action)
        {
            Ble.EnableBluetooth(enable);
#if !UNITY_EDITOR && UNITY_ANDROID
            await UniTask.Delay(1000);
#else
            await UniTask.Delay(1);
#endif
            action.Invoke();
        }
Пример #7
0
        public void RequestDevice(Action <BLEDeviceInterface> action)
        {
            Ble.Initialize(() =>
            {
                action(new BLEMobileDevice());
            }, (error) =>
            {
#if !RELEASE
                Debug.LogErrorFormat("[BLEMobileService.requestDevice]error = {0}", error);
#endif
            });
        }
Пример #8
0
 public void StopScan()
 {
     Ble.StopScan();
 }
Пример #9
0
 public void DisconnectAll()
 {
     Ble.DisconnectAllPeripherals();
     Ble.Finalize();
 }
Пример #10
0
 void OnApplicationQuit()
 {
     Ble.DisconnectAllPeripherals();
     Ble.Finalize();
 }
 /// <summary>
 /// peripheralを切断
 /// </summary>
 public void Disconnect()
 {
     Ble.DisconnectPeripheral(this.device_address);
 }
Пример #12
0
 public void StopNotifications()
 {
     Ble.UnSubscribeCharacteristic(this.deviceAddress, this.serviceUUID, this.characteristicUUID, null);
 }
Пример #13
0
 public void WriteValue(byte[] data, bool withResponse)
 {
     Ble.WriteCharacteristic(this.deviceAddress, this.serviceUUID, this.characteristicUUID, data, data.Length, withResponse, null);
 }