Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle User Bluetooth Disconnection Request #7

Closed
wants to merge 78 commits into from

Conversation

cvcore
Copy link

@cvcore cvcore commented Jul 23, 2023

This PR addresses the issue that the keyboard will keep reconnecting itself to the computer, even if the user disconnects it manually from the bluetooth menu.

Related issue: KinesisCorporation/Adv360-Pro-ZMK#172 (comment)

The previous behavior of zmk in the adv360-z3.2 branch will start open BLE advertising, when there exists no connection for the current profile, or if the current profile is open. This behavior will cause the keyboard to broadcast itself as connectable immediately after user BLE disconnection, causing the above mentioned behavior.

With the proposed change, the keyboard will no longer advertise itself as connectable after BLE disconnection. But wait until the user presses a key on the keyboard to retrigger the BLE advertising.

@ReFil please review and give suggestions.

bortoz and others added 26 commits September 12, 2022 21:58
moved peripheral updating from behaviour bnased to dedicated bluetooth services, added custom lighting effects to the adv360
Dim brightness of LEDS for improved battery life, Decrease settings save timeout to 29.5 seconds so it occurs before idle timeout
Disable battery reporting, stops spurious wakeups on Macs
Changed the endpoints code to rename the existing endpoint types to
"endpoint transport" and add the concept of "endpoint instances". A
transport is the method by which data is sent, while instances allow
describing multiple endpoints that use the same transport (e.g.
bluetooth profiles).

Also added new APIs to get the total number of possible endpoint
instances and assign each instance a unique index, which can be used
for tracking separate state for each endpoint in other code files.
app/src/ble.c Outdated
@@ -48,7 +50,7 @@ static uint8_t passkey_digit = 0;
#endif /* IS_ENABLED(CONFIG_ZMK_BLE_PASSKEY_ENTRY) */

#if IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
#define PROFILE_COUNT (CONFIG_BT_MAX_PAIRED - 1)
#define PROFILE_COUNT (CONFIG_BT_MAX_PAIRED - 1) // should it be ZMK_BLE_PROFILE_COUNT?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are functionally the same, one pairing slot is reserved for the right half

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I can't find where PROFILE_COUNT was used anywhere in the code. Seems everywhere we are referring to ZMK_BLE_PROFILE_COUNT which made me a bit confused.

Copy link
Owner

@ReFil ReFil Jul 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number of profiles configured in ZMK is not the same as the technical limitation on the number of profiles. The PROFILE_COUNT value is defined as compile time based on the max pairing slots configured, you can have 8 pairing slots and then use ZMK_BLE_PROFILE_COUNT to limit the number of actual profiles

app/src/ble.c Outdated

#define DEVICE_NAME CONFIG_BT_DEVICE_NAME
#define DEVICE_NAME CONFIG_BT_DEVICE_NAME // where is this defined?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anything prefixed with CONFIG_ gets set in one of the KConfig files, so adv360_side_defconfig as well as a few other files in the adv360 directory, a lot of parameters are set at compile time by the kconfig file in the root of app as well

app/src/ble.c Outdated
@@ -141,6 +146,7 @@ bool zmk_ble_active_profile_is_connected() {
return err; \
}

/* Start direct advertising to peer if no connection exists for active profile */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe direct advertising to hosts is currently not a thing because apple do not permit it to any apple device

@ReFil
Copy link
Owner

ReFil commented Jul 24, 2023

It all looks good, but I'd like to se it behind a Kconfig option so as not to introduce a potentially confusing change to regulat users

xudongzheng and others added 22 commits August 5, 2023 20:03
* Add two new compatibles for macros that
  take one or two parameters when bound in
  a keymap.
* Use `&macro_param_1to1`, `&macro_param_1to2`, `&macro_param_2to1`,
  and `&macro_param_2to2` control entries in the bindings for the macro
  to have the next binding entry have it's values substituted.

Co-authored-by: Cem Aksoylar <[email protected]>
* Properly return transparent value when processing mode
  for higher disabled layers means the processing is ignored.
…1859)

Add a note about the UF2 drive that automatically unmounts itself
to restart, which may surprise some new users.
* Add Leeloo v2
* Leeloo-Micro v1 updates to support Zephyr 3.2
* Refactored for new Encoder Configuration

Co-authored-by: Cem Aksoylar <[email protected]>
Properly make the battery sensor Kconfig symbols depend
on `SENSOR` config, and minor battery reporting Kconfig
symbol dependency fix.
Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md)
- [Commits](npm/node-semver@v5.7.1...v5.7.2)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
* When the clear bonds Kconfig is set, also clear peripheral
  address slots addresses from settings as well.
* Properly compare to zero when comparing LE addresses.
* Proper usage of bt_uuid_cmp.
* Central's don't start scanning for peripherals if
  `ZMK_BLE_CLEAR_BONDS_ON_START` is enabled.
* Split peripherals don't advertize if
  `ZMK_BLE_CLEAR_BONDS_ON_START` is enabled.
* Don't reference `pro_micro` nexus node in settings_reset
  so it can be used with other controllers.
* Use mock kscan node instead.
* Add new shield for splitkb.com Aurora Sofle, supporting
  keys, encoder(s), displays, and RGB.

Co-authored-by: Cem Aksoylar <[email protected]>
Blocking operations on the high priority system workqueue may result in
deadlocks, particularly when Bluetooth is in use.
@cvcore cvcore changed the base branch from adv360-z3.2 to adv360-z3.2-beta August 26, 2023 11:19
@cvcore
Copy link
Author

cvcore commented Aug 26, 2023

FYI @ReFil : now updated the code base to adv360-z3.2-beta and tested on my hardware.

@cvcore
Copy link
Author

cvcore commented Oct 3, 2023

Closed for #9

@cvcore cvcore closed this Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.