private void ATTClientFindInformationFoundEvent(object sender, Bluegiga.BLE.Events.ATTClient.FindInformationFoundEventArgs e) { String log = String.Format("ble_evt_attclient_find_information_found: connection={0}, chrhandle={1}, uuid=[ {2}]" + Environment.NewLine, e.connection, e.chrhandle, ByteArrayToHexString(e.uuid) ); Console.WriteLine(log); if (e.uuid.SequenceEqual(measurementUuid)) { Console.WriteLine(String.Format("Found measurement attribute w/UUID={0}: handle={1}", ByteArrayToHexString(e.uuid), e.chrhandle) + Environment.NewLine); att_handle_measurement = e.chrhandle; currentChar = e.uuid; } // check for subsequent client characteristic configuration (UUID=0x2902) else if (e.uuid.SequenceEqual(new Byte[] { 0x02, 0x29 }) && currentChar != null && currentChar.SequenceEqual(measurementUuid)) { Console.WriteLine(String.Format("Found measurement control point attribute w/UUID=0x2902: handle={0}", e.chrhandle) + Environment.NewLine); att_handle_measurement_ccc = e.chrhandle; } else { currentChar = null; } }
//------------------------------------------------------------------------------------------------------------- // Event handler for the ATTClientFindInformationFound Event. // Here, a characteristics "group" has been found, and that group must be texted to determine if it is // the specific characteristics group we are interested in. public void ATTClientFindInformationFoundEvent(object sender, Bluegiga.BLE.Events.ATTClient.FindInformationFoundEventArgs e) { String log = String.Format("ble_evt_attclient_find_information_found: connection={0}, chrhandle={1}, uuid=[ {2}]" + Environment.NewLine, e.connection, e.chrhandle, ByteArrayToHexString(e.uuid) ); Console.Write(log); ThreadSafeDelegate(delegate { txtLog.AppendText(log); }); // Check for the specific heart rate measurement characteristic (UUID=0x2A37). // Ref: https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.heart_rate_measurement.xml // using the extension method SequenceEqual if (e.uuid.SequenceEqual(new Byte[] { 0x37, 0x2A })) { // Fount the desired charatceristic, so now record the characteristic's handle ThreadSafeDelegate(delegate { txtLog.AppendText(String.Format("Found attribute w/UUID=0x2A37: handle={0}", e.chrhandle) + Environment.NewLine); }); att_handle_measurement = e.chrhandle; } // Previously found the desired characteristic, so now // check for subsequent client characteristic configuration (UUID=0x2902). // Ref: https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.descriptor.gatt.client_characteristic_configuration.xml else if (e.uuid.SequenceEqual(new Byte[] { 0x02, 0x29 }) && att_handle_measurement > 0) { // Previously found the desired characteristic, // so now record the client characteristic configuration handle. ThreadSafeDelegate(delegate { txtLog.AppendText(String.Format("Found attribute w/UUID=0x2902: handle={0}", e.chrhandle) + Environment.NewLine); }); att_handle_measurement_ccc = e.chrhandle; } }
public void ATTClientFindInformationFoundEvent(object sender, Bluegiga.BLE.Events.ATTClient.FindInformationFoundEventArgs e) { String log = String.Format("ble_evt_attclient_find_information_found: connection={0}, chrhandle={1}, uuid=[ {2}]" + Environment.NewLine, e.connection, e.chrhandle, ByteArrayToHexString(e.uuid) ); Console.Write(log); // check for TX characteristic (UUID=0xfff6) if (e.uuid.SequenceEqual(new Byte[] { 0xf6, 0xff })) { Console.WriteLine(String.Format("Found attribute w/UUID=0xfff6: handle={0}", e.chrhandle) + Environment.NewLine); att_handle_tx = e.chrhandle; } else if (e.uuid.SequenceEqual(new Byte[] { 0xf7, 0xff })) { Console.WriteLine(String.Format("Found attribute w/UUID=0xfff7: handle={0}", e.chrhandle) + Environment.NewLine); att_handle_rx = e.chrhandle; } // check for subsequent client characteristic configuration (UUID=0x2902) else if (e.uuid.SequenceEqual(new Byte[] { 0x02, 0x29 }) && att_handle_rx > 0) { Console.WriteLine(String.Format("Found attribute w/UUID=0x2902: handle={0}", e.chrhandle) + Environment.NewLine); att_handle_rx_ccc = e.chrhandle; } }
// //查找子服务的应答事件,从中提取子服务内容; // public void EventFindInformationFound(object sender, Bluegiga.BLE.Events.ATTClient.FindInformationFoundEventArgs e) { //ThreadSafeDelegate(delegate { txtLog.AppendText(log); }); if (e.connection == c_BleDev.ConnHandle) { if (c_BleDev.IsDeclarePrimaryService(e.uuid))//e.uuid.SequenceEqual(new Byte[] { 0x00, 0x28 })) { } else if (c_BleDev.IsDeclareAttribute(e.uuid))//e.uuid.SequenceEqual(new Byte[] { 0x03, 0x28 })) { } else if (c_BleDev.IsDescClientConfig(e.uuid)) {//ClientCharacteristicConfiguration } else if (c_BleDev.IsDescUserAttribute(e.uuid)) {//Characteristic User Description if (c_BleDev.CurrentPrimSrv.AttrList.Count > 0) { c_BleDev.CurrentPrimSrv.AttrList[c_BleDev.CurrentPrimSrv.AttrList.Count - 1].UserDescHandle = e.chrhandle; } } else {//charactestic attribute if (c_BleDev.CurrentPrimSrv != null) { c_BleDev.CurrentPrimSrv.AddAttribute(c_BleDev.CurrentPrimSrv.UUID, DatConvert.ByteArrayToHexString(e.uuid), "", e.chrhandle); } } } }
/// <summary> /// Information (uuid) about char. found, have to determine which type. The CCC or standard char. uuid. /// </summary> /// <param name="sender"></param> /// <param name="e">FindInformationFoundEventArgs</param> public void ATTClientFindInformationFoundEvent(object sender, Bluegiga.BLE.Events.ATTClient.FindInformationFoundEventArgs e) { String log = String.Format("information_found: connection={0}, chrhandle={1}, uuid=[ {2}]" + Environment.NewLine, e.connection, e.chrhandle, ByteArrayToHexString(e.uuid) ); Console.Write(log); ThreadSafeDelegate(delegate { txtLog.AppendText(log); }); if (app_state == STATE_SEARCH_ATTRIBUTES) { notKnownattrContainer.Add((int)e.uuid[e.uuid.Count() - 4], e.chrhandle); // check for characteristics if (e.uuid.SequenceEqual(new Byte[] { 0x1b, 0xc5, 0xd5, 0xa5, 0x02, 0x00, 0x37, 0xa9, 0xe3, 0x11, 0xde, 0x88, 0x02, 0x00, 0x7e, 0x10 })) { ThreadSafeDelegate(delegate { txtLog.AppendText(String.Format("Found attribute {0} set handle: handle={0}", e.chrhandle) + Environment.NewLine); }); tmpCharContainer1.Handle = e.chrhandle; // att_handle_readOnly = 1; // att_List[att_Counter] = tmpCharContainer; att_Counter++; app_state = STATE_SEARCH_ATTRIBUTES_CCC; } else if (e.uuid.SequenceEqual(new Byte[] { 0x1b, 0xc5, 0xd5, 0xa5, 0x02, 0x00, 0x37, 0xa9, 0xe3, 0x11, 0xde, 0x88, 0x07, 0x00, 0x7e, 0x10 })) { ThreadSafeDelegate(delegate { txtLog.AppendText(String.Format("Found attribute {0} set handle: handle={0}", e.chrhandle) + Environment.NewLine); }); tmpCharContainer2.Handle = e.chrhandle; // att_handle_readOnly = 1; // att_List[att_Counter] = tmpCharContainer; att_Counter++; app_state = STATE_SEARCH_ATTRIBUTES_CCC; } } // check for subsequent client characteristic configuration (UUID=0x2902) else { if (app_state == STATE_SEARCH_ATTRIBUTES_CCC) { if (e.uuid.SequenceEqual(new Byte[] { 0x02, 0x29 })) { app_state = STATE_SEARCH_ATTRIBUTES; ThreadSafeDelegate(delegate { txtLog.AppendText(String.Format("Found attribute 0x2902 set ccc: handle={0}", e.chrhandle) + Environment.NewLine); }); if (!tmpCharContainer1.isCCCSet()) { tmpCharContainer1.Handle_ccc = e.chrhandle; } else //if (tmpCharContainer1.isCCCSet() && !tmpCharContainer2.isCCCSet()) { tmpCharContainer2.Handle_ccc = e.chrhandle; } } } } }
public void AttClientFindInfoEvent(object sender, Bluegiga.BLE.Events.ATTClient.FindInformationFoundEventArgs e) { String log = string.Format("Connection: {0}, Character Handle: {1}, UUID: {2}\r\n", e.connection, e.chrhandle, ByteArrayToHexString(e.uuid)); ThreadSafeDelegate(delegate { rtxtLog.AppendText(log); if (e.chrhandle == 26) { btnOpenSbrick.Enabled = true; } }); }
public void ATTClientFindInformationFoundEvent(object sender, Bluegiga.BLE.Events.ATTClient.FindInformationFoundEventArgs e) { String log = String.Format("ble_evt_attclient_find_information_found: connection={0}, chrhandle={1}, uuid=[ {2}]" + Environment.NewLine, e.connection, e.chrhandle, ByteArrayToHexString(e.uuid) ); //Console.Write(log); //ThreadSafeDelegate(delegate { txtLog.AppendText(log); }); if (debug) { SetLogText(log); } // check for heart rate measurement characteristic (UUID=0x2A37) if (e.uuid.SequenceEqual(new Byte[] { 0x37, 0x2A })) { //ThreadSafeDelegate(delegate { txtLog.AppendText(String.Format("Found attribute w/UUID=0x2A37: handle={0}", e.chrhandle) + Environment.NewLine); }); String logText = String.Format("Found attribute w/UUID=0x2A37: handle={0}", e.chrhandle) + Environment.NewLine; if (debug) { SetLogText(logText); } att_handle_measurement = e.chrhandle; } // check for subsequent client characteristic configuration (UUID=0x2902) else if (e.uuid.SequenceEqual(new Byte[] { 0x02, 0x29 }) && att_handle_measurement > 0) { //ThreadSafeDelegate(delegate { txtLog.AppendText(String.Format("Found attribute w/UUID=0x2902: handle={0}", e.chrhandle) + Environment.NewLine); }); String logText = String.Format("Found attribute w/UUID=0x2902: handle={0}", e.chrhandle) + Environment.NewLine; if (debug) { SetLogText(logText); } att_handle_measurement_ccc = e.chrhandle; } }
public void ATTClientFindInformationFoundEvent(object sender, Bluegiga.BLE.Events.ATTClient.FindInformationFoundEventArgs e) { String log = String.Format("ble_evt_attclient_find_information_found: connection={0}, chrhandle={1}, uuid=[ {2}]" + Environment.NewLine, e.connection, e.chrhandle, ByteArrayToHexString(e.uuid) ); Console.Write(log); ThreadSafeDelegate(delegate { txtLog.AppendText(log); }); if (e.uuid.SequenceEqual((new Byte[] { 0x19, 0xb1, 0x00, 0x12, 0xE8, 0xF2, 0x53, 0x7E, 0x4F, 0x6C, 0xD1, 0x04, 0x76, 0x8A, 0x01, 0x16 }).Reverse())) { ThreadSafeDelegate(delegate { txtLog.AppendText(String.Format("Found Lighthouse service: handle={0}", e.chrhandle) + Environment.NewLine); }); att_handle_measurement = e.chrhandle; } else if (e.uuid.SequenceEqual((new Byte[] { 0x19, 0xb1, 0x00, 0x14, 0xE8, 0xF2, 0x53, 0x7E, 0x4F, 0x6C, 0xD1, 0x04, 0x76, 0x8A, 0x01, 0x16 }).Reverse()) && att_handle_measurement > 0) { ThreadSafeDelegate(delegate { txtLog.AppendText(String.Format("Found IMU service: handle={0}", e.chrhandle) + Environment.NewLine); }); att_handle_measurement_ccc = e.chrhandle; } }
public void AttClientFindInfoEvent(object sender, Bluegiga.BLE.Events.ATTClient.FindInformationFoundEventArgs e) { String log = string.Format("Connection: {0}, Character Handle: {1}, UUID: {2}\r\n", e.connection, e.chrhandle, e.uuid); Log = log; RcvEventType = EventAttClientFindInfo; RcvResponseType = -1; int add = 0; byte[] inUint16 = new byte[2]; RcvByte[add++] = e.connection; inUint16 = BitConverter.GetBytes(e.chrhandle); RcvByte[add++] = inUint16[0]; RcvByte[add++] = inUint16[1]; for (int i = 0; i < e.uuid.Length; i++) { RcvByte[add++] = e.uuid[i]; } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void BLEATTClientFindInformationFoundEvent(object sender, Bluegiga.BLE.Events.ATTClient.FindInformationFoundEventArgs e) { Application.Current.Dispatcher.Invoke(delegate { MessageWriter.LogWrite("ble_evt_attclient_find_information_found: ", string.Format("connection={0}, chrhandle={1}, uuid={2}", e.connection, e.chrhandle, BitConverter.ToString(e.uuid))); BLEPeripheral peripheral; if (!connectedDevices.TryGetConnection(e.connection, out peripheral)) { MessageWriter.DebugWrite("Unable to find connection " + e.connection); return; } peripheral.AddNewAttribute(e.chrhandle, e.uuid); if (e.uuid.SequenceEqual(Bluetooth.Descriptors.ClientCharacteristicConfiguration)) { peripheral.attHandleCCC.Enqueue(e.chrhandle); } }); }