Sdc2017a Released v3.1

October 11, 2017
elixir erlang badgelife skydogcon

Quickie Overview

The SkyDogCon 2016 badge was designed to be a dumb terminal at SkyDogCon. In hindsight, building the badges by hand and writing the firmware and server code maaaay have been a bit too much. I do have a sick addiction to deadlines so I’m doing it again.

Here’s an updated release of the firmware which has the following new functionality:

  1. Set your SSID/Password from the badge! Before you needed to re-flash the firmware. Now, press the “B” button during the first five seconds and the badge will bring up a webserver and captive portal for you to configure against (although the server is still hard-coded) :-/

  2. UDP! This is how we originally wanted to run but we were concerned that we may have issues running through NAT devices. Well, we didn’t, so we’re back to UDP, God’s own protocol.

Here’s a reminder of how the protocol works:

All communication is via UDP. The badge emits the packet with a source-port of 2390 and a destination port of 2391 (evil.red).

Packet Payload Format (Badge -> Server)

Each action on the badge generates one, or more packets. When you power the badge, it will connect to the configured wifi network, resolve evil.red and send two “coldboot” packets. All packets start with the first ten characters being the serial number of the badge zero-padded.

Coldboot Format

0001234567COLDBOOT

Joystick Communication

The directions for the joystick are (U)p, (D)own, (L)eft, ®ight, (P)ush. When the button is active, with consider it (D)own. When the button is released, we consider it (U)p. The message consists of the zero-padded serial number, followed by direction and disposition.

For example, if someone moves the joystick left and then right, the following packets would be sent:

(Note, in this example the joystick is still being held down to the right)

The “B” Button

This is a special case as the button is also used as a part of the microcontroller’s boot process. The line has to be held high during boot for the badge to boot so the logic for this button is reversed compared to the others.

This ‘exception’ is coded for in the firmware so you still get a (B)utton(D)own, when the button is pressed, even though the logic really went 1->0

Packet Payload Format (Server -> Badge)

Did I mention that the badge was dumb? The packet payload consists only of an xbitmap to display. The code on the badge looks like this:

   UdpOut.read(packetBuffer,noBytes);  // read the packet into the buffer

   const char *image = reinterpret_cast<const char*>(packetBuffer); // cast

   display.clear();                    // clear display
   display.drawXbm(0,0,128,64, image); // copy bitmap to framebuffer
   display.display();                  // Refresh display

What’s next?

Bring your badge. Over the next couple of days I will be posting the server software and commentating on the design as I go.