public void StartNotifications(Action <byte[]> action) { Ble.SubscribeCharacteristic(this.deviceAddress, this.serviceUUID, this.characteristicUUID, (address, characteristicUUID, bytes) => { action(bytes); }); }
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)); }); }
public void ReadValue(Action <string, byte[]> action) { Ble.ReadCharacteristic(this.deviceAddress, this.serviceUUID, this.characteristicUUID, (address, characteristicUUID, bytes) => { action(characteristicUUID, bytes); }); }
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); }
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(); }
public void RequestDevice(Action <BLEDeviceInterface> action) { Ble.Initialize(() => { action(new BLEMobileDevice()); }, (error) => { #if !RELEASE Debug.LogErrorFormat("[BLEMobileService.requestDevice]error = {0}", error); #endif }); }
public void StopScan() { Ble.StopScan(); }
public void DisconnectAll() { Ble.DisconnectAllPeripherals(); Ble.Finalize(); }
void OnApplicationQuit() { Ble.DisconnectAllPeripherals(); Ble.Finalize(); }
/// <summary> /// peripheralを切断 /// </summary> public void Disconnect() { Ble.DisconnectPeripheral(this.device_address); }
public void StopNotifications() { Ble.UnSubscribeCharacteristic(this.deviceAddress, this.serviceUUID, this.characteristicUUID, null); }
public void WriteValue(byte[] data, bool withResponse) { Ble.WriteCharacteristic(this.deviceAddress, this.serviceUUID, this.characteristicUUID, data, data.Length, withResponse, null); }