コード例 #1
0
        public async Task <ManufacturerData> GetManufacturerDataAsync()
        {
            var keyValuePair = (await _device.GetManufacturerDataAsync())?.FirstOrDefault();

            if (keyValuePair == null)
            {
                return(null);
            }

            return(new ManufacturerData()
            {
                Data = (byte[])keyValuePair.Value.Value, Id = keyValuePair.Value.Key
            });
        }
コード例 #2
0
ファイル: LPF2Hub.cs プロジェクト: windoze/blego
        private static async Task <LPF2Hub?> CreateHubInstance(IDevice1 dev)
        {
            var data = await dev.GetManufacturerDataAsync();

            if (!data.ContainsKey(0x0397))
            {
                // Not a LEGO product
                return(null);
            }

            var     typeId = ((byte[])data[0x0397])[1];
            LPF2Hub?ret    = null;

            switch (typeId)
            {
            case 32:     // Duplo Train Base
                // TODO:
                break;

            case 64:     // LEGO Boost MoveHub
                ret = new MoveHub(dev);
                break;

            case 65:     // Powered Up Hub
                // TODO:
                break;

            case 66:     // Remote Controller
                // TODO:
                break;

            case 128:     // Technic Medium Hub
                ret = new TechnicMediumHub(dev);
                break;
            }

            if (ret == null)
            {
                // Unknown LEGO Hub
                return(null);
            }

            await ret.Initialize();

            return(ret);
        }