Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ function createCentralCompileCommands() {

echo creating central compile_commands.json

local existing_jsons=` $ROOT/device/build/ $ROOT/right/build/ $ROOT/trackball/build $ROOT/trackpoint/build $ROOT/keycluster/build -name "compile_commands.json" 2>/dev/null`
local existing_jsons=`find $ROOT/device/build/ $ROOT/right/build/ $ROOT/trackball/build $ROOT/trackpoint/build $ROOT/keycluster/build -name "compile_commands.json" 2>/dev/null`

if [ "$existing_jsons" != "" ]
then
Expand Down
4 changes: 3 additions & 1 deletion device/src/bt_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ void BtManager_StopBt() {
}


// The delay has to be at least 100ms. Otherwise, the bluetooth controller can
// easily be overwhelmed and crash with a very non-nescriptive hci_core.c:430
void BtManager_StartScanningAndAdvertisingAsync(bool wasAggresive, const char* eventLabel) {
BT_TRACE_AND_ASSERT("bm4");
uint32_t maxDelay = 5000;
uint32_t minDelay = 20;
uint32_t minDelay = 100;
static int8_t aggressiveTries = 0;

aggressiveTries = wasAggresive ? aggressiveTries + 1 : 0;
Expand Down
22 changes: 18 additions & 4 deletions device/src/bt_pair.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,18 @@ struct check_bonded_device_args_t {
};

void checkBondedDevice(const struct bt_bond_info *info, void *user_data) {
if (info == NULL || user_data == NULL) {
return;
}
struct check_bonded_device_args_t* args = (struct check_bonded_device_args_t*)user_data;
char addr[32];
bt_addr_le_to_str(&info->addr, addr, sizeof(addr));
char ref[32];
bt_addr_le_to_str(args->addr, ref, sizeof(ref));
if (args->addr == NULL || args->bonded == NULL) {
return;
}
ATTR_UNUSED char dbgBondAddr[32];
bt_addr_le_to_str(&info->addr, dbgBondAddr, sizeof(dbgBondAddr));
ATTR_UNUSED char dbgRefAddr[32];
bt_addr_le_to_str(args->addr, dbgRefAddr, sizeof(dbgRefAddr));

if (BtAddrEq(&info->addr, args->addr)) {
*args->bonded = true;
}
Expand All @@ -279,8 +286,13 @@ void checkBondedDevice(const struct bt_bond_info *info, void *user_data) {
bool BtPair_IsDeviceBonded(const bt_addr_le_t *addr)
{
BT_TRACE_AND_ASSERT("bp8");
if (addr == NULL) {
return false;
}
bool bonded = false;



struct check_bonded_device_args_t args = {
.addr = addr,
.bonded = &bonded
Expand All @@ -289,6 +301,8 @@ bool BtPair_IsDeviceBonded(const bt_addr_le_t *addr)
// Iterate over all bonded devices
bt_foreach_bond(BT_ID_DEFAULT, checkBondedDevice, (void*)&args);

Trace_Printc("rbp8");

return bonded;
}

Expand Down
35 changes: 35 additions & 0 deletions doc-dev/other/testing-scenarios.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Following is a list testing suggestions. Not all have to be tested each time.

## Bluetooth:

- Pair ble hid. Unpair. Pair again.
- When two ble hid devices are paired, test that we can `switchHost` between them.
- When a device is paired, check that we can disconnect it and connect it again - i.e., that the bonding information didn't get corrupted. (Optionally, throw in uhk restart, bluetooth restart, test this with multiple devices.)
- Test that we can switch between two dongles and that their leds light up accordingly.
- Issue `switchHost device` against a device that is not present. `switchHost` to current usb. See that uhk now advertises hid (pairing icon) and that a ble hid host can connect.
- Test that we can add a paired device into the host connections. Try pair and add multiple devices within one Agent session.
- Unpair+pair dongle. (Optionally, let a bluetooth hid active while doing so.)

## Usb suspend:

In all scenarios make sure that the works afterwards.

Test with a pc and with a mac separately.

- suspend and wake the pc when connected via usb, via pc's button(s).
- suspend and wake the pc when connected via usb, by tapping any key.
- suspend and wake the pc when connected via usb, by tapping the wake key.
- suspend and wake the pc when connected via ble, via pc's button(s).

## Troubleshooting:

- Use the `panic` macro to check that crash logs are generated as expected.

## Macros:

These are obscure scenarios that are not worth to test often, but may be good to test from time to time.

- test `oneShot` modifiers with multiple oneShot keys. When keystrokeDelay = 250ms and oneshotTimeout = 5000, you have to see modifiers release only after the oneShot key is pressed.
- test `overlayLayer`

-
8 changes: 0 additions & 8 deletions doc-dev/other/testing/bluetooth.md

This file was deleted.

24 changes: 24 additions & 0 deletions doc-dev/other/zephyr_logging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Crash logs - users

## Uhk80

Crash logs have to be enabled via `set devMode true` in `$onInit`

## Uhk60

Crash logs are enabled by default. However, `set devMode true` is suggested as it enables logging in cases of ESD events.

(We don't log esd reboots because they are often and these crash logs are significantly more disturbing than a quick reboot.)

# Developer notes

In order to fit all our uart applications onto two controllers, we use the async uart driver. Unfortunatelly, the async serial backend is significantly less reliable than the default interrupt backend. Especially it is not available at all during early boot phases. When these log are needed, the interrupt driver has to be used:

- Comment out pin wiring stuff in device/src/main.c.

- Comment out this in uhk-80-right.conf:

```
# CONFIG_SHELL_BACKEND_SERIAL_API_ASYNC=y
```

1 change: 1 addition & 0 deletions right/src/event_scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ static bool isSpam(event_scheduler_event_t evt)

static void processEvt(event_scheduler_event_t evt)
{
Trace_Printf("s%d", evt);
switch (evt) {
case EventSchedulerEvent_UpdateBattery:
Charger_UpdateBatteryState();
Expand Down
60 changes: 30 additions & 30 deletions right/src/event_scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,36 @@
// Typedefs:

typedef enum {
EventSchedulerEvent_ModuleConnectionStatusUpdate,
EventSchedulerEvent_SegmentDisplayUpdate,
EventSchedulerEvent_MacroWakeOnTime,
EventSchedulerEvent_MacroRecorderFlashing,
EventSchedulerEvent_SwitchScreen,
EventSchedulerEvent_ShiftScreen,
EventSchedulerEvent_UpdateBattery,
EventSchedulerEvent_UpdateBatteryCharging,
EventSchedulerEvent_Postponer,
EventSchedulerEvent_NativeActions,
EventSchedulerEvent_AgentLed,
EventSchedulerEvent_UpdateLedSleepModes,
EventSchedulerEvent_MouseController,
EventSchedulerEvent_ReenableUart,
EventSchedulerEvent_UpdateMergeSensor,
EventSchedulerEvent_PowerModeUpdate,
EventSchedulerEvent_PowerModeRestart,
EventSchedulerEvent_EndBtPairing,
EventSchedulerEvent_RestartBt,
EventSchedulerEvent_BtStartScanningAndAdvertising,
EventSchedulerEvent_RedrawOled,
EventSchedulerEvent_UpdateDebugOledLine,
EventSchedulerEvent_RoundTripTest,
EventSchedulerEvent_ResendMessage,
EventSchedulerEvent_CheckFwChecksums,
EventSchedulerEvent_CheckDongleProtocolVersion,
EventSchedulerEvent_PutBackToShutDown,
EventSchedulerEvent_BlinkStatusIcons,
EventSchedulerEvent_UnselectHostConnection,
EventSchedulerEvent_OneShotTimeout,
EventSchedulerEvent_ModuleConnectionStatusUpdate = 0,
EventSchedulerEvent_SegmentDisplayUpdate = 1,
EventSchedulerEvent_MacroWakeOnTime = 2,
EventSchedulerEvent_MacroRecorderFlashing = 3,
EventSchedulerEvent_SwitchScreen = 4,
EventSchedulerEvent_ShiftScreen = 5,
EventSchedulerEvent_UpdateBattery = 6,
EventSchedulerEvent_UpdateBatteryCharging = 7,
EventSchedulerEvent_Postponer = 8,
EventSchedulerEvent_NativeActions = 9,
EventSchedulerEvent_AgentLed = 10,
EventSchedulerEvent_UpdateLedSleepModes = 11,
EventSchedulerEvent_MouseController = 12,
EventSchedulerEvent_ReenableUart = 13,
EventSchedulerEvent_UpdateMergeSensor = 14,
EventSchedulerEvent_PowerModeUpdate = 15,
EventSchedulerEvent_PowerModeRestart = 16,
EventSchedulerEvent_EndBtPairing = 17,
EventSchedulerEvent_RestartBt = 18,
EventSchedulerEvent_BtStartScanningAndAdvertising = 19,
EventSchedulerEvent_RedrawOled = 20,
EventSchedulerEvent_UpdateDebugOledLine = 21,
EventSchedulerEvent_RoundTripTest = 22,
EventSchedulerEvent_ResendMessage = 23,
EventSchedulerEvent_CheckFwChecksums = 24,
EventSchedulerEvent_CheckDongleProtocolVersion = 25,
EventSchedulerEvent_PutBackToShutDown = 26,
EventSchedulerEvent_BlinkStatusIcons = 27,
EventSchedulerEvent_UnselectHostConnection = 28,
EventSchedulerEvent_OneShotTimeout = 29,
EventSchedulerEvent_Count
} event_scheduler_event_t;

Expand Down