1- using Buttplug . Core ;
1+ using Buttplug . Core ;
22using Buttplug . Core . Messages ;
33using Buttplug . Server . Bluetooth ;
44using JetBrains . Annotations ;
@@ -66,7 +66,7 @@ public UWPBluetoothDeviceInterface(
6666 _indexedChars . Add ( item . Key , c [ 0 ] ) ;
6767 }
6868 }
69- else if ( aChars . Length <= 2 )
69+ else
7070 {
7171 foreach ( var c in aChars )
7272 {
@@ -83,7 +83,7 @@ public UWPBluetoothDeviceInterface(
8383 }
8484 }
8585 }
86- else
86+ if ( _rxChar == null && _txChar == null && _indexedChars == null )
8787 {
8888 var err = $ "No characteristics to connect to for device { Name } ";
8989 _bpLogger . Error ( err ) ;
@@ -103,6 +103,14 @@ public async Task SubscribeToUpdates()
103103 {
104104 // Server has been informed of clients interest.
105105 }
106+ else
107+ {
108+ _bpLogger . Error ( $ "Cannot subscribe to BLE updates from { Name } : Failed Request") ;
109+ }
110+ }
111+ else
112+ {
113+ _bpLogger . Error ( $ "Cannot subscribe to BLE updates from { Name } : No Rx characteristic found.") ;
106114 }
107115 }
108116
@@ -224,8 +232,13 @@ private async Task<ButtplugMessage> WriteValue(uint aMsgId,
224232
225233 private async Task < ( ButtplugMessage , byte [ ] ) > ReadValue ( uint aMsgId , GattCharacteristic aChar )
226234 {
227- var result = aChar . ReadValueAsync ( ) . GetResults ( ) . Value . ToArray ( ) ;
228- return ( new Ok ( aMsgId ) , result ) ;
235+ var result = await aChar . ReadValueAsync ( ) ;
236+ if ( result ? . Value == null )
237+ {
238+ return ( _bpLogger . LogErrorMsg ( aMsgId , Error . ErrorClass . ERROR_DEVICE , $ "Got null read from { Name } ") , null ) ;
239+ }
240+
241+ return ( new Ok ( aMsgId ) , result . Value . ToArray ( ) ) ;
229242 }
230243
231244 public void Disconnect ( )
0 commit comments