Class: Tinkerforge::BrickMaster

Inherits:
Device
  • Object
show all
Defined in:
lib/tinkerforge/brick_master.rb

Overview

Basis to build stacks and has 4 Bricklet ports

Constant Summary collapse

DEVICE_IDENTIFIER =

:nodoc:

13
DEVICE_DISPLAY_NAME =

:nodoc:

'Master Brick'
CALLBACK_STACK_CURRENT =

This callback is triggered periodically with the period that is set by BrickMaster#set_stack_current_callback_period. The parameter is the current of the sensor.

CALLBACK_STACK_CURRENT is only triggered if the current has changed since the last triggering.

.. versionadded

2.0.5$nbsp;(Firmware)

59
CALLBACK_STACK_VOLTAGE =

This callback is triggered periodically with the period that is set by BrickMaster#set_stack_voltage_callback_period. The parameter is the voltage of the sensor.

CALLBACK_STACK_VOLTAGE is only triggered if the voltage has changed since the last triggering.

.. versionadded

2.0.5$nbsp;(Firmware)

60
CALLBACK_USB_VOLTAGE =

This callback is triggered periodically with the period that is set by BrickMaster#set_usb_voltage_callback_period. The parameter is the USB voltage in mV.

CALLBACK_USB_VOLTAGE is only triggered if the USB voltage has changed since the last triggering.

Does not work with hardware version 2.1.

.. versionadded

2.0.5$nbsp;(Firmware)

61
CALLBACK_STACK_CURRENT_REACHED =

This callback is triggered when the threshold as set by BrickMaster#set_stack_current_callback_threshold is reached. The parameter is the stack current in mA.

If the threshold keeps being reached, the callback is triggered periodically with the period as set by BrickMaster#set_debounce_period.

.. versionadded

2.0.5$nbsp;(Firmware)

62
CALLBACK_STACK_VOLTAGE_REACHED =

This callback is triggered when the threshold as set by BrickMaster#set_stack_voltage_callback_threshold is reached. The parameter is the stack voltage in mV.

If the threshold keeps being reached, the callback is triggered periodically with the period as set by BrickMaster#set_debounce_period.

.. versionadded

2.0.5$nbsp;(Firmware)

63
CALLBACK_USB_VOLTAGE_REACHED =

This callback is triggered when the threshold as set by BrickMaster#set_usb_voltage_callback_threshold is reached. The parameter is the voltage of the sensor.

If the threshold keeps being reached, the callback is triggered periodically with the period as set by BrickMaster#set_debounce_period.

.. versionadded

2.0.5$nbsp;(Firmware)

64
FUNCTION_GET_STACK_VOLTAGE =

:nodoc:

1
FUNCTION_GET_STACK_CURRENT =

:nodoc:

2
FUNCTION_SET_EXTENSION_TYPE =

:nodoc:

3
FUNCTION_GET_EXTENSION_TYPE =

:nodoc:

4
FUNCTION_IS_CHIBI_PRESENT =

:nodoc:

5
FUNCTION_SET_CHIBI_ADDRESS =

:nodoc:

6
FUNCTION_GET_CHIBI_ADDRESS =

:nodoc:

7
FUNCTION_SET_CHIBI_MASTER_ADDRESS =

:nodoc:

8
FUNCTION_GET_CHIBI_MASTER_ADDRESS =

:nodoc:

9
FUNCTION_SET_CHIBI_SLAVE_ADDRESS =

:nodoc:

10
FUNCTION_GET_CHIBI_SLAVE_ADDRESS =

:nodoc:

11
FUNCTION_GET_CHIBI_SIGNAL_STRENGTH =

:nodoc:

12
FUNCTION_GET_CHIBI_ERROR_LOG =

:nodoc:

13
FUNCTION_SET_CHIBI_FREQUENCY =

:nodoc:

14
FUNCTION_GET_CHIBI_FREQUENCY =

:nodoc:

15
FUNCTION_SET_CHIBI_CHANNEL =

:nodoc:

16
FUNCTION_GET_CHIBI_CHANNEL =

:nodoc:

17
FUNCTION_IS_RS485_PRESENT =

:nodoc:

18
FUNCTION_SET_RS485_ADDRESS =

:nodoc:

19
FUNCTION_GET_RS485_ADDRESS =

:nodoc:

20
FUNCTION_SET_RS485_SLAVE_ADDRESS =

:nodoc:

21
FUNCTION_GET_RS485_SLAVE_ADDRESS =

:nodoc:

22
FUNCTION_GET_RS485_ERROR_LOG =

:nodoc:

23
FUNCTION_SET_RS485_CONFIGURATION =

:nodoc:

24
FUNCTION_GET_RS485_CONFIGURATION =

:nodoc:

25
FUNCTION_IS_WIFI_PRESENT =

:nodoc:

26
FUNCTION_SET_WIFI_CONFIGURATION =

:nodoc:

27
FUNCTION_GET_WIFI_CONFIGURATION =

:nodoc:

28
FUNCTION_SET_WIFI_ENCRYPTION =

:nodoc:

29
FUNCTION_GET_WIFI_ENCRYPTION =

:nodoc:

30
FUNCTION_GET_WIFI_STATUS =

:nodoc:

31
FUNCTION_REFRESH_WIFI_STATUS =

:nodoc:

32
FUNCTION_SET_WIFI_CERTIFICATE =

:nodoc:

33
FUNCTION_GET_WIFI_CERTIFICATE =

:nodoc:

34
FUNCTION_SET_WIFI_POWER_MODE =

:nodoc:

35
FUNCTION_GET_WIFI_POWER_MODE =

:nodoc:

36
FUNCTION_GET_WIFI_BUFFER_INFO =

:nodoc:

37
FUNCTION_SET_WIFI_REGULATORY_DOMAIN =

:nodoc:

38
FUNCTION_GET_WIFI_REGULATORY_DOMAIN =

:nodoc:

39
FUNCTION_GET_USB_VOLTAGE =

:nodoc:

40
FUNCTION_SET_LONG_WIFI_KEY =

:nodoc:

41
FUNCTION_GET_LONG_WIFI_KEY =

:nodoc:

42
FUNCTION_SET_WIFI_HOSTNAME =

:nodoc:

43
FUNCTION_GET_WIFI_HOSTNAME =

:nodoc:

44
FUNCTION_SET_STACK_CURRENT_CALLBACK_PERIOD =

:nodoc:

45
FUNCTION_GET_STACK_CURRENT_CALLBACK_PERIOD =

:nodoc:

46
FUNCTION_SET_STACK_VOLTAGE_CALLBACK_PERIOD =

:nodoc:

47
FUNCTION_GET_STACK_VOLTAGE_CALLBACK_PERIOD =

:nodoc:

48
FUNCTION_SET_USB_VOLTAGE_CALLBACK_PERIOD =

:nodoc:

49
FUNCTION_GET_USB_VOLTAGE_CALLBACK_PERIOD =

:nodoc:

50
FUNCTION_SET_STACK_CURRENT_CALLBACK_THRESHOLD =

:nodoc:

51
FUNCTION_GET_STACK_CURRENT_CALLBACK_THRESHOLD =

:nodoc:

52
FUNCTION_SET_STACK_VOLTAGE_CALLBACK_THRESHOLD =

:nodoc:

53
FUNCTION_GET_STACK_VOLTAGE_CALLBACK_THRESHOLD =

:nodoc:

54
FUNCTION_SET_USB_VOLTAGE_CALLBACK_THRESHOLD =

:nodoc:

55
FUNCTION_GET_USB_VOLTAGE_CALLBACK_THRESHOLD =

:nodoc:

56
FUNCTION_SET_DEBOUNCE_PERIOD =

:nodoc:

57
FUNCTION_GET_DEBOUNCE_PERIOD =

:nodoc:

58
FUNCTION_IS_ETHERNET_PRESENT =

:nodoc:

65
FUNCTION_SET_ETHERNET_CONFIGURATION =

:nodoc:

66
FUNCTION_GET_ETHERNET_CONFIGURATION =

:nodoc:

67
FUNCTION_GET_ETHERNET_STATUS =

:nodoc:

68
FUNCTION_SET_ETHERNET_HOSTNAME =

:nodoc:

69
FUNCTION_SET_ETHERNET_MAC_ADDRESS =

:nodoc:

70
FUNCTION_SET_ETHERNET_WEBSOCKET_CONFIGURATION =

:nodoc:

71
FUNCTION_GET_ETHERNET_WEBSOCKET_CONFIGURATION =

:nodoc:

72
FUNCTION_SET_ETHERNET_AUTHENTICATION_SECRET =

:nodoc:

73
FUNCTION_GET_ETHERNET_AUTHENTICATION_SECRET =

:nodoc:

74
FUNCTION_SET_WIFI_AUTHENTICATION_SECRET =

:nodoc:

75
FUNCTION_GET_WIFI_AUTHENTICATION_SECRET =

:nodoc:

76
FUNCTION_GET_CONNECTION_TYPE =

:nodoc:

77
FUNCTION_IS_WIFI2_PRESENT =

:nodoc:

78
FUNCTION_START_WIFI2_BOOTLOADER =

:nodoc:

79
FUNCTION_WRITE_WIFI2_SERIAL_PORT =

:nodoc:

80
FUNCTION_READ_WIFI2_SERIAL_PORT =

:nodoc:

81
FUNCTION_SET_WIFI2_AUTHENTICATION_SECRET =

:nodoc:

82
FUNCTION_GET_WIFI2_AUTHENTICATION_SECRET =

:nodoc:

83
FUNCTION_SET_WIFI2_CONFIGURATION =

:nodoc:

84
FUNCTION_GET_WIFI2_CONFIGURATION =

:nodoc:

85
FUNCTION_GET_WIFI2_STATUS =

:nodoc:

86
FUNCTION_SET_WIFI2_CLIENT_CONFIGURATION =

:nodoc:

87
FUNCTION_GET_WIFI2_CLIENT_CONFIGURATION =

:nodoc:

88
FUNCTION_SET_WIFI2_CLIENT_HOSTNAME =

:nodoc:

89
FUNCTION_GET_WIFI2_CLIENT_HOSTNAME =

:nodoc:

90
FUNCTION_SET_WIFI2_CLIENT_PASSWORD =

:nodoc:

91
FUNCTION_GET_WIFI2_CLIENT_PASSWORD =

:nodoc:

