53 Commits

Author SHA1 Message Date
TJ Horner
931edac2a5 Disable bluetooth proxy active connections by default in stock firmware 2023-10-31 19:00:48 -07:00
TJ Horner
6a5fbfa383 Firmware 1.1.2 2023-10-31 15:48:47 -07:00
TJ Horner
e334e7004f Add nightly build to ensure it always works with latest ESPHome 2023-05-26 20:02:56 -07:00
TJ Horner
c36fcb5232 Change issue template description 2023-05-26 18:42:22 -07:00
TJ Horner
a4484761cd I hope the template supports markdown in the description 2023-05-26 18:41:02 -07:00
TJ Horner
7bf1275e7d Rearrange bug report template 2023-05-26 18:40:00 -07:00
TJ Horner
b28dcb26ca Add bug report issue template 2023-05-26 18:38:07 -07:00
TJ Horner
0ae038b8b7 Switch to using second repository for project_version component 2023-05-23 10:28:23 -07:00
TJ Horner
543f901d90 Obtain custom component from GitHub instead of relative path 2023-05-23 10:19:57 -07:00
TJ Horner
f3b31ecc61 Version 1.1.1 2023-05-23 09:28:05 -07:00
TJ Horner
9bcd331a3d Version 1.1.0 2023-05-23 07:35:09 -07:00
TJ Horner
88f5110e62 Merge branch 'project-version-component' 2023-05-23 07:32:28 -07:00
TJ Horner
4a1289de03 tindie tools update 2023-05-23 07:30:22 -07:00
TJ Horner
6626be4545 Project version component test 2023-05-22 12:31:25 -07:00
TJ Horner
bd416f2ea7 Version 1.0.4 2023-05-22 11:08:28 -07:00
TJ Horner
54384fe695 Firmware and readme changes 2023-05-22 10:14:05 -07:00
TJ Horner
51650653bf Version 1.0.3 2023-05-20 22:20:09 -07:00
TJ Horner
b4aaef1dd2 Various PCB and tools changes, unrelated to firmware 2023-05-20 21:41:09 -07:00
TJ Horner
193cfe88a1 Add height units config back with fixes 2023-05-20 21:38:14 -07:00
TJ Horner
78d6c58d78 Re-add height units config with new method 2023-05-20 21:16:46 -07:00
TJ Horner
583a14d664 Remove "Height Units" from runtime config temporarily 2023-05-20 19:59:36 -07:00
TJ Horner
fd16478c5a Enforce min ESPHome version 2023.5.1 2023-05-18 08:41:43 -07:00
TJ Horner
ce9cb8b003 Version 1.0.1 2023-05-18 08:38:44 -07:00
TJ Horner
274ec9ac94 Fix runtime config addon for ESPHome 2023.5 2023-05-18 08:35:58 -07:00
TJ Horner
0567307595 Update package_import_url 2023-03-12 14:40:59 -07:00
TJ Horner
7a881dc1ee Firmware 1.0.0 2023-03-12 14:38:22 -07:00
TJ Horner
148b9cd379 Add runtime config button to re-detect decoder 2023-03-12 00:58:14 -08:00
TJ Horner
655cb303d3 Auto detection beta 2023-03-11 22:13:24 -08:00
TJ Horner
f4d61cdb36 Add Bluetooth Proxy support to stock firmware 2023-03-11 19:07:36 -08:00
TJ Horner
1986a79782 More tools docs 2023-03-01 10:04:22 -08:00
TJ Horner
a0602c1201 Add flashing script 2023-02-26 13:10:26 -08:00
TJ Horner
4f3b5acf58 0.4.0 2023-02-25 22:21:16 -08:00
TJ Horner
b238eb40c3 Don't import full config on dashboard import 2023-02-25 12:28:41 -08:00
TJ Horner
eb54c2c405 Rename the IDs for desk presets 2023-02-25 12:24:48 -08:00
TJ Horner
c09fa97c77 Move dashboard_import to stock config 2023-02-25 12:20:13 -08:00
TJ Horner
273dd62d9a 0.3.1 RC 2023-02-25 12:15:27 -08:00
TJ Horner
16792d6954 Firmware 0.3.0 2023-02-15 19:09:12 -08:00
TJ Horner
514491edd6 Add omnidesk decoder option 2023-02-01 13:35:38 -08:00
TJ Horner
517766ab65 Update enclosure STLs 2023-02-01 10:45:51 -08:00
TJ Horner
8c4924d9d9 Update doc links 2023-02-01 09:29:57 -08:00
TJ Horner
67e1cf6881 RE firmware 2023-01-31 21:25:10 -08:00
TJ Horner
920013eab1 misc PCB updates 2023-01-31 19:51:05 -08:00
TJ Horner
832859357d fulfillment docs 2023-01-31 19:51:05 -08:00
TJ Horner
3906ae05b2 Create FUNDING.yml 2023-01-03 11:49:01 -08:00
TJ Horner
82cacc03d4 Firmware 0.2.0 2022-10-28 12:45:03 -07:00
TJ Horner
f555c2829f Update README.md 2022-10-19 21:22:19 -07:00
TJ Horner
a6fa7a360c Update firmware with new timeout 2022-10-11 09:08:03 -07:00
TJ Horner
8cfc39eb1f Add test firmware and pcb changes 2022-09-30 20:25:52 -07:00
TJ Horner
ad485e9d5b add support email to readme 2022-09-30 20:15:02 -07:00
TJ Horner
7b82f71386 Debug firmware 2022-09-30 19:45:45 -07:00
TJ Horner
66c7e07592 Fix #10 2022-09-19 11:56:21 -07:00
TJ Horner
849b4d8896 readme update 2022-08-30 09:01:01 -07:00
TJ Horner
347db97405 update readme 2022-08-29 12:03:33 -07:00
38 changed files with 5017 additions and 2880 deletions

