Skip to content

Commit eda4ffe

Browse files
committed
Merge remote-tracking branch 'origin/master' into add_delete_all_data_command
2 parents c275b61 + a099b0b commit eda4ffe

File tree

93 files changed

+2227
-709
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+2227
-709
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
55
The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to the [UHK Versioning](VERSIONING.md) conventions.
77

8+
## [12.2.0] - 2025-01-01
9+
10+
Device Protocol: 4.**13.0** | Module Protocol: 4.3.0 | User Config: 8.3.0 | Hardware Config: 1.0.0 | Smart Macros: 3.0.0
11+
12+
- Fix touchpad stuck tap and doubletap.
13+
- Always update keymap on module change, including bootup.
14+
- Make pairing screen always on.
15+
- Reduce audible noise and expose related settings via the device protocol. `DEVICEPROTOCOL:MINOR`
16+
- Fix ISO LED lighting in switch test mode.
17+
- Fade UHK 80 LEDs gradually.
18+
819
## [12.1.0] - 2024-12-23
920

1021
Device Protocol: 4.**12.0** | Module Protocol: 4.3.0 | User Config: 8.3.0 | Hardware Config: 1.0.0 | Smart Macros: 3.0.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ mkdir firmware
5656
cd firmware
5757
git clone --recurse-submodules [email protected]:UltimateHackingKeyboard/firmware.git
5858
west init -l firmware
59-
west update
59+
west update -o=--depth=1 -n
6060
west patch
6161
west config --local build.cmake-args -- "-Wno-dev"
6262
cd firmware/scripts

