feat: add 0xf8 feature report to get firmware version and add config version

This commit is contained in:
awalol
2026-05-14 20:28:22 +08:00
parent 303a58b9c5
commit 58909831e1
6 changed files with 47 additions and 14 deletions
+11 -4
View File
@@ -30,6 +30,9 @@ jobs:
with: with:
submodules: recursive submodules: recursive
- name: Set firmware version
run: printf 'FIRMWARE_VERSION=%s\n' "${GITHUB_SHA::7}" >> "$GITHUB_ENV"
- name: Prepare build dependency cache - name: Prepare build dependency cache
id: apt-cache id: apt-cache
run: | run: |
@@ -79,7 +82,8 @@ jobs:
run: | run: |
cmake -S . -B build/standard -G Ninja \ cmake -S . -B build/standard -G Ninja \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DPICO_SDK_PATH="$PICO_SDK_PATH" -DPICO_SDK_PATH="$PICO_SDK_PATH" \
-DVERSION="$FIRMWARE_VERSION"
cmake --build build/standard --target ds5-bridge cmake --build build/standard --target ds5-bridge
mkdir -p artifacts mkdir -p artifacts
cp build/standard/ds5-bridge.uf2 artifacts/ds5-bridge.uf2 cp build/standard/ds5-bridge.uf2 artifacts/ds5-bridge.uf2
@@ -90,7 +94,8 @@ jobs:
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DPICO_SDK_PATH="$PICO_SDK_PATH" \ -DPICO_SDK_PATH="$PICO_SDK_PATH" \
-DENABLE_SERIAL=ON \ -DENABLE_SERIAL=ON \
-DENABLE_VERBOSE=ON -DENABLE_VERBOSE=ON \
-DVERSION="$FIRMWARE_VERSION"
cmake --build build/debug --target ds5-bridge cmake --build build/debug --target ds5-bridge
cp build/debug/ds5-bridge.uf2 artifacts/ds5-bridge-debug.uf2 cp build/debug/ds5-bridge.uf2 artifacts/ds5-bridge-debug.uf2
@@ -99,7 +104,8 @@ jobs:
cmake -S . -B build/no-batt-led -G Ninja \ cmake -S . -B build/no-batt-led -G Ninja \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DPICO_SDK_PATH="$PICO_SDK_PATH" \ -DPICO_SDK_PATH="$PICO_SDK_PATH" \
-DENABLE_BATT_LED=OFF -DENABLE_BATT_LED=OFF \
-DVERSION="$FIRMWARE_VERSION"
cmake --build build/no-batt-led --target ds5-bridge cmake --build build/no-batt-led --target ds5-bridge
- name: Build Pico W firmware - name: Build Pico W firmware
@@ -107,7 +113,8 @@ jobs:
cmake -S . -B build/picow -G Ninja \ cmake -S . -B build/picow -G Ninja \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DPICO_SDK_PATH="$PICO_SDK_PATH" \ -DPICO_SDK_PATH="$PICO_SDK_PATH" \
-DPICO_W_BUILD=ON -DPICO_W_BUILD=ON \
-DVERSION="$FIRMWARE_VERSION"
cmake --build build/picow --target ds5-bridge cmake --build build/picow --target ds5-bridge
cp build/picow/ds5-bridge.uf2 artifacts/ds5-bridge-picow.uf2 cp build/picow/ds5-bridge.uf2 artifacts/ds5-bridge-picow.uf2
+9 -2
View File
@@ -33,6 +33,11 @@ jobs:
ref: ${{ github.event.release.tag_name }} ref: ${{ github.event.release.tag_name }}
submodules: recursive submodules: recursive
- name: Set firmware version
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: printf 'FIRMWARE_VERSION=%s\n' "$RELEASE_TAG" >> "$GITHUB_ENV"
- name: Prepare build dependency cache - name: Prepare build dependency cache
id: apt-cache id: apt-cache
run: | run: |
@@ -82,7 +87,8 @@ jobs:
run: | run: |
cmake -S . -B build/standard -G Ninja \ cmake -S . -B build/standard -G Ninja \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DPICO_SDK_PATH="$PICO_SDK_PATH" -DPICO_SDK_PATH="$PICO_SDK_PATH" \
-DVERSION="$FIRMWARE_VERSION"
cmake --build build/standard --target ds5-bridge cmake --build build/standard --target ds5-bridge
mkdir -p artifacts mkdir -p artifacts
cp build/standard/ds5-bridge.uf2 "artifacts/ds5-bridge-${{ github.event.release.tag_name }}.uf2" cp build/standard/ds5-bridge.uf2 "artifacts/ds5-bridge-${{ github.event.release.tag_name }}.uf2"
@@ -93,7 +99,8 @@ jobs:
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DPICO_SDK_PATH="$PICO_SDK_PATH" \ -DPICO_SDK_PATH="$PICO_SDK_PATH" \
-DENABLE_SERIAL=ON \ -DENABLE_SERIAL=ON \
-DENABLE_VERBOSE=ON -DENABLE_VERBOSE=ON \
-DVERSION="$FIRMWARE_VERSION"
cmake --build build/debug --target ds5-bridge cmake --build build/debug --target ds5-bridge
cp build/debug/ds5-bridge.uf2 "artifacts/ds5-bridge-debug-${{ github.event.release.tag_name }}.uf2" cp build/debug/ds5-bridge.uf2 "artifacts/ds5-bridge-debug-${{ github.event.release.tag_name }}.uf2"
+2 -1
View File
@@ -141,9 +141,10 @@ if(WAKE_DEBUG)
WAKE_DEBUG WAKE_DEBUG
) )
endif() endif()
set(VERSION "dev" CACHE STRING "Program version string")
pico_set_program_name(ds5-bridge "ds5-bridge") pico_set_program_name(ds5-bridge "ds5-bridge")
pico_set_program_version(ds5-bridge "0.5.3") pico_set_program_version(ds5-bridge "${VERSION}")
# Modify the below lines to enable/disable output over UART/USB # Modify the below lines to enable/disable output over UART/USB
pico_enable_stdio_uart(ds5-bridge 1) pico_enable_stdio_uart(ds5-bridge 1)
+8 -1
View File
@@ -14,7 +14,8 @@
bool is_pico_cmd(uint8_t report_id) { bool is_pico_cmd(uint8_t report_id) {
if (report_id == 0xf6 || if (report_id == 0xf6 ||
report_id == 0xf7 report_id == 0xf7 ||
report_id == 0xf8
) { ) {
return true; return true;
} }
@@ -31,6 +32,12 @@ uint16_t pico_cmd_get(uint8_t report_id, uint8_t *buffer, uint16_t reqlen) {
memcpy(buffer,&get_config(),len); memcpy(buffer,&get_config(),len);
return len; return len;
} }
if (report_id == 0xf8) {
printf("[HID] Receive 0xf8 getting firmware version\n");
const auto len = std::min(strlen(PICO_PROGRAM_VERSION_STRING), static_cast<size_t>(reqlen));
memcpy(buffer, PICO_PROGRAM_VERSION_STRING, len);
return len;
}
return 0; return 0;
} }
+1
View File
@@ -8,6 +8,7 @@
#include <cstdint> #include <cstdint>
struct __attribute__((packed)) Config_body { struct __attribute__((packed)) Config_body {
uint8_t config_version = 1; // Config Version
float haptics_gain; // [1.0,2.0] float haptics_gain; // [1.0,2.0]
float speaker_volume; // [-100,0] float speaker_volume; // [-100,0]
uint8_t inactive_time; // [10,60] min uint8_t inactive_time; // [10,60] min
+16 -6
View File
@@ -362,8 +362,8 @@ uint8_t descriptor_configuration[] = {
0x00, // bCountryCode: Not localized 0x00, // bCountryCode: Not localized
0x01, // bNumDescriptors: 1 report descriptor 0x01, // bNumDescriptors: 1 report descriptor
0x22, // bDescriptorType: Report 0x22, // bDescriptorType: Report
0x31, 0x01, // wDescriptorLength: 305 (0x0131) DS 0x39, 0x01, // wDescriptorLength: 313 (0x0139) DS
// 0xA5, 0x01, // wDescriptorLength: 421 (0x01A5) DSE // 0xAD, 0x01, // wDescriptorLength: 429 (0x01AD) DSE
// Endpoint Descriptor (HID IN: EP4) // Endpoint Descriptor (HID IN: EP4)
0x07, // bLength 0x07, // bLength
@@ -408,9 +408,9 @@ uint8_t const *tud_descriptor_configuration_cb(uint8_t index) {
descriptor_configuration[offset - 1] = bInterval; descriptor_configuration[offset - 1] = bInterval;
descriptor_configuration[offset - 8] = bInterval; descriptor_configuration[offset - 8] = bInterval;
if (ds_mode()) { if (ds_mode()) {
descriptor_configuration[offset - 16] = 0x31; descriptor_configuration[offset - 16] = 0x39;
}else { }else {
descriptor_configuration[offset - 16] = 0xA5; descriptor_configuration[offset - 16] = 0xAD;
} }
return descriptor_configuration; return descriptor_configuration;
} }
@@ -569,9 +569,14 @@ uint8_t const desc_hid_report_ds[] = {
0x09, 0x38, 0x09, 0x38,
0x95, 0x3F, 0x95, 0x3F,
0xB1, 0x02, 0xB1, 0x02,
0x85, 0xF8,
0x09, 0x39,
0x95, 0x3F,
0xB1, 0x02,
0xC0, // End Collection 0xC0, // End Collection
// 305 bytes // 313 bytes
}; };
static_assert(sizeof(desc_hid_report_ds) == 0x0139);
uint8_t const desc_hid_report_dse[] = { uint8_t const desc_hid_report_dse[] = {
0x05, 0x01, // Usage Page (Generic Desktop Ctrls) 0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
@@ -781,9 +786,14 @@ uint8_t const desc_hid_report_dse[] = {
0x09, 0x38, 0x09, 0x38,
0x95, 0x3F, 0x95, 0x3F,
0xB1, 0x02, 0xB1, 0x02,
0x85, 0xF8,
0x09, 0x39,
0x95, 0x3F,
0xB1, 0x02,
0xC0, // End Collection 0xC0, // End Collection
// 421 bytes // 429 bytes
}; };
static_assert(sizeof(desc_hid_report_dse) == 0x01AD);
// Invoked when received GET HID REPORT DESCRIPTOR // Invoked when received GET HID REPORT DESCRIPTOR
// Application return pointer to descriptor // Application return pointer to descriptor