0
let descriptor_uuid_configure: CBUUID = CBUUID(string: CBUUIDCharacteristicUserDescriptionString)
let descriptor = CBMutableDescriptor(type: descriptor_uuid_configure, value: nil)
    
let dataSenderCharacteristic = CBMutableCharacteristic(type: CBUUID(string: Constants.CHARACTERISTICS_UUID_DATA_SENDER.rawValue), properties: [.read, .notify], value: nil, permissions: [.readable])
    dataSenderCharacteristic.descriptors = [descriptor]
    
let eventControlCharacteristic = CBMutableCharacteristic(type: CBUUID(string: Constants.CHARACTERISTICS_UUID_CONTROL.rawValue), properties: [.read, .notify], value: nil, permissions: [.readable])
    eventControlCharacteristic.descriptors = [descriptor]
    
let pingMessageCharacteristic = CBMutableCharacteristic(type: CBUUID(string: Constants.CHARACTERISTICS_UUID_PING.rawValue), properties: [.read, .notify], value: nil, permissions: [.readable])
    pingMessageCharacteristic.descriptors = [descriptor]
    
let bleService = CBMutableService(type: CBUUID(string: Constants.SERVICE_BLE_GATT.rawValue), primary: true)
    
bleService.characteristics = [dataSenderCharacteristic, eventControlCharacteristic, pingMessageCharacteristic]
peripheralManager?.add(bleService)

This is my code to add descriptor and characteristics for my bleperipheral iOS application.

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Expecting NSString value type for User Description descriptor'
*** First throw call stack:
(0x1d8c2de88 0x1d1f638d8 0x1d3551b4c 0x1f8c535e0 0x10011dd98
0x100118c38 0x10011861c 0x100119c88 0x100119e00 0x1f8c769a0
0x1d30483f0 0x1d305e8d4 0x1d304b860 0x1d304b590 0x1d304a518
0x1f8c21620 0x1f8c20718 0x1f8c20690 0x1006b45a8 0x1006b605c 0x1006be10c 0x1006bee68 0x1006c6670 0x1006c6354 0x1d8cbe6f8
0x1d8ca0058 0x1d8ca4ed4 0x211fa6368 0x1db1833d0 0x1db183034
0x1e1773308 0x100120548 0x1001204d0 0x10012063c 0x1f730c960)
libc++abi: terminating with uncaught exception of type NSException *** Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: 'Expecting NSString value type for User Description descriptor' terminating with uncaught exception of type NSException.

Getting the above thread while run the code.Please let me know the solution for the above problem.

HangarRash
  • 7,314
  • 5
  • 5
  • 32
Anjali
  • 1
  • 1
  • `CBMutableDescriptor(type: descriptor_uuid_configure, value: nil)` -> `CBMutableDescriptor(type: descriptor_uuid_configure, value: "test")`? – Larme Dec 30 '22 at 13:40

0 Answers0