public iOSBluetoothDeviceProximityProbeCentralManagerDelegate(CBMutableService service, CBMutableCharacteristic characteristic, iOSBluetoothDeviceProximityProbe probe) { _service = service; _characteristic = characteristic; _probe = probe; _peripheralCentralTimestamps = new List <Tuple <CBPeripheral, CBCentralManager, DateTimeOffset> >(); }
public void Build(CBMutableService service) { this.native = new CBMutableCharacteristic( CBUUID.FromString(this.Uuid), this.properties, null, this.permissions ); service.Characteristics = service.Characteristics.Expand(this.native); if (this.onWrite != null) { this.manager.WriteRequestsReceived += this.OnWrite; } if (this.onRead != null) { this.manager.ReadRequestReceived += this.OnRead; } if (this.onSubscribe != null) { this.manager.CharacteristicSubscribed += this.OnSubscribed; this.manager.CharacteristicUnsubscribed += this.OnUnSubscribed; } }
public void Start(TracingInformation tracingInformation) { if (tracingInformation == null || _enabled) { return; } _tracingInformation = tracingInformation; _peripheralManager.RemoveAllServices(); CBUUID uuidService = CBUUID.FromString(tracingInformation.ServiceId); CBUUID uuidCharacteristic = CBUUID.FromString(tracingInformation.CharacteristicId); var data = NSData.FromArray(PayloadFormatter.GetBytesToSend(new PackageData(tracingInformation.DeviceId))); var characteristic = new CBMutableCharacteristic(uuidCharacteristic, CBCharacteristicProperties.Read, data, CBAttributePermissions.Readable); var service = new CBMutableService(uuidService, true); service.Characteristics = new CBCharacteristic[] { characteristic }; _peripheralManager.AddService(service); StartAdvertisingOptions advData = new StartAdvertisingOptions { ServicesUUID = new CBUUID[] { uuidService } }; _peripheralManager.StartAdvertising(advData); TracingState.Instance.SetAdvertisingState(true); _enabled = true; _logger.LogDebug("Advertising starting. DeviceId: " + _tracingInformation.DeviceId); }
public GattService(CBPeripheralManager manager, IGattServer server, Guid serviceUuid, bool primary) : base(server, serviceUuid, primary) { this.manager = manager; #if __TVOS__ #else this.Native = new CBMutableService(serviceUuid.ToCBUuid(), primary); #endif }
public void Start(BleDevice device, BleCharacteristic[] characteristics) { string dataServiceUUIDsKey = "71DA3FD1-7E10-41C1-B16F-4430B5060000"; string customBeaconServiceUUIDsKey = "71DA3FD1-7E10-41C1-B16F-4430B5060001"; string customBeaconCharacteristicUUIDKey = "71DA3FD1-7E10-41C1-B16F-4430B5060002"; string identifier = "71DA3FD1-7E10-41C1-B16F-4430B5060003"; peripheralManager = new CBPeripheralManager(this, DispatchQueue.DefaultGlobalQueue); peripheralManager.AdvertisingStarted += (sender, e) => { if (e.Error != null) { System.Diagnostics.Debug.WriteLine(string.Format("*** BleServer -> Advertising error: {0}", e.Error.Description)); } else { System.Diagnostics.Debug.WriteLine("*** BleServer -> We are advertising."); } }; var customBeaconServiceUUID = CBUUID.FromString(customBeaconServiceUUIDsKey); var customBeaconCharacteristicUUID = CBUUID.FromString(customBeaconCharacteristicUUIDKey); var service = new CBMutableService(customBeaconServiceUUID, true); var dataUUID = NSData.FromString(identifier, NSStringEncoding.UTF8); var characteristic = new CBMutableCharacteristic( customBeaconCharacteristicUUID, CBCharacteristicProperties.Read, dataUUID, CBAttributePermissions.Readable); service.Characteristics = new CBCharacteristic[] { characteristic }; peripheralManager.AddService(service); var localName = new NSString("CustomBeacon"); //var advertisingData = new NSDictionary( CBAdvertisement.DataLocalNameKey, localName, // CBAdvertisement.IsConnectable, false, // CBAdvertisement.DataManufacturerDataKey, CBUUID.FromString(dataServiceUUIDsKey), // CBAdvertisement.DataServiceUUIDsKey, CBUUID.FromString(dataServiceUUIDsKey)); //peripheralManager.StartAdvertising(advertisingData); var UUI = new CBUUID[] { CBUUID.FromString("71DA3FD1-7E10-41C1-B16F-4430B5060000") }; NSArray arry = NSArray.FromObjects(UUI); var test = NSObject.FromObject(arry); var ad = new NSDictionary(CBAdvertisement.DataServiceUUIDsKey, test); peripheralManager.StartAdvertising(ad); }
protected override async Task InitializeAsync() { await base.InitializeAsync(); // create device id characteristic _deviceIdCharacteristic = new CBMutableCharacteristic(CBUUID.FromString(DEVICE_ID_CHARACTERISTIC_UUID), CBCharacteristicProperties.Read, NSData.FromArray(Encoding.UTF8.GetBytes(SensusServiceHelper.Get().DeviceId)), CBAttributePermissions.Readable); // create service with device id characteristic _deviceIdService = new CBMutableService(CBUUID.FromString(Protocol.Id), true); _deviceIdService.Characteristics = new CBCharacteristic[] { _deviceIdCharacteristic }; }
public CBMutableService CreateService(bool isEncrypted = false) { var service = new CBMutableService(BluetoothServiceUuid.ChatServiceUuid, true); service.Characteristics = new CBCharacteristic[] { CreateMessageCharacteristic(isEncrypted), CreateConnectionInviteCharacteristic(isEncrypted), CreateStatusCharacteristic(isEncrypted), CreateNameCharacteristic(isEncrypted) }; return service; }
protected override void Initialize() { // the following code relies on SensusServiceHelper singleton, which will not be available above in the constructor. // create device id characteristic _deviceIdCharacteristic = new CBMutableCharacteristic(CBUUID.FromString(DEVICE_ID_CHARACTERISTIC_UUID), CBCharacteristicProperties.Read, NSData.FromArray(Encoding.UTF8.GetBytes(SensusServiceHelper.Get().DeviceId)), CBAttributePermissions.Readable); // create service with device id characteristic _deviceIdService = new CBMutableService(CBUUID.FromString(DEVICE_ID_SERVICE_UUID), true); _deviceIdService.Characteristics = new CBCharacteristic[] { _deviceIdCharacteristic }; }
public RemoteXServerForIos() { CBUUID[] cBUUIDs = new CBUUID[1]; CBUUID cBUUID = CBUUID.FromString("AD86E9A5-AB95-4D75-A4BC-2A969F26E028"); cBPeripheralManager = new CBPeripheralManager(); remoteService = new CBMutableService(cBUUID, true); cBPeripheralManager.AddService(remoteService); cBUUIDs.Append(cBUUID); var advertisingOption = new StartAdvertisingOptions { LocalName = "RemoteX Controller" }; advertisingOption.ServicesUUID = cBUUIDs; cBPeripheralManager.StartAdvertising(advertisingOption); }
public void Start_old(BleDevice device, BleCharacteristic[] characteristics) { try { if (device == null) { throw new Exception("Could not initialize server without a service description."); } if ((characteristics == null) || (characteristics.Length == 0)) { throw new Exception("Could not initialize server without characteristic descriptions."); } // setup a peripheral manager _PeripheralManager = new CBPeripheralManager(); var uuid = CBUUID.FromPartial(device.GuidValue); System.Diagnostics.Debug.WriteLine(string.Format("*** BleServer.Start - Device Guid: {0}", uuid.Uuid)); _Service = new CBMutableService(uuid, true); _Characteristics = characteristics.Select(ch => new CBMutableCharacteristic(CBUUID.FromPartial(ch.GuidValue), CBCharacteristicProperties.Read, null, CBAttributePermissions.Readable)).ToList(); _Service.Characteristics = _Characteristics.ToArray(); // register services _PeripheralManager.AddService(_Service); _PeripheralManager.AdvertisingStarted += (sender, e) => { if (e.Error != null) { System.Diagnostics.Debug.WriteLine(string.Format("*** BleServer -> Advertising error: {0}", e.Error.Description)); } else { System.Diagnostics.Debug.WriteLine("*** BleServer -> We are advertising."); } }; // advertise services var opt = new StartAdvertisingOptions(); opt.ServicesUUID = new CBUUID[] { _Service.UUID }; _PeripheralManager.StartAdvertising(opt); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(string.Format("*** BleServer.Start - Exception: {0}", ex)); } }
public iOSBluetoothDeviceProximityProbePeripheralManagerDelegate(CBMutableService service, CBMutableCharacteristic characteristic, iOSBluetoothDeviceProximityProbe probe) { _service = service; _characteristic = characteristic; _probe = probe; }
private void InitializeServices() { _service = _serviceProvider.CreateService(); _peripheralManager.AddService(_service); }
public void PublishServices(CBPeripheralManager peripheralManager, CBMutableService service) { peripheralManager.AddService(service); }