scan_beacon 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ae0be9271595f436430f8494d6f0cb9710e8083
4
- data.tar.gz: 7afac292c5b16a158134c0461ca483a07e506b3a
3
+ metadata.gz: b97500f1a0b47564be46701c0aa5ae7551ea802f
4
+ data.tar.gz: 04e4b224e01a2d30b7af811cd6f378486107ab46
5
5
  SHA512:
6
- metadata.gz: bf44f28c567d9c4c221802aa4fa98b3fbcd00f0459faf60b4a8cb662107de7a84f1e2f9ef59ade343efed26edc1328976e046bf11ad0ba00b3a602c9b8562199
7
- data.tar.gz: 791bd526ce8efaddf2b5085317e5d88024cadf2d676f4bfd61c30965bc01caa2d31d1417cb851200ddfea31cb460844bf3dcef7f74f966d37e55f50d3505eb84
6
+ metadata.gz: cf657f7dffc86477efcca6d8821c5386d0d49cd80e023a8e6e41c158f7df32b85dcedc767d2d8558e3b48818d201faaad2a34edeb2ce482897c133f7f37e6214
7
+ data.tar.gz: 1134b3f84873408a7ade2bef1b1b95b326ace6007fa72260407cf0c2a7150c127a6adce11be953d78080035d0a97ea408e2d67a01396c3167eec62d5b7413954
data/.gitignore CHANGED
@@ -3,3 +3,6 @@ yell.rb
3
3
  yeller.rb
4
4
  .DS_Store
5
5
  pkg/
6
+
7
+ # Since this is a gem not an app, ignore the lock file
8
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+
2
+ source "http://www.rubygems.org"
3
+
4
+ gemspec
@@ -5,9 +5,11 @@ module ScanBeacon
5
5
  BG_COMMAND = 0
6
6
  BG_EVENT = 0x80
7
7
  # msg classes
8
+ BG_MSG_CLASS_SYSTEM = 0
8
9
  BG_MSG_CLASS_CONNECTION = 3
9
10
  BG_MSG_CLASS_GAP = 6
10
11
  # messages
12
+ BG_RESET = 0
11
13
  BG_DISCONNECT = 0
12
14
  BG_SET_MODE = 1
13
15
  BG_DISCOVER = 2
@@ -23,6 +25,7 @@ module ScanBeacon
23
25
  end
24
26
 
25
27
  def open
28
+ configure_port
26
29
  File.open(@port, 'r+b') do |file|
27
30
  @file = file
28
31
  yield self
@@ -30,6 +33,12 @@ module ScanBeacon
30
33
  @file = nil
31
34
  end
32
35
 
36
+ def configure_port
37
+ if RUBY_PLATFORM =~ /linux/
38
+ system("stty -F #{@port} 115200 -brkint -icrnl -imaxbel -opost -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke;min=0")
39
+ end
40
+ end
41
+
33
42
  def start_scan
34
43
  # disconnect any connections
35
44
  bg_command(@file, BG_MSG_CLASS_CONNECTION, BG_DISCONNECT,0)
@@ -51,6 +60,15 @@ module ScanBeacon
51
60
  BLE112Response.new( bg_read(@file) )
52
61
  end
53
62
 
63
+ def reset
64
+ open do
65
+ @file.write([BG_COMMAND, 1, BG_MSG_CLASS_SYSTEM, BG_RESET, 0].pack('C*'))
66
+ end
67
+ # give time for the device to reboot.
68
+ # TODO: figure out a way that doesn't involve sleeping arbitrarily.
69
+ sleep 1
70
+ end
71
+
54
72
  class BLE112Response
55
73
  def initialize(data)
56
74
  @data = data
@@ -1,3 +1,3 @@
1
1
  module ScanBeacon
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
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.2.0
4
+ version: 0.3.0
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-06-23 00:00:00.000000000 Z
11
+ date: 2015-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -60,6 +60,7 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
+ - Gemfile
63
64
  - LICENSE.txt
64
65
  - README.md
65
66
  - Rakefile