92
FUNCTION_SET_WIFI2_AP_CONFIGURATION =

:nodoc:

93
FUNCTION_GET_WIFI2_AP_CONFIGURATION =

:nodoc:

94
FUNCTION_SET_WIFI2_AP_PASSWORD =

:nodoc:

95
FUNCTION_GET_WIFI2_AP_PASSWORD =

:nodoc:

96
FUNCTION_SAVE_WIFI2_CONFIGURATION =

:nodoc:

97
FUNCTION_GET_WIFI2_FIRMWARE_VERSION =

:nodoc:

98
FUNCTION_ENABLE_WIFI2_STATUS_LED =

:nodoc:

99
FUNCTION_DISABLE_WIFI2_STATUS_LED =

:nodoc:

100
FUNCTION_IS_WIFI2_STATUS_LED_ENABLED =

:nodoc:

101
FUNCTION_ENABLE_STATUS_LED =

:nodoc:

238
FUNCTION_DISABLE_STATUS_LED =

:nodoc:

239
FUNCTION_IS_STATUS_LED_ENABLED =

:nodoc:

240
FUNCTION_GET_PROTOCOL1_BRICKLET_NAME =

:nodoc:

241
FUNCTION_GET_CHIP_TEMPERATURE =

:nodoc:

242
FUNCTION_RESET =

:nodoc:

243
FUNCTION_GET_IDENTITY =

:nodoc:

255
EXTENSION_TYPE_CHIBI =

:nodoc:

1
EXTENSION_TYPE_RS485 =

:nodoc:

2
EXTENSION_TYPE_WIFI =

:nodoc:

3
EXTENSION_TYPE_ETHERNET =

:nodoc:

4
EXTENSION_TYPE_WIFI2 =

:nodoc:

5
CHIBI_FREQUENCY_OQPSK_868_MHZ =

:nodoc:

0
CHIBI_FREQUENCY_OQPSK_915_MHZ =

:nodoc:

1
CHIBI_FREQUENCY_OQPSK_780_MHZ =

:nodoc:

2
CHIBI_FREQUENCY_BPSK40_915_MHZ =

:nodoc:

3
RS485_PARITY_NONE =

:nodoc:

'n'
RS485_PARITY_EVEN =

:nodoc:

'e'
RS485_PARITY_ODD =

:nodoc:

'o'
WIFI_CONNECTION_DHCP =

:nodoc:

0
WIFI_CONNECTION_STATIC_IP =

:nodoc:

1
WIFI_CONNECTION_ACCESS_POINT_DHCP =

:nodoc:

2
WIFI_CONNECTION_ACCESS_POINT_STATIC_IP =

:nodoc:

3
WIFI_CONNECTION_AD_HOC_DHCP =

:nodoc:

4
WIFI_CONNECTION_AD_HOC_STATIC_IP =

:nodoc:

5
WIFI_ENCRYPTION_WPA_WPA2 =

:nodoc:

0
WIFI_ENCRYPTION_WPA_ENTERPRISE =

:nodoc:

1
WIFI_ENCRYPTION_WEP =

:nodoc:

2
WIFI_ENCRYPTION_NO_ENCRYPTION =

:nodoc:

3
WIFI_EAP_OPTION_OUTER_AUTH_EAP_FAST =

:nodoc:

0
WIFI_EAP_OPTION_OUTER_AUTH_EAP_TLS =

:nodoc:

1
WIFI_EAP_OPTION_OUTER_AUTH_EAP_TTLS =

:nodoc:

2
WIFI_EAP_OPTION_OUTER_AUTH_EAP_PEAP =

:nodoc:

3
WIFI_EAP_OPTION_INNER_AUTH_EAP_MSCHAP =

:nodoc:

0
WIFI_EAP_OPTION_INNER_AUTH_EAP_GTC =

:nodoc:

4
WIFI_EAP_OPTION_CERT_TYPE_CA_CERT =

:nodoc:

0
WIFI_EAP_OPTION_CERT_TYPE_CLIENT_CERT =

:nodoc:

8
WIFI_EAP_OPTION_CERT_TYPE_PRIVATE_KEY =

:nodoc:

16
WIFI_STATE_DISASSOCIATED =

:nodoc:

0
WIFI_STATE_ASSOCIATED =

:nodoc:

1
WIFI_STATE_ASSOCIATING =

:nodoc:

2
WIFI_STATE_ERROR =

:nodoc:

3
WIFI_STATE_NOT_INITIALIZED_YET =

:nodoc:

255
WIFI_POWER_MODE_FULL_SPEED =

:nodoc:

0
WIFI_POWER_MODE_LOW_POWER =

:nodoc:

1
WIFI_DOMAIN_CHANNEL_1TO11 =

:nodoc:

0
WIFI_DOMAIN_CHANNEL_1TO13 =

:nodoc:

1
WIFI_DOMAIN_CHANNEL_1TO14 =

:nodoc:

2
THRESHOLD_OPTION_OFF =

:nodoc:

'x'
THRESHOLD_OPTION_OUTSIDE =

:nodoc:

'o'
THRESHOLD_OPTION_INSIDE =

:nodoc:

'i'
THRESHOLD_OPTION_SMALLER =

:nodoc:

'<'
THRESHOLD_OPTION_GREATER =

:nodoc:

'>'
ETHERNET_CONNECTION_DHCP =

:nodoc:

0
ETHERNET_CONNECTION_STATIC_IP =

:nodoc:

1
CONNECTION_TYPE_NONE =

:nodoc:

0
CONNECTION_TYPE_USB =

:nodoc:

1
CONNECTION_TYPE_SPI_STACK =

:nodoc:

2
CONNECTION_TYPE_CHIBI =

:nodoc:

3
CONNECTION_TYPE_RS485 =

:nodoc:

4
CONNECTION_TYPE_WIFI =

:nodoc:

5
CONNECTION_TYPE_ETHERNET =

:nodoc:

6
CONNECTION_TYPE_WIFI2 =

:nodoc:

7
WIFI2_PHY_MODE_B =

:nodoc:

0
WIFI2_PHY_MODE_G =

:nodoc:

1
WIFI2_PHY_MODE_N =

:nodoc:

2
WIFI2_CLIENT_STATUS_IDLE =

:nodoc:

0
WIFI2_CLIENT_STATUS_CONNECTING =

:nodoc:

1
WIFI2_CLIENT_STATUS_WRONG_PASSWORD =

:nodoc:

2
WIFI2_CLIENT_STATUS_NO_AP_FOUND =

:nodoc:

3
WIFI2_CLIENT_STATUS_CONNECT_FAILED =

:nodoc:

4
WIFI2_CLIENT_STATUS_GOT_IP =

:nodoc:

5
WIFI2_AP_ENCRYPTION_OPEN =

:nodoc:

0
WIFI2_AP_ENCRYPTION_WEP =

:nodoc:

1
WIFI2_AP_ENCRYPTION_WPA_PSK =

:nodoc:

2
WIFI2_AP_ENCRYPTION_WPA2_PSK =

:nodoc:

3
WIFI2_AP_ENCRYPTION_WPA_WPA2_PSK =

:nodoc:

4

Constants inherited from Device

Device::RESPONSE_EXPECTED_ALWAYS_FALSE, Device::RESPONSE_EXPECTED_ALWAYS_TRUE, Device::RESPONSE_EXPECTED_FALSE, Device::RESPONSE_EXPECTED_INVALID_FUNCTION_ID, Device::RESPONSE_EXPECTED_TRUE

Instance Attribute Summary

Attributes inherited from Device

#callback_formats, #expected_response_function_id, #expected_response_sequence_number, #registered_callbacks, #uid

Instance Method Summary collapse

Methods inherited from Device

#dequeue_response, #enqueue_response, #get_api_version, #get_response_expected, #send_request, #set_response_expected, #set_response_expected_all

Constructor Details

#initialize(uid, ipcon) ⇒ BrickMaster

Creates an object with the unique device ID uid and adds it to the IP Connection ipcon.



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/tinkerforge/brick_master.rb', line 256

