Giter VIP home page Giter VIP logo

desk_control's Introduction

desk_control

Purpose

      Work provided me a desk. Fancy. Sit to stand. It was crap.
      Well, it looked like crap, because the desk-top was cheap, small, and ugly.
      When I began to disassemble it, though, I noticed that the mechanics beneath it's surface were of very high
      quality.
      This is the UPLIFT sit-to-stand desk from a major paper-supply company named after the tiny bits of metal used
      to bind their paper-products together.

      I decided that the desk-top was the only low quality bit involved, so I kept the desk and purchased a new
      countertop from a Swedish Furniture store popular in my area. The new countertop is HEAVY (65lbs), but the dual
      200N motors on this baby can support that just fine!

      So, as I'm re-assembling the desk, I notice an odd rj11 device. It's...bluetooth?!
      That's right. a bluetooth device set up on an rj-11 port. Why not like, integrate or go USB?
      Anyway, to operate this Bluetooth dongle, and therefore my desk, you've got to DOWNLOAD THE APP.
      Yep. Another. Stinking. App.
      As you'd expect, it's a cheap product with Chinese Developer making the app.
      I don't need another app on my phone, especially not a low-budget app which requires camera access to operate.

      Well, it's just a device. At the basic level, it's just sending some data to the desk. If I can identify that data, then I
      can send that data to the desk myself. Idk, with a pi or something?

      My first thought was to patch together an rj-11 listening device, path the split to rpi GPIO and just listen in on the
      physical data transmissions,
      replace the bluetooth all-together with an ethernet cable from the rpi-GPIO to the rj11.
      A Buddy, however, suggested I learn me a bluetooth hack. Turns out it didn't require much hacking. Security was
      very low.

      This repo holds the code used now to control my desk, as well as some auxiliary info obtained during the reverse
      engineering process.


Contents

File Description
desk_control.sh The core of the desk-control ecosystem. Basic. Get's the Job done. Great for impressing the ladies with Command Line superpowers.
desk_control.py A Python3 implementation of the same code. Slightly more refined, designed to allow for easy importing (to an api, maybe write your own app?)
desk_characteristics.txt Data from the bluetooth reconnaisance
bluetooth_ctl_properties.txt Some attempted reconnaisance using bluetoothctl. MUCH Less useful than gatttool.
README.MD A useless file full of sentimental reminiscing
delta.txt A saved version of advertised BT data after making a change to height. There's no discernable declaration of the desk height, though. So it's a useless file. (I'm gonna go back to this and learn more, it's simply GOT to have the data.)

Requirements

Basic Functionality:

  • Uplift Sit-to-Stand Desk from Staples with the jcp35n-blt bluetooth adapter
  • Linux
  • gatttol installed
  • compatible bluetooth chip/dongle

Advanced Functionality:

  • Basic Requirements+
  • Python3
  • pygatt (a Front End for gatttool) (also in the requirements.txt, can be installed via pip.)
  • non-root user with sudo (python can't access the bluetooth without sudo)

Usage

  • Note: the 'sit' and 'stand' features presume that you've already saved these values into the desk memory.
    • You can do this with the crappy app, or you can do so with the physical controller.
    • Once you have this script working, you can unplug the physical controller.
      • I've tested this, as my toddler recently learned how to push the buttons while I'm working.
        • That maybe one of the biggest motivations for this codebase.
  • Note: Edge Cases. They're a thing. I have not yet identified how to discern the current extension length of the desk.
    • If you bottom out, it doesn't do anything, but I'm not sure about maxing out. Exercise caution at great heights.

Bash

  1. Once all requirements are met, put the desk_control.sh file wherever you like to put scripts, and make it executable.
  2. Edit the desk_control.sh file to replace my bt_addr with your bt_addr.
  3. Make your desk bounce like a hydrolic lowrider with bash desk_control.sh -s stand or bash desk_control.sh -s sit

Python3

  1. Once all requirements are met, put the desk_control.py file wherever you like to put scripts, and make it executable.
  2. Edit the desk_control.py file to replace my bt_addr with your bt_addr in the __main__ section.
  3. Make your desk bounce like a hydrolic lowrider with sudo python3 desk_control.py sit or sudo python3 desk_control.py raise 10
    • On my desk, each iteration of raise or lower is approximately .3 inches as measured by my LASER MEASURING TAPE.

Future Features

  1. Read the current height from the bluetooth. This will allow setting specific heights in the code.
  2. Program my own presets (eliminate physical controls completely!)
  3. API Wrapper. That way I can control it from my phone. So cool and innovative!

desk_control's People

Contributors

c-lock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

jameshirka

desk_control's Issues

Not an actual issue - THANK YOU!

I've got the same desk and controller but from a different company as I'm in Australia. It's obviously so crappy they no longer offer the BLE module.
I've searched for solutions before and even contacted the manufacturer, but never really got anything.
Today by random fluke I came upon your repo, and wanted to say thank you for creating this!

I intend to run this on my Raspberry Pi connected to the UPS under my desk, and will then have to figure out how to get it to talk to Home Assistant (as I plan to have my desk go up every time I get on a Teams call).

Thank you!

Uplift v2 BT Commands

The scripts weren't working for me so I captured BT packets from my phone and then kept trying the commands until I found the ones that worked.

Using Adapter SKU FRM125.

Handle: 0x000d

Commands:

  • Stand Height: f1f11b02046a8b7e
  • Sit Height: f1f11b0202adcc7e
  • Raise Desk: f1f10100017e (apx 0.5")
  • Lower Desk: f1f10200027e (apx 0.5")

I think the height is transmitted via handle 0x000f, but it isn't clear. The seventh and ninth set of hex would update between commands. When translated to decimal, the ninth set is always eight higher than the seventh. IE - it would be 0x17 and 0x1f (23/31), 0x0d and 0x15 (13/21), 0x23 and 0x2b (35/43), etc.

Read current height

What do you think it would take to read the current height of the desk?
I had the manufacturer send me some info a while ago that may have useful programming references, but it doesn't mean a huge amount to me, so I'd be happy to share those.
Unfortunately I'm no dev (only a bit of YAML, JSON and HTML here and there), but happy to help with what I can.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.