Skip to content

A plugin that emulates a remote control aka a doofah

Notifications You must be signed in to change notification settings

Metrological/ThunderDoofah

Repository files navigation

Doofah

Doofah is a remote control emulator to be used in the Thunder ecosystem. It will consist of a Plugin communicating to an endpoint. The endpoint will contain the needed hardware to control the box. For now, we only focused on a BLE endpoint running on a cheap, widely available ESP32 microcontroller. We use the M5Stack ATOM lite. IR should also be possible in the future.

Setup Endpoint

Installation

  1. Install Visual Code Studio
  2. Install PlatformIO
  3. Open the Doofah-Endpoint folder in Visual Code Studio.
  4. Connect the ESP32 to your computer.
  5. Setup the upload_port for your environment.
  6. Compile (:ballot_box_with_check:) and upload (:arrow_right:) the project (see the blue bar on the bottom of Visual Code Studio).
  • When you upload for the first time, please do a factory reset by pressing the button for more than 10 seconds. The led will blink red in this process

Enable verbose logging

There is an option to get some logging from the endpoint. An additional USB to TTL-Serial adapter is then required.

  1. Connect the USB to TTL-Serial to these pins
  2. Connect the USB to TTL-Serial adapter to your computer.
  3. Connect your ESP32 to your computer.
  4. Setup the monitor_port for your environment.
  5. Compile and upload the project
  6. Open the USB to TTL-Serial port on your computer
  7. If you reset the ESP32, you should see something like this.
    3 [lib/Storage/Storage.cpp:28 (0x3ffc3980) Allocate] 132 bytes avalaible on address 0
    12 [lib/Storage/Storage.cpp:28 (0x3ffc3980) Allocate] 19 bytes avalaible on address 134
    62 [lib/Storage/Storage.cpp:87 (0x3ffc3980) Begin] 
    69 [lib/Storage/Storage.cpp:89 (0x3ffc3980) Begin] Starting Storage with max 155 bytes
    77 [lib/Storage/Storage.cpp:115 (0x3ffc3980) DumpFlash] Flash[155]: '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
    110 [lib/Contoller/Controller.cpp:79 (0x3ffc39a0) StartDevices] Starting 2 devices
    118 [lib/Storage/Storage.cpp:44 (0x3ffc3980) Read] No data
    433 [lib/Devices/BleKeyboardDevice.h:87 (0x3ffc23ec) Begin] Started BLE [94:b9:7e:8b:ee:f2]
    442 [lib/Storage/Storage.cpp:44 (0x3ffc3980) Read] No data
    448 [lib/Devices/IRKeyboardDevice.h:57 (0x3ffc23d8) Begin] Started IR [12]
    456 [src/main.cpp:242 setup] Starting endpoint build Wed Aug 10 13:22:05 2022
    463 [src/main.cpp:77 SendMessage] Sending 5 bytes with operation=0x80 result=0x00...
    471 [src/main.cpp:67 PrintMessage] SendMessage: message[8000000026]
    916 [src/main.cpp:77 SendMessage] Sending 5 bytes with operation=0x80 result=0x00...
    923 [src/main.cpp:67 PrintMessage] SendMessage: message[8000000026]
    

Setup Plugin

Build

The plugin is a CMake-based project built like all other existing Thunder plugins

Options:

  1. PLUGIN_DOOFAH_AUTOSTART: Automatically start the plugin; default: false
  2. PLUGIN_DOOFAH_CONNECTOR_CONFIG: Custom config for the connector/serial port; default: "")

JSONRPC API

list Devices

curl --location --request POST 'http://<Thunder IP>/jsonrpc/Doofah' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "jsonrpc": "2.0",
        "id": 42,
        "method": "Doofah.1.devices"
    }'

Reboot Endpoint

curl --location --request POST 'http://<Thunder IP>/jsonrpc/Doofah' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "jsonrpc": "2.0",
        "id": 42,
        "method": "Doofah.1.reset",
        "params": {
            "device": "0x00"
        }
    }'

Press Key

curl --location --request POST 'http://<Thunder IP>/jsonrpc/Doofah' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "jsonrpc": "2.0",
        "id": 42,
        "method": "Doofah.1.press",
        "params": {
            "device": "0x01",
            "code": "0x1233"
        }
    }'

Release Key

curl --location --request POST 'http://<Thunder IP>/jsonrpc/Doofah' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "jsonrpc": "2.0",
        "id": 42,
        "method": "Doofah.1.release",
        "params": {
            "device": "0x01",
            "code": "0x1233"
        }
    }'

Setup BLE device

curl --location --request POST 'http://<Thunder IP>/jsonrpc/Doofah' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "jsonrpc": "2.0",
        "id": 42,
        "method": "Doofah.1.setup",
        "params": {
            "device":"0x01",
            "configuration": {
                "type":"ble",
                "setup":{
                    "vid":"0x1234",
                    "pid":"0xabcd",
                    "name":"custom-doofer-name"
                }
            }
        }
    }'

Clear BLE device

curl --location --request POST 'http://<Thunder IP>/jsonrpc/Doofah' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "jsonrpc": "2.0",
        "id": 42,
        "method": "Doofah.1.reset",
        "params": {
            "device": "0x01"
        }
    }'

About

A plugin that emulates a remote control aka a doofah

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •