/// <summary> /// Connect to a TechnicMediumHub at specified MAC address /// </summary> /// <param name="address">The MAC address</param> /// <param name="timeout">The scan will stop after the period</param> /// <returns>TechnicMediumHub instance if the device is successfully found and connected</returns> public new static async Task <TechnicMediumHub?> Connect(string address, TimeSpan?timeout = null) { var device = await ScanAndConnectInternal(new ScanFilter(address), timeout); if (device == null) { return(null); } var ret = new TechnicMediumHub(device); await ret.Initialize(); return(ret); }
/// <summary> /// Scan and connect to a TechnicMediumHub /// </summary> /// <param name="timeout">The scan will stop after the period</param> /// <returns>TechnicMediumHub instance if the device is successfully found and connected</returns> public static async Task <TechnicMediumHub?> ScanAndConnect(TimeSpan?timeout = null) { var device = await ScanAndConnectInternal(new ScanFilter(name : "Technic Hub"), timeout); if (device == null) { return(null); } var ret = new TechnicMediumHub(device); await ret.Initialize(); return(ret); }
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); }