Esempio n. 1
0
        // Using device type decideds which device object to initilise, this allows for dynamic object creation.
        public static DeviceBase GetDeviceObject(DeviceInformation deviceInfo, DeviceType type)
        {
            DeviceBase device = null;

            // Main switch statement to handle the creation of the device objects.
            switch (type)
            {
            case DeviceType.GenericAccess:
                device = new GenericAccessDevice();
                break;

//中島追加
            case DeviceType.LightBlueBean:
                device = new LightBlueBeanDevice();
                break;
            }

            if (device == null)
            {
                // Display error if device does not have a value and return null.
                MessageHelper.DisplayBasicMessage(StringResources.InitialisationError);
                return(device);
            }

            device.Initialise(deviceInfo.Id);

            return(device);
        }
Esempio n. 2
0
        //中島追加
        public async void DeviceConnector(int cnt)
        {
            try
            {
                lightBlueBeanDevice = (LightBlueBeanDevice)DeviceHelper.GetDeviceObject(dInfoLightBlueBean[cnt], DeviceHelper.GetGuid("LightBlue Bean").Type);
                var characteristicsLightBlueBean = await lightBlueBeanDevice.GetCharacteristics(ServiceHandler.GetGuid("LightBlueBeanScratch1"));

                var characteristicLightBlueBean = characteristicsLightBlueBean.FirstOrDefault();
                lightBlueBeanDevice.LightBlueBeanScratch1_Measured += AddLightBlueBeanScratchData;

                StartCheckNotigficationTimer();
            }
            catch
            {
                MessageHelper.DisplayBasicMessage("センサとペアリングされていますか?");
            }
        }