tamashii-bluetooth 0.1.0.beta.1 → 0.1.0.beta.2

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: c1ff2cef1ee5114af03c06796095de46d2636320
4
- data.tar.gz: 7a60d10486b1336b23841a749ac6073001845e4d
3
+ metadata.gz: dbc4a56a2f2dc7d712a4ac976e3912c5f181c63d
4
+ data.tar.gz: b43e6f0208c8eb5a1163add2869174cb9d8042e5
5
5
  SHA512:
6
- metadata.gz: 59bda2a80fab368e623dd79c17a875cb0c2b9fb75ef1020ce046e51170ca6bba37817faf10934a8ed788be610b1bdf23948135e6627cee1b00cb9791922a14a7
7
- data.tar.gz: cbbbecc34b4a0de84cddf48d8ef2aec6d37f4b651f41f468e1dab37a29c9e118e356c98e30c4e5049210a7d3ec22092f0e4d4c2195978b614bac4b60c5a3e0a5
6
+ metadata.gz: 7af6e87ddf7562edb8664da781df24e3752b475911f16d3d1f57df405e0d4f5e491fb7992c248aea1b48ebcc6fbee536f181b0c0d2eb9f96829f69fcf8071679
7
+ data.tar.gz: b3e1a58f29c08a7591f3dce206a7cce895ba19122c57d0bfa71d06a9d1f42d1443c92e2a993fb79d63baba9f1360f6d3edca761e2f2083df5b8f164086f6134b
data/README.md CHANGED
@@ -95,7 +95,7 @@ end.join
95
95
  * [ ] Linux support (libbluetooth)
96
96
  * [ ] Advertising
97
97
  * [x] iBeacon
98
- * [ ] iBeacon Class
98
+ * [x] iBeacon Class
99
99
  * [x] LINE Beacon Class
100
100
  * [ ] EddyStone
101
101
  * [ ] Tests
@@ -5,6 +5,7 @@ module Tamashii
5
5
  # Beacon Support
6
6
  module Beacon
7
7
  autoload :LINE, 'tamashii/bluetooth/beacon/line'
8
+ autoload :IBeacon, 'tamashii/bluetooth/beacon/ibeacon'
8
9
  end
9
10
  end
10
11
  end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tamashii
4
+ module Bluetooth
5
+ module Beacon
6
+ # Apple iBeacon
7
+ class IBeacon < Advertisment
8
+ attr_reader :uuid, :major, :minior, :measured_power
9
+
10
+ def initialize(uuid, major = 0, minior = 0, measured_power = -59)
11
+ @uuid = uuid.delete('-')
12
+ @major = major
13
+ @minior = minior
14
+ @measured_power = measured_power
15
+
16
+ @data = create_data
17
+ end
18
+
19
+ def create_data
20
+ [
21
+ frame.length + 5,
22
+ 0xFF, 0x4C, 0x00, 0x02,
23
+ frame.length,
24
+ frame
25
+ ].flatten
26
+ end
27
+
28
+ def frame
29
+ @frame ||= [
30
+ uuid_hex,
31
+ int_to_hex(major, 2),
32
+ int_to_hex(minior, 2),
33
+ measured_power
34
+ ].flatten
35
+ end
36
+
37
+ def int_to_hex(value, size)
38
+ value
39
+ .to_s(16)
40
+ .rjust(size * 2, '0')
41
+ .scan(/../)
42
+ .map(&:hex)
43
+ end
44
+
45
+ def uuid_hex
46
+ uuid.scan(/../).map(&:hex)
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tamashii
4
4
  module Bluetooth
5
- VERSION = '0.1.0.beta.1'
5
+ VERSION = '0.1.0.beta.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tamashii-bluetooth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.beta.1
4
+ version: 0.1.0.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - 蒼時弦也
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-14 00:00:00.000000000 Z
11
+ date: 2018-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -121,6 +121,7 @@ files:
121
121
  - ext/bluetooth/osx/xpc.c
122
122
  - lib/tamashii/bluetooth.rb
123
123
  - lib/tamashii/bluetooth/beacon.rb
124
+ - lib/tamashii/bluetooth/beacon/ibeacon.rb
124
125
  - lib/tamashii/bluetooth/beacon/line.rb
125
126
  - lib/tamashii/bluetooth/device.rb
126
127
  - lib/tamashii/bluetooth/version.rb