@@ -536,7 +536,9 @@ public void onMethodCall(MethodCall call, Result result) {
536536 characteristic = locateCharacteristic (gattServer , request .getServiceUuid (), request .getSecondaryServiceUuid (), request .getCharacteristicUuid ());
537537 cccDescriptor = characteristic .getDescriptor (CCCD_ID );
538538 if (cccDescriptor == null ) {
539- throw new Exception ("could not locate CCCD descriptor for characteristic: " +characteristic .getUuid ().toString ());
539+ //Some devices - including the widely used Bluno do not actually set the CCCD_ID.
540+ //thus setNotifications works perfectly (tested on Bluno) without cccDescriptor
541+ log (LogLevel .INFO , "could not locate CCCD descriptor for characteristic: " + characteristic .getUuid ().toString ());
540542 }
541543 } catch (Exception e ) {
542544 result .error ("set_notification_error" , e .getMessage (), null );
@@ -567,14 +569,16 @@ public void onMethodCall(MethodCall call, Result result) {
567569 return ;
568570 }
569571
570- if (!cccDescriptor .setValue (value )) {
571- result .error ("set_notification_error" , "error when setting the descriptor value to: " + value , null );
572- return ;
573- }
572+ if (cccDescriptor != null ) {
573+ if (!cccDescriptor .setValue (value )) {
574+ result .error ("set_notification_error" , "error when setting the descriptor value to: " + value , null );
575+ return ;
576+ }
574577
575- if (!gattServer .writeDescriptor (cccDescriptor )) {
576- result .error ("set_notification_error" , "error when writing the descriptor" , null );
577- return ;
578+ if (!gattServer .writeDescriptor (cccDescriptor )) {
579+ result .error ("set_notification_error" , "error when writing the descriptor" , null );
580+ return ;
581+ }
578582 }
579583
580584 result .success (null );
0 commit comments