nfc-door-lock-and-access-control uwb implementation

Developing an implementation for UltraWideBandImpl for a different UWB hardware solution (not the provided qm35 implementation) and running into integration problems

The (binary only) Aliro library is doing some pre/post processing of messages so it is not clear what the actual format of BLE messages sent to and from the implementation should include. For example, an InitiateRanging notification doesn't contain an overall length (2 bytes) field, but the resulting UWB M1 message seems to require I put one in the reply?

Also, the UWB Session Id attribute in the M1 message is supposed to be set to the low 32 bits of the "Transaction ID" which is not available to the UltraWideBandImpl class and is not added to the M1 message by the Aliro library, so how is that supposed to work?   If I just add a 32 bit number the Aliro test harness fails with "Invalid Session Id".  If I omit it, the test harness seems happy with my M1 message, says it is sending an M2 message, but my firmware says it gets a General Error message?  I am stuck here.  Is there *any* documentation on the data formats the UltraWideBandImpl class should send/receive and when?

Also, the (default) Qurvo implementation has leaked into the general solution where vendor specific extensions to the UltraWideBandImpl class are called from the (generic) Aliro interface code. Namely, in app/src/aliro/init.cpp calls to

    const char *fwVersion = UltraWideBandImpl::Instance().GetQm35FirmwareVersion();
    const auto *caps = UltraWideBandImpl::Instance().GetCccCapabilities();

That should be extracted.  I would do a PR but the the Qurvo source isn't available.  Please have them fix that.

Relevant logs from f/w:

[00:00:47.104,522] <dbg> HSM: [ToUwbRangingTransition]: [BleSessionState -> UwbRangingState]
[00:00:47.104,553] <dbg> UwbRangingState::Entry
[00:00:47.104,583] <inf> uwbImplMU2BP: _ConfigureRangingSession
[00:00:47.104,614] <inf> uwbImplMU2BP: SessionHandler: 0x2000E0A0  Id:51E04C82
[00:00:47.104,644] <dbg> UwbRangingState::Run
[00:00:48.350,555] <dbg> aliro_stack: LogHexdump: BLE message:
                                      03 00 00 35 33 df 13 ac  2e 89 65 92 34 f8 1a 11 |...53... ..e.4...
                                      d7 a2 94 5c 6a 3b 15 2f  80 18 ba 40 b4 d8 b7 e1 |...\j;./ ...@....
                                      f6 3b 19 34 dd 1a f8 1a  35 9c 69 55 e5 64 5c 88 |.;.4.... 5.iU.d\.
                                      93 e7 84 6e 45 08 b1 c6  f7                      |...nE... .       
[00:00:48.350,585] <dbg> Received Message, Protocol Type: 3, ID: 0
[00:00:48.351,135] <dbg> HSM: [UwbRangingState]: Data received
[00:00:48.351,623] <dbg> UwbRangingState::Run
[00:00:48.599,639] <dbg> aliro_stack: LogHexdump: BLE message:
                                      02 01 00 12 50 a4 6b d9  93 46 42 9f b1 82 2e 6b |....P.k. .FB....k
                                      12 60 57 18 ed 5a                                |.`W..Z           
[00:00:48.599,700] <dbg> Received Message, Protocol Type: 2, ID: 1
[00:00:48.600,097] <dbg> HSM: [UwbRangingState]: Data received
[00:00:48.600,555] <dbg> UwbRangingState::Run
[00:00:48.600,616] <dbg> aliro_stack: LogHexdump: Message Ranging received
                                      02 01 00 02 00 00                                |......           
[00:00:48.600,646] <dbg> Ranging attribute received: InitiateRangingSession
[00:00:48.600,677] <inf> uwbImplMU2BP: BLE BLOB
                                       02 01 00 02 00 00                                |......           
[00:00:48.600,708] <inf> uwbImplMU2BP: BLE Msg: NTF 01
[00:00:48.600,708] <inf> uwbImplMU2BP: Ranging Notification
[00:00:48.600,738] <inf> uwbImplMU2BP: M1 -------------------
                                       01 00 00 0a 00 02 00 00  01 01 00 03 01 ff       |........ ......  
[00:00:48.600,799] <dbg> aliro_stack: LogHexdump: Sending RangingSessionSetupM1 message
                                      00 02 00 00 01 01 00 03  01 ff                   |........ ..      
[00:00:50.374,694] <dbg> aliro_stack: LogHexdump: BLE message:
                                      02 00 00 13 4a 15 d5 0e  d0 48 dd aa 02 fa f1 ac |....J... .H......
                                      ae b5 bc e9 73 a2 66                             |....s.f          
[00:00:50.374,755] <dbg> Received Message, Protocol Type: 2, ID: 0
[00:00:50.375,122] <dbg> General Error event received
[00:00:50.375,610] <dbg> HSM: [ToGeneralErrorTransition]: [UwbRangingState -> GeneralErrorState]
[00:00:50.375,640] <dbg> UwbRangingState::Exit
[00:00:50.375,732] <dbg> GeneralErrorState::Run
[00:00:50.375,762] <dbg> aliro_stack: LogHexdump: BLE error message

Logs from Test Harness (which dont match the f/w logs after M1 exchange for some reason?)

Additional data: b'02000003'
IV: b'000000000000000100000003'
Encryption key: b'7dd372bd57f7ac786b5949eb39417fe48908ae3515bd79ab6d0a3f779f4e6c9e'
Ciphertext: b'4a15d5'
Authentication tag: b'0ed048ddaa02faf1acaeb5bce973a266'
Sending BLE message: b'020000134a15d50ed048ddaa02faf1acaeb5bce973a266'
Sending data using BLE: b'020000134a15d50ed048ddaa02faf1acaeb5bce973a266'
Send le cb data
writing to Murata: b'0242071c000040001700020000134a15d50ed048ddaa02faf1acaeb5bce973a26628'
confirm received
Test Step Completed [PASSED]: Step3: Reader sends AP message: RSS-M1
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Executing Test Step: Step4: User Device sends AP message: RSS-M2
Test Step Completed [PASSED]: Step4: User Device sends AP message: RSS-M2
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Executing Test Step: Step5: Reader sends AP message: RSS-M3
Waiting for command
Wait for data
Unexpected Command received:
FSCI message:
OpGroup: L2CAP
OpCode: LOCAL_CREDITS_NOTIFICATION
Length: 0x6
Data: b'010040000000'
CRC: b'80'
Unexpected Command received:
FSCI message:
OpGroup: L2CAP
OpCode: LOCAL_CREDITS_NOTIFICATION
Length: 0x6
Data: b'010040000100'
CRC: b'81'
Received data from device id: 0
Received data: b'02000003010100'
Received message: b'02000003010100'
Received BLE message with header: 0x02 and id: 0x00
Handling ranging session setup message M3
Decrypting BLE message
Encrypted payload: b''
Authentication tag: b'010100'
Additional data: b'02000000'
IV: b'000000000000000000000003'
Decryption key: b'82b848e411a0e3ad77249b2df28a36b155c47d315c4e9ad399e85ff0eca845a8'
Verification failed
Test Failure: VerificationError: VerificationError()
Test Step Completed [FAILED]: Step5: Reader sends AP message: RSS-M3
--------------------------------------------------------------------------------
BLEUWB_RDR_EXPEDITED_STANDARD_PHASE Cleanup
Related