Skip to content
hexagon2206 edited this page Dec 22, 2016 · 16 revisions

General

The game controller listens on port 6524 (TCP). The port can be changed via the ESP firmware.

WiFi configuration

The WiFi SSID and password, the ESP should connect to, can be configured via USB:

  1. Connect the NodeMCU to a computer
  2. Press reset and the button next to the LEDs simultaneously
  3. The NodeMCU now has a baud rate of 115200 and waits for data on its serial interface
  4. The SSID and password can be transferred with the following format: xSSIDxPASSx where x is a separator. x should be 0x00.
  5. Press reset again and the NodeMCU will start normally, using the new configuration.

Circuit diagram

The circuit diagram has been created with draw.io and is available as an image or an XML file.

schltplan

the XML file is Located at "SmartChair/gameController/doku/schaltplan.xml"

Protocol Specification

All integers are in network byte order (Big-Endian)

Fields

Version (16Bit)

The most significant bit is always set. The current version is 0x8001

Magic Number (16Bit)

A 16Bit magic Number. The value is always 0xBABA

Session ID (16Bit)

The most significant bit is always 0, A valid session ID cannot be 0

Therefore valid session IDs are in range 1(inclusive) to 32768(exclusive)

Packet ID (24Bit) unsigned

Identifies a packet. The first packet ID should be 0 and every following should increment this value by 1.

Device ID (16Bit)

An ID describing the device. A list of device IDs can be found further down this page.

Error code (8Bit)

¿Unused/Not implemented?

Communication flow

Connect

  >>> [ version ] [ Magic Number ]
  <<< [ version ] [ Session ID ]

Data transfer

 >>> [ Session ID ] [ Packet ID ] [ Data Size (8Bit) ]
        size*( [ Device ] [ Value (16Bit) ] )

Error:

  <<< [ Session ID ] [ Packet ID ] [ Error code ] [Data Size (16Bit)]
        size*([Value (16Bit)])

Session teardown

  >>> [ Session ID ] [ Packet ID ] [ 0 (8Bit) ]
  <<< [ Version ] [ 0 (16Bit)]

Joystick devices

All IDs below 0x0100 are reserved for joystick interactions.

Device 0x0001 X-Axis

A signed 16Bit value which indicates the position on the X-Axis. 0 is the point of origin.

Device 0x0002 Y-Axis

A signed 16Bit value which indicates the position on the Y-Axis. 0 is the point of origin.

Device 0x0003 Button 0-15

A list of 16 bits. Every bit indicates the state of a single button (1: Pressed, 0: Released). The most significant bit is button 0 while the least significant bit is button 15.

Device 0x0004 Button 16-31

A list of 16 bits. Every bit indicates the state of a single button (1: Pressed, 0: Released). The most significant bit is button 16 while the least significant bit is button 31.

Keyboard devices

Every ID between 0x0100(inclusive) and 0x0200(exclusive) are reserved for keyboard inputs

##Device 0x01XX Where XX is a value from this enum. This list is definitely absolutely 100% correct. Its not

Data: [ 16bit duration ] The key, corresponding to the keycode, will be pressed for x milliseconds where x is the number given in the duration field. If a key is already pressed, the remaining duration will be overwritten with the new value.

#Hardware interaction 0x0200(inclusive) - 0x0300(exclusive)

Device 0x0200 Orange LED

0=off

!0=on

Device 0x0201 Green LED

0=off

!0=on

Device 0x0202 Red LED

0=off

!0=on

Clone this wiki locally