1
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1 @@
ko_fi: tjhorner

50
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@@ -0,0 +1,50 @@
name: Bug Report
description: File a bug report or get help with an issue.
labels: ["bug"]
assignees:
- tjhorner
body:
- type: checkboxes
id: troubleshooting-followed
attributes:
label: Troubleshooting Guide
description: Please confirm you have followed the [troubleshooting guide](https://upsy-desky.tjhorner.dev/docs/troubleshooting).
options:
- label: I have followed the steps in the troubleshooting guide and my issue is either not listed or is not solved.
required: true
- type: textarea
id: description
attributes:
label: Description
description: Please describe the bug you encountered, and what you expected to happen instead.
validations:
required: true
- type: textarea
id: logs
attributes:
label: Logs
description: Please copy and paste any relevant log output. Learn how to obtain logs [here](https://upsy-desky.tjhorner.dev/docs/troubleshooting/#other-issues).
render: plain text
- type: input
id: config-version
attributes:
label: Which version of the Upsy Desky firmware config are you running?
placeholder: "1.1.1"
- type: dropdown
id: update-management
attributes:
label: How do you manage your Upsy Desky's updates?
options:
- OTA Updates
- ESPHome YAML Config
- type: input
id: esphome-version
attributes:
label: If you're using an ESPHome YAML config, which version of ESPHome are you running?
placeholder: "2023.5.4"
- type: textarea
id: esphome-config
attributes:
label: ESPHome Config
description: If you have your own ESPHome YAML configuration, please paste it here. Remember to redact any sensitive information like encryption keys or passwords.
render: YAML

View File

@@ -17,14 +17,23 @@ jobs:
- name: Install ESPHome
run: pip install --user esphome
- name: Compile Firmware
- name: Compile Release Firmware
working-directory: firmware
run: |
esphome compile config.yaml
esphome compile stock.yaml
mkdir -p bin
cp .esphome/build/upsy-desky/.pioenvs/upsy-desky/firmware-factory.bin bin/firmware-factory.bin
cp .esphome/build/upsy-desky/.pioenvs/upsy-desky/firmware.bin bin/firmware.bin
- name: Compile Debug Firmware
working-directory: firmware
run: |
rm -rf .esphome/build/upsy-desky
esphome compile debug.yaml
mkdir -p bin
cp .esphome/build/upsy-desky/.pioenvs/upsy-desky/firmware-factory.bin bin/debug-firmware-factory.bin
cp .esphome/build/upsy-desky/.pioenvs/upsy-desky/firmware.bin bin/debug-firmware.bin
- name: Upload Firmware
uses: skx/github-action-publish-binaries@release-1.3
env:

40
.github/workflows/nightly-build.yaml vendored Normal file
View File

@@ -0,0 +1,40 @@
name: Nightly Stock Firmware Build
on:
schedule:
- cron: "0 0 * * *"
jobs:
build:
name: Build Firmware
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.9"
- name: Install ESPHome
run: pip install --user esphome
- name: Compile Release Firmware
working-directory: firmware
run: |
esphome compile stock.yaml
mkdir -p bin
cp .esphome/build/upsy-desky/.pioenvs/upsy-desky/firmware-factory.bin bin/firmware-factory.bin
cp .esphome/build/upsy-desky/.pioenvs/upsy-desky/firmware.bin bin/firmware.bin
- uses: actions/upload-artifact@v3
with:
name: firmware-bin
path: firmware/bin
- name: Send Discord failure notification
if: failure()
uses: appleboy/discord-action@master
with:
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }}
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
color: "#FF6961"
message: "The latest nightly build failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"

View File

