private void ListenOnCtrl() { Program.Debug.WriteLine("ListenOnCtrl started"); ushort ctrlCid = _cidCtrl; for (; ;) { byte[] ucBuffer = new byte[1024]; uint cSize = 0; Program.Debug.WriteLine("Try Read CTRL"); int iErr = L2CAPAPI.L2CAPRead(ctrlCid, (uint)ucBuffer.Length, ref cSize, ucBuffer); Program.Debug.WriteLine(String.Format("Read CTRL : {0} [cSize={1}, ucBuffer[0] = {2}]", iErr, cSize, (cSize > 0) ? ucBuffer[0] : -1)); if (iErr != 0) { Disconnect(); break; } if (cSize > 0 && 0 != (ucBuffer[0] & 0x70)) { byte[] szBuffer = new byte[1]; szBuffer[0] = 0; iErr = L2CAPAPI.L2CAPWrite(ctrlCid, 1, szBuffer); Program.Debug.WriteLine("Write CTRL: Responding to 0x70: " + iErr); _state = 1; } else if (cSize > 0 && 0 != (ucBuffer[0] & 0x90)) { byte[] szBuffer = new byte[1]; szBuffer[0] = 0; iErr = L2CAPAPI.L2CAPWrite(ctrlCid, 1, szBuffer); Program.Debug.WriteLine("Write CTRL: Responding to 0x90: " + iErr); _state = 1; } else { byte[] szBuffer = new byte[1]; szBuffer[0] = 0; iErr = L2CAPAPI.L2CAPWrite(ctrlCid, 1, szBuffer); Program.Debug.WriteLine("Write CTRL: No Response"); } } }
private void ListenOnIntr() { Program.Debug.WriteLine("ListenOnIntr started"); ushort intrCid = _cidIntr; for (; ;) { byte[] ucBuffer = new byte[1024]; uint cSize = 0; Program.Debug.WriteLine("Try Read INTR"); int iErr = L2CAPAPI.L2CAPRead(intrCid, (uint)ucBuffer.Length, ref cSize, ucBuffer); Program.Debug.WriteLine("Read INTR : " + iErr); if (iErr != 0) { Disconnect(); break; } } }