build.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,16 @@ function processArguments() {
7171
DEVICES="$DEVICES uhk-80-left uhk-80-right uhk-dongle"
7272
shift
7373
;;
74-
clean|setup|update|build|make|flash|flashUsb|shell|release)
74+
clean|setup|update|build|make|flash|shell|release)
7575
ACTIONS="$ACTIONS $1"
7676
TARGET_TMUX_SESSION=$BUILD_SESSION_NAME
7777
shift
7878
;;
79+
flashUsb)
80+
ACTIONS="$ACTIONS make $1"
81+
TARGET_TMUX_SESSION=$BUILD_SESSION_NAME
82+
shift
83+
;;
7984
addrline)
8085
shift
8186
ADDR=$1
@@ -266,7 +271,7 @@ function performAction() {
266271
git submodule init
267272
git submodule update --init --recursive
268273
cd "$ROOT/.."
269-
west init -l "$ROOT" -mf west.yml
274+
west init -l "$ROOT"
270275
west update -o=--depth=1 -n
271276
west patch
272277
west config --local build.cmake-args -- "-Wno-dev"
@@ -374,7 +379,7 @@ function run() {
374379
if [ `echo $DEVICES | wc -w` -gt 1 ]
375380
then
376381
runPerDevice
377-
elif [ `echo $DEVICES | wc -w` -eq 0 ]
382+
elif [ `echo $DEVICES | wc -w` -le 1 ]
378383
then
379384
performActions $DEVICES
380385
else

device/prj.conf.overlays/nrf_shared.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ CONFIG_BT_SMP=y
1717

1818
CONFIG_BT_L2CAP_TX_BUF_COUNT=5
1919

20+
# Todo: place these where they belong
21+
# config for right half host switching
22+
CONFIG_BT_MAX_CONN=4
23+
CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT=3
24+
CONFIG_BT_FILTER_ACCEPT_LIST=y
25+
26+
2027
# negotiate larger MTU for NUS
2128
CONFIG_BT_USER_DATA_LEN_UPDATE=y
2229
CONFIG_BT_BUF_ACL_RX_SIZE=251

device/src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ set(usb_cpp_sources
88
usb/command_app.cpp
99
usb/controls_app.cpp
1010
usb/gamepad_app.cpp
11-
usb/hid_battery_app.cpp
1211
usb/keyboard_app.cpp
1312
usb/mouse_app.cpp
1413
usb/usb_compatibility.cpp
@@ -29,6 +28,7 @@ if(NOT CONFIG_BOARD_UHK_60_RIGHT)
2928
bt_conn.c
3029
bt_manager.c
3130
bt_pair.c
31+
connections.c
3232
debug_eventloop_timing.c
3333
device_state.c
3434
flash.c

device/src/bt_advertise.c

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#include "bt_advertise.h"
22
#include <bluetooth/services/nus.h>
33
#include <zephyr/bluetooth/gatt.h>
4+
#include "bt_conn.h"
5+
#include "connections.h"
46
#include "device.h"
7+
#include "event_scheduler.h"
8+
#include "bt_scan.h"
59

610
#undef DEVICE_NAME
711
#define DEVICE_NAME CONFIG_BT_DEVICE_NAME
@@ -38,8 +42,24 @@ static const struct bt_data sdHid[] = {SD_HID_DATA};
3842

3943
static const struct bt_data sdNusHid[] = {SD_NUS_DATA SD_HID_DATA};
4044

41-
void BtAdvertise_Start(uint8_t adv_type)
45+
static struct bt_le_adv_param advertisementParams[] = BT_LE_ADV_CONN;
46+
47+
static void setFilters() {
48+
bt_le_filter_accept_list_clear();
49+
if (DEVICE_IS_UHK80_RIGHT) {
50+
if (BtConn_UnusedPeripheralConnectionCount() <= 1 && SelectedHostConnectionId != ConnectionId_Invalid) {
51+
bt_le_filter_accept_list_add(&HostConnection(SelectedHostConnectionId)->bleAddress);
52+
advertisementParams->options = BT_LE_ADV_OPT_FILTER_CONN;
53+
} else {
54+
advertisementParams->options = BT_LE_ADV_OPT_NONE;
55+
}
56+
}
57+
}
58+
59+
uint8_t BtAdvertise_Start(uint8_t adv_type)
4260
{
61+
setFilters();
62+
4363
int err;
4464
const char *adv_type_string;
4565
if (adv_type == (ADVERTISE_NUS | ADVERTISE_HID)) {
@@ -54,33 +74,54 @@ void BtAdvertise_Start(uint8_t adv_type)
5474
err = bt_le_adv_start(BT_LE_ADV_CONN, adHid, ARRAY_SIZE(adHid), sdHid, ARRAY_SIZE(sdHid));
5575
} else {
5676
printk("Attempted to start advertising without any type! Ignoring.\n");
57-
return;
77+
return 0;
5878
}
5979

6080
if (err == 0) {
6181
printk("%s advertising successfully started\n", adv_type_string);
82+
return 0;
6283
} else if (err == -EALREADY) {
6384
printk("%s advertising continued\n", adv_type_string);
85+
return 0;
6486
} else {
65-
printk("%s advertising failed to start (err %d)\n", adv_type_string, err);
87+
printk("%s advertising failed to start (err %d), free connections: %d\n", adv_type_string, err, BtConn_UnusedPeripheralConnectionCount());
88+
return err;
6689
}
6790
}
6891

6992
void BtAdvertise_Stop() {
7093
int err = bt_le_adv_stop();
7194
if (err) {
7295
printk("Advertising failed to stop (err %d)\n", err);
73-
} else {
74-
printk("Advertising successfully stopped\n");
7596
}
7697
}
7798

99+
static uint8_t connectedHidCount() {
100+
uint8_t connectedHids = 0;
101+
for (uint8_t peerId = PeerIdFirstHost; peerId <= PeerIdLastHost; peerId++) {
102+
if (Peers[peerId].conn && Connections_Type(Peers[peerId].connectionId) == ConnectionType_BtHid) {
103+
connectedHids++;
104+
}
105+
}
106+
return connectedHids;
107+
}
108+
78109
uint8_t BtAdvertise_Type() {
79110
switch (DEVICE_ID) {
80111
case DeviceId_Uhk80_Left:
81112
return ADVERTISE_NUS;
82113
case DeviceId_Uhk80_Right:
83-
return ADVERTISE_NUS | ADVERTISE_HID;
114+
if (BtConn_UnusedPeripheralConnectionCount() > 0) {
115+
if (connectedHidCount() > 0) {
116+
return ADVERTISE_NUS;
117+
} else {
118+
return ADVERTISE_NUS | ADVERTISE_HID;
119+
}
120+
} else {
121+
printk("Current slot count %d, not advertising\n", BtConn_UnusedPeripheralConnectionCount());
122+
BtConn_ListCurrentConnections();
123+
return 0;
124+
}
84125
case DeviceId_Uhk_Dongle:
85126
return 0;
86127
default:

device/src/bt_advertise.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
// Functions:
1414

15-
void BtAdvertise_Start(uint8_t adv_type);
15+
uint8_t BtAdvertise_Start(uint8_t adv_type);
1616
void BtAdvertise_Stop();
1717
uint8_t BtAdvertise_Type();
1818

0 commit comments

Comments
 (0)