TCP/IP - Remote Switch Bricklet – Tinkerforge

- Getting Started
  - Primer
  - Tutorials
  - FAQ
- Hardware
  - Bricks
  - Bricklets
  - Master Extensions
  - Power Supplies
  - Accessories
  - Timeline
- Software
  - Brick Daemon (brickd)
  - Brick Viewer (brickv)
  - API Bindings
  - Firmwares and Plugins
  - Device Identifier
  - Source Code and Bug Tracking
  - Programming Interface
- Starter Kits
  - Weather Station
  - Hardware Hacking
  - Server Room Monitoring
  - Blinkenlights
  - Internet of Things
  - Camera Slider
- Embedded Boards
  - Raspberry Pi
- Specifications
  - Technical Data
  - TCP/IP Protocol
    - Protocol
    - API
      - Brick Daemon Functions
      - Broadcast Functions
      - General Callbacks
      - Bricks and Bricklets
        - Bricks
        - Bricklets
          - Ambient Light Bricklet
          - Analog In Bricklet
          - Analog Out Bricklet
          - Barometer Bricklet
          - Color Bricklet
          - Current12 Bricklet
          - Current25 Bricklet
          - Distance IR Bricklet
          - Distance US Bricklet
          - Dual Button Bricklet
          - Dual Relay Bricklet
          - GPS Bricklet
          - Hall Effect Bricklet
          - Humidity Bricklet
          - Industrial Digital In 4 Bricklet
          - Industrial Digital Out 4 Bricklet
          - Industrial Dual 0-20mA Bricklet
          - Industrial Quad Relay Bricklet
          - IO-16 Bricklet
          - IO-4 Bricklet
          - Joystick Bricklet
          - LCD 16x2 Bricklet
          - LCD 20x4 Bricklet
          - LED Strip Bricklet
          - Line Bricklet
          - Linear Poti Bricklet
          - Moisture Bricklet
          - Motion Detector Bricklet
          - Multi Touch Bricklet
          - NFC/RFID Bricklet
          - Piezo Buzzer Bricklet
          - Piezo Speaker Bricklet
          - PTC Bricklet
          - Remote Switch Bricklet
            - API
              - Basic Functions
              - Advanced Functions
              - Callbacks
          - Rotary Encoder Bricklet
          - Rotary Poti Bricklet
          - Segment Display 4x7 Bricklet
          - Solid State Relay Bricklet
          - Sound Intensity Bricklet
          - Temperature Bricklet
          - Temperature IR Bricklet
          - Tilt Bricklet
          - Voltage Bricklet
          - Voltage/Current Bricklet
  - Modbus Protocol
  - Wireshark Dissector

# TCP/IP - Remote Switch Bricklet

This is the description of the TCP/IP protocol for the Remote Switch Bricklet. General information and technical specifications for the Remote Switch Bricklet are summarized in its hardware description.

## API

A general description of the TCP/IP protocol structure can be found here.

### Basic Functions

`BrickletRemoteSwitch.``switch_socket`

  Function ID: | 1

  Request:

  - house_code -- uint8
  - receiver_code -- uint8
  - switch_to -- uint8

  Response: | no response

  This function is deprecated, use `switch_socket_a` instead.

`BrickletRemoteSwitch.``get_switching_state`

  Function ID: | 2
  Request: | empty payload

  Response:

  - state -- uint8

  Returns the current switching state. If the current state is busy, the Bricklet is currently sending a code to switch a socket. It will not accept any calls of `switch_socket` until the state changes to ready.

  How long the switching takes is dependent on the number of repeats, see `set_repeats`.

`BrickletRemoteSwitch.``switch_socket_a`

  Function ID: | 6

  Request:

  - house_code -- uint8
  - receiver_code -- uint8
  - switch_to -- uint8

  Response: | no response

  To switch a type A socket you have to give the house code, receiver code and the state (on or off) you want to switch to.

  The house code and receiver code have a range of 0 to 31 (5bit).

  A detailed description on how you can figure out the house and receiver code can be found here.

  New in version 2.0.1 (Plugin).

`BrickletRemoteSwitch.``switch_socket_b`

  Function ID: | 7

  Request:

  - address -- uint32
  - unit -- uint8
  - switch_to -- uint8

  Response: | no response

  To switch a type B socket you have to give the address, unit and the state (on or off) you want to switch to.

  The address has a range of 0 to 67108863 (26bit) and the unit has a range of 0 to 15 (4bit). To switch all devices with the same address use 255 for the unit.

  A detailed description on how you can teach a socket the address and unit can be found here.

  New in version 2.0.1 (Plugin).

`BrickletRemoteSwitch.``dim_socket_b`

  Function ID: | 8

  Request:

  - address -- uint32
  - unit -- uint8
  - dim_value -- uint8

  Response: | no response

  To control a type B dimmer you have to give the address, unit and the dim value you want to set the dimmer to.

  The address has a range of 0 to 67108863 (26bit), the unit and the dim value has a range of 0 to 15 (4bit).

  A detailed description on how you can teach a dimmer the address and unit can be found here.

  New in version 2.0.1 (Plugin).

`BrickletRemoteSwitch.``switch_socket_c`

  Function ID: | 9

  Request:

  - system_code -- char
  - device_code -- uint8
  - switch_to -- uint8

  Response: | no response

  To switch a type C socket you have to give the system code, device code and the state (on or off) you want to switch to.

  The system code has a range of 'A' to 'P' (4bit) and the device code has a range of 1 to 16 (4bit).

  A detailed description on how you can figure out the system and device code can be found here.

  New in version 2.0.1 (Plugin).

### Advanced Functions

`BrickletRemoteSwitch.``set_repeats`

  Function ID: | 4

  Request:

  - repeats -- uint8

  Response: | no response

  Sets the number of times the code is send when of the `switch_socket` functions is called. The repeats basically correspond to the amount of time that a button of the remote is pressed.

  Some dimmers are controlled by the length of a button pressed, this can be simulated by increasing the repeats.

  The default value is 5.

`BrickletRemoteSwitch.``get_repeats`

  Function ID: | 5
  Request: | empty payload

  Response:

  - repeats -- uint8

  Returns the number of repeats as set by `set_repeats`.

`BrickletRemoteSwitch.``get_identity`

  Function ID: | 255
  Request: | empty payload

  Response:

  - uid -- char[8]
  - connected_uid -- char[8]
  - position -- char
  - hardware_version -- uint8[3]
  - firmware_version -- uint8[3]
  - device_identifier -- uint16

  Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.

  The position can be 'a', 'b', 'c' or 'd'.

  The device identifier numbers can be found here.

### Callbacks

`BrickletRemoteSwitch.``CALLBACK_SWITCHING_DONE`

  Function ID: | 3
  Response: | empty payload

  This callback is called whenever the switching state changes from busy to ready, see `get_switching_state`.

The content of this page is licensed under Creative Commons Attribution 3.0 Unported License.