@@ -2,11 +2,13 @@
This repository contains the source files for the Upsy Desky, a device which lets you connect your standing desk to any home automation system.
I will be selling them on Tindie, but if you're seeing this, it isn't available for purchase yet. You can sign up [here](https://forms.gle/285GffmpfHamryEu6) to get notified as soon as it is available. I anticipate starting sales sometime during the week of August 29th.
You can buy one on Tindie:
<!-- You can buy one on Tindie:
<a href="https://www.tindie.com/products/tjhorner/upsy-desky/?ref=offsite_badges&utm_source=sellers_tjhorner&utm_medium=badges&utm_campaign=badge_large"><img src="https://d2ss6ovg47m0r5.cloudfront.net/badges/tindie-larges.png" alt="I sell on Tindie" width="200" height="104"></a>
<a href="https://www.tindie.com/products/tjhorner/upsy-desky/?ref=offsite_badges&utm_source=sellers_tjhorner&utm_medium=badges&utm_campaign=badge_large"><img src="https://d2ss6ovg47m0r5.cloudfront.net/badges/tindie-larges.png" alt="I sell on Tindie" width="200" height="104"></a> -->
## Need Support?
If you need help with your Upsy Desky, please join the Upsy Desky [Discord server](https://discord.gg/ZHfXKQrSxF) where you can ask for help from the community and myself.
## Repository Structure
@@ -23,6 +25,7 @@ With these you can make your own Upsy Desky from scratch, or you can make change
This is the successor to the [WiFi Standing Desk Controller](https://github.com/tjhorner/wifi-desk-controller), packed with improvements and bug fixes — most notably:
- USB-C port for easy flashing (and because USB-C is cool 😎)
- Runtime firmware configuration -- no more manual flashing or compiling ESPHome to change stuff
- Improved enclosure design with a more snug fit and screw-mounted PCB, allowing for easier repairs and troubleshooting
- Replacing the D1 Mini with an ESP32-WROOM module, providing hardware UART for more reliable desk connection
- A catchier name, because "WiFi Standing Desk Controller" was a mouthful
@@ -43,15 +46,12 @@ Or whatever else you'd like. The possibilities are endless! As long as the possi
## Compatibility
Any standing desk that uses RJ45 to connect to the keypad is likely compatible, but these brands of desks have been verified to work, with official firmware provided:
- UPLIFT v2
- Fully Jarvis
Any standing desk that uses RJ45 to connect to the keypad is likely compatible, but the control boxes listed [here](https://upsy-desky.tjhorner.dev/docs/reference/compatibility/) are verified to be compatible.
## Documentation
You can find everything you need in the [GitHub wiki](https://github.com/tjhorner/upsy-desky/wiki/Getting-Started).
You can find everything you need in the [documentation](https://upsy-desky.tjhorner.dev/docs/getting-started/).
## Licenses
The ESPHome configs are licensed under MIT; everything else (enclosure and PCB design) are CC BY-NC-SA 4.0. The appropriate license files are available in the root of the repo.
The ESPHome configs are licensed under MIT; everything else (enclosure and PCB design) are CC BY-NC-SA 4.0. The appropriate license files are available in the root of the repo.

31
docs/fulfillment.md Normal file
View File

@@ -0,0 +1,31 @@
# Order Fulfillment Process
I wrote this out in order to help my future self if I ever go on hiatus or something. But it could be useful if you're starting to sell a similar product and are wondering what the process is like.
## Batch Order & Packing Slips
When ready to start fulfilling orders, export the unshipped orders from Tindie and generate packing slips to print using [this tool](https://github.com/tjhorner/tindie-packing-slip-generator).
## Shipping Labels
Upload the order CSV from Tindie to Pirate Ship to generate the shipping labels. If needed, make sure to split the CSV based on shipping speed (first class, priority, etc).
Print the shipping labels for the batch on a 4x6 label printer.
## Provision & QA Boards
Grab the amount of boards needed for the order, and send each of them through the QA process, which is semi-automated.
Flash the test target firmware to each board, and plug it in via RJ45 to a test host board. Plug a USB-C cable into the host board and watch for six flashes of the host's LED. If it flashes 6 times, the test is complete and QA is passed. Place a QA sticker on the back.
## Assemble Enclosure
If the customer opted for one, put the boards in enclosures and screw them in place.
## Flash Firmware
Flash the stock firmware on each of the boards using [this tool](https://shop.horner.tj/things/upsy-desky/setup/stock), via USB-C.
## Pack & Ship
Place shipping label for the order on the box. Fold the shipping label, place in the box. Put the items in bubble wrap, and place in the box. Seal the box, and ship it off. Repeat until done with batch.

Binary file not shown.

Binary file not shown.

18
firmware/README.md Normal file
View File

@@ -0,0 +1,18 @@
# Firmware Configs
This directory contains [ESPHome](https://esphome.io) config files for the Upsy Desky.
It is organized like so:
- `base.yaml`: The base essential configuration, which contains components for reading the desk height, preset buttons, etc.
- `stock.yaml`: Inherits everything from `base.yaml` and adds components which are useful on stock firmware, such as the WiFi hotspot, web server, and Improv Serial
- `debug.yaml`: Inherits everything from `stock.yaml` and adds components which are useful for debugging
## Addons
Major parts of the config are separated into "addons" so they can be easily included or excluded. The following addons are available:
- `presets.yaml`: Adds support for recalling and setting presets on the desk control box
- `runtime-config.yaml`: Adds support for runtime configuration options (you might want to remove this if you are configuring everything via ESPHome yaml)
- `bluetooth-proxy.yaml`: Contains the necessary configuration to use the Upsy Desky as a [Bluetooth Proxy](https://esphome.io/components/bluetooth_proxy.html)
- `stable-ids.yaml`: Contains configuration necessary to keep some entity IDs stable via the HTTP API

View File

@@ -0,0 +1,7 @@
substitutions:
bluetooth_proxy_active_connections: "true"
esp32_ble_tracker:
bluetooth_proxy:
active: ${bluetooth_proxy_active_connections}

View File

@@ -0,0 +1,105 @@
output:
- platform: gpio
inverted: true
id: button_bit1
pin: ${button_bit1_pin}
- platform: gpio
inverted: true
id: button_bit2
pin: ${button_bit2_pin}
- platform: gpio
inverted: true
id: button_bit4
pin: ${button_bit4_pin}
- platform: gpio
inverted: true
id: button_m
pin: ${button_m_pin}
button:
# Recall Presets
- platform: template
id: recall_preset_1
name: "Preset 1"
icon: "mdi:numeric-1-box"
on_press:
- output.turn_on: button_bit1
- output.turn_on: button_bit2
- delay: 1s
- output.turn_off: button_bit2
- output.turn_off: button_bit1
- platform: template
id: recall_preset_2
name: "Preset 2"
icon: "mdi:numeric-2-box"
on_press:
- output.turn_on: button_bit4
- delay: 100ms
- output.turn_off: button_bit4
- platform: template
id: recall_preset_3
name: "Preset 3"
icon: "mdi:numeric-3-box"
on_press:
- output.turn_on: button_bit2
- output.turn_on: button_bit4
- delay: 100ms
- output.turn_off: button_bit4
- output.turn_off: button_bit2
- platform: template
id: recall_preset_4
name: "Preset 4"
icon: "mdi:numeric-4-box"
on_press:
- output.turn_on: button_bit4
- output.turn_on: button_bit1
- delay: 100ms
- output.turn_off: button_bit1
- output.turn_off: button_bit4
# Set Presets
- platform: template
name: "Set Preset 1"
entity_category: "config"
icon: "mdi:numeric-1-box-multiple"
on_press:
- output.turn_on: button_m
- delay: 100ms
- output.turn_off: button_m
- button.press: recall_preset_1
- platform: template
name: "Set Preset 2"
entity_category: "config"
icon: "mdi:numeric-2-box-multiple"
on_press:
- output.turn_on: button_m
- delay: 100ms
- output.turn_off: button_m
- button.press: recall_preset_2
- platform: template
name: "Set Preset 3"
entity_category: "config"
icon: "mdi:numeric-3-box-multiple"
on_press:
- output.turn_on: button_m
- delay: 100ms
- output.turn_off: button_m
- button.press: recall_preset_3
- platform: template
name: "Set Preset 4"
entity_category: "config"
icon: "mdi:numeric-4-box-multiple"
on_press:
- output.turn_on: button_m
- delay: 100ms
- output.turn_off: button_m
- button.press: recall_preset_4

View File

@@ -0,0 +1,56 @@
select:
- platform: template
id: height_units_config
name: "Height Units"
entity_category: "config"
optimistic: true
restore_value: true
options:
- in
- cm
initial_option: ${default_height_units}
on_value:
then:
lambda: |
const char *unit = id(height_units_config)->state.c_str();
id(desk_height)->set_unit_of_measurement(unit);
id(target_desk_height)->traits.set_unit_of_measurement(unit);
button:
- platform: template
name: "Re-Detect Decoder"
entity_category: "config"
icon: "mdi:cog-refresh"
on_press:
- uart.write:
id: handset_tx
data: [ 0x0 ]
- standing_desk_height.detect_decoder: desk_height
number:
- platform: template
name: "Min Target Height"
entity_category: "config"
min_value: 0
max_value: 150
step: 0.1
optimistic: true
restore_value: true
initial_value: ${standing_desk_min_height}
on_value:
then:
lambda: |
id(target_desk_height)->traits.set_min_value(x);
- platform: template
name: "Max Target Height"
entity_category: "config"
min_value: 0
max_value: 150
step: 0.1
optimistic: true
restore_value: true
initial_value: ${standing_desk_max_height}
on_value:
then:
lambda: |
id(target_desk_height)->traits.set_max_value(x);

View File

@@ -0,0 +1,35 @@
# This file provides stable entity IDs for various components, in order to be used in the HTTP API.
# ESPHome derives entity IDs (internally called "object IDs") from the component name, which is
# used as the ID in the HTTP API endpoints. Unfortunately there is no way to control them so they
# are set independently of the name, so this is a weird workaround for that.
sensor:
- platform: copy
source_id: desk_height
internal: true
name: "desk_height"
number:
- platform: copy
source_id: target_desk_height
internal: true
name: "target_desk_height"
button:
- platform: copy
source_id: recall_preset_1
internal: true
name: "desk_preset_1"
- platform: copy
source_id: recall_preset_2
internal: true
name: "desk_preset_2"
- platform: copy
source_id: recall_preset_3
internal: true
name: "desk_preset_3"
- platform: copy
source_id: recall_preset_4
internal: true
name: "desk_preset_4"

63
firmware/base.yaml Normal file
View File

@@ -0,0 +1,63 @@
# Essential ESPHome config options
esphome:
name: "${name}"
friendly_name: "${friendly_name}"
name_add_mac_suffix: true
min_version: "2023.5.1"
on_boot:
then:
# Wakes up the desk and reports height
- uart.write:
id: handset_tx
data: [ 0x0 ]
project:
name: tj_horner.upsy_desky
version: "1.2.0"
uart:
id: handset_tx
tx_pin: 16
baud_rate: 9600
esp32:
board: esp32dev
# Configurable options
substitutions:
name: "upsy-desky"
friendly_name: "Upsy Desky"
desk_height_name: "Desk Height"
target_desk_height_name: "Target Desk Height"
# Standing Desk Component Config
standing_desk_uart_rx_pin: "17"
standing_desk_up_pin: "21"
standing_desk_down_pin: "22"
standing_desk_min_height: "25.2"
standing_desk_max_height: "50.8"
# Presets Addon Config
button_bit1_pin: "21"
button_bit2_pin: "22"
button_bit4_pin: "19"
button_m_pin: "18"
# Runtime Config Defaults
default_height_units: "in" # Must be "in" or "cm"
packages:
standing_desk: github://tjhorner/esphome-standing-desk/configs/template.yaml
addon_presets: !include addons/presets.yaml
addon_stable_ids: !include addons/stable-ids.yaml
addon_runtime_config: !include addons/runtime-config.yaml
button:
- platform: restart
name: "Restart"
light:
- platform: status_led
id: upsy_desky_status_led
name: "Status LED"
pin: GPIO23
restore_mode: RESTORE_DEFAULT_ON

View File

@@ -1,132 +1,8 @@
substitutions:
name: "upsy-desky"
friendly_name: "Upsy Desky"
# This file is here for reverse compatibility. Older versions of the firmware
# pointed to `config.yaml` instead of `base.yaml`. That file also included the
# config found in `stock.yaml`, which is why it's being included here.
# Defaults
standing_desk_uart_rx_pin: "17"
standing_desk_up_pin: "21"
standing_desk_down_pin: "22"
standing_desk_variant: "uplift"
standing_desk_min_height: "25.2"
standing_desk_max_height: "50.8"
# Presets
button_bit1_pin: "21"
button_bit2_pin: "22"
button_bit4_pin: "19"
button_m_pin: "18"
esphome:
name: "${name}"
name_add_mac_suffix: true
on_boot:
then:
# Wakes up the desk and reports height
- uart.write:
id: handset_tx
data: [ 0x0 ]
project:
name: tj_horner.upsy_desky
version: "0.1.0"
dashboard_import:
package_import_url: github://tjhorner/upsy-desky/firmware/config.yaml
uart:
id: handset_tx
tx_pin: 16
baud_rate: 9600
esp32:
board: esp32dev
logger:
level: INFO
wifi:
ap:
password: "hunter2hunter2"
captive_portal:
improv_serial:
api:
password: ""
reboot_timeout: 0s
web_server:
port: 80
ota:
password: ""
# Please use `base.yaml` for new configurations and customizations.
packages:
standing_desk: github://tjhorner/esphome-standing-desk/configs/template.yaml
presets_addon: github://tjhorner/esphome-standing-desk/configs/addons/presets.yaml
select:
- platform: template
name: "${friendly_name} Height Decoder Variant"
entity_category: "config"
optimistic: true
restore_value: true
options:
- uplift
- jarvis
initial_option: ${standing_desk_variant}
on_value:
then:
lambda: "id(desk_height)->set_decoder_variant(x);"
- platform: template
name: "${friendly_name} Height Units"
entity_category: "config"
optimistic: true
restore_value: true
options:
- in
- cm
initial_option: in
on_value:
then:
lambda: |
id(desk_height)->set_unit_of_measurement(x);
id(target_desk_height)->traits.set_unit_of_measurement(x);
number:
- platform: template
name: "${friendly_name} Min Target Height"
entity_category: "config"
min_value: 0
max_value: 150
step: 0.1
optimistic: true
restore_value: true
initial_value: ${standing_desk_min_height}
on_value:
then:
lambda: |
id(target_desk_height)->traits.set_min_value(x);
- platform: template
name: "${friendly_name} Max Target Height"
entity_category: "config"
min_value: 0
max_value: 150
step: 0.1
optimistic: true
restore_value: true
initial_value: ${standing_desk_max_height}
on_value:
then:
lambda: |
id(target_desk_height)->traits.set_max_value(x);
switch:
- platform: restart
name: "${friendly_name} Restart"
light:
- platform: status_led
id: status
pin: GPIO23
restore_mode: ALWAYS_ON
stock: !include stock.yaml

13
firmware/debug.yaml Normal file
View File

@@ -0,0 +1,13 @@
packages:
stock: !include stock.yaml
logger:
level: DEBUG
debug:
update_interval: 5s
text_sensor:
- platform: debug
device:
name: "Device Info"

42
firmware/stock.yaml Normal file
View File

@@ -0,0 +1,42 @@
packages:
base: !include base.yaml
addon_bluetooth_proxy: !include addons/bluetooth-proxy.yaml
substitutions:
bluetooth_proxy_active_connections: "false"
external_components:
- source: github://tjhorner/esphome-custom-components
components: [ project_version ]
text_sensor:
- platform: project_version
name: "Upsy Desky Firmware Version"
internal: true
logger:
level: INFO
wifi:
ap:
password: "hunter2hunter2"
captive_portal:
improv_serial:
esp32_improv:
authorizer: false
api:
reboot_timeout: 0s
web_server:
port: 80
js_url: "https://upsy-desky.tjhorner.dev/esphome-webserver/www.js"
ota:
password: ""
dashboard_import:
package_import_url: github://tjhorner/upsy-desky/firmware/stock.yaml@v1.1.1

4
pcb/.gitignore vendored
View File

@@ -28,4 +28,6 @@ fp-info-cache
*.xml
*.csv
gerbers/
gerbers/
*auto_saved_files*

View File

@@ -1,6 +1,6 @@
(footprint "ASSMANN_A-2004-2-4-LPS-N-R" (version 20211014) (generator pcbnew)
(layer "F.Cu")
(tedit 62311021)
(tedit 63864A77)
(attr through_hole)
(fp_text reference "REF**" (at -4.555 -11.889) (layer "F.SilkS")
(effects (font (size 1.4 1.4) (thickness 0.15)))
@@ -26,8 +26,8 @@
(fp_line (start 7.9 -10.3) (end 7.9 8.3) (layer "F.Fab") (width 0.127) (tstamp 9be18c40-130d-4b66-9102-1da4e1c80119))
(fp_line (start 7.9 8.3) (end -7.9 8.3) (layer "F.Fab") (width 0.127) (tstamp da8e1788-d257-4d54-96d3-98c87df0cc6e))
(fp_circle (center -8.586 -6.281) (end -8.486 -6.281) (layer "F.Fab") (width 0.2) (fill none) (tstamp a9c8a56e-461b-492b-9749-aebe8a2a8c81))
(pad "" np_thru_hole circle (at -5.715 0) (size 3.2 3.2) (drill 3.2) (layers *.Cu *.Mask) (tstamp 6ad6668c-228b-41c6-ba41-b8d810fe2c36))
(pad "" np_thru_hole circle (at 5.715 0) (size 3.2 3.2) (drill 3.2) (layers *.Cu *.Mask) (tstamp c370c61a-aa48-4c72-bac6-3715e3d21ea7))
(pad "" np_thru_hole circle (at -5.715 0) (size 3 3) (drill 3) (layers F&B.Cu *.Mask) (tstamp 6ad6668c-228b-41c6-ba41-b8d810fe2c36))
(pad "" np_thru_hole circle (at 5.715 0) (size 3 3) (drill 3) (layers F&B.Cu *.Mask) (tstamp c370c61a-aa48-4c72-bac6-3715e3d21ea7))
(pad "1" thru_hole rect (at -4.445 -6.35) (size 1.408 1.408) (drill 0.9) (layers *.Cu *.Mask) (tstamp bf05b196-f692-40f6-810b-c29cb2a69ab8))
(pad "2" thru_hole circle (at -3.175 -8.89) (size 1.408 1.408) (drill 0.9) (layers *.Cu *.Mask) (tstamp e63b355a-7064-4efd-a5a1-ac83a46530f8))
(pad "3" thru_hole circle (at -1.905 -6.35) (size 1.408 1.408) (drill 0.9) (layers *.Cu *.Mask) (tstamp d47596a7-7b6b-44f8-b2da-486cb1ae09ed))

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,6 @@
{
"board": {
"3dviewports": [],
"design_settings": {
"defaults": {
"board_outline_line_width": 0.09999999999999999,
@@ -138,7 +139,8 @@
"zones_allow_external_fillets": false,
"zones_use_no_outline": true
},
"layer_presets": []
"layer_presets": [],
"viewports": []
},
"boards": [],
"cvpcb": {
@@ -322,18 +324,23 @@
"rule_severities": {
"bus_definition_conflict": "error",
"bus_entry_needed": "error",
"bus_label_syntax": "error",
"bus_to_bus_conflict": "error",
"bus_to_net_conflict": "error",
"conflicting_netclasses": "error",
"different_unit_footprint": "error",
"different_unit_net": "error",
"duplicate_reference": "error",
"duplicate_sheet_names": "error",
"endpoint_off_grid": "warning",
"extra_units": "error",
"global_label_dangling": "warning",
"hier_label_mismatch": "error",
"label_dangling": "error",
"lib_symbol_issues": "warning",
"missing_bidi_pin": "warning",
"missing_input_pin": "warning",
"missing_power_pin": "error",
"missing_unit": "warning",
"multiple_net_names": "warning",
"net_not_bus_member": "warning",
"no_connect_connected": "warning",
@@ -343,6 +350,7 @@
"pin_to_pin": "warning",
"power_pin_not_driven": "error",
"similar_labels": "warning",
"simulation_model_issue": "error",
"unannotated": "error",
"unit_value_mismatch": "error",
"unresolved_variable": "error",
@@ -360,7 +368,7 @@
"net_settings": {
"classes": [
{
"bus_width": 12.0,
"bus_width": 12,
"clearance": 0.2,
"diff_pair_gap": 0.25,
"diff_pair_via_gap": 0.25,
@@ -374,13 +382,15 @@
"track_width": 0.25,
"via_diameter": 0.8,
"via_drill": 0.4,
"wire_width": 6.0
"wire_width": 6
}
],
"meta": {
"version": 2
"version": 3
},
"net_colors": null
"net_colors": null,
"netclass_assignments": null,
"netclass_patterns": []
},
"pcbnew": {
"last_paths": {
@@ -396,6 +406,8 @@
"schematic": {
"annotate_start_num": 0,
"drawing": {
"dashed_lines_dash_length_ratio": 12.0,
"dashed_lines_gap_length_ratio": 3.0,
"default_line_thickness": 6.0,
"default_text_size": 50.0,
"field_names": [],
@@ -425,9 +437,13 @@
"workbook_filename": ""
},
"page_layout_descr_file": "",
"plot_directory": "",
"plot_directory": "./",
"spice_adjust_passive_values": false,
"spice_current_sheet_as_root": false,
"spice_external_command": "spice \"%I\"",
"spice_model_current_sheet_as_root": true,
"spice_save_all_currents": false,
"spice_save_all_voltages": false,
"subpart_first_id": 65,
"subpart_id_separator": 0
},

File diff suppressed because it is too large Load Diff

5
reversing-firmware/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
# Gitignore settings for ESPHome
# This is an example and may include too much for your use-case.
# You can modify this file to suit your needs.
/.esphome/
/secrets.yaml

View File

@@ -0,0 +1,11 @@
# Reverse Engineering Firmware
This is a special firmware designed to aid in the reverse engineering of new desk control box protocols. You can find the complete reverse engineering guide [here](https://upsy-desky.tjhorner.dev/docs/advanced/reverse-engineering/).
You can flash this firmware on your stock Upsy Desky; no additional hardware is required. It uses ESPHome's [UART debugging feature](https://esphome.io/components/uart.html#debugging) to log all communication between the keypad and control box. You can use this data to reverse engineer the protocol based on the RE guide linked above.
## Customization
Aside from the normal UART parameters like baud rate, it may be helpful to adjust the parameters in the UART debugging component to make the data more readable and easier to RE. Particularly useful is the `after` parameter, which allows you to log a string of bytes after some specified number of bytes, timeout, or delimiter. You can see the specific configuration options in the [ESPHome documentation](https://esphome.io/components/uart.html#debugging).
You may also wish to change the GPIO port to match the RX and TX pins on your control box if the defaults don't match yours. See the [GPIO Pinout](https://upsy-desky.tjhorner.dev/docs/reference/gpio/) mapping to see which RJ45 pins correspond to which GPIO pins.

View File

@@ -0,0 +1,50 @@
substitutions:
name: "upsy-desky"
esphome:
name: "${name}"
name_add_mac_suffix: true
esp32:
board: esp32dev
logger:
level: DEBUG
# UART logging is from the perspective of the handset, i.e.:
# - TX is the data sent from the handset to the control box
# - RX is the data sent from the control box to the handset
uart:
- # Direction: Handset -> Control Box
id: handset_tx
baud_rate: 9600
rx_pin: 17
debug: &uart_debug
direction: RX
dummy_receiver: true
after:
timeout: 50ms
sequence:
- lambda: UARTDebug::log_hex(uart::UART_DIRECTION_TX, bytes, ':');
- # Direction: Control Box -> Handset
id: handset_rx
baud_rate: 9600
rx_pin: 16
debug:
<<: *uart_debug
sequence:
- lambda: UARTDebug::log_hex(uart::UART_DIRECTION_RX, bytes, ':');
wifi:
ap:
password: "hunter2hunter2"
captive_portal:
improv_serial:
web_server:
port: 80
ota:
password: ""

5
test-firmware/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch

10
test-firmware/.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}

13
test-firmware/README.md Normal file
View File

@@ -0,0 +1,13 @@
# Test Firmware
This firmware is used to test assembled boards before shipping. In the future I'd like this process to be more automated and comprehensive but this is what I have for now.
## Usage
You will need 2 desk controller boards for this.
1. Flash the `test_host` env to a board. This will be the known-good "host" board that will report the test results.
2. Flash the `test_target` env to the board you want to test. Unplug both from the computer.
3. Connect the host board to the target board with an RJ45 patch cable.
4. Plug the target board into power using micro USB. This will provide power to both boards since the +5V line is shared between them.
5. The LED on the host board should flash a total of 6 times. If it doesn't, this means one of the pins is not connected correctly. Troubleshoot accordingly.

View File

@@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

46
test-firmware/lib/README Normal file
View File

@@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html

View File

@@ -0,0 +1,20 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env]
platform = espressif32
board = esp32dev
framework = arduino
[env:test_host]
build_flags = -D TEST_HOST
[env:test_target]
build_flags = -D TEST_TARGET

View File

@@ -0,0 +1,68 @@
#include <Arduino.h>
#define LED_BUILTIN 23
// These correspond to RJ45 pins 1-6
int pins_to_test[] = {
18,
17,
16,
19,
21,
22
};
void setup() {
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
#ifdef TEST_HOST
Serial.println("Initializing test host...");
for (int &pin : pins_to_test) {
pinMode(pin, INPUT);
}
digitalWrite(LED_BUILTIN, HIGH);
delay(100);
for (int &pin : pins_to_test) {
Serial.print("Waiting for pin ");
Serial.print(pin);
Serial.println();
while (digitalRead(pin) == LOW) {
delay(50);
}
digitalWrite(LED_BUILTIN, LOW);
delay(100);
digitalWrite(LED_BUILTIN, HIGH);
}
#else
digitalWrite(LED_BUILTIN, HIGH);
Serial.println("Initializing test target...");
for (int &pin : pins_to_test) {
pinMode(pin, OUTPUT);
digitalWrite(pin, LOW);
}
#endif
}
void loop() {
#ifdef TEST_TARGET
for (int &pin : pins_to_test) {
Serial.print("Pulsing pin ");
Serial.print(pin);
Serial.println();
digitalWrite(pin, HIGH);
delay(1000);
digitalWrite(pin, LOW);
}
#endif
}

11
test-firmware/test/README Normal file
View File

@@ -0,0 +1,11 @@
This directory is intended for PlatformIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PlatformIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html

9
tools/README.md Normal file
View File

@@ -0,0 +1,9 @@
# Tools
## `oem-flash.sh`
This script is used before shipment to flash the Upsy Desky with the stock firmware, and to reprogram the CP2102 USB-to-serial chip with the correct name and serial (based on MAC address).
## `test-flash.sh`
Flashes the test firmware with PlatformIO (see `../test-firmware`).

12
tools/oem-flash.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
MAC_ADDR=$(esptool.py --chip esp32 read_mac | sed -En "s/MAC: (.*)/\1/p" | uniq | sed 's/://g')
esphome upload --device /dev/cu.usbserial* ../firmware/stock.yaml
if ! command -v cp210x-cfg &> /dev/null
then
# Get cp210x-cfg from https://github.com/DiUS/cp210x-cfg
echo "cp210x-cfg was not found; CP2102 will not be serialized or renamed"
else
cp210x-cfg -N "Upsy Desky" -S $MAC_ADDR
fi

2
tools/test-flash.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
platformio run -d ../test-firmware --target upload --environment test_target

1
tools/tindie/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.csv

26
tools/tindie/split-csv.sh Executable file
View File

@@ -0,0 +1,26 @@
#!/bin/bash
rm -f ud_orders.csv first_class_and_intl.csv priority.csv priority_express.csv pickup.csv
csvq -o ud_orders.csv "SELECT * FROM all_orders WHERE \`Model Number\` LIKE \"%UPSY%\";"
csvq -o first_class_and_intl.csv "SELECT * FROM ud_orders WHERE \`Shipping Method\` LIKE \"%First-Class%\" OR \`Shipping Method\` LIKE \"%Simple Export Rate%\";"
csvq -o priority.csv "SELECT * FROM ud_orders WHERE \`Shipping Method\` LIKE \"%Priority Mail%\" AND \`Shipping Method\` NOT LIKE \"%Priority Mail Express%\";"
csvq -o priority_express.csv "SELECT * FROM ud_orders WHERE \`Shipping Method\` LIKE \"%Priority Mail Express%\";"
csvq -o pickup.csv "SELECT * FROM ud_orders WHERE \`Shipping Method\` LIKE \"%Pickup%\";"
SANITY_CHECK_QUERY=$(cat <<-END
SELECT
(SELECT count(*) from ud_orders)
=
(
(SELECT count(*) from first_class_and_intl) +
(SELECT count(*) from priority) +
(SELECT count(*) from priority_express) +
(SELECT count(*) from pickup)
)
AS SanityCheck;
END
)
csvq "$SANITY_CHECK_QUERY"