Closed ricsydothu closed 3 years ago
AFAIKR this was the last bit of the code I added. It was not fully tested at the time as I did not end up using this lib.
I have update the code on the following branch NotificationFix. I need to dig around to find my BLE test device to test the changes, the should work, you can give it a try if you like.
Resolved on main branch.
here a line like memcpy(p, pEvent->CharacteristicValue->Data, pEvent->CharacteristicValue->DataSize); is missing, the allocated memory is uninitialized. The received data in callbackContext->getNotificationHandler()(*notification); was junk.
https://github.com/DerekGn/WinBle/blob/3e039543af0ca6c539331ec2c12864407e171f9b/src/WinBleLib/BleGattCharacteristic.cpp#L122
or rather, malloc and copy should be in the BleGattNotificationData::BleGattNotificationData(ULONG dataSize, PBYTE bytes) constructor, since freeing is already done in the destructor