public TWScanDevice_Item AddTWScanDevice_Item(string address, string name, string data = "") { foreach (TWScanDevice_Item g in G) { if (g.address.Equals(address)) { return(null); } } demo.gameObject.SetActive(false); TWScanDevice_Item i = MonoBehaviour.Instantiate(demo); i.Init(address, name, data); i.transform.SetParent(demo.transform.parent); i.gameObject.SetActive(true); i.transform.localScale = Vector3.one; G.Add(i); return(i); }
private IEnumerator GetAllInfor(float waitTime) { yield return(new WaitForSeconds(waitTime)); { CURRENT_STATIC = this; Debug.Log("TOAN2446: Trying to read " + LISTS.Count + " characteristics"); int c = 0; foreach (characteristicUUIDInfo i in LISTS) { is_get_info = false; GetAllCharacteristics(i.address, i.serviceUUID, i.characteristicUUID); while (!is_get_info) { yield return(new WaitForSeconds(0.05f)); } c++; Debug.Log("TOAN2447: Got " + c + "/" + LISTS.Count + " " + i.characteristicUUID); } } //if (loadingobject != null) Destroy(loadingobject); //TW.I.AddWarning("", "Obtained " + DICT_OBTAINED.Count + " characteristics, from address: " + address + " with name: " + name +"Current length: " + UserInformation.DEVICESAVEINFO.N.Get(), onclickyes); UserInformation.DEVICESAVEINFO.AddDeviceInfo(address, name, ""); DeviceInfo di = UserInformation.DEVICESAVEINFO.GetDeviceInfobyID(address); bool[] service_found = new bool[TWScanDevice.SUPPORTED_SERVICES.Length]; for (int i = 0; i < service_found.Length; i++) { service_found[i] = false; } if (di != null) { string s = ""; foreach (KeyValuePair <string, characteristicUUIDInfo> i in DICT_OBTAINED) { if (IsEqual(i.Value.characteristicUUID, "2a01") || IsEqual(i.Value.characteristicUUID, "2a02") || IsEqual(i.Value.characteristicUUID, "2a03") || IsEqual(i.Value.characteristicUUID, "2a04") || IsEqual(i.Value.characteristicUUID, "2a05") || IsEqual(i.Value.characteristicUUID, "2a9e") || IsEqual(i.Value.characteristicUUID, "2a2a")) { ; } else if (IsEqual(i.Value.characteristicUUID, "2a19")) { int batterry = -1; int.TryParse(i.Value.DATA, System.Globalization.NumberStyles.HexNumber, null, out batterry); i.Value.DATA = batterry.ToString(); } else { i.Value.DATA = System.Text.Encoding.ASCII.GetString(i.Value.DATA_bytes);// + " (" + i.Value.DATA.Length+") " + i.Value.DATA; } string serviceUUID_ = i.Value.serviceUUID; string characteristicUUID_ = i.Value.characteristicUUID; if (serviceUUID_.Length >= 32) { serviceUUID_ = serviceUUID_.Substring(4, 4); } if (characteristicUUID_.Length >= 32) { characteristicUUID_ = characteristicUUID_.Substring(4, 4); } s += serviceUUID_ + "," + characteristicUUID_ + "," + i.Value.DATA + "\n"; for (int i2 = 0; i2 < service_found.Length; i2++) { if (IsEqual(serviceUUID_, TWScanDevice.SUPPORTED_SERVICES[i2])) { service_found[i2] = true; } } } di.INFO.STR = s; di.Save(); } string my_service = ""; for (int i = 0; i < service_found.Length; i++) { if (service_found[i]) { my_service = TWScanDevice.SUPPORTED_SERVICES[i]; } } //UserInformation.DEVICESAVEINFO.AddDeviceInfo(address, name, my_service); di.SERVICE_UUID.STR = my_service; di.Save(); DeviceList.I.UpdateUI(); createWeighingDevice(null, di, DICT_OBTAINED); //if (loadingobject != null) Destroy(loadingobject); }