def initialize(uid, ipcon)
  super uid, ipcon

  @api_version = [2, 0, 4]

  @response_expected[FUNCTION_GET_STACK_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_STACK_CURRENT] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_EXTENSION_TYPE] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_EXTENSION_TYPE] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_IS_CHIBI_PRESENT] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_CHIBI_ADDRESS] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_CHIBI_ADDRESS] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_CHIBI_MASTER_ADDRESS] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_CHIBI_MASTER_ADDRESS] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_CHIBI_SLAVE_ADDRESS] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_CHIBI_SLAVE_ADDRESS] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_CHIBI_SIGNAL_STRENGTH] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_CHIBI_ERROR_LOG] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_CHIBI_FREQUENCY] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_CHIBI_FREQUENCY] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_CHIBI_CHANNEL] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_CHIBI_CHANNEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_IS_RS485_PRESENT] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_RS485_ADDRESS] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_RS485_ADDRESS] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_RS485_SLAVE_ADDRESS] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_RS485_SLAVE_ADDRESS] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_RS485_ERROR_LOG] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_RS485_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_RS485_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_IS_WIFI_PRESENT] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_WIFI_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_WIFI_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_WIFI_ENCRYPTION] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_WIFI_ENCRYPTION] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_WIFI_STATUS] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_REFRESH_WIFI_STATUS] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_SET_WIFI_CERTIFICATE] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_WIFI_CERTIFICATE] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_WIFI_POWER_MODE] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_WIFI_POWER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_WIFI_BUFFER_INFO] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_WIFI_REGULATORY_DOMAIN] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_WIFI_REGULATORY_DOMAIN] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_USB_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_LONG_WIFI_KEY] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_LONG_WIFI_KEY] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_WIFI_HOSTNAME] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_WIFI_HOSTNAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_STACK_CURRENT_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
  @response_expected[FUNCTION_GET_STACK_CURRENT_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_STACK_VOLTAGE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
  @response_expected[FUNCTION_GET_STACK_VOLTAGE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_USB_VOLTAGE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
  @response_expected[FUNCTION_GET_USB_VOLTAGE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_STACK_CURRENT_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
  @response_expected[FUNCTION_GET_STACK_CURRENT_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_STACK_VOLTAGE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
  @response_expected[FUNCTION_GET_STACK_VOLTAGE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_USB_VOLTAGE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
  @response_expected[FUNCTION_GET_USB_VOLTAGE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_TRUE
  @response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[CALLBACK_STACK_CURRENT] = RESPONSE_EXPECTED_ALWAYS_FALSE
  @response_expected[CALLBACK_STACK_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_FALSE
  @response_expected[CALLBACK_USB_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_FALSE
  @response_expected[CALLBACK_STACK_CURRENT_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
  @response_expected[CALLBACK_STACK_VOLTAGE_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
  @response_expected[CALLBACK_USB_VOLTAGE_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
  @response_expected[FUNCTION_IS_ETHERNET_PRESENT] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_ETHERNET_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_ETHERNET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_ETHERNET_STATUS] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_ETHERNET_HOSTNAME] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_SET_ETHERNET_MAC_ADDRESS] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_SET_ETHERNET_WEBSOCKET_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_ETHERNET_WEBSOCKET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_ETHERNET_AUTHENTICATION_SECRET] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_ETHERNET_AUTHENTICATION_SECRET] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_WIFI_AUTHENTICATION_SECRET] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_WIFI_AUTHENTICATION_SECRET] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_CONNECTION_TYPE] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_IS_WIFI2_PRESENT] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_START_WIFI2_BOOTLOADER] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_WRITE_WIFI2_SERIAL_PORT] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_READ_WIFI2_SERIAL_PORT] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_WIFI2_AUTHENTICATION_SECRET] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_WIFI2_AUTHENTICATION_SECRET] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_WIFI2_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_WIFI2_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_WIFI2_STATUS] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_WIFI2_CLIENT_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_WIFI2_CLIENT_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_WIFI2_CLIENT_HOSTNAME] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_WIFI2_CLIENT_HOSTNAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_WIFI2_CLIENT_PASSWORD] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_WIFI2_CLIENT_PASSWORD] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_WIFI2_AP_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_WIFI2_AP_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_WIFI2_AP_PASSWORD] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_WIFI2_AP_PASSWORD] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SAVE_WIFI2_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_WIFI2_FIRMWARE_VERSION] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_ENABLE_WIFI2_STATUS_LED] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_DISABLE_WIFI2_STATUS_LED] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_IS_WIFI2_STATUS_LED_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_ENABLE_STATUS_LED] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_DISABLE_STATUS_LED] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_IS_STATUS_LED_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_PROTOCOL1_BRICKLET_NAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE

  @callback_formats[CALLBACK_STACK_CURRENT] = 'S'
  @callback_formats[CALLBACK_STACK_VOLTAGE] = 'S'
  @callback_formats[CALLBACK_USB_VOLTAGE] = 'S'
  @callback_formats[CALLBACK_STACK_CURRENT_REACHED] = 'S'
  @callback_formats[CALLBACK_STACK_VOLTAGE_REACHED] = 'S'
  @callback_formats[CALLBACK_USB_VOLTAGE_REACHED] = 'S'
end

Instance Method Details

#disable_status_ledObject

Disables the status LED.

The status LED is the blue LED next to the USB connector. If enabled is is on and it flickers if data is transfered. If disabled it is always off.

The default state is enabled.

.. versionadded

2.3.2$nbsp;(Firmware)



1506
1507
1508
# File 'lib/tinkerforge/brick_master.rb', line 1506

def disable_status_led
  send_request(FUNCTION_DISABLE_STATUS_LED, [], '', 0, '')
end

#disable_wifi2_status_ledObject

Turns the green status LED of the WIFI Extension 2.0 off.

.. versionadded

2.4.0$nbsp;(Firmware)



1475
1476
1477
# File 'lib/tinkerforge/brick_master.rb', line 1475

def disable_wifi2_status_led
  send_request(FUNCTION_DISABLE_WIFI2_STATUS_LED, [], '', 0, '')
end

#enable_status_ledObject

Enables the status LED.

The status LED is the blue LED next to the USB connector. If enabled is is on and it flickers if data is transfered. If disabled it is always off.

The default state is enabled.

.. versionadded

2.3.2$nbsp;(Firmware)



1494
1495
1496
# File 'lib/tinkerforge/brick_master.rb', line 1494

def enable_status_led
  send_request(FUNCTION_ENABLE_STATUS_LED, [], '', 0, '')
end

#enable_wifi2_status_ledObject

Turns the green status LED of the WIFI Extension 2.0 on.

.. versionadded

2.4.0$nbsp;(Firmware)



1468
1469
1470
# File 'lib/tinkerforge/brick_master.rb', line 1468

def enable_wifi2_status_led
  send_request(FUNCTION_ENABLE_WIFI2_STATUS_LED, [], '', 0, '')
end

#get_chibi_addressObject

Returns the address as set by BrickMaster#set_chibi_address.



432
433
434
# File 'lib/tinkerforge/brick_master.rb', line 432

def get_chibi_address
  send_request(FUNCTION_GET_CHIBI_ADDRESS, [], '', 1, 'C')
end

#get_chibi_channelObject

Returns the channel as set by BrickMaster#set_chibi_channel.



529
530
531
# File 'lib/tinkerforge/brick_master.rb', line 529

def get_chibi_channel
  send_request(FUNCTION_GET_CHIBI_CHANNEL, [], '', 1, 'C')
end

#get_chibi_error_logObject

Returns underrun, CRC error, no ACK and overflow error counts of the Chibi communication. If these errors start rising, it is likely that either the distance between two Chibi stacks is becoming too big or there are interferences.



486
487
488
# File 'lib/tinkerforge/brick_master.rb', line 486

def get_chibi_error_log
  send_request(FUNCTION_GET_CHIBI_ERROR_LOG, [], '', 8, 'S S S S')
end

#get_chibi_frequencyObject

Returns the frequency value as set by BrickMaster#set_chibi_frequency.



507
508
509
# File 'lib/tinkerforge/brick_master.rb', line 507

def get_chibi_frequency
  send_request(FUNCTION_GET_CHIBI_FREQUENCY, [], '', 1, 'C')
end

#get_chibi_master_addressObject

Returns the address as set by BrickMaster#set_chibi_master_address.



447
448
449
# File 'lib/tinkerforge/brick_master.rb', line 447

def get_chibi_master_address
  send_request(FUNCTION_GET_CHIBI_MASTER_ADDRESS, [], '', 1, 'C')
end

#get_chibi_signal_strengthObject

Returns the signal strength in dBm. The signal strength updates every time a packet is received.



478
479
480
# File 'lib/tinkerforge/brick_master.rb', line 478

def get_chibi_signal_strength
  send_request(FUNCTION_GET_CHIBI_SIGNAL_STRENGTH, [], '', 1, 'C')
end

#get_chibi_slave_address(num) ⇒ Object

Returns the slave address for a given num as set by BrickMaster#set_chibi_slave_address.



472
473
474
# File 'lib/tinkerforge/brick_master.rb', line 472

def get_chibi_slave_address(num)
  send_request(FUNCTION_GET_CHIBI_SLAVE_ADDRESS, [num], 'C', 1, 'C')
end

#get_chip_temperatureObject

Returns the temperature in °C/10 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 an accuracy of +-15%. Practically it is only useful as an indicator for temperature changes.



1532
1533
1534
# File 'lib/tinkerforge/brick_master.rb', line 1532

def get_chip_temperature
  send_request(FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's')
end

#get_connection_typeObject

Returns the type of the connection over which this function was called.

.. versionadded

2.4.0$nbsp;(Firmware)



1173
1174
1175
# File 'lib/tinkerforge/brick_master.rb', line 1173

def get_connection_type
  send_request(FUNCTION_GET_CONNECTION_TYPE, [], '', 1, 'C')
end

#get_debounce_periodObject

Returns the debounce period as set by BrickMaster#set_debounce_period.

.. versionadded

2.0.5$nbsp;(Firmware)



1009
1010
1011
# File 'lib/tinkerforge/brick_master.rb', line 1009

