Exemple #1
0
        public static async Task RegisterGattApplication(ServerContext serverContext)
        {
            var gattServiceDescription = new GattServiceDescription
            {
                UUID    = "12345678-1234-5678-1234-56789abcdef0",
                Primary = true
            };

            var gattCharacteristicDescription = new GattCharacteristicDescription
            {
                CharacteristicSource = new ExampleCharacteristicSource(),
                UUID  = "12345678-1234-5678-1234-56789abcdef1",
                Flags = CharacteristicFlags.Read | CharacteristicFlags.Write | CharacteristicFlags.WritableAuxiliaries
            };
            var gattDescriptorDescription = new GattDescriptorDescription
            {
                Value = new[] { (byte)'t' },
                UUID  = "12345678-1234-5678-1234-56789abcdef2",
                Flags = new[] { "read", "write" }
            };
            var gab = new GattApplicationBuilder();

            gab
            .AddService(gattServiceDescription)
            .WithCharacteristic(gattCharacteristicDescription, new[] { gattDescriptorDescription });

            await new GattApplicationManager(serverContext).RegisterGattApplication(gab.BuildServiceDescriptions());
        }
Exemple #2
0
 public static GattService1Properties CreateGattService(GattServiceDescription serviceDescription)
 {
     return(new GattService1Properties
     {
         UUID = serviceDescription.UUID,
         Primary = serviceDescription.Primary,
         Characteristics = new ObjectPath[0]
     });
 }
Exemple #3
0
        private async Task <GattService> AddNewService(GattApplication application,
                                                       GattServiceDescription serviceDescription)
        {
            var gattService1Properties = GattPropertiesFactory.CreateGattService(serviceDescription);
            var gattService            = application.AddService(gattService1Properties);
            await _ServerContext.Connection.RegisterObjectAsync(gattService);

            return(gattService);
        }
Exemple #4
0
 public GattServiceBuilder(GattServiceDescription gattServiceServiceDescription)
 {
     ServiceDescription = gattServiceServiceDescription;
 }