public async Task SendAsync(RXSendMessage sendMsg)
        {
            var sendByteList = new List <byte>();

            sendByteList.AddRange(BitConverter.GetBytes(sendMsg.ChannelCode));
            sendByteList.AddRange(sendMsg.Bytes);

            await RfcommConnection.OutputStream.WriteAsync(sendByteList.ToArray(), 0, sendByteList.Count);

            await RfcommConnection.OutputStream.FlushAsync();
        }
 public Task <AttributeReadResult> ReadAsync(string attributeKey)
 {
     return(Task.Run(() =>
     {
         Guid requestGuid = Guid.NewGuid();
         AttributeReadRequest readRequest = new AttributeReadRequest
         {
             RequestKey = attributeKey,
             RequestGuid = requestGuid
         };
         var sendMsg = new RXSendMessage()
         {
             ChannelCode = ATTRIBUTE_CHANNEL_CODE,
             Bytes = readRequest.EncodeToBytesArray()
         };
         lock (_WaitingThreadDictLock)
         {
             _WaitingThreadDict.Add(requestGuid, new ThreadResponseBundle {
                 Thread = Thread.CurrentThread
             });
         }
         var sendTask = RemoteRXDevice.ConnectionManager.SendAsync(sendMsg);
         AttributeReadResult result;
         try
         {
             Thread.Sleep(SessionTimeOutInMs);
             result = new AttributeReadResult
             {
                 RequestGuid = requestGuid,
                 ReadState = AttributeReadState.Error
             };
         }
         catch (ThreadInterruptedException)
         {
             lock (_WaitingThreadDictLock)
             {
                 result = _WaitingThreadDict[requestGuid].Result;
             }
         }
         finally
         {
             _WaitingThreadDict.Remove(requestGuid);
         }
         return result;
     }));
 }