Building BitFlips is easy. You just create a URL with a query string. BitFlips consist of buttons, leds and a topic.
btn
key on the query string. The value is
the name of the button.
You can create as many buttons as you like, but each must have a unique value.
led
key on the query string. The value is
the color of the led. Valid
colors are: white,red,green,blue,purple,yellow,cyan
. You can only have one
led of each color.
topic
key on the query string. If you omit a topic, one will be generated for you. Since BitFlip uses a public broker, you will see all messages sent to this topic, even ones you do not send.
Examples:
btn=button+one&btn=button+two&led=red&topic=example1
btn=phone+home&led=red&led=white&led=blue&topic=demo1
Button messages are sent to your topic. While led messages are recieved.
When you click a button, the BitFlip device publishes a message on the topic you provide on
the query string of the form:
{ "click" : "button-name"}
Another program can subscribe to this topic then decide what to do with the message.
Example:
A BitFlip button on the query stringbtn=Play+chime&topic=test
sends the message
{"click":"play chime"}
to
the topic /bitflip/test
. Any application subscribing to that topic will recieve the
message and decide how to take
action for example perhaps it plays a random tone.
When a message arrives on your topic, it can turn an LED ON or OFF. The message the device
sends must be of the form:
{ "led" : "color", "state" : "ON|OFF"}
The color is the color of the led you want to turn on or off, one of the values
white,red,green,blue,purple,yellow,cyan
. The state is either ON
or
OFF
.
Example:
When this message arrives on your topic:{"led" : "purple", "state" : "ON"}
, your
BitFlip device will turn on the purple led (provided it has one).
When you see a message in your logs like this:
INFO: { "led" : "green", "state" : "off" } is not actionable
BitFlip is telling you that it cannot take action on the message. The MQTT protocol makes no
restrictions
on the message format, and BitFlip can only toggle LEDs you have setup. These messages are
displayed for
informational purposes as you will see all the messages on your MQTT topic.