Missing “value” in didUpdateValueFor

Hello there. We are writing an iPad app (in swift) to monitor another iPad app (older, written in objective C) via BLE.

I've added some BLE peripheral functionality to the older App, which sets up a service and characteristics, starts advertising, and keeps a characteristic updated at 1Hz with local state data.


Then I added BLE central functionality to the new/swift App, which scans for advertisers, connects, discovers services, discovers characteristics, and then receives updates and decodes the data.


This all works great EXCEPT when I receive the data updates on the Swift/central side, the "value" of the characteristic appears to be nil. I've double checked my characteristic tree, my UUIDs, my permissions, all seems to be ok. Note that my peripheral is always advertising and always updating, it doesn't seem to interfere with the connection process, but maybe I need to sequence it differently (eg does the advertising function interfere with data transfer somehow)?


Below I've provided the relevant functions. Is there anything that looks wrong?


The configuration code on the Peripheral/iOS/Objective C side. This is the code that sets up my characteristics tree, with all permissions and capabilities


-(void) OnPoweredOnInit
{
    CBUUID *uuidService = [CBUUID UUIDWithString:pUUIDObserverService];
    CBUUID *uuidData = [CBUUID UUIDWithString:pUUIDObserverData];
    CBUUID *uuidTX = [CBUUID UUIDWithString:pUUIDObserverSerialTX];
    CBUUID *uuidRX = [CBUUID UUIDWithString:pUUIDObserverSerialRX];
    char_Data = [[CBMutableCharacteristic alloc] initWithType:uuidData properties:CBCharacteristicPropertyWrite|CBCharacteristicPropertyRead value:nil permissions:CBAttributePermissionsWriteable|CBAttributePermissionsReadable];
    char_TX = [[CBMutableCharacteristic alloc] initWithType:uuidTX properties:CBCharacteristicPropertyWrite value:nil permissions:CBAttributePermissionsWriteable];
    char_RX = [[CBMutableCharacteristic alloc] initWithType:uuidRX properties:CBCharacteristicPropertyRead value:nil permissions:CBAttributePermissionsReadable];
    service_Obs = [[CBMutableService alloc] initWithType:uuidService primary:YES];
    service_Obs.characteristics = @[char_Data, char_TX, char_RX];
    [ptr_CBPeriphMgr addService:service_Obs];
}


The sending code on the Peripheral/iOS/Objective C side. This is always called every second or so. Please note that I am also always advertising -- is this a problem? I haven't seen anything saying that that's a problem yet...


-(void) Update
{
    /
    Byte tmp[7];
    tmp[0] = (m_LastState >> 1) % 16;
    tmp[1] = m_LastState % 16;
    tmp[2] = m_LastUnits % 16;
    tmp[3] = (m_LastmilliPSI >> 3) % 16;
    tmp[4] = (m_LastmilliPSI >> 2) % 16;
    tmp[5] = (m_LastmilliPSI >> 1) % 16;
    tmp[6] = (m_LastmilliPSI >> 0) % 16;
    NSData *data = [NSData dataWithBytes:tmp length:7];
    bool z = [ptr_CBPeriphMgr updateValue:data forCharacteristic:char_Data onSubscribedCentrals:nil];
}


The receiving code on the Central/iOS/Swift side. I know my use of optionals is sloppy, still getting used to them. This is getting called, but fails the if (didUpdateValueFor.value != nil) test, seeming to mean that there is no data to decode. It seems like all the UUIDs match up, and it fires at the expected time, just no payload...


func peripheral(_ cm:CBPeripheral, didUpdateValueFor: CBCharacteristic, error: Error?)
{
    if (m_Peripheral != nil)
    {
        if (m_Peripheral == cm)
        {
                if (didUpdateValueFor.uuid.uuidString == stringuuid_DataCharacteristic)
                {
                    if (didUpdateValueFor.value != nil). /
                    {
                        let array = [UInt8](didUpdateValueFor.value!) /
                        if (array.count >= 7)
                        {
                            let state:UInt16 = UInt16(array[0]) * 16 + UInt16(array[1])
                            let units:UInt16 = UInt16(array[2])
                            let milliPSI:UInt32 = UInt32(array[3]) * 4096 + UInt32(array[4]) * 256 + UInt32(array[5]) * 16 + UInt32(array[6])
                            for o in general_observers { o.RxBlueFIREData(state:state, units:units, milliPSI:milliPSI) }
                        }
                    }
                }
        }
    }
}


Does anything above look incorrect? Anything I am doing wrong or failing to do that could cause "value" to be nil on the update event (which otherwise fires at the right time with the expected UUIDs).


Thanks for any insight!