1#!/bin/sh 2# Connects to localhost:4223 by default, use --host and --port to change this 3 4uid=XYZ# Change XYZ to the UID of your Dual Button Bricklet 2.0 5 6# Handle incoming state changed callbacks 7tinkerforgedispatchdual-button-v2-bricklet$uidstate-changed& 8 9# Enable state changed callback10tinkerforgecalldual-button-v2-bricklet$uidset-state-changed-callback-configurationtrue1112echo"Press key to exit";readdummy
1314kill---$$# Stop callback dispatch in background
The <function> to be called can take different options depending of its
kind. All functions can take the following options:
--help shows help for the specific function and exits
Getter functions can take the following options:
--execute<command> shell command line to execute for each incoming
response (see section about output formatting
for details)
Setter functions can take the following options:
--expect-response requests response and waits for it
The --expect-response option for setter functions allows to detect
timeouts and other error conditions calls of setters as well. The device will
then send a response for this purpose. If this option is not given for a
setter function then no response is sent and errors are silently ignored,
because they cannot be detected.
<led-l> – Type: Int, Range: See symbols, Default: 1
<led-r> – Type: Int, Range: See symbols, Default: 1
Output:
no output
Sets the state of the LEDs. Possible states are:
0 = AutoToggleOn: Enables auto toggle with initially enabled LED.
1 = AutoToggleOff: Activates auto toggle with initially disabled LED.
2 = On: Enables LED (auto toggle is disabled).
3 = Off: Disables LED (auto toggle is disabled).
In auto toggle mode the LED is toggled automatically at each press of a button.
If you just want to set one of the LEDs and don't know the current state
of the other LED, you can get the state with get-led-state or you
can use set-selected-led-state.
The following symbols are available for this function:
<config> – Type: Int, Range: See symbols, Default: 3
Output:
no output
Sets the status LED configuration. By default the LED shows
communication traffic between Brick and Bricklet, it flickers once
for every 10 received data packets.
You can also turn the LED permanently on/off or show a heartbeat.
If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
The following symbols are available for this function:
temperature – Type: Int, Unit: 1 °C, Range: [-215 to 215 - 1]
Returns the temperature as measured inside the microcontroller. The
value returned is not the ambient temperature!
The temperature is only proportional to the real temperature and it has bad
accuracy. Practically it is only useful as an indicator for
temperature changes.
Using callbacks for recurring events is always preferred
compared to using getters. It will use less USB bandwidth and the latency
will be a lot better, since there is no round trip time.
Internal functions are used for maintenance tasks such as flashing a new firmware
of changing the UID of a Bricklet. These task should be performed using
Brick Viewer instead of using the internal functions directly.
Sets the bootloader mode and returns the status after the requested
mode change was instigated.
You can change from bootloader mode to firmware mode and vice versa. A change
from bootloader mode to firmware mode will only take place if the entry function,
device identifier and CRC are present and correct.
This function is used by Brick Viewer during flashing. It should not be
necessary to call it in a normal user program.
The following symbols are available for this function:
Sets the firmware pointer for write-firmware. The pointer has
to be increased by chunks of size 64. The data is written to flash
every 4 chunks (which equals to one page of size 256).
This function is used by Brick Viewer during flashing. It should not be
necessary to call it in a normal user program.