public override void AddDeviceButton(string name, string uuid) { if (UduinoManager.Instance.interfaceType == UduinoInterfaceType.None) { return; } GameObject deviceBtn = Instantiate(getDeviceButtonPrefab(), getPanel()); deviceBtn.transform.name = name; deviceBtn.transform.Find("DeviceName").transform.GetComponent <Text>().text = name; Button btn = deviceBtn.GetComponent <Button>(); deviceBtn.gameObject.SetActive(true); BLEDeviceButton_Interface deviceInterface = new BLEDeviceButton_Interface(btn); devicesButtons.Add(name, deviceInterface); // Add connect event btn.onClick.AddListener(() => boardConnection.ConnectPeripheral(uuid, name)); // Add disconnect event deviceInterface.disconnect.GetComponent <Button>().onClick.AddListener(() => UduinoManager.Instance.CloseDevice(name)); }
public override void UduinoConnected(string name) { BLEDeviceButton_Interface currentDeviceBtn = null; if (devicesButtons.TryGetValue(name, out currentDeviceBtn)) { DisplayDebugPanel(true); currentDeviceBtn.Connected(); } }
public override void UduinoConnecting(string name) { BLEDeviceButton_Interface currentDeviceBtn = null; if (devicesButtons.TryGetValue(name, out currentDeviceBtn)) { currentDeviceBtn.Connecting(); } Log.Info("connecting to " + name); }
public override void UduinoDisconnected(string name) { BLEDeviceButton_Interface currentDeviceBtn = null; if (devicesButtons.TryGetValue(name, out currentDeviceBtn)) { DisplayDebugPanel(false); currentDeviceBtn.Disconnected(); } else { // TODO : We close all of them if we don't find the good one, because sometimes NAME is send in behalf of identity foreach (KeyValuePair <string, BLEDeviceButton_Interface> a in devicesButtons) { a.Value.Disconnected(); } } }