tinkerforge 2.1.1 → 2.1.2
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.
- data/lib/tinkerforge/brick_dc.rb +2 -2
- data/lib/tinkerforge/brick_imu.rb +2 -2
- data/lib/tinkerforge/brick_master.rb +2 -2
- data/lib/tinkerforge/brick_servo.rb +2 -2
- data/lib/tinkerforge/brick_stepper.rb +2 -2
- data/lib/tinkerforge/bricklet_ambient_light.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_in.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_out.rb +2 -2
- data/lib/tinkerforge/bricklet_barometer.rb +2 -2
- data/lib/tinkerforge/bricklet_color.rb +325 -0
- data/lib/tinkerforge/bricklet_current12.rb +2 -2
- data/lib/tinkerforge/bricklet_current25.rb +2 -2
- data/lib/tinkerforge/bricklet_distance_ir.rb +2 -2
- data/lib/tinkerforge/bricklet_distance_us.rb +2 -2
- data/lib/tinkerforge/bricklet_dual_button.rb +2 -2
- data/lib/tinkerforge/bricklet_dual_relay.rb +2 -2
- data/lib/tinkerforge/bricklet_gps.rb +2 -2
- data/lib/tinkerforge/bricklet_hall_effect.rb +2 -2
- data/lib/tinkerforge/bricklet_humidity.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +2 -2
- data/lib/tinkerforge/bricklet_io16.rb +4 -2
- data/lib/tinkerforge/bricklet_io4.rb +4 -2
- data/lib/tinkerforge/bricklet_joystick.rb +2 -2
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +2 -2
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +2 -2
- data/lib/tinkerforge/bricklet_led_strip.rb +2 -2
- data/lib/tinkerforge/bricklet_line.rb +2 -2
- data/lib/tinkerforge/bricklet_linear_poti.rb +2 -2
- data/lib/tinkerforge/bricklet_moisture.rb +2 -2
- data/lib/tinkerforge/bricklet_motion_detector.rb +2 -2
- data/lib/tinkerforge/bricklet_multi_touch.rb +2 -2
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +222 -0
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +2 -2
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +2 -2
- data/lib/tinkerforge/bricklet_ptc.rb +2 -2
- data/lib/tinkerforge/bricklet_remote_switch.rb +2 -2
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +2 -2
- data/lib/tinkerforge/bricklet_rotary_poti.rb +2 -2
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +2 -2
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +103 -0
- data/lib/tinkerforge/bricklet_sound_intensity.rb +2 -2
- data/lib/tinkerforge/bricklet_temperature.rb +2 -2
- data/lib/tinkerforge/bricklet_temperature_ir.rb +2 -2
- data/lib/tinkerforge/bricklet_tilt.rb +2 -2
- data/lib/tinkerforge/bricklet_voltage.rb +2 -2
- data/lib/tinkerforge/bricklet_voltage_current.rb +2 -2
- data/lib/tinkerforge/version.rb +1 -1
- metadata +6 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
|
2
|
+
#############################################################
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
|
+
# #
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
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 that can read and write NFC and RFID tags
|
|
14
|
+
class BrickletNFCRFID < Device
|
|
15
|
+
DEVICE_IDENTIFIER = 246 # :nodoc:
|
|
16
|
+
|
|
17
|
+
# This callback is called if the state of the NFC/RFID Bricklet changes.
|
|
18
|
+
# See BrickletNFCRFID#get_state for more information about the possible states.
|
|
19
|
+
CALLBACK_STATE_CHANGED = 8
|
|
20
|
+
|
|
21
|
+
FUNCTION_REQUEST_TAG_ID = 1 # :nodoc:
|
|
22
|
+
FUNCTION_GET_TAG_ID = 2 # :nodoc:
|
|
23
|
+
FUNCTION_GET_STATE = 3 # :nodoc:
|
|
24
|
+
FUNCTION_AUTHENTICATE_MIFARE_CLASSIC_PAGE = 4 # :nodoc:
|
|
25
|
+
FUNCTION_WRITE_PAGE = 5 # :nodoc:
|
|
26
|
+
FUNCTION_REQUEST_PAGE = 6 # :nodoc:
|
|
27
|
+
FUNCTION_GET_PAGE = 7 # :nodoc:
|
|
28
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
29
|
+
|
|
30
|
+
TAG_TYPE_MIFARE_CLASSIC = 0 # :nodoc:
|
|
31
|
+
TAG_TYPE_TYPE1 = 1 # :nodoc:
|
|
32
|
+
TAG_TYPE_TYPE2 = 2 # :nodoc:
|
|
33
|
+
STATE_INITIALIZATION = 0 # :nodoc:
|
|
34
|
+
STATE_IDLE = 128 # :nodoc:
|
|
35
|
+
STATE_ERROR = 192 # :nodoc:
|
|
36
|
+
STATE_REQUEST_TAG_ID = 2 # :nodoc:
|
|
37
|
+
STATE_REQUEST_TAG_ID_READY = 130 # :nodoc:
|
|
38
|
+
STATE_REQUEST_TAG_ID_ERROR = 194 # :nodoc:
|
|
39
|
+
STATE_AUTHENTICATING_MIFARE_CLASSIC_PAGE = 3 # :nodoc:
|
|
40
|
+
STATE_AUTHENTICATING_MIFARE_CLASSIC_PAGE_READY = 131 # :nodoc:
|
|
41
|
+
STATE_AUTHENTICATING_MIFARE_CLASSIC_PAGE_ERROR = 195 # :nodoc:
|
|
42
|
+
STATE_WRITE_PAGE = 4 # :nodoc:
|
|
43
|
+
STATE_WRITE_PAGE_READY = 132 # :nodoc:
|
|
44
|
+
STATE_WRITE_PAGE_ERROR = 196 # :nodoc:
|
|
45
|
+
STATE_REQUEST_PAGE = 5 # :nodoc:
|
|
46
|
+
STATE_REQUEST_PAGE_READY = 133 # :nodoc:
|
|
47
|
+
STATE_REQUEST_PAGE_ERROR = 197 # :nodoc:
|
|
48
|
+
KEY_A = 0 # :nodoc:
|
|
49
|
+
KEY_B = 1 # :nodoc:
|
|
50
|
+
|
|
51
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
52
|
+
# the IP Connection <tt>ipcon</tt>.
|
|
53
|
+
def initialize(uid, ipcon)
|
|
54
|
+
super uid, ipcon
|
|
55
|
+
|
|
56
|
+
@api_version = [2, 0, 0]
|
|
57
|
+
|
|
58
|
+
@response_expected[FUNCTION_REQUEST_TAG_ID] = RESPONSE_EXPECTED_FALSE
|
|
59
|
+
@response_expected[FUNCTION_GET_TAG_ID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
60
|
+
@response_expected[FUNCTION_GET_STATE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
61
|
+
@response_expected[FUNCTION_AUTHENTICATE_MIFARE_CLASSIC_PAGE] = RESPONSE_EXPECTED_FALSE
|
|
62
|
+
@response_expected[FUNCTION_WRITE_PAGE] = RESPONSE_EXPECTED_FALSE
|
|
63
|
+
@response_expected[FUNCTION_REQUEST_PAGE] = RESPONSE_EXPECTED_FALSE
|
|
64
|
+
@response_expected[FUNCTION_GET_PAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
65
|
+
@response_expected[CALLBACK_STATE_CHANGED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
|
66
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
67
|
+
|
|
68
|
+
@callback_formats[CALLBACK_STATE_CHANGED] = 'C ?'
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# To read or write a tag that is in proximity of the NFC/RFID Bricklet you
|
|
72
|
+
# first have to call this function with the expected tag type as parameter.
|
|
73
|
+
# It is no problem if you don't know the tag type. You can cycle through
|
|
74
|
+
# the available tag types until the tag gives an answer to the request.
|
|
75
|
+
#
|
|
76
|
+
# Current the following tag types are supported:
|
|
77
|
+
#
|
|
78
|
+
# * Mifare Classic
|
|
79
|
+
# * NFC Forum Type 1
|
|
80
|
+
# * NFC Forum Type 2
|
|
81
|
+
#
|
|
82
|
+
# After you call BrickletNFCRFID#request_tag_id the NFC/RFID Bricklet will try to read
|
|
83
|
+
# the tag ID from the tag. After this process is done the state will change.
|
|
84
|
+
# You can either register the CALLBACK_STATE_CHANGED callback or you can poll
|
|
85
|
+
# BrickletNFCRFID#get_state to find out about the state change.
|
|
86
|
+
#
|
|
87
|
+
# If the state changes to *RequestTagIDError* it means that either there was
|
|
88
|
+
# no tag present or that the tag is of an incompatible type. If the state
|
|
89
|
+
# changes to *RequestTagIDReady* it means that a compatible tag was found
|
|
90
|
+
# and that the tag ID could be read out. You can now get the tag ID by
|
|
91
|
+
# calling BrickletNFCRFID#get_tag_id.
|
|
92
|
+
#
|
|
93
|
+
# If two tags are in the proximity of the NFC/RFID Bricklet, this
|
|
94
|
+
# function will cycle through the tags. To select a specific tag you have
|
|
95
|
+
# to call BrickletNFCRFID#request_tag_id until the correct tag id is found.
|
|
96
|
+
#
|
|
97
|
+
# In case of any *Error* state the selection is lost and you have to
|
|
98
|
+
# start again by calling BrickletNFCRFID#request_tag_id.
|
|
99
|
+
def request_tag_id(tag_type)
|
|
100
|
+
send_request(FUNCTION_REQUEST_TAG_ID, [tag_type], 'C', 0, '')
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Returns the tag type, tag ID and the length of the tag ID
|
|
104
|
+
# (4 or 7 bytes are possible length). This function can only be called if the
|
|
105
|
+
# NFC/RFID is currently in one of the *Ready* states. The returned ID
|
|
106
|
+
# is the ID that was saved through the last call of BrickletNFCRFID#request_tag_id.
|
|
107
|
+
#
|
|
108
|
+
# To get the tag ID of a tag the approach is as follows:
|
|
109
|
+
#
|
|
110
|
+
# * Call BrickletNFCRFID#request_tag_id
|
|
111
|
+
# * Wait for state to change to *RequestTagIDReady* (see BrickletNFCRFID#get_state or CALLBACK_STATE_CHANGED)
|
|
112
|
+
# * Call BrickletNFCRFID#get_tag_id
|
|
113
|
+
def get_tag_id
|
|
114
|
+
send_request(FUNCTION_GET_TAG_ID, [], '', 9, 'C C C7')
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Returns the current state of the NFC/RFID Bricklet.
|
|
118
|
+
#
|
|
119
|
+
# On startup the Bricklet will be in the *Initialization* state. The initialization
|
|
120
|
+
# will only take about 20ms. After that it changes to *Idle*.
|
|
121
|
+
#
|
|
122
|
+
# The functions of this Bricklet can be called in the *Idle* state and all of
|
|
123
|
+
# the *Ready* and *Error* states.
|
|
124
|
+
#
|
|
125
|
+
# Example: If you call BrickletNFCRFID#request_page, the state will change to
|
|
126
|
+
# *RequestPage* until the reading of the page is finished. Then it will change
|
|
127
|
+
# to either *RequestPageReady* if it worked or to *RequestPageError* if it
|
|
128
|
+
# didn't. If the request worked you can get the page by calling BrickletNFCRFID#get_page.
|
|
129
|
+
#
|
|
130
|
+
# The same approach is used analogously for the other API functions.
|
|
131
|
+
def get_state
|
|
132
|
+
send_request(FUNCTION_GET_STATE, [], '', 2, 'C ?')
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Mifare Classic tags use authentication. If you want to read from or write to
|
|
136
|
+
# a Mifare Classic page you have to authenticate it beforehand.
|
|
137
|
+
# Each page can be authenticated with two keys (A and B). A new Mifare Classic
|
|
138
|
+
# tag that has not yet been written to can can be accessed with key number A
|
|
139
|
+
# and the default key *[0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]*.
|
|
140
|
+
#
|
|
141
|
+
# The approach to read or write a Mifare Classic page is as follows:
|
|
142
|
+
#
|
|
143
|
+
# * Call BrickletNFCRFID#request_tag_id
|
|
144
|
+
# * Wait for state to change to *RequestTagIDReady* (see BrickletNFCRFID#get_state or CALLBACK_STATE_CHANGED)
|
|
145
|
+
# * Call BrickletNFCRFID#get_tag_id and check if tag ID is correct
|
|
146
|
+
# * Call BrickletNFCRFID#authenticate_mifare_classic_page with page and key for the page
|
|
147
|
+
# * Wait for state to change to *AuthenticatingMifareClassicPageReady*
|
|
148
|
+
# * Call BrickletNFCRFID#request_page or :func`WritePage` to read/write page
|
|
149
|
+
def authenticate_mifare_classic_page(page, key_number, key)
|
|
150
|
+
send_request(FUNCTION_AUTHENTICATE_MIFARE_CLASSIC_PAGE, [page, key_number, key], 'S C C6', 0, '')
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Writes 16 bytes starting from the given page. How many pages are written
|
|
154
|
+
# depends on the tag type. The page sizes are as follows:
|
|
155
|
+
#
|
|
156
|
+
# * Mifare Classic page size: 16 byte (1 page is written)
|
|
157
|
+
# * NFC Forum Type 1 page size: 8 byte (2 pages are written)
|
|
158
|
+
# * NFC Forum Type 2 page size: 4 byte (4 pages are written)
|
|
159
|
+
#
|
|
160
|
+
# The general approach for writing to a tag is as follows:
|
|
161
|
+
#
|
|
162
|
+
# * Call BrickletNFCRFID#request_tag_id
|
|
163
|
+
# * Wait for state to change to *RequestTagIDReady* (see BrickletNFCRFID#get_state or CALLBACK_STATE_CHANGED)
|
|
164
|
+
# * Call BrickletNFCRFID#get_tag_id and check if tag ID is correct
|
|
165
|
+
# * Call BrickletNFCRFID#write_page with page number and data
|
|
166
|
+
# * Wait for state to change to *WritePageReady*
|
|
167
|
+
#
|
|
168
|
+
# If you use a Mifare Classic tag you have to authenticate a page before you
|
|
169
|
+
# can write to it. See BrickletNFCRFID#authenticate_mifare_classic_page.
|
|
170
|
+
def write_page(page, data)
|
|
171
|
+
send_request(FUNCTION_WRITE_PAGE, [page, data], 'S C16', 0, '')
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Reads 16 bytes starting from the given page and stores them into a buffer.
|
|
175
|
+
# The buffer can then be read out with BrickletNFCRFID#get_page.
|
|
176
|
+
# How many pages are read depends on the tag type. The page sizes are
|
|
177
|
+
# as follows:
|
|
178
|
+
#
|
|
179
|
+
# * Mifare Classic page size: 16 byte (one page is read)
|
|
180
|
+
# * NFC Forum Type 1 page size: 8 byte (two pages are read)
|
|
181
|
+
# * NFC Forum Type 2 page size: 4 byte (four pages are read)
|
|
182
|
+
#
|
|
183
|
+
# The general approach for reading a tag is as follows:
|
|
184
|
+
#
|
|
185
|
+
# * Call BrickletNFCRFID#request_tag_id
|
|
186
|
+
# * Wait for state to change to *RequestTagIDReady* (see BrickletNFCRFID#get_state or CALLBACK_STATE_CHANGED)
|
|
187
|
+
# * Call BrickletNFCRFID#get_tag_id and check if tag ID is correct
|
|
188
|
+
# * Call BrickletNFCRFID#request_page with page number
|
|
189
|
+
# * Wait for state to change to *RequestPageReady*
|
|
190
|
+
# * Call BrickletNFCRFID#get_page to retrieve the page from the buffer
|
|
191
|
+
#
|
|
192
|
+
# If you use a Mifare Classic tag you have to authenticate a page before you
|
|
193
|
+
# can read it. See BrickletNFCRFID#authenticate_mifare_classic_page.
|
|
194
|
+
def request_page(page)
|
|
195
|
+
send_request(FUNCTION_REQUEST_PAGE, [page], 'S', 0, '')
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# Returns 16 bytes of data from an internal buffer. To fill the buffer
|
|
199
|
+
# with specific pages you have to call BrickletNFCRFID#request_page beforehand.
|
|
200
|
+
def get_page
|
|
201
|
+
send_request(FUNCTION_GET_PAGE, [], '', 16, 'C16')
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
|
205
|
+
# the position, the hardware and firmware version as well as the
|
|
206
|
+
# device identifier.
|
|
207
|
+
#
|
|
208
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
|
209
|
+
#
|
|
210
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
211
|
+
# |device_identifier_constant|
|
|
212
|
+
def get_identity
|
|
213
|
+
send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
217
|
+
def register_callback(id, &block)
|
|
218
|
+
callback = block
|
|
219
|
+
@registered_callbacks[id] = callback
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
|
2
|
+
#############################################################
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
|
+
# #
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
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 AC and DC Solid State Relays
|
|
14
|
+
class BrickletSolidStateRelay < Device
|
|
15
|
+
DEVICE_IDENTIFIER = 244 # :nodoc:
|
|
16
|
+
|
|
17
|
+
# This callback is triggered whenever the monoflop timer reaches 0.
|
|
18
|
+
# The parameter is the current state of the relay
|
|
19
|
+
# (the state after the monoflop).
|
|
20
|
+
CALLBACK_MONOFLOP_DONE = 5
|
|
21
|
+
|
|
22
|
+
FUNCTION_SET_STATE = 1 # :nodoc:
|
|
23
|
+
FUNCTION_GET_STATE = 2 # :nodoc:
|
|
24
|
+
FUNCTION_SET_MONOFLOP = 3 # :nodoc:
|
|
25
|
+
FUNCTION_GET_MONOFLOP = 4 # :nodoc:
|
|
26
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
30
|
+
# the IP Connection <tt>ipcon</tt>.
|
|
31
|
+
def initialize(uid, ipcon)
|
|
32
|
+
super uid, ipcon
|
|
33
|
+
|
|
34
|
+
@api_version = [2, 0, 0]
|
|
35
|
+
|
|
36
|
+
@response_expected[FUNCTION_SET_STATE] = RESPONSE_EXPECTED_FALSE
|
|
37
|
+
@response_expected[FUNCTION_GET_STATE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
38
|
+
@response_expected[FUNCTION_SET_MONOFLOP] = RESPONSE_EXPECTED_FALSE
|
|
39
|
+
@response_expected[FUNCTION_GET_MONOFLOP] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
40
|
+
@response_expected[CALLBACK_MONOFLOP_DONE] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
|
41
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
42
|
+
|
|
43
|
+
@callback_formats[CALLBACK_MONOFLOP_DONE] = '?'
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Sets the state of the relays *true* means on and *false* means off.
|
|
47
|
+
#
|
|
48
|
+
# Running monoflop timers will be overwritten if this function is called.
|
|
49
|
+
#
|
|
50
|
+
# The default value is *false*.
|
|
51
|
+
def set_state(state)
|
|
52
|
+
send_request(FUNCTION_SET_STATE, [state], '?', 0, '')
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Returns the state of the relay, *true* means on and *false* means off.
|
|
56
|
+
def get_state
|
|
57
|
+
send_request(FUNCTION_GET_STATE, [], '', 1, '?')
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# The first parameter is the desired state of the relay (*true* means on
|
|
61
|
+
# and *false* means off). The second parameter indicates the time (in ms) that
|
|
62
|
+
# the relay should hold the state.
|
|
63
|
+
#
|
|
64
|
+
# If this function is called with the parameters (true, 1500):
|
|
65
|
+
# The relay will turn on and in 1.5s it will turn off again.
|
|
66
|
+
#
|
|
67
|
+
# A monoflop can be used as a failsafe mechanism. For example: Lets assume you
|
|
68
|
+
# have a RS485 bus and a Solid State Relay Bricklet connected to one of the slave
|
|
69
|
+
# stacks. You can now call this function every second, with a time parameter
|
|
70
|
+
# of two seconds. The relay will be on all the time. If now the RS485
|
|
71
|
+
# connection is lost, the relay will turn off in at most two seconds.
|
|
72
|
+
def set_monoflop(state, time)
|
|
73
|
+
send_request(FUNCTION_SET_MONOFLOP, [state, time], '? L', 0, '')
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Returns the current state and the time as set by
|
|
77
|
+
# BrickletSolidStateRelay#set_monoflop as well as the remaining time until the state flips.
|
|
78
|
+
#
|
|
79
|
+
# If the timer is not running currently, the remaining time will be returned
|
|
80
|
+
# as 0.
|
|
81
|
+
def get_monoflop
|
|
82
|
+
send_request(FUNCTION_GET_MONOFLOP, [], '', 9, '? L L')
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
|
86
|
+
# the position, the hardware and firmware version as well as the
|
|
87
|
+
# device identifier.
|
|
88
|
+
#
|
|
89
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
|
90
|
+
#
|
|
91
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
92
|
+
# |device_identifier_constant|
|
|
93
|
+
def get_identity
|
|
94
|
+
send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
98
|
+
def register_callback(id, &block)
|
|
99
|
+
callback = block
|
|
100
|
+
@registered_callbacks[id] = callback
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2014-
|
|
3
|
+
# This file was automatically generated on 2014-08-11. #
|
|
4
4
|
# #
|
|
5
|
-
# Bindings Version 2.1.
|
|
5
|
+
# Bindings Version 2.1.2 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
data/lib/tinkerforge/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tinkerforge
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.1.
|
|
4
|
+
version: 2.1.2
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2014-
|
|
12
|
+
date: 2014-08-11 00:00:00.000000000 Z
|
|
13
13
|
dependencies: []
|
|
14
14
|
description:
|
|
15
15
|
email: matthias@tinkerforge.com
|
|
@@ -22,6 +22,7 @@ files:
|
|
|
22
22
|
- lib/tinkerforge/bricklet_gps.rb
|
|
23
23
|
- lib/tinkerforge/bricklet_industrial_digital_out_4.rb
|
|
24
24
|
- lib/tinkerforge/bricklet_temperature.rb
|
|
25
|
+
- lib/tinkerforge/bricklet_solid_state_relay.rb
|
|
25
26
|
- lib/tinkerforge/bricklet_current25.rb
|
|
26
27
|
- lib/tinkerforge/bricklet_piezo_speaker.rb
|
|
27
28
|
- lib/tinkerforge/bricklet_rotary_encoder.rb
|
|
@@ -42,8 +43,10 @@ files:
|
|
|
42
43
|
- lib/tinkerforge/bricklet_motion_detector.rb
|
|
43
44
|
- lib/tinkerforge/bricklet_line.rb
|
|
44
45
|
- lib/tinkerforge/bricklet_joystick.rb
|
|
46
|
+
- lib/tinkerforge/bricklet_nfc_rfid.rb
|
|
45
47
|
- lib/tinkerforge/ip_connection.rb
|
|
46
48
|
- lib/tinkerforge/bricklet_lcd_16x2.rb
|
|
49
|
+
- lib/tinkerforge/bricklet_color.rb
|
|
47
50
|
- lib/tinkerforge/bricklet_dual_relay.rb
|
|
48
51
|
- lib/tinkerforge/bricklet_remote_switch.rb
|
|
49
52
|
- lib/tinkerforge/bricklet_sound_intensity.rb
|
|
@@ -68,7 +71,7 @@ files:
|
|
|
68
71
|
- lib/tinkerforge/bricklet_barometer.rb
|
|
69
72
|
homepage: http://www.tinkerforge.com/
|
|
70
73
|
licenses:
|
|
71
|
-
-
|
|
74
|
+
- CC0-1.0
|
|
72
75
|
post_install_message:
|
|
73
76
|
rdoc_options:
|
|
74
77
|
- --title
|