public override void OnScanResult(ScanCallbackType callbackType, ScanResult res) { base.OnScanResult(callbackType, res); BES.beacon dad = new BES.beacon(); BluetoothDevice btd = res.Device; ScanRecord rec = res.ScanRecord; string mac = btd.Address; string nom = btd.Name; string cla = btd.BluetoothClass.ToString(); string bon = btd.BondState.ToString(); int rss = res.Rssi; string uui = ""; int tax = 3; IDictionary <ParcelUuid, byte[]> sda; if (nom == "OnyxBeacon") { sda = rec.ServiceData; uui = Retorna_UUID(sda).ToString(); } tax = rec.TxPowerLevel; dad.distancia = Calcula_Dist(rss, tax); dad.btd = btd; dad.nome = nom; dad.mac = mac; dad.rssi = rss; dad.taxa = tax.ToString(); dad.uuid = uui; dad.classe = cla; dad.bond = bon; bec[mac] = dad; }
protected void OnDeviceDiscovered(BluetoothDevice device, ScanRecord scanRecord, int rssi) { if (!_discoveredDevices.Any(d => device.Address == d.Address)) { _discoveredDevices.Add(device); DeviceDiscovered?.Invoke(this, new DeviceDiscoveredEventArgs(device, scanRecord, rssi)); } }
public static ushort GetMinorFromRecord(ScanRecord scanRecord) { byte[] recordByteData = scanRecord.GetBytes(); string minorStr = BitConverter.ToString(recordByteData, 27, 2).Replace("-", ""); ushort minor = Convert.ToUInt16(minorStr, 16); return(minor); }
public static short GetTxPowerFromRecord(ScanRecord scanRecord) { byte[] recordByteData = scanRecord.GetBytes(); string txPowerStr = BitConverter.ToString(recordByteData, 29, 1); short txPower = Convert.ToSByte(txPowerStr, 16); return(txPower); }
public static Guid GetUuidFromRecord(ScanRecord scanRecord) { byte[] recordByteData = scanRecord.GetBytes(); string uuidStr = BitConverter.ToString(recordByteData, 9, 4).Replace("-", "") + "-" + BitConverter.ToString(recordByteData, 13, 2).Replace("-", "") + "-" + BitConverter.ToString(recordByteData, 15, 2).Replace("-", "") + "-" + BitConverter.ToString(recordByteData, 17, 2).Replace("-", "") + "-" + BitConverter.ToString(recordByteData, 19, 6).Replace("-", ""); return(new Guid(uuidStr)); }
private Dictionary <Guid, byte[]> ProcessData(ScanRecord scanRecord) { var dict = new Dictionary <Guid, byte[]>(); foreach (var serviceData in scanRecord.ServiceData) { var guid = Guid.ParseExact(serviceData.Key.ToString(), "d"); var data = serviceData.Value; dict[guid] = data; } return(dict); }
public static bool IsIBeacon(ScanRecord scanRecord) { byte[] recordByteData = scanRecord.GetBytes(); if (recordByteData.Length > 30 && recordByteData[5] == 0x4c && recordByteData[6] == 0x00 && recordByteData[7] == 0x02 && recordByteData[8] == 0x15) { return(true); } return(false); }
protected ScanResult ToScanResult(BluetoothDevice native, int rssi, ScanRecord scanRecord) { if (scanRecord?.DeviceName == "FSC_BP103") { } var beacon = Beacon.ParseBeacon(scanRecord?.GetBytes()); var device = Device.GetDeviceInfo(native); //var dev = this.Devices.GetDevice(native); //var result = new ScanResult(dev, rssi, ad); var result = new ScanResult(Guid.Empty, rssi, device, beacon); return(result); }
private void ScanCallback_ScanResultEvent(BluetoothDevice device, int rssi, ScanRecord record) { // 同じアイテムならListに追加しない。 if (bleDevices.Count == 0) bleDevices.Add(new BleDeviceData { Name = device.Name, Id = device.Address }); else { foreach (var item in bleDevices) { if (!item.Id.Contains(device.Address)) bleDevices.Add(new BleDeviceData { Name = device.Name ?? "Unknown", Id = device.Address }); } } // MainThreadで処理する。 RunOnUiThread(() => { listView.Adapter = new SimpleListItem2_Adapter(this, bleDevices); }); }
public ScanRecord GetXRayRecord(string name) { // when an xray is taken, and the popup dialog is loaded, this is called to return the xray to display. // this should be a record who's time taken is null. then, a copy of that record should be added with a timestamp // on it, so if another is taken, the whole sequence can be kept. foreach (ScanRecord record in XRayRecords) { if (record.Name.ToLower() == name.ToLower () && (record.TimeTaken == null || record.TimeTaken == "" )){ ScanRecord newRecord = new ScanRecord(); newRecord.Name = record.Name; newRecord.Type = record.Type ; newRecord.Filename = record.Filename; // resource path or url for CT, an xml in resources of string[] image stack paths newRecord.Thumbnail = record.Thumbnail; // still frame for index/viewer newRecord.Region = record.Region; XRayRecords.Add (newRecord); // the dialog will timestamp this new one and future xrays will clone the null timestamp one... return newRecord; } } return null; }
public DeviceDiscoveredEventArgs(BluetoothDevice device, ScanRecord scanRecord, int rssi) { Device = device; Rssi = rssi; ScanRecord = scanRecord; }
public ScanEventArgs(BluetoothDevice device, int rssi, ScanRecord scanRecord) : this(device, rssi) { this.AdvertisementData = new AdvertisementData(scanRecord); }
/// <summary> /// Note the completion of a scan. /// This will result in a decrement of the number of available scans and an increment of the number /// of completed scans. /// </summary> /// <param name="scanRecord">a <see cref="ScanRecord"/> containing information about the scan</param> /// <returns><c>ScanCount</c> containing counts for the device; <c>null</c> if failure occurs</returns> /// <exception cref="HttpInvocationException">thrown when any HTTP status code other than /// 200 is returned by the server; fields in the exception hold the status code and /// error message returned</exception> /// <exception cref="InvocationException">thrown when an error occurs invoking the service /// on the server, prior to the service running</exception> /// <exception cref="MalformedUriException">thrown when a valid URI cannot be constructed /// from the base URI and additional relative path</exception> public ScanCount NoteScanCompletion(ScanRecord scanRecord) { return(Invoke <ScanRecord, ScanCount>("POST", "/complete", scanRecord)); }
public AdvertisementData(ScanRecord scanRecord) : this(scanRecord.GetBytes()) { }
void RemoveRecordByName(List<ScanRecord> list, ScanRecord record){ // this needs to only remove the null timestamp instance of the named record. foreach (ScanRecord test in list){ if (test.Name == record.Name && (test.TimeTaken == null || test.TimeTaken == "")){ list.Remove(test); return; } } }
public void LoadScanRecord(ScanRecord record){ switch(record.Type){ case eScanType.XRay: RemoveRecordByName(Record.XRayRecords, record); Record.XRayRecords.Add(record); break; case eScanType.FAST: RemoveRecordByName(Record.FastRecords, record); Record.FastRecords.Add(record); break; case eScanType.CT: RemoveRecordByName(Record.CTRecords, record); Record.CTRecords.Add(record); break; } }