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

Commit

Permalink
Merge branch 'master-paired'
Browse files Browse the repository at this point in the history
  • Loading branch information
mondalaci committed Oct 28, 2024
2 parents 83bca68 + 4fe2147 commit 4daa0da
Show file tree
Hide file tree
Showing 59 changed files with 1,578 additions and 295 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: CI
on:
push:
branches:
- master
- master*
pull_request:
branches:
- master
- master*

jobs:
release:
Expand Down
17 changes: 16 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ usage: ./build DEVICE1 DEVICE2 ... ACTION1 ACTION2 ...
DEVICE is in { uhk-80-left | uhk-80-right | uhk-60-right | uhk-dongle }
there are also these aliases: { left | right | dongle | all }
ACTION is in { clean | setup | update | build | make | flash | flashUsb | shell | uart }
ACTION is in { clean | setup | update | build | make | flash | flashUsb | shell | uart | addrline <address> }
setup initialize submodules and set up zephyr environment
clean removes zephyr libraries
Expand Down Expand Up @@ -75,6 +75,19 @@ function processArguments() {
TARGET_TMUX_SESSION=$BUILD_SESSION_NAME
shift
;;
addrline)
shift
ADDR=$1
shift
for device in $DEVICES
do
echo "addrline for $ADDR:"
printf " "
# addr2line -e device/build/$device/zephyr/zephyr.elf $ADDR
arm-none-eabi-addr2line -e device/build/$device/zephyr/zephyr.elf $ADDR
done
exit 0
;;
uart)
ACTIONS="$ACTIONS $1"
TARGET_TMUX_SESSION=$UART_SESSION_NAME
Expand Down Expand Up @@ -276,6 +289,8 @@ END
uart)
setupUartMonitor
;;
addrline)
;;
*)
help
;;
Expand Down
1 change: 0 additions & 1 deletion device/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,3 @@ CONFIG_UDC_DRIVER_LOG_LEVEL_WRN=y
# we can't just do it from the main thread
CONFIG_C2USB_UDC_MAC_THREAD_STACK_SIZE=2048


29 changes: 27 additions & 2 deletions device/src/bt_advertise.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "bt_advertise.h"
#include <bluetooth/services/nus.h>
#include <zephyr/bluetooth/gatt.h>
#include "device.h"

#undef DEVICE_NAME
#define DEVICE_NAME CONFIG_BT_DEVICE_NAME
#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1)

Expand Down Expand Up @@ -36,7 +38,7 @@ static const struct bt_data sdHid[] = {SD_HID_DATA};

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

void Advertise(uint8_t adv_type)
void BtAdvertise_Start(uint8_t adv_type)
{
int err;
const char *adv_type_string;
Expand All @@ -51,7 +53,7 @@ void Advertise(uint8_t adv_type)
adv_type_string = "HID";
err = bt_le_adv_start(BT_LE_ADV_CONN, adHid, ARRAY_SIZE(adHid), sdHid, ARRAY_SIZE(sdHid));
} else {
assert(false);
printk("Attempted to start advertising without any type! Ignoring.\n");
return;
}

Expand All @@ -63,3 +65,26 @@ void Advertise(uint8_t adv_type)
printk("%s advertising failed to start (err %d)\n", adv_type_string, err);
}
}

void BtAdvertise_Stop() {
int err = bt_le_adv_stop();
if (err) {
printk("Advertising failed to stop (err %d)\n", err);
} else {
printk("Advertising successfully stopped\n");
}
}

uint8_t BtAdvertise_Type() {
switch (DEVICE_ID) {
case DeviceId_Uhk80_Left:
return ADVERTISE_NUS;
case DeviceId_Uhk80_Right:
return ADVERTISE_NUS | ADVERTISE_HID;
case DeviceId_Uhk_Dongle:
return 0;
default:
printk("unknown device!\n");
return 0;
}
}
4 changes: 3 additions & 1 deletion device/src/bt_advertise.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

// Functions:

extern void Advertise(uint8_t adv_type);
void BtAdvertise_Start(uint8_t adv_type);
void BtAdvertise_Stop();
uint8_t BtAdvertise_Type();

#endif // __BT_ADVERTISE_H__
Loading

0 comments on commit 4daa0da

Please sign in to comment.