tinkerforge 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. data/lib/tinkerforge.rb +5 -0
  2. data/lib/tinkerforge/brick_dc.rb +359 -0
  3. data/lib/tinkerforge/brick_imu.rb +512 -0
  4. data/lib/tinkerforge/brick_master.rb +1120 -0
  5. data/lib/tinkerforge/brick_servo.rb +475 -0
  6. data/lib/tinkerforge/brick_stepper.rb +556 -0
  7. data/lib/tinkerforge/bricklet_ambient_light.rb +246 -0
  8. data/lib/tinkerforge/bricklet_analog_in.rb +273 -0
  9. data/lib/tinkerforge/bricklet_analog_out.rb +90 -0
  10. data/lib/tinkerforge/bricklet_barometer.rb +313 -0
  11. data/lib/tinkerforge/bricklet_current12.rb +274 -0
  12. data/lib/tinkerforge/bricklet_current25.rb +274 -0
  13. data/lib/tinkerforge/bricklet_distance_ir.rb +274 -0
  14. data/lib/tinkerforge/bricklet_dual_relay.rb +127 -0
  15. data/lib/tinkerforge/bricklet_gps.rb +301 -0
  16. data/lib/tinkerforge/bricklet_humidity.rb +245 -0
  17. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +165 -0
  18. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +177 -0
  19. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +177 -0
  20. data/lib/tinkerforge/bricklet_io16.rb +237 -0
  21. data/lib/tinkerforge/bricklet_io4.rb +236 -0
  22. data/lib/tinkerforge/bricklet_joystick.rb +274 -0
  23. data/lib/tinkerforge/bricklet_lcd_16x2.rb +175 -0
  24. data/lib/tinkerforge/bricklet_lcd_20x4.rb +231 -0
  25. data/lib/tinkerforge/bricklet_linear_poti.rb +241 -0
  26. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +84 -0
  27. data/lib/tinkerforge/bricklet_ptc.rb +277 -0
  28. data/lib/tinkerforge/bricklet_rotary_poti.rb +241 -0
  29. data/lib/tinkerforge/bricklet_temperature.rb +188 -0
  30. data/lib/tinkerforge/bricklet_temperature_ir.rb +275 -0
  31. data/lib/tinkerforge/bricklet_voltage.rb +241 -0
  32. data/lib/tinkerforge/bricklet_voltage_current.rb +386 -0
  33. data/lib/tinkerforge/ip_connection.rb +1027 -0
  34. data/lib/tinkerforge/version.rb +4 -0
  35. metadata +98 -0
