scan_beacon 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/scan_beacon/ble112_device.rb +34 -8
- data/lib/scan_beacon/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2854fb487434f83d2e24c5d9928d38f1da8c5159
|
4
|
+
data.tar.gz: 6e731cc3982883356caa1c8b87d94d8e7440c40b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74f7cb551de59d34214f478a6af5308b442910894360ce3abfd4a997c2b71f34a5d7009fce3b8c9dc3bd3979f1dc3b13166365852debf15960af43bb3bdb07b1
|
7
|
+
data.tar.gz: 6d5ddf2c696194f18daff43b165e3658995e4591c01859984a6cd8b16b01a5736098e60ecdf96e84c88fe520d9b2c7d7c93573dc9a172a16fd42a00bf5afb0e1
|
@@ -28,14 +28,8 @@ module ScanBeacon
|
|
28
28
|
BG_GAP_CONNECTABLE = 2
|
29
29
|
|
30
30
|
def self.find_all
|
31
|
-
|
32
|
-
|
33
|
-
devices.map {|device_path|
|
34
|
-
Thread.new { self.new(device_path).reset }
|
35
|
-
}.each(&:join)
|
36
|
-
# reset causes devices to reattach, possibly at different path
|
37
|
-
devices = Dir.glob("/dev/{cu.usbmodem,ttyACM}*")
|
38
|
-
devices.select {|device_path|
|
31
|
+
self.reset_all
|
32
|
+
possible_devices.select {|device_path|
|
39
33
|
device = self.new(device_path)
|
40
34
|
device.open{ device.get_addr } != nil
|
41
35
|
}
|
@@ -134,6 +128,38 @@ module ScanBeacon
|
|
134
128
|
sleep 1
|
135
129
|
end
|
136
130
|
|
131
|
+
def self.possible_devices
|
132
|
+
Dir.glob("/dev/{cu.usbmodem,ttyACM}*")
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.reset_all
|
136
|
+
# try to reset all the devices
|
137
|
+
device_count = possible_devices.count
|
138
|
+
possible_devices.each do |device_path|
|
139
|
+
File.open(device_path, 'r+b') do |file|
|
140
|
+
file.write([BG_COMMAND, 1, BG_MSG_CLASS_SYSTEM, BG_RESET, 0].pack('C*'))
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
# wait for them to show up again, but only wait for up to 5 secs
|
145
|
+
sleep 0.1
|
146
|
+
wait_count = 0
|
147
|
+
while possible_devices.count < device_count && wait_count < 50
|
148
|
+
sleep 0.1
|
149
|
+
wait_count += 1
|
150
|
+
end
|
151
|
+
|
152
|
+
# try to open them - if we get a busy, wait and try again
|
153
|
+
possible_devices.each do |device_path|
|
154
|
+
begin
|
155
|
+
File.open(device_path, 'r+b') {|f| f.close }
|
156
|
+
rescue Errno::EBUSY
|
157
|
+
sleep 0.1
|
158
|
+
retry
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
137
163
|
class BLE112Response
|
138
164
|
def initialize(data)
|
139
165
|
data ||= ""
|
data/lib/scan_beacon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scan_beacon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Radius Networks
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|