def get_debounce_period
  send_request(FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L')
end

#get_ethernet_authentication_secretObject

Returns the authentication secret as set by BrickMaster#set_ethernet_authentication_secret.

.. versionadded

2.2.0$nbsp;(Firmware)



1141
1142
1143
# File 'lib/tinkerforge/brick_master.rb', line 1141

def get_ethernet_authentication_secret
  send_request(FUNCTION_GET_ETHERNET_AUTHENTICATION_SECRET, [], '', 64, 'Z64')
end

#get_ethernet_configurationObject

Returns the configuration as set by BrickMaster#set_ethernet_configuration.

.. versionadded

2.1.0$nbsp;(Firmware)



1051
1052
1053
# File 'lib/tinkerforge/brick_master.rb', line 1051

def get_ethernet_configuration
  send_request(FUNCTION_GET_ETHERNET_CONFIGURATION, [], '', 15, 'C C4 C4 C4 S')
end

#get_ethernet_statusObject

Returns the status of the Ethernet Extension.

mac_address, ip, subnet_mask and gateway are given as an array. The first element of the array is the least significant byte of the address.

rx_count and tx_count are the number of bytes that have been received/send since last restart.

hostname is the currently used hostname.

.. versionadded

2.1.0$nbsp;(Firmware)



1066
1067
1068
# File 'lib/tinkerforge/brick_master.rb', line 1066

def get_ethernet_status
  send_request(FUNCTION_GET_ETHERNET_STATUS, [], '', 58, 'C6 C4 C4 C4 L L Z32')
end

#get_ethernet_websocket_configurationObject

Returns the configuration as set by BrickMaster#set_ethernet_configuration.

.. versionadded

2.2.0$nbsp;(Firmware)



1116
1117
1118
# File 'lib/tinkerforge/brick_master.rb', line 1116

def get_ethernet_websocket_configuration
  send_request(FUNCTION_GET_ETHERNET_WEBSOCKET_CONFIGURATION, [], '', 3, 'C S')
end

#get_extension_type(extension) ⇒ Object

Returns the type for a given extension as set by BrickMaster#set_extension_type.



413
414
415
# File 'lib/tinkerforge/brick_master.rb', line 413

def get_extension_type(extension)
  send_request(FUNCTION_GET_EXTENSION_TYPE, [extension], 'C', 4, 'L')
end

#get_identityObject

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

The position can be ‘0’-‘8’ (stack position).

The device identifier numbers can be found :ref:‘here <device_identifier>`. |device_identifier_constant|



1554
1555
1556
# File 'lib/tinkerforge/brick_master.rb', line 1554

def get_identity
  send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
end

#get_long_wifi_keyObject

Returns the encryption key as set by BrickMaster#set_long_wifi_key.

.. versionadded

2.0.2$nbsp;(Firmware)



824
825
826
# File 'lib/tinkerforge/brick_master.rb', line 824

def get_long_wifi_key
  send_request(FUNCTION_GET_LONG_WIFI_KEY, [], '', 64, 'Z64')
end

#get_protocol1_bricklet_name(port) ⇒ Object

Returns the firmware and protocol version and the name of the Bricklet for a given port.

This functions sole purpose is to allow automatic flashing of v1.x.y Bricklet plugins.



1522
1523
1524
# File 'lib/tinkerforge/brick_master.rb', line 1522

def get_protocol1_bricklet_name(port)
  send_request(FUNCTION_GET_PROTOCOL1_BRICKLET_NAME, [port], 'k', 44, 'C C3 Z40')
end

#get_rs485_addressObject

Returns the address as set by BrickMaster#set_rs485_address.



551
552
553
# File 'lib/tinkerforge/brick_master.rb', line 551

def get_rs485_address
  send_request(FUNCTION_GET_RS485_ADDRESS, [], '', 1, 'C')
end

#get_rs485_configurationObject

Returns the configuration as set by BrickMaster#set_rs485_configuration.



605
606
607
# File 'lib/tinkerforge/brick_master.rb', line 605

def get_rs485_configuration
  send_request(FUNCTION_GET_RS485_CONFIGURATION, [], '', 6, 'L k C')
end

#get_rs485_error_logObject

Returns CRC error counts of the RS485 communication. If this counter starts rising, it is likely that the distance between the RS485 nodes is too big or there is some kind of interference.



584
585
586
# File 'lib/tinkerforge/brick_master.rb', line 584

def get_rs485_error_log
  send_request(FUNCTION_GET_RS485_ERROR_LOG, [], '', 2, 'S')
end

#get_rs485_slave_address(num) ⇒ Object

Returns the slave address for a given num as set by BrickMaster#set_rs485_slave_address.



576
577
578
# File 'lib/tinkerforge/brick_master.rb', line 576

def get_rs485_slave_address(num)
  send_request(FUNCTION_GET_RS485_SLAVE_ADDRESS, [num], 'C', 1, 'C')
end

#get_stack_currentObject

Returns the stack current in mA. The stack current is the current that is drawn via the stack, i.e. it is given by a Step-Down or Step-Up Power Supply.



388
389
390
# File 'lib/tinkerforge/brick_master.rb', line 388

def get_stack_current
  send_request(FUNCTION_GET_STACK_CURRENT, [], '', 2, 'S')
end

#get_stack_current_callback_periodObject

Returns the period as set by :func:SetCurrentCallbackPeriod.

.. versionadded

2.0.5$nbsp;(Firmware)



863
864
865
# File 'lib/tinkerforge/brick_master.rb', line 863

def get_stack_current_callback_period
  send_request(FUNCTION_GET_STACK_CURRENT_CALLBACK_PERIOD, [], '', 4, 'L')
end

#get_stack_current_callback_thresholdObject

Returns the threshold as set by BrickMaster#set_stack_current_callback_threshold.

.. versionadded

2.0.5$nbsp;(Firmware)



929
930
931
# File 'lib/tinkerforge/brick_master.rb', line 929

def get_stack_current_callback_threshold
  send_request(FUNCTION_GET_STACK_CURRENT_CALLBACK_THRESHOLD, [], '', 5, 'k S S')
end

#get_stack_voltageObject

Returns the stack voltage in mV. The stack voltage is the voltage that is supplied via the stack, i.e. it is given by a Step-Down or Step-Up Power Supply.



381
382
383
# File 'lib/tinkerforge/brick_master.rb', line 381

def get_stack_voltage
  send_request(FUNCTION_GET_STACK_VOLTAGE, [], '', 2, 'S')
end

#get_stack_voltage_callback_periodObject

Returns the period as set by BrickMaster#set_stack_voltage_callback_period.

.. versionadded

2.0.5$nbsp;(Firmware)



883
884
885
# File 'lib/tinkerforge/brick_master.rb', line 883

def get_stack_voltage_callback_period
  send_request(FUNCTION_GET_STACK_VOLTAGE_CALLBACK_PERIOD, [], '', 4, 'L')
end

#get_stack_voltage_callback_thresholdObject

Returns the threshold as set by BrickMaster#set_stack_voltage_callback_threshold.

.. versionadded

2.0.5$nbsp;(Firmware)



955
956
957
# File 'lib/tinkerforge/brick_master.rb', line 955

def get_stack_voltage_callback_threshold
  send_request(FUNCTION_GET_STACK_VOLTAGE_CALLBACK_THRESHOLD, [], '', 5, 'k S S')
end

#get_usb_voltageObject

Returns the USB voltage in mV. Does not work with hardware version 2.1.



804
805
806
# File 'lib/tinkerforge/brick_master.rb', line 804

def get_usb_voltage
  send_request(FUNCTION_GET_USB_VOLTAGE, [], '', 2, 'S')
end

#get_usb_voltage_callback_periodObject

Returns the period as set by BrickMaster#set_usb_voltage_callback_period.

.. versionadded

2.0.5$nbsp;(Firmware)



903
904
905
# File 'lib/tinkerforge/brick_master.rb', line 903

def get_usb_voltage_callback_period
  send_request(FUNCTION_GET_USB_VOLTAGE_CALLBACK_PERIOD, [], '', 4, 'L')
end

#get_usb_voltage_callback_thresholdObject

Returns the threshold as set by BrickMaster#set_usb_voltage_callback_threshold.

.. versionadded

2.0.5$nbsp;(Firmware)



981
982
983
# File 'lib/tinkerforge/brick_master.rb', line 981

def get_usb_voltage_callback_threshold
  send_request(FUNCTION_GET_USB_VOLTAGE_CALLBACK_THRESHOLD, [], '', 5, 'k S S')
end

#get_wifi2_ap_configurationObject

Returns the access point configuration as set by BrickMaster#set_wifi2_ap_configuration.

.. versionadded

2.4.0$nbsp;(Firmware)



1421
1422
1423
# File 'lib/tinkerforge/brick_master.rb', line 1421

def get_wifi2_ap_configuration
  send_request(FUNCTION_GET_WIFI2_AP_CONFIGURATION, [], '', 54, '? Z32 C4 C4 C4 C ? C C6')
end

#get_wifi2_ap_passwordObject

Returns the access point password as set by BrickMaster#set_wifi2_ap_password.

.. versionadded

2.4.0$nbsp;(Firmware)



1442
1443
1444
# File 'lib/tinkerforge/brick_master.rb', line 1442

def get_wifi2_ap_password
  send_request(FUNCTION_GET_WIFI2_AP_PASSWORD, [], '', 64, 'Z64')
end

#get_wifi2_authentication_secretObject

Returns the WIFI authentication secret as set by BrickMaster#set_wifi2_authentication_secret.

.. versionadded

2.4.0$nbsp;(Firmware)



1253
1254
1255
# File 'lib/tinkerforge/brick_master.rb', line 1253

def get_wifi2_authentication_secret
  send_request(FUNCTION_GET_WIFI2_AUTHENTICATION_SECRET, [], '', 64, 'Z64')
end

#get_wifi2_client_configurationObject

Returns the client configuration as set by BrickMaster#set_wifi2_client_configuration.

.. versionadded

2.4.0$nbsp;(Firmware)



1334
1335
1336
# File 'lib/tinkerforge/brick_master.rb', line 1334

def get_wifi2_client_configuration
  send_request(FUNCTION_GET_WIFI2_CLIENT_CONFIGURATION, [], '', 57, '? Z32 C4 C4 C4 C6 C6')
end

#get_wifi2_client_hostnameObject

Returns the client hostname as set by BrickMaster#set_wifi2_client_hostname.

.. versionadded

2.4.0$nbsp;(Firmware)



1356
1357
1358
# File 'lib/tinkerforge/brick_master.rb', line 1356

def get_wifi2_client_hostname
  send_request(FUNCTION_GET_WIFI2_CLIENT_HOSTNAME, [], '', 32, 'Z32')
end

#get_wifi2_client_passwordObject

Returns the client password as set by BrickMaster#set_wifi2_client_password.

.. versionadded

2.4.0$nbsp;(Firmware)



1376
1377
1378
# File 'lib/tinkerforge/brick_master.rb', line 1376

def get_wifi2_client_password
  send_request(FUNCTION_GET_WIFI2_CLIENT_PASSWORD, [], '', 64, 'Z64')
end

#get_wifi2_configurationObject

Returns the general configuration as set by BrickMaster#set_wifi2_configuration.

.. versionadded

2.4.0$nbsp;(Firmware)



1287
1288
1289
# File 'lib/tinkerforge/brick_master.rb', line 1287

def get_wifi2_configuration
  send_request(FUNCTION_GET_WIFI2_CONFIGURATION, [], '', 9, 'S S S C C C')
end

#get_wifi2_firmware_versionObject

Returns the current version of the WIFI Extension 2.0 firmware (major, minor, revision).

.. versionadded

2.4.0$nbsp;(Firmware)



1461
1462
1463
# File 'lib/tinkerforge/brick_master.rb', line 1461

def get_wifi2_firmware_version
  send_request(FUNCTION_GET_WIFI2_FIRMWARE_VERSION, [], '', 3, 'C3')
end

#get_wifi2_statusObject

Returns the client and access point status of the WIFI Extension 2.0.

.. versionadded

2.4.0$nbsp;(Firmware)



1294
1295
1296
# File 'lib/tinkerforge/brick_master.rb', line 1294

def get_wifi2_status
  send_request(FUNCTION_GET_WIFI2_STATUS, [], '', 57, '? C C4 C4 C4 C6 L L c ? C4 C4 C4 C6 L L C')
end

#get_wifi_authentication_secretObject

Returns the authentication secret as set by BrickMaster#set_wifi_authentication_secret.

.. versionadded

2.2.0$nbsp;(Firmware)



1166
1167
1168
# File 'lib/tinkerforge/brick_master.rb', line 1166

def get_wifi_authentication_secret
  send_request(FUNCTION_GET_WIFI_AUTHENTICATION_SECRET, [], '', 64, 'Z64')
end

#get_wifi_buffer_infoObject

Returns informations about the Wi-Fi receive buffer. The Wi-Fi receive buffer has a max size of 1500 byte and if data is transfered too fast, it might overflow.

The return values are the number of overflows, the low watermark (i.e. the smallest number of bytes that were free in the buffer) and the bytes that are currently used.

You should always try to keep the buffer empty, otherwise you will have a permanent latency. A good rule of thumb is, that you can transfer 1000 messages per second without problems.

Try to not send more then 50 messages at a time without any kind of break between them.



781
782
783
# File 'lib/tinkerforge/brick_master.rb', line 781

def get_wifi_buffer_info
  send_request(FUNCTION_GET_WIFI_BUFFER_INFO, [], '', 8, 'L S S')
end

#get_wifi_certificate(index) ⇒ Object

Returns the certificate for a given index as set by BrickMaster#set_wifi_certificate.



746
747
748
# File 'lib/tinkerforge/brick_master.rb', line 746

def get_wifi_certificate(index)
  send_request(FUNCTION_GET_WIFI_CERTIFICATE, [index], 'S', 33, 'C32 C')
end

#get_wifi_configurationObject

Returns the configuration as set by BrickMaster#set_wifi_configuration.



644
645
646
# File 'lib/tinkerforge/brick_master.rb', line 644

def get_wifi_configuration
  send_request(FUNCTION_GET_WIFI_CONFIGURATION, [], '', 47, 'Z32 C C4 C4 C4 S')
end

#get_wifi_encryptionObject

Returns the encryption as set by BrickMaster#set_wifi_encryption.



692
693
694
# File 'lib/tinkerforge/brick_master.rb', line 692

def get_wifi_encryption
  send_request(FUNCTION_GET_WIFI_ENCRYPTION, [], '', 59, 'C Z50 C C S S S')
end

#get_wifi_hostnameObject

Returns the hostname as set by BrickMaster#set_wifi_hostname.

An empty String means, that the default hostname is used.

.. versionadded

2.0.5$nbsp;(Firmware)



843
844
845
# File 'lib/tinkerforge/brick_master.rb', line 843

def get_wifi_hostname
  send_request(FUNCTION_GET_WIFI_HOSTNAME, [], '', 16, 'Z16')
end

#get_wifi_power_modeObject

Returns the power mode as set by BrickMaster#set_wifi_power_mode.



763
764
765
# File 'lib/tinkerforge/brick_master.rb', line 763

def get_wifi_power_mode
  send_request(FUNCTION_GET_WIFI_POWER_MODE, [], '', 1, 'C')
end

#get_wifi_regulatory_domainObject

Returns the regulatory domain as set by BrickMaster#set_wifi_regulatory_domain.



799
800
801
# File 'lib/tinkerforge/brick_master.rb', line 799

def get_wifi_regulatory_domain
  send_request(FUNCTION_GET_WIFI_REGULATORY_DOMAIN, [], '', 1, 'C')
end

#get_wifi_statusObject

Returns the status of the WIFI Extension. The state is updated automatically, all of the other parameters are updated on startup and every time BrickMaster#refresh_wifi_status is called.

Possible states are:

"State", "Description"

"0", "Disassociated"
"1", "Associated"
"2", "Associating"
"3", "Error"
"255", "Not initialized yet"


709
710
711
# File 'lib/tinkerforge/brick_master.rb', line 709

def get_wifi_status
  send_request(FUNCTION_GET_WIFI_STATUS, [], '', 36, 'C6 C6 C s C4 C4 C4 L L C')
end

#is_chibi_presentObject

Returns true if a Chibi Extension is available to be used by the Master Brick.



418
419
420
# File 'lib/tinkerforge/brick_master.rb', line 418

def is_chibi_present
  send_request(FUNCTION_IS_CHIBI_PRESENT, [], '', 1, '?')
end

#is_ethernet_presentObject

Returns true if a Ethernet Extension is available to be used by the Master Brick.

.. versionadded

2.1.0$nbsp;(Firmware)



1017
1018
1019
# File 'lib/tinkerforge/brick_master.rb', line 1017

def is_ethernet_present
  send_request(FUNCTION_IS_ETHERNET_PRESENT, [], '', 1, '?')
end

#is_rs485_presentObject

Returns true if a RS485 Extension is available to be used by the Master Brick.



534
535
536
# File 'lib/tinkerforge/brick_master.rb', line 534

def is_rs485_present
  send_request(FUNCTION_IS_RS485_PRESENT, [], '', 1, '?')
end

#is_status_led_enabledObject

Returns true if the status LED is enabled, false otherwise.

.. versionadded

2.3.2$nbsp;(Firmware)



1513
1514
1515
# File 'lib/tinkerforge/brick_master.rb', line 1513

def is_status_led_enabled
  send_request(FUNCTION_IS_STATUS_LED_ENABLED, [], '', 1, '?')
end

#is_wifi2_presentObject

Returns true if a WIFI Extension 2.0 is available to be used by the Master Brick.

.. versionadded

2.4.0$nbsp;(Firmware)



1181
1182
1183
# File 'lib/tinkerforge/brick_master.rb', line 1181

def is_wifi2_present
  send_request(FUNCTION_IS_WIFI2_PRESENT, [], '', 1, '?')
end

#is_wifi2_status_led_enabledObject

Returns true if the green status LED of the WIFI Extension 2.0 is turned on.

.. versionadded

2.4.0$nbsp;(Firmware)



1482
1483
1484
# File 'lib/tinkerforge/brick_master.rb', line 1482

def is_wifi2_status_led_enabled
  send_request(FUNCTION_IS_WIFI2_STATUS_LED_ENABLED, [], '', 1, '?')
end

#is_wifi_presentObject

Returns true if a WIFI Extension is available to be used by the Master Brick.



610
611
612
# File 'lib/tinkerforge/brick_master.rb', line 610

def is_wifi_present
  send_request(FUNCTION_IS_WIFI_PRESENT, [], '', 1, '?')
end

#read_wifi2_serial_port(length) ⇒ Object

Reads up to 60 bytes (number of bytes to be read specified by length) from the serial port of the bootloader of the WIFI Extension 2.0. Returns the number of actually read bytes.

Before this function can be used the bootloader has to be started using the BrickMaster#start_wifi2_bootloader function.

It is recommended to use the Brick Viewer to update the firmware of the WIFI Extension 2.0.

.. versionadded

2.4.0$nbsp;(Firmware)



1227
1228
1229
# File 'lib/tinkerforge/brick_master.rb', line 1227

def read_wifi2_serial_port(length)
  send_request(FUNCTION_READ_WIFI2_SERIAL_PORT, [length], 'C', 61, 'C60 C')
end

#refresh_wifi_statusObject

Refreshes the Wi-Fi status (see BrickMaster#get_wifi_status). To read the status of the Wi-Fi module, the Master Brick has to change from data mode to command mode and back. This transaction and the readout itself is unfortunately time consuming. This means, that it might take some ms until the stack with attached WIFI Extension reacts again after this function is called.



719
720
721
# File 'lib/tinkerforge/brick_master.rb', line 719

def refresh_wifi_status
  send_request(FUNCTION_REFRESH_WIFI_STATUS, [], '', 0, '')
end

#register_callback(id, &block) ⇒ Object

Registers a callback with ID id to the block block.



1559
1560
1561
1562
# File 'lib/tinkerforge/brick_master.rb', line 1559

def register_callback(id, &block)
  callback = block
  @registered_callbacks[id] = callback
end

#resetObject

Calling this function will reset the Brick. Calling this function on a Brick inside of a stack will reset the whole stack.

After a reset you have to create new device objects, calling functions on the existing ones will result in undefined behavior!



1542
1543
1544
# File 'lib/tinkerforge/brick_master.rb', line 1542

def reset
  send_request(FUNCTION_RESET, [], '', 0, '')
end

#save_wifi2_configurationObject

All configuration functions for the WIFI Extension 2.0 do not change the values permanently. After configuration this function has to be called to permanently store the values.

The values are stored in the EEPROM and only applied on startup. That means you have to restart the Master Brick after configuration.

.. versionadded

2.4.0$nbsp;(Firmware)



1454
1455
1456
# File 'lib/tinkerforge/brick_master.rb', line 1454

def save_wifi2_configuration
  send_request(FUNCTION_SAVE_WIFI2_CONFIGURATION, [], '', 1, 'C')
end

#set_chibi_address(address) ⇒ Object

Sets the address (1-255) belonging to the Chibi Extension.

It is possible to set the address with the Brick Viewer and it will be saved in the EEPROM of the Chibi Extension, it does not have to be set on every startup.



427
428
429
# File 'lib/tinkerforge/brick_master.rb', line 427

def set_chibi_address(address)
  send_request(FUNCTION_SET_CHIBI_ADDRESS, [address], 'C', 0, '')
end

#set_chibi_channel(channel) ⇒ Object

Sets the channel used by the Chibi Extension. Possible channels are different for different frequencies:

"Frequency",             "Possible Channels"

"OQPSK 868MHz (Europe)", "0"
"OQPSK 915MHz (US)",     "1, 2, 3, 4, 5, 6, 7, 8, 9, 10"
"OQPSK 780MHz (China)",  "0, 1, 2, 3"
"BPSK40 915MHz",         "1, 2, 3, 4, 5, 6, 7, 8, 9, 10"

It is possible to set the channel with the Brick Viewer and it will be saved in the EEPROM of the Chibi Extension, it does not have to be set on every startup.



524
525
526
# File 'lib/tinkerforge/brick_master.rb', line 524

def set_chibi_channel(channel)
  send_request(FUNCTION_SET_CHIBI_CHANNEL, [channel], 'C', 0, '')
end

#set_chibi_frequency(frequency) ⇒ Object

Sets the Chibi frequency range for the Chibi Extension. Possible values are:

"Type", "Description"

"0",    "OQPSK 868MHz (Europe)"
"1",    "OQPSK 915MHz (US)"
"2",    "OQPSK 780MHz (China)"
"3",    "BPSK40 915MHz"

It is possible to set the frequency with the Brick Viewer and it will be saved in the EEPROM of the Chibi Extension, it does not have to be set on every startup.



502
503
504
# File 'lib/tinkerforge/brick_master.rb', line 502

def set_chibi_frequency(frequency)
  send_request(FUNCTION_SET_CHIBI_FREQUENCY, [frequency], 'C', 0, '')
end

#set_chibi_master_address(address) ⇒ Object

Sets the address (1-255) of the Chibi Master. This address is used if the Chibi Extension is used as slave (i.e. it does not have a USB connection).

It is possible to set the address with the Brick Viewer and it will be saved in the EEPROM of the Chibi Extension, it does not have to be set on every startup.



442
443
444
# File 'lib/tinkerforge/brick_master.rb', line 442

def set_chibi_master_address(address)
  send_request(FUNCTION_SET_CHIBI_MASTER_ADDRESS, [address], 'C', 0, '')
end

#set_chibi_slave_address(num, address) ⇒ Object

Sets up to 254 slave addresses. Valid addresses are in range 1-255. 0 has a special meaning, it is used as list terminator and not allowed as normal slave address. The address numeration (via num parameter) has to be used ascending from 0. For example: If you use the Chibi Extension in Master mode (i.e. the stack has an USB connection) and you want to talk to three other Chibi stacks with the slave addresses 17, 23, and 42, you should call with “(0, 17)“, “(1, 23)“, “(2, 42)“ and “(3, 0)“. The last call with “(3, 0)“ is a list terminator and indicates that the Chibi slave address list contains 3 addresses in this case.

It is possible to set the addresses with the Brick Viewer, that will take care of correct address numeration and list termination.

The slave addresses will be saved in the EEPROM of the Chibi Extension, they don’t have to be set on every startup.



466
467
468
# File 'lib/tinkerforge/brick_master.rb', line 466

def set_chibi_slave_address(num, address)
  send_request(FUNCTION_SET_CHIBI_SLAVE_ADDRESS, [num, address], 'C C', 0, '')
end

#set_debounce_period(debounce) ⇒ Object

Sets the period in ms with which the threshold callbacks

  • CALLBACK_STACK_CURRENT_REACHED,

  • CALLBACK_STACK_VOLTAGE_REACHED,

  • CALLBACK_USB_VOLTAGE_REACHED

are triggered, if the thresholds

  • BrickMaster#set_stack_current_callback_threshold,

  • BrickMaster#set_stack_voltage_callback_threshold,

  • BrickMaster#set_usb_voltage_callback_threshold

keep being reached.

The default value is 100.

.. versionadded

2.0.5$nbsp;(Firmware)



1002
1003
1004
# File 'lib/tinkerforge/brick_master.rb', line 1002

def set_debounce_period(debounce)
  send_request(FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, '')
end

#set_ethernet_authentication_secret(secret) ⇒ Object

Sets the Ethernet authentication secret. The secret can be a string of up to 64 characters. An empty string disables the authentication.

See the :ref:‘authentication tutorial <tutorial_authentication>` for more information.

The secret is stored in the EEPROM and only applied on startup. That means you have to restart the Master Brick after configuration.

It is recommended to use the Brick Viewer to set the Ethernet authentication secret.

The default value is an empty string (authentication disabled).

.. versionadded

2.2.0$nbsp;(Firmware)



1134
1135
1136
# File 'lib/tinkerforge/brick_master.rb', line 1134

def set_ethernet_authentication_secret(secret)
  send_request(FUNCTION_SET_ETHERNET_AUTHENTICATION_SECRET, [secret], 'Z64', 0, '')
end

#set_ethernet_configuration(connection, ip, subnet_mask, gateway, port) ⇒ Object

Sets the configuration of the Ethernet Extension. Possible values for connection are:

"Value", "Description"

"0", "DHCP"
"1", "Static IP"

If you set connection to static IP options then you have to supply ip, subnet_mask and gateway as an array of size 4 (first element of the array is the least significant byte of the address). If connection is set to the DHCP options then ip, subnet_mask and gateway are ignored, you can set them to 0.

The last parameter is the port that your program will connect to. The default port, that is used by brickd, is 4223.

The values are stored in the EEPROM and only applied on startup. That means you have to restart the Master Brick after configuration.

It is recommended to use the Brick Viewer to set the Ethernet configuration.

.. versionadded

2.1.0$nbsp;(Firmware)



1044
1045
1046
# File 'lib/tinkerforge/brick_master.rb', line 1044

def set_ethernet_configuration(connection, ip, subnet_mask, gateway, port)
  send_request(FUNCTION_SET_ETHERNET_CONFIGURATION, [connection, ip, subnet_mask, gateway, port], 'C C4 C4 C4 S', 0, '')
end

#set_ethernet_hostname(hostname) ⇒ Object

Sets the hostname of the Ethernet Extension. The hostname will be displayed by access points as the hostname in the DHCP clients table.

Setting an empty String will restore the default hostname.

The current hostname can be discovered with BrickMaster#get_ethernet_status.

.. versionadded

2.1.0$nbsp;(Firmware)



1078
1079
1080
# File 'lib/tinkerforge/brick_master.rb', line 1078

def set_ethernet_hostname(hostname)
  send_request(FUNCTION_SET_ETHERNET_HOSTNAME, [hostname], 'Z32', 0, '')
end

#set_ethernet_mac_address(mac_address) ⇒ Object

Sets the MAC address of the Ethernet Extension. The Ethernet Extension should come configured with a valid MAC address, that is also written on a sticker of the extension itself.

The MAC address can be read out again with BrickMaster#get_ethernet_status.

.. versionadded

2.1.0$nbsp;(Firmware)



1089
1090
1091
# File 'lib/tinkerforge/brick_master.rb', line 1089

def set_ethernet_mac_address(mac_address)
  send_request(FUNCTION_SET_ETHERNET_MAC_ADDRESS, [mac_address], 'C6', 0, '')
end

#set_ethernet_websocket_configuration(sockets, port) ⇒ Object

Sets the Ethernet WebSocket configuration. The first parameter sets the number of socket connections that are reserved for WebSockets. The range is 0-7. The connections are shared with the plain sockets. Example: If you set the connections to 3, there will be 3 WebSocket and 4 plain socket connections available.

The second parameter is the port for the WebSocket connections. The port can not be the same as the port for the plain socket connections.

The values are stored in the EEPROM and only applied on startup. That means you have to restart the Master Brick after configuration.

It is recommended to use the Brick Viewer to set the Ethernet configuration.

The default values are 3 for the socket connections and 4280 for the port.

.. versionadded

2.2.0$nbsp;(Firmware)



1109
1110
1111
# File 'lib/tinkerforge/brick_master.rb', line 1109

def set_ethernet_websocket_configuration(sockets, port)
  send_request(FUNCTION_SET_ETHERNET_WEBSOCKET_CONFIGURATION, [sockets, port], 'C S', 0, '')
end

#set_extension_type(extension, exttype) ⇒ Object

Writes the extension type to the EEPROM of a specified extension. The extension is either 0 or 1 (0 is the on the bottom, 1 is the one on top, if only one extension is present use 0).

Possible extension types:

"Type", "Description"

"1",    "Chibi"
"2",    "RS485"
"3",    "WIFI"
"4",    "Ethernet"
"5",    "WIFI 2.0"

The extension type is already set when bought and it can be set with the Brick Viewer, it is unlikely that you need this function.



408
409
410
# File 'lib/tinkerforge/brick_master.rb', line 408

def set_extension_type(extension, exttype)
  send_request(FUNCTION_SET_EXTENSION_TYPE, [extension, exttype], 'C L', 0, '')
end

#set_long_wifi_key(key) ⇒ Object

Sets a long Wi-Fi key (up to 63 chars, at least 8 chars) for WPA encryption. This key will be used if the key in BrickMaster#set_wifi_encryption is set to “-”. In the old protocol, a payload of size 63 was not possible, so the maximum key length was 50 chars.

With the new protocol this is possible, since we didn’t want to break API, this function was added additionally.

.. versionadded

2.0.2$nbsp;(Firmware)



817
818
819
# File 'lib/tinkerforge/brick_master.rb', line 817

def set_long_wifi_key(key)
  send_request(FUNCTION_SET_LONG_WIFI_KEY, [key], 'Z64', 0, '')
end

#set_rs485_address(address) ⇒ Object

Sets the address (0-255) belonging to the RS485 Extension.

Set to 0 if the RS485 Extension should be the RS485 Master (i.e. connected to a PC via USB).

It is possible to set the address with the Brick Viewer and it will be saved in the EEPROM of the RS485 Extension, it does not have to be set on every startup.



546
547
548
# File 'lib/tinkerforge/brick_master.rb', line 546

def set_rs485_address(address)
  send_request(FUNCTION_SET_RS485_ADDRESS, [address], 'C', 0, '')
end

#set_rs485_configuration(speed, parity, stopbits) ⇒ Object

Sets the configuration of the RS485 Extension. Speed is given in baud. The Master Brick will try to match the given baud rate as exactly as possible. The maximum recommended baud rate is 2000000 (2Mbit/s). Possible values for parity are ‘n’ (none), ‘e’ (even) and ‘o’ (odd). Possible values for stop bits are 1 and 2.

If your RS485 is unstable (lost messages etc.), the first thing you should try is to decrease the speed. On very large bus (e.g. 1km), you probably should use a value in the range of 100000 (100kbit/s).

The values are stored in the EEPROM and only applied on startup. That means you have to restart the Master Brick after configuration.



600
601
602
# File 'lib/tinkerforge/brick_master.rb', line 600

def set_rs485_configuration(speed, parity, stopbits)
  send_request(FUNCTION_SET_RS485_CONFIGURATION, [speed, parity, stopbits], 'L k C', 0, '')
end

#set_rs485_slave_address(num, address) ⇒ Object

Sets up to 255 slave addresses. Valid addresses are in range 1-255. 0 has a special meaning, it is used as list terminator and not allowed as normal slave address. The address numeration (via num parameter) has to be used ascending from 0. For example: If you use the RS485 Extension in Master mode (i.e. the stack has an USB connection) and you want to talk to three other RS485 stacks with the addresses 17, 23, and 42, you should call with “(0, 17)“, “(1, 23)“, “(2, 42)“ and “(3, 0)“. The last call with “(3, 0)“ is a list terminator and indicates that the RS485 slave address list contains 3 addresses in this case.

It is possible to set the addresses with the Brick Viewer, that will take care of correct address numeration and list termination.

The slave addresses will be saved in the EEPROM of the Chibi Extension, they don’t have to be set on every startup.



570
571
572
# File 'lib/tinkerforge/brick_master.rb', line 570

def set_rs485_slave_address(num, address)
  send_request(FUNCTION_SET_RS485_SLAVE_ADDRESS, [num, address], 'C C', 0, '')
end

#set_stack_current_callback_period(period) ⇒ Object

Sets the period in ms with which the CALLBACK_STACK_CURRENT callback is triggered periodically. A value of 0 turns the callback off.

CALLBACK_STACK_CURRENT is only triggered if the current has changed since the last triggering.

The default value is 0.

.. versionadded

2.0.5$nbsp;(Firmware)



856
857
858
# File 'lib/tinkerforge/brick_master.rb', line 856

def set_stack_current_callback_period(period)
  send_request(FUNCTION_SET_STACK_CURRENT_CALLBACK_PERIOD, [period], 'L', 0, '')
end

#set_stack_current_callback_threshold(option, min, max) ⇒ Object

Sets the thresholds for the CALLBACK_STACK_CURRENT_REACHED callback.

The following options are possible:

"Option", "Description"

"'x'",    "Callback is turned off"
"'o'",    "Callback is triggered when the current is *outside* the min and max values"
"'i'",    "Callback is triggered when the current is *inside* the min and max values"
"'<'",    "Callback is triggered when the current is smaller than the min value (max is ignored)"
"'>'",    "Callback is triggered when the current is greater than the min value (max is ignored)"

The default value is (‘x’, 0, 0).

.. versionadded

2.0.5$nbsp;(Firmware)



922
923
924
# File 'lib/tinkerforge/brick_master.rb', line 922

def set_stack_current_callback_threshold(option, min, max)
  send_request(FUNCTION_SET_STACK_CURRENT_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, '')
end

#set_stack_voltage_callback_period(period) ⇒ Object

Sets the period in ms with which the CALLBACK_STACK_VOLTAGE callback is triggered periodically. A value of 0 turns the callback off.

CALLBACK_STACK_VOLTAGE is only triggered if the voltage has changed since the last triggering.

The default value is 0.

.. versionadded

2.0.5$nbsp;(Firmware)



876
877
878
# File 'lib/tinkerforge/brick_master.rb', line 876

def set_stack_voltage_callback_period(period)
  send_request(FUNCTION_SET_STACK_VOLTAGE_CALLBACK_PERIOD, [period], 'L', 0, '')
end

#set_stack_voltage_callback_threshold(option, min, max) ⇒ Object

Sets the thresholds for the :func:StackStackVoltageReached callback.

The following options are possible:

"Option", "Description"

"'x'",    "Callback is turned off"
"'o'",    "Callback is triggered when the voltage is *outside* the min and max values"
"'i'",    "Callback is triggered when the voltage is *inside* the min and max values"
"'<'",    "Callback is triggered when the voltage is smaller than the min value (max is ignored)"
"'>'",    "Callback is triggered when the voltage is greater than the min value (max is ignored)"

The default value is (‘x’, 0, 0).

.. versionadded

2.0.5$nbsp;(Firmware)



948
949
950
# File 'lib/tinkerforge/brick_master.rb', line 948

def set_stack_voltage_callback_threshold(option, min, max)
  send_request(FUNCTION_SET_STACK_VOLTAGE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, '')
end

#set_usb_voltage_callback_period(period) ⇒ Object

Sets the period in ms with which the CALLBACK_USB_VOLTAGE callback is triggered periodically. A value of 0 turns the callback off.

CALLBACK_USB_VOLTAGE is only triggered if the voltage has changed since the last triggering.

The default value is 0.

.. versionadded

2.0.5$nbsp;(Firmware)



896
897
898
# File 'lib/tinkerforge/brick_master.rb', line 896

def set_usb_voltage_callback_period(period)
  send_request(FUNCTION_SET_USB_VOLTAGE_CALLBACK_PERIOD, [period], 'L', 0, '')
end

#set_usb_voltage_callback_threshold(option, min, max) ⇒ Object

Sets the thresholds for the CALLBACK_USB_VOLTAGE_REACHED callback.

The following options are possible:

"Option", "Description"

"'x'",    "Callback is turned off"
"'o'",    "Callback is triggered when the voltage is *outside* the min and max values"
"'i'",    "Callback is triggered when the voltage is *inside* the min and max values"
"'<'",    "Callback is triggered when the voltage is smaller than the min value (max is ignored)"
"'>'",    "Callback is triggered when the voltage is greater than the min value (max is ignored)"

The default value is (‘x’, 0, 0).

.. versionadded

2.0.5$nbsp;(Firmware)



974
975
976
# File 'lib/tinkerforge/brick_master.rb', line 974

def set_usb_voltage_callback_threshold(option, min, max)
  send_request(FUNCTION_SET_USB_VOLTAGE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, '')
end

#set_wifi2_ap_configuration(enable, ssid, ip, subnet_mask, gateway, encryption, hidden, channel, mac_address) ⇒ Object

Sets the access point specific configuration of the WIFI Extension 2.0.

The enable parameter enables or disables the access point part fo the WIFI Extension 2.0. The default value is true.

The ssid parameter sets the SSID (up to 32 characters) of the access point.

If the ip, subnet_mask and gateway parameters are set to all zero then a DHCP server is enabled. Otherwise those three parameters can be used to configure a static IP address for the access point. The default configuration is DHCP.

The encryption parameter sets the encryption mode to be used. Possible values are Open (no encryption), WEP or WPA/WPA2 PSK. The default value is WPA/WPA2 PSK. Use the BrickMaster#set_wifi2_ap_password function to set the encryption password.

The hidden parameter makes the access point hide or show its SSID. The default value is false.

The channel parameter sets the channel (1 to 13) of the access point. The default value is 1.

If the mac_address parameter is set to all zero then the factory MAC address is used. Otherwise this parameter can be used to set a custom MAC address.

To apply configuration changes to the WIFI Extension 2.0 the BrickMaster#save_wifi2_configuration function has to be called and the Master Brick has to be restarted afterwards.

It is recommended to use the Brick Viewer to set the access point configuration.

.. versionadded

2.4.0$nbsp;(Firmware)



1414
1415
1416
# File 'lib/tinkerforge/brick_master.rb', line 1414

def set_wifi2_ap_configuration(enable, ssid, ip, subnet_mask, gateway, encryption, hidden, channel, mac_address)
  send_request(FUNCTION_SET_WIFI2_AP_CONFIGURATION, [enable, ssid, ip, subnet_mask, gateway, encryption, hidden, channel, mac_address], '? Z32 C4 C4 C4 C ? C C6', 0, '')
end

#set_wifi2_ap_password(password) ⇒ Object

Sets the access point password (up to 63 chars) for the configured encryption mode, see BrickMaster#set_wifi2_ap_configuration.

To apply configuration changes to the WIFI Extension 2.0 the BrickMaster#save_wifi2_configuration function has to be called and the Master Brick has to be restarted afterwards.

It is recommended to use the Brick Viewer to set the access point password.

.. versionadded

2.4.0$nbsp;(Firmware)



1435
1436
1437
# File 'lib/tinkerforge/brick_master.rb', line 1435

def set_wifi2_ap_password(password)
  send_request(FUNCTION_SET_WIFI2_AP_PASSWORD, [password], 'Z64', 0, '')
end

#set_wifi2_authentication_secret(secret) ⇒ Object

Sets the WIFI authentication secret. The secret can be a string of up to 64 characters. An empty string disables the authentication. The default value is an empty string (authentication disabled).

See the :ref:‘authentication tutorial <tutorial_authentication>` for more information.

To apply configuration changes to the WIFI Extension 2.0 the BrickMaster#save_wifi2_configuration function has to be called and the Master Brick has to be restarted afterwards.

It is recommended to use the Brick Viewer to set the WIFI authentication secret.

.. versionadded

2.4.0$nbsp;(Firmware)



1245
1246
1247
# File 'lib/tinkerforge/brick_master.rb', line 1245

def set_wifi2_authentication_secret(secret)
  send_request(FUNCTION_SET_WIFI2_AUTHENTICATION_SECRET, [secret], 'Z64', 0, '')
end

#set_wifi2_client_configuration(enable, ssid, ip, subnet_mask, gateway, mac_address, bssid) ⇒ Object

Sets the client specific configuration of the WIFI Extension 2.0.

The enable parameter enables or disables the client part fo the WIFI Extension 2.0. The default value is true.

The ssid parameter sets the SSID (up to 32 characters) of the access point to connect to.

If the ip, subnet_mask and gateway parameters are set to all zero then DHCP is used for IP address configuration. Otherwise those three parameters can be used to configure a static IP address. The default configuration is DHCP.

If the mac_address parameter is set to all zero then the factory MAC address is used. Otherwise this parameter can be used to set a custom MAC address.

If the bssid parameter is set to all zero then WIFI Extension 2.0 will connect to any access point that matches the configured SSID. Otherwise this parameter can be used to make the WIFI Extension 2.0 only connect to an access point if SSID and BSSID match.

To apply configuration changes to the WIFI Extension 2.0 the BrickMaster#save_wifi2_configuration function has to be called and the Master Brick has to be restarted afterwards.

It is recommended to use the Brick Viewer to set the client configuration.

.. versionadded

2.4.0$nbsp;(Firmware)



1327
1328
1329
# File 'lib/tinkerforge/brick_master.rb', line 1327

def set_wifi2_client_configuration(enable, ssid, ip, subnet_mask, gateway, mac_address, bssid)
  send_request(FUNCTION_SET_WIFI2_CLIENT_CONFIGURATION, [enable, ssid, ip, subnet_mask, gateway, mac_address, bssid], '? Z32 C4 C4 C4 C6 C6', 0, '')
end

#set_wifi2_client_hostname(hostname) ⇒ Object

Sets the client hostname (up to 32 characters) of the WIFI Extension 2.0. The hostname will be displayed by access points as the hostname in the DHCP clients table.

To apply configuration changes to the WIFI Extension 2.0 the BrickMaster#save_wifi2_configuration function has to be called and the Master Brick has to be restarted afterwards.

It is recommended to use the Brick Viewer to set the client hostname.

.. versionadded

2.4.0$nbsp;(Firmware)



1349
1350
1351
# File 'lib/tinkerforge/brick_master.rb', line 1349

def set_wifi2_client_hostname(hostname)
  send_request(FUNCTION_SET_WIFI2_CLIENT_HOSTNAME, [hostname], 'Z32', 0, '')
end

#set_wifi2_client_password(password) ⇒ Object

Sets the client password (up to 63 chars) for WPA/WPA2 encryption.

To apply configuration changes to the WIFI Extension 2.0 the BrickMaster#save_wifi2_configuration function has to be called and the Master Brick has to be restarted afterwards.

It is recommended to use the Brick Viewer to set the client password.

.. versionadded

2.4.0$nbsp;(Firmware)



1369
1370
1371
# File 'lib/tinkerforge/brick_master.rb', line 1369

def set_wifi2_client_password(password)
  send_request(FUNCTION_SET_WIFI2_CLIENT_PASSWORD, [password], 'Z64', 0, '')
end

#set_wifi2_configuration(port, websocket_port, website_port, phy_mode, sleep_mode, website) ⇒ Object

Sets the general configuration of the WIFI Extension 2.0.

The port parameter sets the port number that your programm will connect to. The default value is 4223.

The websocket_port parameter sets the WebSocket port number that your JavaScript programm will connect to. The default value is 4280.

The website_port parameter sets the port number for the website of the WIFI Extension 2.0. The default value is 80.

The phy_mode parameter sets the specific wireless network mode to be used. Possible values are B, G and N. The default value is G.

The sleep_mode and website parameters are currently unused.

To apply configuration changes to the WIFI Extension 2.0 the BrickMaster#save_wifi2_configuration function has to be called and the Master Brick has to be restarted afterwards.

It is recommended to use the Brick Viewer to set the Ethernet configuration.

.. versionadded

2.4.0$nbsp;(Firmware)



1280
1281
1282
# File 'lib/tinkerforge/brick_master.rb', line 1280

def set_wifi2_configuration(port, websocket_port, website_port, phy_mode, sleep_mode, website)
  send_request(FUNCTION_SET_WIFI2_CONFIGURATION, [port, websocket_port, website_port, phy_mode, sleep_mode, website], 'S S S C C C', 0, '')
end

#set_wifi_authentication_secret(secret) ⇒ Object

Sets the WIFI authentication secret. The secret can be a string of up to 64 characters. An empty string disables the authentication.

See the :ref:‘authentication tutorial <tutorial_authentication>` for more information.

The secret is stored in the EEPROM and only applied on startup. That means you have to restart the Master Brick after configuration.

It is recommended to use the Brick Viewer to set the WIFI authentication secret.

The default value is an empty string (authentication disabled).

.. versionadded

2.2.0$nbsp;(Firmware)



1159
1160
1161
# File 'lib/tinkerforge/brick_master.rb', line 1159

def set_wifi_authentication_secret(secret)
  send_request(FUNCTION_SET_WIFI_AUTHENTICATION_SECRET, [secret], 'Z64', 0, '')
end

#set_wifi_certificate(index, data, data_length) ⇒ Object

This function is used to set the certificate as well as password and username for WPA Enterprise. To set the username use index 0xFFFF, to set the password use index 0xFFFE. The max length of username and password is 32.

The certificate is written in chunks of size 32 and the index is used as the index of the chunk. data_length should nearly always be 32. Only the last chunk can have a length that is not equal to 32.

The starting index of the CA Certificate is 0, of the Client Certificate 10000 and for the Private Key 20000. Maximum sizes are 1312, 1312 and 4320 byte respectively.

The values are stored in the EEPROM and only applied on startup. That means you have to restart the Master Brick after uploading the certificate.

It is recommended to use the Brick Viewer to set the certificate, username and password.



741
742
743
# File 'lib/tinkerforge/brick_master.rb', line 741

def set_wifi_certificate(index, data, data_length)
  send_request(FUNCTION_SET_WIFI_CERTIFICATE, [index, data, data_length], 'S C32 C', 0, '')
end

#set_wifi_configuration(ssid, connection, ip, subnet_mask, gateway, port) ⇒ Object

Sets the configuration of the WIFI Extension. The ssid can have a max length of 32 characters. Possible values for connection are:

"Value", "Description"

"0", "DHCP"
"1", "Static IP"
"2", "Access Point: DHCP"
"3", "Access Point: Static IP"
"4", "Ad Hoc: DHCP"
"5", "Ad Hoc: Static IP"

If you set connection to one of the static IP options then you have to supply ip, subnet_mask and gateway as an array of size 4 (first element of the array is the least significant byte of the address). If connection is set to one of the DHCP options then ip, subnet_mask and gateway are ignored, you can set them to 0.

The last parameter is the port that your program will connect to. The default port, that is used by brickd, is 4223.

The values are stored in the EEPROM and only applied on startup. That means you have to restart the Master Brick after configuration.

It is recommended to use the Brick Viewer to set the WIFI configuration.



639
640
641
# File 'lib/tinkerforge/brick_master.rb', line 639

def set_wifi_configuration(ssid, connection, ip, subnet_mask, gateway, port)
  send_request(FUNCTION_SET_WIFI_CONFIGURATION, [ssid, connection, ip, subnet_mask, gateway, port], 'Z32 C C4 C4 C4 S', 0, '')
end

#set_wifi_encryption(encryption, key, key_index, eap_options, ca_certificate_length, client_certificate_length, private_key_length) ⇒ Object

Sets the encryption of the WIFI Extension. The first parameter is the type of the encryption. Possible values are:

"Value", "Description"

"0", "WPA/WPA2"
"1", "WPA Enterprise (EAP-FAST, EAP-TLS, EAP-TTLS, PEAP)"
"2", "WEP"
"3", "No Encryption"

The key has a max length of 50 characters and is used if encryption is set to 0 or 2 (WPA/WPA2 or WEP). Otherwise the value is ignored.

For WPA/WPA2 the key has to be at least 8 characters long. If you want to set a key with more than 50 characters, see BrickMaster#set_long_wifi_key.

For WEP the key has to be either 10 or 26 hexadecimal digits long. It is possible to set the WEP key_index (1-4). If you don’t know your key_index, it is likely 1.

If you choose WPA Enterprise as encryption, you have to set eap_options and the length of the certificates (for other encryption types these parameters are ignored). The certificate length are given in byte and the certificates themselves can be set with BrickMaster#set_wifi_certificate. eap_options consist of the outer authentication (bits 1-2), inner authentication (bit 3) and certificate type (bits 4-5):

"Option", "Bits", "Description"

"outer authentication", "1-2", "0=EAP-FAST, 1=EAP-TLS, 2=EAP-TTLS, 3=EAP-PEAP"
"inner authentication", "3", "0=EAP-MSCHAP, 1=EAP-GTC"
"certificate type", "4-5", "0=CA Certificate, 1=Client Certificate, 2=Private Key"

Example for EAP-TTLS + EAP-GTC + Private Key: “option = 2 | (1 << 2) | (2 << 3)“.

The values are stored in the EEPROM and only applied on startup. That means you have to restart the Master Brick after configuration.

It is recommended to use the Brick Viewer to set the Wi-Fi encryption.



687
688
689
# File 'lib/tinkerforge/brick_master.rb', line 687

def set_wifi_encryption(encryption, key, key_index, eap_options, ca_certificate_length, client_certificate_length, private_key_length)
  send_request(FUNCTION_SET_WIFI_ENCRYPTION, [encryption, key, key_index, eap_options, ca_certificate_length, client_certificate_length, private_key_length], 'C Z50 C C S S S', 0, '')
end

#set_wifi_hostname(hostname) ⇒ Object

Sets the hostname of the WIFI Extension. The hostname will be displayed by access points as the hostname in the DHCP clients table.

Setting an empty String will restore the default hostname.

.. versionadded

2.0.5$nbsp;(Firmware)



834
835
836
# File 'lib/tinkerforge/brick_master.rb', line 834

def set_wifi_hostname(hostname)
  send_request(FUNCTION_SET_WIFI_HOSTNAME, [hostname], 'Z16', 0, '')
end

#set_wifi_power_mode(mode) ⇒ Object

Sets the power mode of the WIFI Extension. Possible modes are:

"Mode", "Description"

"0", "Full Speed (high power consumption, high throughput)"
"1", "Low Power (low power consumption, low throughput)"

The default value is 0 (Full Speed).



758
759
760
# File 'lib/tinkerforge/brick_master.rb', line 758

def set_wifi_power_mode(mode)
  send_request(FUNCTION_SET_WIFI_POWER_MODE, [mode], 'C', 0, '')
end

#set_wifi_regulatory_domain(domain) ⇒ Object

Sets the regulatory domain of the WIFI Extension. Possible domains are:

"Domain", "Description"

"0", "FCC: Channel 1-11 (N/S America, Australia, New Zealand)"
"1", "ETSI: Channel 1-13 (Europe, Middle East, Africa)"
"2", "TELEC: Channel 1-14 (Japan)"

The default value is 1 (ETSI).



794
795
796
# File 'lib/tinkerforge/brick_master.rb', line 794

def set_wifi_regulatory_domain(domain)
  send_request(FUNCTION_SET_WIFI_REGULATORY_DOMAIN, [domain], 'C', 0, '')
end

#start_wifi2_bootloaderObject

Starts the bootloader of the WIFI Extension 2.0. Returns 0 on success. Afterwards the BrickMaster#write_wifi2_serial_port and BrickMaster#read_wifi2_serial_port functions can be used to communicate with the bootloader to flash a new firmware.

The bootloader should only be started over a USB connection. It cannot be started over a WIFI2 connection, see the BrickMaster#get_connection_type function.

It is recommended to use the Brick Viewer to update the firmware of the WIFI Extension 2.0.

.. versionadded

2.4.0$nbsp;(Firmware)



1197
1198
1199
# File 'lib/tinkerforge/brick_master.rb', line 1197

def start_wifi2_bootloader
  send_request(FUNCTION_START_WIFI2_BOOTLOADER, [], '', 1, 'c')
end

#write_wifi2_serial_port(data, length) ⇒ Object

Writes up to 60 bytes (number of bytes to be written specified by length) to the serial port of the bootloader of the WIFI Extension 2.0. Returns 0 on success.

Before this function can be used the bootloader has to be started using the BrickMaster#start_wifi2_bootloader function.

It is recommended to use the Brick Viewer to update the firmware of the WIFI Extension 2.0.

.. versionadded

2.4.0$nbsp;(Firmware)



1212
1213
1214
# File 'lib/tinkerforge/brick_master.rb', line 1212

def write_wifi2_serial_port(data, length)
  send_request(FUNCTION_WRITE_WIFI2_SERIAL_PORT, [data, length], 'C60 C', 1, 'c')
end