@@ -0,0 +1,1120 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2013-05-16. #
4
+ # #
5
+ # Bindings Version 2.0.7 #
6
+ # #
7
+ # If you have a bugfix for this file and want to commit it, #
8
+ # please fix the bug in the generator. You can find a link #
9
+ # to the generator git on tinkerforge.com #
10
+ #############################################################
11
+
12
+ module Tinkerforge
13
+ # Device for controlling Stacks and four Bricklets
14
+ class BrickMaster < Device
15
+ DEVICE_IDENTIFIER = 13 # :nodoc:
16
+
17
+ # This callback is triggered periodically with the period that is set by
18
+ # BrickMaster#set_stack_current_callback_period. The parameter is the current of the
19
+ # sensor.
20
+ #
21
+ # CALLBACK_STACK_CURRENT is only triggered if the current has changed since the
22
+ # last triggering.
23
+ #
24
+ # .. versionadded:: 2.0.5~(Firmware)
25
+ CALLBACK_STACK_CURRENT = 59
26
+
27
+ # This callback is triggered periodically with the period that is set by
28
+ # BrickMaster#set_stack_voltage_callback_period. The parameter is the voltage of the
29
+ # sensor.
30
+ #
31
+ # CALLBACK_STACK_VOLTAGE is only triggered if the voltage has changed since the
32
+ # last triggering.
33
+ #
34
+ # .. versionadded:: 2.0.5~(Firmware)
35
+ CALLBACK_STACK_VOLTAGE = 60
36
+
37
+ # This callback is triggered periodically with the period that is set by
38
+ # BrickMaster#set_usb_voltage_callback_period. The parameter is the USB voltage
39
+ # in mV.
40
+ #
41
+ # CALLBACK_USB_VOLTAGE is only triggered if the USB voltage has changed since the
42
+ # last triggering.
43
+ #
44
+ # .. versionadded:: 2.0.5~(Firmware)
45
+ CALLBACK_USB_VOLTAGE = 61
46
+
47
+ # This callback is triggered when the threshold as set by
48
+ # BrickMaster#set_stack_current_callback_threshold is reached.
49
+ # The parameter is the stack current in mA.
50
+ #
51
+ # If the threshold keeps being reached, the callback is triggered periodically
52
+ # with the period as set by BrickMaster#set_debounce_period.
53
+ #
54
+ # .. versionadded:: 2.0.5~(Firmware)
55
+ CALLBACK_STACK_CURRENT_REACHED = 62
56
+
57
+ # This callback is triggered when the threshold as set by
58
+ # BrickMaster#set_stack_voltage_callback_threshold is reached.
59
+ # The parameter is the stack voltage in mV.
60
+ #
61
+ # If the threshold keeps being reached, the callback is triggered periodically
62
+ # with the period as set by BrickMaster#set_debounce_period.
63
+ #
64
+ # .. versionadded:: 2.0.5~(Firmware)
65
+ CALLBACK_STACK_VOLTAGE_REACHED = 63
66
+
67
+ # This callback is triggered when the threshold as set by
68
+ # BrickMaster#set_usb_voltage_callback_threshold is reached.
69
+ # The parameter is the voltage of the sensor.
70
+ #
71
+ # If the threshold keeps being reached, the callback is triggered periodically
72
+ # with the period as set by BrickMaster#set_debounce_period.
73
+ #
74
+ # .. versionadded:: 2.0.5~(Firmware)
75
+ CALLBACK_USB_VOLTAGE_REACHED = 64
76
+
77
+ FUNCTION_GET_STACK_VOLTAGE = 1 # :nodoc:
78
+ FUNCTION_GET_STACK_CURRENT = 2 # :nodoc:
79
+ FUNCTION_SET_EXTENSION_TYPE = 3 # :nodoc:
80
+ FUNCTION_GET_EXTENSION_TYPE = 4 # :nodoc:
81
+ FUNCTION_IS_CHIBI_PRESENT = 5 # :nodoc:
82
+ FUNCTION_SET_CHIBI_ADDRESS = 6 # :nodoc:
83
+ FUNCTION_GET_CHIBI_ADDRESS = 7 # :nodoc:
84
+ FUNCTION_SET_CHIBI_MASTER_ADDRESS = 8 # :nodoc:
85
+ FUNCTION_GET_CHIBI_MASTER_ADDRESS = 9 # :nodoc:
86
+ FUNCTION_SET_CHIBI_SLAVE_ADDRESS = 10 # :nodoc:
87
+ FUNCTION_GET_CHIBI_SLAVE_ADDRESS = 11 # :nodoc:
88
+ FUNCTION_GET_CHIBI_SIGNAL_STRENGTH = 12 # :nodoc:
89
+ FUNCTION_GET_CHIBI_ERROR_LOG = 13 # :nodoc:
90
+ FUNCTION_SET_CHIBI_FREQUENCY = 14 # :nodoc:
91
+ FUNCTION_GET_CHIBI_FREQUENCY = 15 # :nodoc:
92
+ FUNCTION_SET_CHIBI_CHANNEL = 16 # :nodoc:
93
+ FUNCTION_GET_CHIBI_CHANNEL = 17 # :nodoc:
94
+ FUNCTION_IS_RS485_PRESENT = 18 # :nodoc:
95
+ FUNCTION_SET_RS485_ADDRESS = 19 # :nodoc:
96
+ FUNCTION_GET_RS485_ADDRESS = 20 # :nodoc:
97
+ FUNCTION_SET_RS485_SLAVE_ADDRESS = 21 # :nodoc:
98
+ FUNCTION_GET_RS485_SLAVE_ADDRESS = 22 # :nodoc:
99
+ FUNCTION_GET_RS485_ERROR_LOG = 23 # :nodoc:
100
+ FUNCTION_SET_RS485_CONFIGURATION = 24 # :nodoc:
101
+ FUNCTION_GET_RS485_CONFIGURATION = 25 # :nodoc:
102
+ FUNCTION_IS_WIFI_PRESENT = 26 # :nodoc:
103
+ FUNCTION_SET_WIFI_CONFIGURATION = 27 # :nodoc:
104
+ FUNCTION_GET_WIFI_CONFIGURATION = 28 # :nodoc:
105
+ FUNCTION_SET_WIFI_ENCRYPTION = 29 # :nodoc:
106
+ FUNCTION_GET_WIFI_ENCRYPTION = 30 # :nodoc:
107
+ FUNCTION_GET_WIFI_STATUS = 31 # :nodoc:
108
+ FUNCTION_REFRESH_WIFI_STATUS = 32 # :nodoc:
109
+ FUNCTION_SET_WIFI_CERTIFICATE = 33 # :nodoc:
110
+ FUNCTION_GET_WIFI_CERTIFICATE = 34 # :nodoc:
111
+ FUNCTION_SET_WIFI_POWER_MODE = 35 # :nodoc:
112
+ FUNCTION_GET_WIFI_POWER_MODE = 36 # :nodoc:
113
+ FUNCTION_GET_WIFI_BUFFER_INFO = 37 # :nodoc:
114
+ FUNCTION_SET_WIFI_REGULATORY_DOMAIN = 38 # :nodoc:
115
+ FUNCTION_GET_WIFI_REGULATORY_DOMAIN = 39 # :nodoc:
116
+ FUNCTION_GET_USB_VOLTAGE = 40 # :nodoc:
117
+ FUNCTION_SET_LONG_WIFI_KEY = 41 # :nodoc:
118
+ FUNCTION_GET_LONG_WIFI_KEY = 42 # :nodoc:
119
+ FUNCTION_SET_WIFI_HOSTNAME = 43 # :nodoc:
120
+ FUNCTION_GET_WIFI_HOSTNAME = 44 # :nodoc:
121
+ FUNCTION_SET_STACK_CURRENT_CALLBACK_PERIOD = 45 # :nodoc:
122
+ FUNCTION_GET_STACK_CURRENT_CALLBACK_PERIOD = 46 # :nodoc:
123
+ FUNCTION_SET_STACK_VOLTAGE_CALLBACK_PERIOD = 47 # :nodoc:
124
+ FUNCTION_GET_STACK_VOLTAGE_CALLBACK_PERIOD = 48 # :nodoc:
125
+ FUNCTION_SET_USB_VOLTAGE_CALLBACK_PERIOD = 49 # :nodoc:
126
+ FUNCTION_GET_USB_VOLTAGE_CALLBACK_PERIOD = 50 # :nodoc:
127
+ FUNCTION_SET_STACK_CURRENT_CALLBACK_THRESHOLD = 51 # :nodoc:
128
+ FUNCTION_GET_STACK_CURRENT_CALLBACK_THRESHOLD = 52 # :nodoc:
129
+ FUNCTION_SET_STACK_VOLTAGE_CALLBACK_THRESHOLD = 53 # :nodoc:
130
+ FUNCTION_GET_STACK_VOLTAGE_CALLBACK_THRESHOLD = 54 # :nodoc:
131
+ FUNCTION_SET_USB_VOLTAGE_CALLBACK_THRESHOLD = 55 # :nodoc:
132
+ FUNCTION_GET_USB_VOLTAGE_CALLBACK_THRESHOLD = 56 # :nodoc:
133
+ FUNCTION_SET_DEBOUNCE_PERIOD = 57 # :nodoc:
134
+ FUNCTION_GET_DEBOUNCE_PERIOD = 58 # :nodoc:
135
+ FUNCTION_IS_ETHERNET_PRESENT = 65 # :nodoc:
136
+ FUNCTION_SET_ETHERNET_CONFIGURATION = 66 # :nodoc:
137
+ FUNCTION_GET_ETHERNET_CONFIGURATION = 67 # :nodoc:
138
+ FUNCTION_GET_ETHERNET_STATUS = 68 # :nodoc:
139
+ FUNCTION_SET_ETHERNET_HOSTNAME = 69 # :nodoc:
140
+ FUNCTION_SET_ETHERNET_MAC_ADDRESS = 70 # :nodoc:
141
+ FUNCTION_GET_PROTOCOL1_BRICKLET_NAME = 241 # :nodoc:
142
+ FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
143
+ FUNCTION_RESET = 243 # :nodoc:
144
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
145
+
146
+ EXTENSION_TYPE_CHIBI = 1 # :nodoc:
147
+ EXTENSION_TYPE_RS485 = 2 # :nodoc:
148
+ EXTENSION_TYPE_WIFI = 3 # :nodoc:
149
+ EXTENSION_TYPE_ETHERNET = 4 # :nodoc:
150
+ CHIBI_FREQUENCY_OQPSK_868_MHZ = 0 # :nodoc:
151
+ CHIBI_FREQUENCY_OQPSK_915_MHZ = 1 # :nodoc:
152
+ CHIBI_FREQUENCY_OQPSK_780_MHZ = 2 # :nodoc:
153
+ CHIBI_FREQUENCY_BPSK40_915_MHZ = 3 # :nodoc:
154
+ RS485_PARITY_NONE = 'n' # :nodoc:
155
+ RS485_PARITY_EVEN = 'e' # :nodoc:
156
+ RS485_PARITY_ODD = 'o' # :nodoc:
157
+ WIFI_CONNECTION_DHCP = 0 # :nodoc:
158
+ WIFI_CONNECTION_STATIC_IP = 1 # :nodoc:
159
+ WIFI_CONNECTION_ACCESS_POINT_DHCP = 2 # :nodoc:
160
+ WIFI_CONNECTION_ACCESS_POINT_STATIC_IP = 3 # :nodoc:
161
+ WIFI_CONNECTION_AD_HOC_DHCP = 4 # :nodoc:
162
+ WIFI_CONNECTION_AD_HOC_STATIC_IP = 5 # :nodoc:
163
+ WIFI_ENCRYPTION_WPA_WPA2 = 0 # :nodoc:
164
+ WIFI_ENCRYPTION_WPA_ENTERPRISE = 1 # :nodoc:
165
+ WIFI_ENCRYPTION_WEP = 2 # :nodoc:
166
+ WIFI_ENCRYPTION_NO_ENCRYPTION = 3 # :nodoc:
167
+ WIFI_EAP_OPTION_OUTER_AUTH_EAP_FAST = 0 # :nodoc:
168
+ WIFI_EAP_OPTION_OUTER_AUTH_EAP_TLS = 1 # :nodoc:
169
+ WIFI_EAP_OPTION_OUTER_AUTH_EAP_TTLS = 2 # :nodoc:
170
+ WIFI_EAP_OPTION_OUTER_AUTH_EAP_PEAP = 3 # :nodoc:
171
+ WIFI_EAP_OPTION_INNER_AUTH_EAP_MSCHAP = 0 # :nodoc:
172
+ WIFI_EAP_OPTION_INNER_AUTH_EAP_GTC = 4 # :nodoc:
173
+ WIFI_EAP_OPTION_CERT_TYPE_CA_CERT = 0 # :nodoc:
174
+ WIFI_EAP_OPTION_CERT_TYPE_CLIENT_CERT = 8 # :nodoc:
175
+ WIFI_EAP_OPTION_CERT_TYPE_PRIVATE_KEY = 16 # :nodoc:
176
+ WIFI_STATE_DISASSOCIATED = 0 # :nodoc:
177
+ WIFI_STATE_ASSOCIATED = 1 # :nodoc:
178
+ WIFI_STATE_ASSOCIATING = 2 # :nodoc:
179
+ WIFI_STATE_ERROR = 3 # :nodoc:
180
+ WIFI_STATE_NOT_INITIALIZED_YET = 255 # :nodoc:
181
+ WIFI_POWER_MODE_FULL_SPEED = 0 # :nodoc:
182
+ WIFI_POWER_MODE_LOW_POWER = 1 # :nodoc:
183
+ WIFI_DOMAIN_CHANNEL_1TO11 = 0 # :nodoc:
184
+ WIFI_DOMAIN_CHANNEL_1TO13 = 1 # :nodoc:
185
+ WIFI_DOMAIN_CHANNEL_1TO14 = 2 # :nodoc:
186
+ THRESHOLD_OPTION_OFF = 'x' # :nodoc:
187
+ THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
188
+ THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
189
+ THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
190
+ THRESHOLD_OPTION_GREATER = '>' # :nodoc:
191
+ ETHERNET_CONNECTION_DHCP = 0 # :nodoc:
192
+ ETHERNET_CONNECTION_STATIC_IP = 1 # :nodoc:
193
+
194
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
195
+ # the IP Connection <tt>ipcon</tt>.
196
+ def initialize(uid, ipcon)
197
+ super uid, ipcon
198
+
199
+ @api_version = [2, 0, 2]
200
+
201
+ @response_expected[FUNCTION_GET_STACK_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
202
+ @response_expected[FUNCTION_GET_STACK_CURRENT] = RESPONSE_EXPECTED_ALWAYS_TRUE
203
+ @response_expected[FUNCTION_SET_EXTENSION_TYPE] = RESPONSE_EXPECTED_FALSE
204
+ @response_expected[FUNCTION_GET_EXTENSION_TYPE] = RESPONSE_EXPECTED_ALWAYS_TRUE
205
+ @response_expected[FUNCTION_IS_CHIBI_PRESENT] = RESPONSE_EXPECTED_ALWAYS_TRUE
206
+ @response_expected[FUNCTION_SET_CHIBI_ADDRESS] = RESPONSE_EXPECTED_FALSE
207
+ @response_expected[FUNCTION_GET_CHIBI_ADDRESS] = RESPONSE_EXPECTED_ALWAYS_TRUE
208
+ @response_expected[FUNCTION_SET_CHIBI_MASTER_ADDRESS] = RESPONSE_EXPECTED_FALSE
209
+ @response_expected[FUNCTION_GET_CHIBI_MASTER_ADDRESS] = RESPONSE_EXPECTED_ALWAYS_TRUE
210
+ @response_expected[FUNCTION_SET_CHIBI_SLAVE_ADDRESS] = RESPONSE_EXPECTED_FALSE
211
+ @response_expected[FUNCTION_GET_CHIBI_SLAVE_ADDRESS] = RESPONSE_EXPECTED_ALWAYS_TRUE
212
+ @response_expected[FUNCTION_GET_CHIBI_SIGNAL_STRENGTH] = RESPONSE_EXPECTED_ALWAYS_TRUE
213
+ @response_expected[FUNCTION_GET_CHIBI_ERROR_LOG] = RESPONSE_EXPECTED_ALWAYS_TRUE
214
+ @response_expected[FUNCTION_SET_CHIBI_FREQUENCY] = RESPONSE_EXPECTED_FALSE
215
+ @response_expected[FUNCTION_GET_CHIBI_FREQUENCY] = RESPONSE_EXPECTED_ALWAYS_TRUE
216
+ @response_expected[FUNCTION_SET_CHIBI_CHANNEL] = RESPONSE_EXPECTED_FALSE
217
+ @response_expected[FUNCTION_GET_CHIBI_CHANNEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
218
+ @response_expected[FUNCTION_IS_RS485_PRESENT] = RESPONSE_EXPECTED_ALWAYS_TRUE
219
+ @response_expected[FUNCTION_SET_RS485_ADDRESS] = RESPONSE_EXPECTED_FALSE
220
+ @response_expected[FUNCTION_GET_RS485_ADDRESS] = RESPONSE_EXPECTED_ALWAYS_TRUE
221
+ @response_expected[FUNCTION_SET_RS485_SLAVE_ADDRESS] = RESPONSE_EXPECTED_FALSE
222
+ @response_expected[FUNCTION_GET_RS485_SLAVE_ADDRESS] = RESPONSE_EXPECTED_ALWAYS_TRUE
223
+ @response_expected[FUNCTION_GET_RS485_ERROR_LOG] = RESPONSE_EXPECTED_ALWAYS_TRUE
224
+ @response_expected[FUNCTION_SET_RS485_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
225
+ @response_expected[FUNCTION_GET_RS485_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
226
+ @response_expected[FUNCTION_IS_WIFI_PRESENT] = RESPONSE_EXPECTED_ALWAYS_TRUE
227
+ @response_expected[FUNCTION_SET_WIFI_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
228
+ @response_expected[FUNCTION_GET_WIFI_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
229
+ @response_expected[FUNCTION_SET_WIFI_ENCRYPTION] = RESPONSE_EXPECTED_FALSE
230
+ @response_expected[FUNCTION_GET_WIFI_ENCRYPTION] = RESPONSE_EXPECTED_ALWAYS_TRUE
231
+ @response_expected[FUNCTION_GET_WIFI_STATUS] = RESPONSE_EXPECTED_ALWAYS_TRUE
232
+ @response_expected[FUNCTION_REFRESH_WIFI_STATUS] = RESPONSE_EXPECTED_FALSE
233
+ @response_expected[FUNCTION_SET_WIFI_CERTIFICATE] = RESPONSE_EXPECTED_FALSE
234
+ @response_expected[FUNCTION_GET_WIFI_CERTIFICATE] = RESPONSE_EXPECTED_ALWAYS_TRUE
235
+ @response_expected[FUNCTION_SET_WIFI_POWER_MODE] = RESPONSE_EXPECTED_FALSE
236
+ @response_expected[FUNCTION_GET_WIFI_POWER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
237
+ @response_expected[FUNCTION_GET_WIFI_BUFFER_INFO] = RESPONSE_EXPECTED_ALWAYS_TRUE
238
+ @response_expected[FUNCTION_SET_WIFI_REGULATORY_DOMAIN] = RESPONSE_EXPECTED_FALSE
239
+ @response_expected[FUNCTION_GET_WIFI_REGULATORY_DOMAIN] = RESPONSE_EXPECTED_ALWAYS_TRUE
240
+ @response_expected[FUNCTION_GET_USB_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
241
+ @response_expected[FUNCTION_SET_LONG_WIFI_KEY] = RESPONSE_EXPECTED_FALSE
242
+ @response_expected[FUNCTION_GET_LONG_WIFI_KEY] = RESPONSE_EXPECTED_ALWAYS_TRUE
243
+ @response_expected[FUNCTION_SET_WIFI_HOSTNAME] = RESPONSE_EXPECTED_FALSE
244
+ @response_expected[FUNCTION_GET_WIFI_HOSTNAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
245
+ @response_expected[FUNCTION_SET_STACK_CURRENT_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
246
+ @response_expected[FUNCTION_GET_STACK_CURRENT_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
247
+ @response_expected[FUNCTION_SET_STACK_VOLTAGE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
248
+ @response_expected[FUNCTION_GET_STACK_VOLTAGE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
249
+ @response_expected[FUNCTION_SET_USB_VOLTAGE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
250
+ @response_expected[FUNCTION_GET_USB_VOLTAGE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
251
+ @response_expected[FUNCTION_SET_STACK_CURRENT_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
252
+ @response_expected[FUNCTION_GET_STACK_CURRENT_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
253
+ @response_expected[FUNCTION_SET_STACK_VOLTAGE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
254
+ @response_expected[FUNCTION_GET_STACK_VOLTAGE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
255
+ @response_expected[FUNCTION_SET_USB_VOLTAGE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
256
+ @response_expected[FUNCTION_GET_USB_VOLTAGE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
257
+ @response_expected[FUNCTION_SET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_TRUE
258
+ @response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
259
+ @response_expected[CALLBACK_STACK_CURRENT] = RESPONSE_EXPECTED_ALWAYS_FALSE
260
+ @response_expected[CALLBACK_STACK_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_FALSE
261
+ @response_expected[CALLBACK_USB_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_FALSE
262
+ @response_expected[CALLBACK_STACK_CURRENT_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
263
+ @response_expected[CALLBACK_STACK_VOLTAGE_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
264
+ @response_expected[CALLBACK_USB_VOLTAGE_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
265
+ @response_expected[FUNCTION_IS_ETHERNET_PRESENT] = RESPONSE_EXPECTED_ALWAYS_TRUE
266
+ @response_expected[FUNCTION_SET_ETHERNET_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
267
+ @response_expected[FUNCTION_GET_ETHERNET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
268
+ @response_expected[FUNCTION_GET_ETHERNET_STATUS] = RESPONSE_EXPECTED_ALWAYS_TRUE
269
+ @response_expected[FUNCTION_SET_ETHERNET_HOSTNAME] = RESPONSE_EXPECTED_FALSE
270
+ @response_expected[FUNCTION_SET_ETHERNET_MAC_ADDRESS] = RESPONSE_EXPECTED_FALSE
271
+ @response_expected[FUNCTION_GET_PROTOCOL1_BRICKLET_NAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
272
+ @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
273
+ @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
274
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
275
+
276
+ @callback_formats[CALLBACK_STACK_CURRENT] = 'S'
277
+ @callback_formats[CALLBACK_STACK_VOLTAGE] = 'S'
278
+ @callback_formats[CALLBACK_USB_VOLTAGE] = 'S'
279
+ @callback_formats[CALLBACK_STACK_CURRENT_REACHED] = 'S'
280
+ @callback_formats[CALLBACK_STACK_VOLTAGE_REACHED] = 'S'
281
+ @callback_formats[CALLBACK_USB_VOLTAGE_REACHED] = 'S'
282
+ end
283
+
284
+ # Returns the stack voltage in mV. The stack voltage is the
285
+ # voltage that is supplied via the stack, i.e. it is given by a
286
+ # Step-Down or Step-Up Power Supply.
287
+ def get_stack_voltage
288
+ send_request(FUNCTION_GET_STACK_VOLTAGE, [], '', 2, 'S')
289
+ end
290
+
291
+ # Returns the stack current in mA. The stack current is the
292
+ # current that is drawn via the stack, i.e. it is given by a
293
+ # Step-Down or Step-Up Power Supply.
294
+ def get_stack_current
295
+ send_request(FUNCTION_GET_STACK_CURRENT, [], '', 2, 'S')
296
+ end
297
+
298
+ # Writes the extension type to the EEPROM of a specified extension.
299
+ # The extension is either 0 or 1 (0 is the on the bottom, 1 is the on on top,
300
+ # if only one extension is present use 0).
301
+ #
302
+ # Possible extension types:
303
+ #
304
+ # "Type", "Description"
305
+ #
306
+ # "1", "Chibi"
307
+ # "2", "RS485"
308
+ # "3", "WIFI"
309
+ # "4", "Ethernet"
310
+ #
311
+ # The extension type is already set when bought and it can be set with the
312
+ # Brick Viewer, it is unlikely that you need this function.
313
+ #
314
+ # The value will be saved in the EEPROM of the Chibi Extension, it does not
315
+ # have to be set on every startup.
316
+ def set_extension_type(extension, exttype)
317
+ send_request(FUNCTION_SET_EXTENSION_TYPE, [extension, exttype], 'C L', 0, '')
318
+ end
319
+
320
+ # Returns the extension type for a given extension as set by
321
+ # BrickMaster#set_extension_type.
322
+ def get_extension_type(extension)
323
+ send_request(FUNCTION_GET_EXTENSION_TYPE, [extension], 'C', 4, 'L')
324
+ end
325
+
326
+ # Returns *true* if a Chibi Extension is available to be used by the Master.
327
+ #
328
+ # .. versionadded:: 1.1.0~(Firmware)
329
+ def is_chibi_present
330
+ send_request(FUNCTION_IS_CHIBI_PRESENT, [], '', 1, '?')
331
+ end
332
+
333
+ # Sets the address (1-255) belonging to the Chibi Extension.
334
+ #
335
+ # It is possible to set the address with the Brick Viewer and it will be
336
+ # saved in the EEPROM of the Chibi Extension, it does not
337
+ # have to be set on every startup.
338
+ #
339
+ # .. versionadded:: 1.1.0~(Firmware)
340
+ def set_chibi_address(address)
341
+ send_request(FUNCTION_SET_CHIBI_ADDRESS, [address], 'C', 0, '')
342
+ end
343
+
344
+ # Returns the address as set by BrickMaster#set_chibi_address.
345
+ #
346
+ # .. versionadded:: 1.1.0~(Firmware)
347
+ def get_chibi_address
348
+ send_request(FUNCTION_GET_CHIBI_ADDRESS, [], '', 1, 'C')
349
+ end
350
+
351
+ # Sets the address (1-255) of the Chibi Master. This address is used if the
352
+ # Chibi Extension is used as slave (i.e. it does not have a USB connection).
353
+ #
354
+ # It is possible to set the address with the Brick Viewer and it will be
355
+ # saved in the EEPROM of the Chibi Extension, it does not
356
+ # have to be set on every startup.
357
+ #
358
+ # .. versionadded:: 1.1.0~(Firmware)
359
+ def set_chibi_master_address(address)
360
+ send_request(FUNCTION_SET_CHIBI_MASTER_ADDRESS, [address], 'C', 0, '')
361
+ end
362
+
363
+ # Returns the address as set by BrickMaster#set_chibi_master_address.
364
+ #
365
+ # .. versionadded:: 1.1.0~(Firmware)
366
+ def get_chibi_master_address
367
+ send_request(FUNCTION_GET_CHIBI_MASTER_ADDRESS, [], '', 1, 'C')
368
+ end
369
+
370
+ # Sets up to 254 slave addresses. Valid addresses are in range 1-255. 0 has a
371
+ # special meaning, it is used as list terminator and not allowed as normal slave
372
+ # address. The address numeration (via num parameter) has to be used
373
+ # ascending from 0. For example: If you use the Chibi Extension in Master mode
374
+ # (i.e. the stack has an USB connection) and you want to talk to three other
375
+ # Chibi stacks with the slave addresses 17, 23, and 42, you should call with
376
+ # "(0, 17), (1, 23), (2, 42) and (3, 0)". The last call with "(3, 0)" is a list
377
+ # terminator and indicates that the Chibi slave address list contains 3 addresses
378
+ # in this case.
379
+ #
380
+ # It is possible to set the addresses with the Brick Viewer, that will take care
381
+ # of correct address numeration and list termination.
382
+ #
383
+ # The slave addresses will be saved in the EEPROM of the Chibi Extension, they
384
+ # don't have to be set on every startup.
385
+ #
386
+ # .. versionadded:: 1.1.0~(Firmware)
387
+ def set_chibi_slave_address(num, address)
388
+ send_request(FUNCTION_SET_CHIBI_SLAVE_ADDRESS, [num, address], 'C C', 0, '')
389
+ end
390
+
391
+ # Returns the slave address for a given num as set by
392
+ # BrickMaster#set_chibi_slave_address.
393
+ #
394
+ # .. versionadded:: 1.1.0~(Firmware)
395
+ def get_chibi_slave_address(num)
396
+ send_request(FUNCTION_GET_CHIBI_SLAVE_ADDRESS, [num], 'C', 1, 'C')
397
+ end
398
+
399
+ # Returns the signal strength in dBm. The signal strength updates every time a
400
+ # packet is received.
401
+ #
402
+ # .. versionadded:: 1.1.0~(Firmware)
403
+ def get_chibi_signal_strength
404
+ send_request(FUNCTION_GET_CHIBI_SIGNAL_STRENGTH, [], '', 1, 'C')
405
+ end
406
+
407
+ # Returns underrun, CRC error, no ACK and overflow error counts of the Chibi
408
+ # communication. If these errors start rising, it is likely that either the
409
+ # distance between two Chibi stacks is becoming too big or there are
410
+ # interferences.
411
+ #
412
+ # .. versionadded:: 1.1.0~(Firmware)
413
+ def get_chibi_error_log
414
+ send_request(FUNCTION_GET_CHIBI_ERROR_LOG, [], '', 8, 'S S S S')
415
+ end
416
+
417
+ # Sets the Chibi frequency range for the Chibi Extension. Possible values are:
418
+ #
419
+ # "Type", "Description"
420
+ #
421
+ # "0", "OQPSK 868MHz (Europe)"
422
+ # "1", "OQPSK 915MHz (US)"
423
+ # "2", "OQPSK 780MHz (China)"
424
+ # "3", "BPSK40 915MHz"
425
+ #
426
+ # It is possible to set the frequency with the Brick Viewer and it will be
427
+ # saved in the EEPROM of the Chibi Extension, it does not
428
+ # have to be set on every startup.
429
+ #
430
+ # .. versionadded:: 1.1.0~(Firmware)
431
+ def set_chibi_frequency(frequency)
432
+ send_request(FUNCTION_SET_CHIBI_FREQUENCY, [frequency], 'C', 0, '')
433
+ end
434
+
435
+ # Returns the frequency value as set by BrickMaster#set_chibi_frequency.
436
+ #
437
+ # .. versionadded:: 1.1.0~(Firmware)
438
+ def get_chibi_frequency
439
+ send_request(FUNCTION_GET_CHIBI_FREQUENCY, [], '', 1, 'C')
440
+ end
441
+
442
+ # Sets the channel used by the Chibi Extension. Possible channels are
443
+ # different for different frequencies:
444
+ #
445
+ # "Frequency", "Possible Channels"
446
+ #
447
+ # "OQPSK 868MHz (Europe)", "0"
448
+ # "OQPSK 915MHz (US)", "1, 2, 3, 4, 5, 6, 7, 8, 9, 10"
449
+ # "OQPSK 780MHz (China)", "0, 1, 2, 3"
450
+ # "BPSK40 915MHz", "1, 2, 3, 4, 5, 6, 7, 8, 9, 10"
451
+ #
452
+ # It is possible to set the channel with the Brick Viewer and it will be
453
+ # saved in the EEPROM of the Chibi Extension, it does not
454
+ # have to be set on every startup.
455
+ #
456
+ # .. versionadded:: 1.1.0~(Firmware)
457
+ def set_chibi_channel(channel)
458
+ send_request(FUNCTION_SET_CHIBI_CHANNEL, [channel], 'C', 0, '')
459
+ end
460
+
461
+ # Returns the channel as set by BrickMaster#set_chibi_channel.
462
+ #
463
+ # .. versionadded:: 1.1.0~(Firmware)
464
+ def get_chibi_channel
465
+ send_request(FUNCTION_GET_CHIBI_CHANNEL, [], '', 1, 'C')
466
+ end
467
+
468
+ # Returns *true* if a RS485 Extension is available to be used by the Master.
469
+ #
470
+ # .. versionadded:: 1.2.0~(Firmware)
471
+ def is_rs485_present
472
+ send_request(FUNCTION_IS_RS485_PRESENT, [], '', 1, '?')
473
+ end
474
+
475
+ # Sets the address (0-255) belonging to the RS485 Extension.
476
+ #
477
+ # Set to 0 if the RS485 Extension should be the RS485 Master (i.e.
478
+ # connected to a PC via USB).
479
+ #
480
+ # It is possible to set the address with the Brick Viewer and it will be
481
+ # saved in the EEPROM of the RS485 Extension, it does not
482
+ # have to be set on every startup.
483
+ #
484
+ # .. versionadded:: 1.2.0~(Firmware)
485
+ def set_rs485_address(address)
486
+ send_request(FUNCTION_SET_RS485_ADDRESS, [address], 'C', 0, '')
487
+ end
488
+
489
+ # Returns the address as set by BrickMaster#set_rs485_address.
490
+ #
491
+ # .. versionadded:: 1.2.0~(Firmware)
492
+ def get_rs485_address
493
+ send_request(FUNCTION_GET_RS485_ADDRESS, [], '', 1, 'C')
494
+ end
495
+
496
+ # Sets up to 255 slave addresses. Valid addresses are in range 1-255. 0 has a
497
+ # special meaning, it is used as list terminator and not allowed as normal slave
498
+ # address. The address numeration (via num parameter) has to be used
499
+ # ascending from 0. For example: If you use the RS485 Extension in Master mode
500
+ # (i.e. the stack has an USB connection) and you want to talk to three other
501
+ # RS485 stacks with the addresses 17, 23, and 42, you should call with "(0, 17),
502
+ # (1, 23), (2, 42) and (3, 0)". The last call with "(3, 0)" is a list terminator
503
+ # and indicates that the RS485 slave address list contains 3 addresses in this
504
+ # case.
505
+ #
506
+ # It is possible to set the addresses with the Brick Viewer, that will take care
507
+ # of correct address numeration and list termination.
508
+ #
509
+ # The slave addresses will be saved in the EEPROM of the Chibi Extension, they
510
+ # don't have to be set on every startup.
511
+ #
512
+ # .. versionadded:: 1.2.0~(Firmware)
513
+ def set_rs485_slave_address(num, address)
514
+ send_request(FUNCTION_SET_RS485_SLAVE_ADDRESS, [num, address], 'C C', 0, '')
515
+ end
516
+
517
+ # Returns the slave address for a given num as set by
518
+ # BrickMaster#set_rs485_slave_address.
519
+ #
520
+ # .. versionadded:: 1.2.0~(Firmware)
521
+ def get_rs485_slave_address(num)
522
+ send_request(FUNCTION_GET_RS485_SLAVE_ADDRESS, [num], 'C', 1, 'C')
523
+ end
524
+
525
+ # Returns CRC error counts of the RS485 communication.
526
+ # If this counter starts rising, it is likely that the distance
527
+ # between the RS485 nodes is too big or there is some kind of
528
+ # interference.
529
+ #
530
+ # .. versionadded:: 1.2.0~(Firmware)
531
+ def get_rs485_error_log
532
+ send_request(FUNCTION_GET_RS485_ERROR_LOG, [], '', 2, 'S')
533
+ end
534
+
535
+ # Sets the configuration of the RS485 Extension. Speed is given in baud. The
536
+ # Master Brick will try to match the given baud rate as exactly as possible.
537
+ # The maximum recommended baud rate is 2000000 (2Mbit/s).
538
+ # Possible values for parity are 'n' (none), 'e' (even) and 'o' (odd).
539
+ # Possible values for stop bits are 1 and 2.
540
+ #
541
+ # If your RS485 is unstable (lost messages etc.), the first thing you should
542
+ # try is to decrease the speed. On very large bus (e.g. 1km), you probably
543
+ # should use a value in the range of 100000 (100kbit/s).
544
+ #
545
+ # The values are stored in the EEPROM and only applied on startup. That means
546
+ # you have to restart the Master Brick after configuration.
547
+ #
548
+ # .. versionadded:: 1.2.0~(Firmware)
549
+ def set_rs485_configuration(speed, parity, stopbits)
550
+ send_request(FUNCTION_SET_RS485_CONFIGURATION, [speed, parity, stopbits], 'L k C', 0, '')
551
+ end
552
+
553
+ # Returns the configuration as set by BrickMaster#set_rs485_configuration.
554
+ #
555
+ # .. versionadded:: 1.2.0~(Firmware)
556
+ def get_rs485_configuration
557
+ send_request(FUNCTION_GET_RS485_CONFIGURATION, [], '', 6, 'L k C')
558
+ end
559
+
560
+ # Returns *true* if a WIFI Extension is available to be used by the Master.
561
+ #
562
+ # .. versionadded:: 1.2.0~(Firmware)
563
+ def is_wifi_present
564
+ send_request(FUNCTION_IS_WIFI_PRESENT, [], '', 1, '?')
565
+ end
566
+
567
+ # Sets the configuration of the WIFI Extension. The *ssid* can have a max length
568
+ # of 32 characters. Possible values for *connection* are:
569
+ #
570
+ # "Value", "Description"
571
+ #
572
+ # "0", "DHCP"
573
+ # "1", "Static IP"
574
+ # "2", "Access Point: DHCP"
575
+ # "3", "Access Point: Static IP"
576
+ # "4", "Ad Hoc: DHCP"
577
+ # "5", "Ad Hoc: Static IP"
578
+ #
579
+ # If you set *connection* to one of the static IP options then you have to supply
580
+ # *ip*, *subnet_mask* and *gateway* as an array of size 4 (first element of the
581
+ # array is the least significant byte of the address). If *connection* is set to
582
+ # one of the DHCP options then *ip*, *subnet_mask* and *gateway* are ignored, you
583
+ # can set them to 0.
584
+ #
585
+ # The last parameter is the port that your program will connect to. The
586
+ # default port, that is used by brickd, is 4223.
587
+ #
588
+ # The values are stored in the EEPROM and only applied on startup. That means
589
+ # you have to restart the Master Brick after configuration.
590
+ #
591
+ # It is recommended to use the Brick Viewer to set the WIFI configuration.
592
+ #
593
+ # .. versionadded:: 1.3.0~(Firmware)
594
+ def set_wifi_configuration(ssid, connection, ip, subnet_mask, gateway, port)
595
+ send_request(FUNCTION_SET_WIFI_CONFIGURATION, [ssid, connection, ip, subnet_mask, gateway, port], 'Z32 C C4 C4 C4 S', 0, '')
596
+ end
597
+
598
+ # Returns the configuration as set by BrickMaster#set_wifi_configuration.
599
+ #
600
+ # .. versionadded:: 1.3.0~(Firmware)
601
+ def get_wifi_configuration
602
+ send_request(FUNCTION_GET_WIFI_CONFIGURATION, [], '', 47, 'Z32 C C4 C4 C4 S')
603
+ end
604
+
605
+ # Sets the encryption of the WIFI Extension. The first parameter is the
606
+ # type of the encryption. Possible values are:
607
+ #
608
+ # "Value", "Description"
609
+ #
610
+ # "0", "WPA/WPA2"
611
+ # "1", "WPA Enterprise (EAP-FAST, EAP-TLS, EAP-TTLS, PEAP)"
612
+ # "2", "WEP"
613
+ # "3", "No Encryption"
614
+ #
615
+ # The key has a max length of 50 characters and is used if encryption
616
+ # is set to 0 or 2 (WPA/WPA2 or WEP). Otherwise the value is ignored.
617
+ #
618
+ # For WPA/WPA2 the key has to be at least 8 characters long. If you want to set
619
+ # a key with more than 50 characters, see BrickMaster#set_long_wifi_key.
620
+ #
621
+ # For WEP the key has to be either 10 or 26 hexadecimal digits long. It is
622
+ # possible to set the WEP key index (1-4). If you don't know your key index,
623
+ # it is likely 1.
624
+ #
625
+ # If you choose WPA Enterprise as encryption, you have to set eap options and
626
+ # the length of the certificates (for other encryption types these parameters
627
+ # are ignored). The certificate length are given in byte and the certificates
628
+ # themselves can be set with BrickMaster#set_wifi_certificate. Eap options consist of
629
+ # the outer authentication (bits 1-2), inner authentication (bit 3) and
630
+ # certificate type (bits 4-5):
631
+ #
632
+ # "Option", "Bits", "Description"
633
+ #
634
+ # "outer auth", "1-2", "0=EAP-FAST, 1=EAP-TLS, 2=EAP-TTLS, 3=EAP-PEAP"
635
+ # "inner auth", "3", "0=EAP-MSCHAP, 1=EAP-GTC"
636
+ # "cert type", "4-5", "0=CA Certificate, 1=Client Certificate, 2=Private Key"
637
+ #
638
+ # Example for EAP-TTLS + EAP-GTC + Private Key: option = 2 | (1 << 2) | (2 << 3).
639
+ #
640
+ # The values are stored in the EEPROM and only applied on startup. That means
641
+ # you have to restart the Master Brick after configuration.
642
+ #
643
+ # It is recommended to use the Brick Viewer to set the WIFI encryption.
644
+ #
645
+ # .. versionadded:: 1.3.0~(Firmware)
646
+ def set_wifi_encryption(encryption, key, key_index, eap_options, ca_certificate_length, client_certificate_length, private_key_length)
647
+ 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, '')
648
+ end
649
+
650
+ # Returns the encryption as set by BrickMaster#set_wifi_encryption.
651
+ #
652
+ # .. versionadded:: 1.3.0~(Firmware)
653
+ def get_wifi_encryption
654
+ send_request(FUNCTION_GET_WIFI_ENCRYPTION, [], '', 59, 'C Z50 C C S S S')
655
+ end
656
+
657
+ # Returns the status of the WIFI Extension. The state is updated automatically,
658
+ # all of the other parameters are updated on startup and every time
659
+ # BrickMaster#refresh_wifi_status is called.
660
+ #
661
+ # Possible states are:
662
+ #
663
+ # "State", "Description"
664
+ #
665
+ # "0", "Disassociated"
666
+ # "1", "Associated"
667
+ # "2", "Associating"
668
+ # "3", "Error"
669
+ # "255", "Not initialized yet"
670
+ #
671
+ # .. versionadded:: 1.3.0~(Firmware)
672
+ def get_wifi_status
673
+ send_request(FUNCTION_GET_WIFI_STATUS, [], '', 36, 'C6 C6 C s C4 C4 C4 L L C')
674
+ end
675
+
676
+ # Refreshes the WIFI status (see BrickMaster#get_wifi_status). To read the status
677
+ # of the WIFI module, the Master Brick has to change from data mode to
678
+ # command mode and back. This transaction and the readout itself is
679
+ # unfortunately time consuming. This means, that it might take some ms
680
+ # until the stack with attached WIFI Extensions reacts again after this
681
+ # function is called.
682
+ #
683
+ # .. versionadded:: 1.3.0~(Firmware)
684
+ def refresh_wifi_status
685
+ send_request(FUNCTION_REFRESH_WIFI_STATUS, [], '', 0, '')
686
+ end
687
+
688
+ # This function is used to set the certificate as well as password and username
689
+ # for WPA Enterprise. To set the username use index 0xFFFF,
690
+ # to set the password use index 0xFFFE. The max length of username and
691
+ # password is 32.
692
+ #
693
+ # The certificate is written in chunks of size 32 and the index is used as
694
+ # the index of the chunk. The data length should nearly always be 32. Only
695
+ # the last chunk can have a length that is not equal to 32.
696
+ #
697
+ # The starting index of the CA Certificate is 0, of the Client Certificate
698
+ # 10000 and for the Private Key 20000. Maximum sizes are 1312, 1312 and
699
+ # 4320 byte respectively.
700
+ #
701
+ # The values are stored in the EEPROM and only applied on startup. That means
702
+ # you have to restart the Master Brick after uploading the certificate.
703
+ #
704
+ # It is recommended to use the Brick Viewer to set the certificate, username
705
+ # and password.
706
+ #
707
+ # .. versionadded:: 1.3.0~(Firmware)
708
+ def set_wifi_certificate(index, data, data_length)
709
+ send_request(FUNCTION_SET_WIFI_CERTIFICATE, [index, data, data_length], 'S C32 C', 0, '')
710
+ end
711
+
712
+ # Returns the certificate for a given index as set by BrickMaster#set_wifi_certificate.
713
+ #
714
+ # .. versionadded:: 1.3.0~(Firmware)
715
+ def get_wifi_certificate(index)
716
+ send_request(FUNCTION_GET_WIFI_CERTIFICATE, [index], 'S', 33, 'C32 C')
717
+ end
718
+
719
+ # Sets the power mode of the WIFI Extension. Possible modes are:
720
+ #
721
+ # "Mode", "Description"
722
+ #
723
+ # "0", "Full Speed (high power consumption, high throughput)"
724
+ # "1", "Low Power (low power consumption, low throughput)"
725
+ #
726
+ # The default value is 0 (Full Speed).
727
+ #
728
+ # .. versionadded:: 1.3.0~(Firmware)
729
+ def set_wifi_power_mode(mode)
730
+ send_request(FUNCTION_SET_WIFI_POWER_MODE, [mode], 'C', 0, '')
731
+ end
732
+
733
+ # Returns the power mode as set by BrickMaster#set_wifi_power_mode.
734
+ #
735
+ # .. versionadded:: 1.3.0~(Firmware)
736
+ def get_wifi_power_mode
737
+ send_request(FUNCTION_GET_WIFI_POWER_MODE, [], '', 1, 'C')
738
+ end
739
+
740
+ # Returns informations about the WIFI receive buffer. The WIFI
741
+ # receive buffer has a max size of 1500 byte and if data is transfered
742
+ # too fast, it might overflow.
743
+ #
744
+ # The return values are the number of overflows, the low watermark
745
+ # (i.e. the smallest number of bytes that were free in the buffer) and
746
+ # the bytes that are currently used.
747
+ #
748
+ # You should always try to keep the buffer empty, otherwise you will
749
+ # have a permanent latency. A good rule of thumb is, that you can transfer
750
+ # 1000 messages per second without problems.
751
+ #
752
+ # Try to not send more then 50 messages at a time without any kind of
753
+ # break between them.
754
+ #
755
+ # .. versionadded:: 1.3.2~(Firmware)
756
+ def get_wifi_buffer_info
757
+ send_request(FUNCTION_GET_WIFI_BUFFER_INFO, [], '', 8, 'L S S')
758
+ end
759
+
760
+ # Sets the regulatory domain of the WIFI Extension. Possible domains are:
761
+ #
762
+ # "Domain", "Description"
763
+ #
764
+ # "0", "FCC: Channel 1-11 (N/S America, Australia, New Zealand)"
765
+ # "1", "ETSI: Channel 1-13 (Europe, Middle East, Africa)"
766
+ # "2", "TELEC: Channel 1-14 (Japan)"
767
+ #
768
+ # The default value is 1 (ETSI).
769
+ #
770
+ # .. versionadded:: 1.3.4~(Firmware)
771
+ def set_wifi_regulatory_domain(domain)
772
+ send_request(FUNCTION_SET_WIFI_REGULATORY_DOMAIN, [domain], 'C', 0, '')
773
+ end
774
+
775
+ # Returns the regulatory domain as set by BrickMaster#set_wifi_regulatory_domain.
776
+ #
777
+ # .. versionadded:: 1.3.4~(Firmware)
778
+ def get_wifi_regulatory_domain
779
+ send_request(FUNCTION_GET_WIFI_REGULATORY_DOMAIN, [], '', 1, 'C')
780
+ end
781
+
782
+ # Returns the USB voltage in mV.
783
+ #
784
+ # .. versionadded:: 1.3.5~(Firmware)
785
+ def get_usb_voltage
786
+ send_request(FUNCTION_GET_USB_VOLTAGE, [], '', 2, 'S')
787
+ end
788
+
789
+ # Sets a long WIFI key (up to 63 chars, at least 8 chars) for WPA encryption.
790
+ # This key will be used
791
+ # if the key in BrickMaster#set_wifi_encryption is set to "-". In the old protocol,
792
+ # a payload of size 63 was not possible, so the maximum key length was 50 chars.
793
+ #
794
+ # With the new protocol this is possible, since we didn't want to break API,
795
+ # this function was added additionally.
796
+ #
797
+ # .. versionadded:: 2.0.2~(Firmware)
798
+ def set_long_wifi_key(key)
799
+ send_request(FUNCTION_SET_LONG_WIFI_KEY, [key], 'Z64', 0, '')
800
+ end
801
+
802
+ # Returns the encryption key as set by BrickMaster#set_long_wifi_key.
803
+ #
804
+ # .. versionadded:: 2.0.2~(Firmware)
805
+ def get_long_wifi_key
806
+ send_request(FUNCTION_GET_LONG_WIFI_KEY, [], '', 64, 'Z64')
807
+ end
808
+
809
+ # Sets the hostname of the WIFI Extension. The hostname will be displayed
810
+ # by access points as the hostname in the DHCP clients table.
811
+ #
812
+ # Setting an empty String will restore the default hostname.
813
+ #
814
+ # .. versionadded:: 2.0.5~(Firmware)
815
+ def set_wifi_hostname(hostname)
816
+ send_request(FUNCTION_SET_WIFI_HOSTNAME, [hostname], 'Z16', 0, '')
817
+ end
818
+
819
+ # Returns the hostname as set by BrickMaster#get_wifi_hostname.
820
+ #
821
+ # An empty String means, that the default hostname is used.
822
+ #
823
+ # .. versionadded:: 2.0.5~(Firmware)
824
+ def get_wifi_hostname
825
+ send_request(FUNCTION_GET_WIFI_HOSTNAME, [], '', 16, 'Z16')
826
+ end
827
+
828
+ # Sets the period in ms with which the CALLBACK_STACK_CURRENT callback is triggered
829
+ # periodically. A value of 0 turns the callback off.
830
+ #
831
+ # CALLBACK_STACK_CURRENT is only triggered if the current has changed since the
832
+ # last triggering.
833
+ #
834
+ # The default value is 0.
835
+ #
836
+ # .. versionadded:: 2.0.5~(Firmware)
837
+ def set_stack_current_callback_period(period)
838
+ send_request(FUNCTION_SET_STACK_CURRENT_CALLBACK_PERIOD, [period], 'L', 0, '')
839
+ end
840
+
841
+ # Returns the period as set by :func:`SetCurrentCallbackPeriod`.
842
+ #
843
+ # .. versionadded:: 2.0.5~(Firmware)
844
+ def get_stack_current_callback_period
845
+ send_request(FUNCTION_GET_STACK_CURRENT_CALLBACK_PERIOD, [], '', 4, 'L')
846
+ end
847
+
848
+ # Sets the period in ms with which the CALLBACK_STACK_VOLTAGE callback is triggered
849
+ # periodically. A value of 0 turns the callback off.
850
+ #
851
+ # CALLBACK_STACK_VOLTAGE is only triggered if the voltage has changed since the
852
+ # last triggering.
853
+ #
854
+ # The default value is 0.
855
+ #
856
+ # .. versionadded:: 2.0.5~(Firmware)
857
+ def set_stack_voltage_callback_period(period)
858
+ send_request(FUNCTION_SET_STACK_VOLTAGE_CALLBACK_PERIOD, [period], 'L', 0, '')
859
+ end
860
+
861
+ # Returns the period as set by BrickMaster#set_stack_voltage_callback_period.
862
+ #
863
+ # .. versionadded:: 2.0.5~(Firmware)
864
+ def get_stack_voltage_callback_period
865
+ send_request(FUNCTION_GET_STACK_VOLTAGE_CALLBACK_PERIOD, [], '', 4, 'L')
866
+ end
867
+
868
+ # Sets the period in ms with which the CALLBACK_USB_VOLTAGE callback is triggered
869
+ # periodically. A value of 0 turns the callback off.
870
+ #
871
+ # CALLBACK_USB_VOLTAGE is only triggered if the voltage has changed since the
872
+ # last triggering.
873
+ #
874
+ # The default value is 0.
875
+ #
876
+ # .. versionadded:: 2.0.5~(Firmware)
877
+ def set_usb_voltage_callback_period(period)
878
+ send_request(FUNCTION_SET_USB_VOLTAGE_CALLBACK_PERIOD, [period], 'L', 0, '')
879
+ end
880
+
881
+ # Returns the period as set by BrickMaster#set_usb_voltage_callback_period.
882
+ #
883
+ # .. versionadded:: 2.0.5~(Firmware)
884
+ def get_usb_voltage_callback_period
885
+ send_request(FUNCTION_GET_USB_VOLTAGE_CALLBACK_PERIOD, [], '', 4, 'L')
886
+ end
887
+
888
+ # Sets the thresholds for the CALLBACK_STACK_CURRENT_REACHED callback.
889
+ #
890
+ # The following options are possible:
891
+ #
892
+ # "Option", "Description"
893
+ #
894
+ # "'x'", "Callback is turned off"
895
+ # "'o'", "Callback is triggered when the current is *outside* the min and max values"
896
+ # "'i'", "Callback is triggered when the current is *inside* the min and max values"
897
+ # "'<'", "Callback is triggered when the current is smaller than the min value (max is ignored)"
898
+ # "'>'", "Callback is triggered when the current is greater than the min value (max is ignored)"
899
+ #
900
+ # The default value is ('x', 0, 0).
901
+ #
902
+ # .. versionadded:: 2.0.5~(Firmware)
903
+ def set_stack_current_callback_threshold(option, min, max)
904
+ send_request(FUNCTION_SET_STACK_CURRENT_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, '')
905
+ end
906
+
907
+ # Returns the threshold as set by BrickMaster#set_stack_current_callback_threshold.
908
+ #
909
+ # .. versionadded:: 2.0.5~(Firmware)
910
+ def get_stack_current_callback_threshold
911
+ send_request(FUNCTION_GET_STACK_CURRENT_CALLBACK_THRESHOLD, [], '', 5, 'k S S')
912
+ end
913
+
914
+ # Sets the thresholds for the :func:`StackStackVoltageReached` callback.
915
+ #
916
+ # The following options are possible:
917
+ #
918
+ # "Option", "Description"
919
+ #
920
+ # "'x'", "Callback is turned off"
921
+ # "'o'", "Callback is triggered when the voltage is *outside* the min and max values"
922
+ # "'i'", "Callback is triggered when the voltage is *inside* the min and max values"
923
+ # "'<'", "Callback is triggered when the voltage is smaller than the min value (max is ignored)"
924
+ # "'>'", "Callback is triggered when the voltage is greater than the min value (max is ignored)"
925
+ #
926
+ # The default value is ('x', 0, 0).
927
+ #
928
+ # .. versionadded:: 2.0.5~(Firmware)
929
+ def set_stack_voltage_callback_threshold(option, min, max)
930
+ send_request(FUNCTION_SET_STACK_VOLTAGE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, '')
931
+ end
932
+
933
+ # Returns the threshold as set by BrickMaster#set_stack_voltage_callback_threshold.
934
+ #
935
+ # .. versionadded:: 2.0.5~(Firmware)
936
+ def get_stack_voltage_callback_threshold
937
+ send_request(FUNCTION_GET_STACK_VOLTAGE_CALLBACK_THRESHOLD, [], '', 5, 'k S S')
938
+ end
939
+
940
+ # Sets the thresholds for the CALLBACK_USB_VOLTAGE_REACHED callback.
941
+ #
942
+ # The following options are possible:
943
+ #
944
+ # "Option", "Description"
945
+ #
946
+ # "'x'", "Callback is turned off"
947
+ # "'o'", "Callback is triggered when the voltage is *outside* the min and max values"
948
+ # "'i'", "Callback is triggered when the voltage is *inside* the min and max values"
949
+ # "'<'", "Callback is triggered when the voltage is smaller than the min value (max is ignored)"
950
+ # "'>'", "Callback is triggered when the voltage is greater than the min value (max is ignored)"
951
+ #
952
+ # The default value is ('x', 0, 0).
953
+ #
954
+ # .. versionadded:: 2.0.5~(Firmware)
955
+ def set_usb_voltage_callback_threshold(option, min, max)
956
+ send_request(FUNCTION_SET_USB_VOLTAGE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, '')
957
+ end
958
+
959
+ # Returns the threshold as set by BrickMaster#set_usb_voltage_callback_threshold.
960
+ #
961
+ # .. versionadded:: 2.0.5~(Firmware)
962
+ def get_usb_voltage_callback_threshold
963
+ send_request(FUNCTION_GET_USB_VOLTAGE_CALLBACK_THRESHOLD, [], '', 5, 'k S S')
964
+ end
965
+
966
+ # Sets the period in ms with which the threshold callbacks
967
+ #
968
+ # CALLBACK_STACK_CURRENT_REACHED, CALLBACK_STACK_VOLTAGE_REACHED, CALLBACK_USB_VOLTAGE_REACHED
969
+ #
970
+ # are triggered, if the thresholds
971
+ #
972
+ # BrickMaster#set_stack_current_callback_threshold, BrickMaster#set_stack_voltage_callback_threshold, BrickMaster#set_usb_voltage_callback_threshold
973
+ #
974
+ # keep being reached.
975
+ #
976
+ # The default value is 100.
977
+ #
978
+ # .. versionadded:: 2.0.5~(Firmware)
979
+ def set_debounce_period(debounce)
980
+ send_request(FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, '')
981
+ end
982
+
983
+ # Returns the debounce period as set by BrickMaster#set_debounce_period.
984
+ #
985
+ # .. versionadded:: 2.0.5~(Firmware)
986
+ def get_debounce_period
987
+ send_request(FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L')
988
+ end
989
+
990
+ # Returns *true* if a Ethernet Extension is available to be used by the Master.
991
+ #
992
+ # .. versionadded:: 2.1.0~(Firmware)
993
+ def is_ethernet_present
994
+ send_request(FUNCTION_IS_ETHERNET_PRESENT, [], '', 1, '?')
995
+ end
996
+
997
+ # Sets the configuration of the WIFI Extension. Possible values for *connection* are:
998
+ #
999
+ # "Value", "Description"
1000
+ #
1001
+ # "0", "DHCP"
1002
+ # "1", "Static IP"
1003
+ #
1004
+ # If you set *connection* to static IP options then you have to supply
1005
+ # *ip*, *subnet_mask* and *gateway* as an array of size 4 (first element of the
1006
+ # array is the least significant byte of the address). If *connection* is set to
1007
+ # the DHCP options then *ip*, *subnet_mask* and *gateway* are ignored, you
1008
+ # can set them to 0.
1009
+ #
1010
+ # The last parameter is the port that your program will connect to. The
1011
+ # default port, that is used by brickd, is 4223.
1012
+ #
1013
+ # The values are stored in the EEPROM and only applied on startup. That means
1014
+ # you have to restart the Master Brick after configuration.
1015
+ #
1016
+ # It is recommended to use the Brick Viewer to set the Ethernet configuration.
1017
+ #
1018
+ # .. versionadded:: 2.1.0~(Firmware)
1019
+ def set_ethernet_configuration(connection, ip, subnet_mask, gateway, port)
1020
+ send_request(FUNCTION_SET_ETHERNET_CONFIGURATION, [connection, ip, subnet_mask, gateway, port], 'C C4 C4 C4 S', 0, '')
1021
+ end
1022
+
1023
+ # Returns the configuration as set by BrickMaster#set_ethernet_configuration.
1024
+ #
1025
+ # .. versionadded:: 2.1.0~(Firmware)
1026
+ def get_ethernet_configuration
1027
+ send_request(FUNCTION_GET_ETHERNET_CONFIGURATION, [], '', 15, 'C C4 C4 C4 S')
1028
+ end
1029
+
1030
+ # Returns the status of the Ethernet Extension.
1031
+ #
1032
+ # *mac_address*, *ip*, *subnet_mask* and *gateway* are given as an array
1033
+ # (first element of the array is the least significant byte of the address).
1034
+ #
1035
+ # *rx_count* and *tx_count* are the number of bytes that have been received/send
1036
+ # since last restart
1037
+ #
1038
+ # *hostname* is the currently used hostname.
1039
+ #
1040
+ # .. versionadded:: 2.1.0~(Firmware)
1041
+ def get_ethernet_status
1042
+ send_request(FUNCTION_GET_ETHERNET_STATUS, [], '', 58, 'C6 C4 C4 C4 L L Z32')
1043
+ end
1044
+
1045
+ # Sets the hostname of the Ethernet Extension. The hostname will be displayed
1046
+ # by access points as the hostname in the DHCP clients table.
1047
+ #
1048
+ # Setting an empty String will restore the default hostname.
1049
+ #
1050
+ # The current hostname can be discovered with BrickMaster#get_ethernet_status.
1051
+ #
1052
+ # .. versionadded:: 2.1.0~(Firmware)
1053
+ def set_ethernet_hostname(hostname)
1054
+ send_request(FUNCTION_SET_ETHERNET_HOSTNAME, [hostname], 'Z32', 0, '')
1055
+ end
1056
+
1057
+ # Sets the MAC address of the Ethernet Extension. The Ethernet Extension should
1058
+ # come configured with a valid MAC address, that is also written on a
1059
+ # sticker of the extension itself.
1060
+ #
1061
+ # The MAC address can be read out again with BrickMaster#get_ethernet_status.
1062
+ #
1063
+ # .. versionadded:: 2.1.0~(Firmware)
1064
+ def set_ethernet_mac_address(mac_address)
1065
+ send_request(FUNCTION_SET_ETHERNET_MAC_ADDRESS, [mac_address], 'C6', 0, '')
1066
+ end
1067
+
1068
+ # Returns the firmware and protocol version and the name of the Bricklet for a given port.
1069
+ #
1070
+ # This functions sole purpose is to allow automatic flashing of v1.x.y Bricklet plugins.
1071
+ #
1072
+ # .. versionadded:: 2.0.0~(Firmware)
1073
+ def get_protocol1_bricklet_name(port)
1074
+ send_request(FUNCTION_GET_PROTOCOL1_BRICKLET_NAME, [port], 'k', 44, 'C C3 Z40')
1075
+ end
1076
+
1077
+ # Returns the temperature in °C/10 as measured inside the microcontroller. The
1078
+ # value returned is not the ambient temperature!
1079
+ #
1080
+ # The temperature is only proportional to the real temperature and it has an
1081
+ # accuracy of +-15%. Practically it is only useful as an indicator for
1082
+ # temperature changes.
1083
+ #
1084
+ # .. versionadded:: 1.2.1~(Firmware)
1085
+ def get_chip_temperature
1086
+ send_request(FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's')
1087
+ end
1088
+
1089
+ # Calling this function will reset the Brick. Calling this function
1090
+ # on a Brick inside of a stack will reset the whole stack.
1091
+ #
1092
+ # After a reset you have to create new device objects,
1093
+ # calling functions on the existing ones will result in
1094
+ # undefined behavior!
1095
+ #
1096
+ # .. versionadded:: 1.2.1~(Firmware)
1097
+ def reset
1098
+ send_request(FUNCTION_RESET, [], '', 0, '')
1099
+ end
1100
+
1101
+ # Returns the UID, the UID where the Brick is connected to,
1102
+ # the position, the hardware and firmware version as well as the
1103
+ # device identifier.
1104
+ #
1105
+ # The position can be '0'-'8' (stack position).
1106
+ #
1107
+ # The device identifiers can be found :ref:`here <device_identifier>`.
1108
+ #
1109
+ # .. versionadded:: 2.0.0~(Firmware)
1110
+ def get_identity
1111
+ send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
1112
+ end
1113
+
1114
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
1115
+ def register_callback(id, &block)
1116
+ callback = block
1117
+ @registered_callbacks[id] = callback
1118
+ end
1119
+ end
1120
+ end