Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Implement PoC of OOB pairing. #320

Merged
merged 28 commits into from
Oct 19, 2024
Merged

Implement PoC of OOB pairing. #320

merged 28 commits into from
Oct 19, 2024

Conversation

kareltucek
Copy link
Contributor

@kareltucek kareltucek commented Oct 9, 2024

@ert78gb here is some PoC of the pairing process so that you can start working on it.

It still has some minor bugs, such as left half not working after pairing though.

You will find some documentation in doc-dev/other/pairing/ of this PR.

Closes UltimateHackingKeyboard/firmware#876
Closes UltimateHackingKeyboard/firmware#980
Closes UltimateHackingKeyboard/firmware#877
Closes UltimateHackingKeyboard/firmware#964

@kareltucek
Copy link
Contributor Author

Alright, @mondalaci @ert78gb this seems to be working on my side.

Testing instructions:

  • copy scripts from doc-dev/other/pairing/ to agent80/packages/usb
  • cd into agent80/packages/usb
  • run ./pair.sh

@kareltucek kareltucek changed the title WIP: Implement PoC of OOB pairing. Implement PoC of OOB pairing. Oct 11, 2024
@mondalaci
Copy link
Member

Thanks, very excited about this! Robi will probably have time to implement his part the next week.

@kareltucek kareltucek changed the base branch from master to master-paired October 13, 2024 10:08
@ert78gb
Copy link
Member

ert78gb commented Oct 19, 2024

I would like to download the firmware from the CI, but it not building, because the CI runs only when the base/destination branch of the pull request is the master branch.
The base branch of this PR is master-paired. Please add the name of the branch to the .github/workflows/ci.yml ~line 10 as - master-paired or we could use wildcard pattern like - master-* for the future.

@kareltucek
Copy link
Contributor Author

I see, will solve in a minute. Also will remove 0x1c command and readress 0x1d to 0x1c.

@kareltucek
Copy link
Contributor Author

Done.

@ert78gb
Copy link
Member

ert78gb commented Oct 19, 2024

thx. the doc-dev/other/pairing/pair.sh script is really good specification 👍

@kareltucek
Copy link
Contributor Author

You are welcome :-)

@mondalaci
Copy link
Member

Please let's use switchover. It's a single word.

@ert78gb
Copy link
Member

ert78gb commented Oct 19, 2024

@kareltucek in the last step of doc-dev/other/pairing/pair.sh you check the 2 device are paired or not. You use the IsPaired = 0x1b USB command.
I am thinking on to first check if the Device isPaired to the Dongle vica versa. And run the only the necessary pairing. But I don't know should be both device in pairing mode at the same time or enough only the one.

Example: The right half contains the dongle BLE address, but the dongle does not contain the right half BLE address.
Logically would be enough to write right half BLE address to the dongle, but I don't know send the PairCentral = 0x19 command to the dongle is enough or have to send PairPeripheral = 0x18 to the device too?

I am thinking on it to decrease the number of delete and write commands, because less communication causes less trouble.

  1. question is just for curiosity. What are the 0-s in the delete bonds command?
#delete all bonds
./cmd.sh dongle 0x1a 0 0 0 0 0 0 > /dev/null

@kareltucek
Copy link
Contributor Author

kareltucek commented Oct 19, 2024

I am thinking on to first check if the Device isPaired to the Dongle vica versa. And run the only the necessary pairing. But I don't know should be both device in pairing mode at the same time or enough only the one.

You don't need to be in pairing mode in order to check if a device is paired.

You should check both devices, and if either of them is not paired, you should delete the bond on the other and then pair them with the full procedure.

If you decide to pair, you always send both 0x18 and 0x19, where peripheral (0x18) should go first.

All occurences of 0x1c, 0x16, 0x17, 0x18 and 0x19 in the pair.sh script are obligatory.

question is just for curiosity. What are the 0-s in the delete bonds command?

Sending a zero address stands for "delete all bonds". If you send a (non-zero) address, it will delete only that one bond.

@kareltucek
Copy link
Contributor Author

kareltucek commented Oct 19, 2024

As for decreasing the number of commands, I could restructure the protocol to use less command calls, but honestly, I would prefer not to, for sake of readability of the entire process.

@mondalaci
Copy link
Member

mondalaci commented Oct 19, 2024

We're far from using the entire device protocol command ID space, and some legacy command IDs can be reused, so I'm not worried as long as we create new commands judiciously.

@kareltucek
Copy link
Contributor Author

Now we are talking about number of calls during one pairing procedure, not the total of distinct command opcodes.

@mondalaci
Copy link
Member

Oh, I see. No worries about this, either. Pairing is a rarely occurring process whose protocol doesn't have to be optimized. Readability and simplicity should prevail.

@kareltucek kareltucek merged commit 2acfe49 into master-paired Oct 19, 2024
1 check passed
@kareltucek
Copy link
Contributor Author

This is blocking me -> merging. @ert78gb if you need a newer testing firmware, please use master-paired

@kareltucek kareltucek deleted the dongle_pairing4 branch October 21, 2024 20:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dongle pairing Pairing the halves
3 participants