artoo-pebble 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +64 -0
- data/LICENSE +13 -0
- data/README.md +26 -0
- data/Rakefile +10 -0
- data/artoo-pebble.gemspec +27 -0
- data/examples/hello_pebble.rb +11 -0
- data/examples/media_control.rb +17 -0
- data/lib/artoo/adaptors/pebble.rb +59 -0
- data/lib/artoo/drivers/pebble.rb +35 -0
- data/lib/artoo-pebble/version.rb +5 -0
- data/lib/artoo-pebble.rb +3 -0
- data/test/adaptors/pebble_adaptor_test.rb +28 -0
- data/test/drivers/pebble_driver_test.rb +4 -0
- data/test/test_helper.rb +7 -0
- metadata +128 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3505baa398f392646707145a946f5e83bb260eb5
|
4
|
+
data.tar.gz: b198a9e5738ca21c843c25feb63aa69339c7b536
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 30ff2cdb96a3c645530326c6238becc308bc7d72871a893d6e03f87a773eeef464c4304efcd1567cdda58b20042027e9e5f6bf96faa15ee8cb2fac6a61328071
|
7
|
+
data.tar.gz: 5ace8f4288c64ac20c77924730bcb14222457304d73cc6a233fd03c1a47646e5eedacf268450d311deda504083d4d0b45406a38af84f19027ddab19cdfcc21d1
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
artoo-pebble (0.0.1)
|
5
|
+
artoo (~> 1.0.0.rc1)
|
6
|
+
hybridgroup-pebblewatch (~> 0.0.4)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
artoo (1.0.0.rc1)
|
12
|
+
celluloid (~> 0.14.1)
|
13
|
+
celluloid-io (~> 0.14.1)
|
14
|
+
multi_json (~> 1.6)
|
15
|
+
pry (~> 0.9)
|
16
|
+
rake (~> 10.0)
|
17
|
+
reel (~> 0.4.0.pre)
|
18
|
+
celluloid (0.14.1)
|
19
|
+
timers (>= 1.0.0)
|
20
|
+
celluloid-io (0.14.1)
|
21
|
+
celluloid (>= 0.14.1)
|
22
|
+
nio4r (>= 0.4.5)
|
23
|
+
certified (0.1.1)
|
24
|
+
coderay (1.0.9)
|
25
|
+
http (0.4.0)
|
26
|
+
certified
|
27
|
+
http_parser.rb
|
28
|
+
http_parser.rb (0.5.3)
|
29
|
+
hybridgroup-pebblewatch (0.0.4)
|
30
|
+
hybridgroup-serialport (~> 1.2)
|
31
|
+
hybridgroup-serialport (1.2.1)
|
32
|
+
metaclass (0.0.1)
|
33
|
+
method_source (0.8.1)
|
34
|
+
minitest (5.0.6)
|
35
|
+
minitest-happy (1.0.0)
|
36
|
+
mocha (0.14.0)
|
37
|
+
metaclass (~> 0.0.1)
|
38
|
+
multi_json (1.7.7)
|
39
|
+
nio4r (0.4.6)
|
40
|
+
pry (0.9.12.2)
|
41
|
+
coderay (~> 1.0.5)
|
42
|
+
method_source (~> 0.8)
|
43
|
+
slop (~> 3.4)
|
44
|
+
rack (1.5.2)
|
45
|
+
rake (10.1.0)
|
46
|
+
reel (0.4.0.pre)
|
47
|
+
celluloid-io (>= 0.8.0)
|
48
|
+
http (>= 0.2.0)
|
49
|
+
http_parser.rb (>= 0.5.3)
|
50
|
+
rack (>= 1.4.0)
|
51
|
+
websocket_parser (>= 0.1.2)
|
52
|
+
slop (3.4.5)
|
53
|
+
timers (1.1.0)
|
54
|
+
websocket_parser (0.1.4)
|
55
|
+
http
|
56
|
+
|
57
|
+
PLATFORMS
|
58
|
+
ruby
|
59
|
+
|
60
|
+
DEPENDENCIES
|
61
|
+
artoo-pebble!
|
62
|
+
minitest (~> 5.0)
|
63
|
+
minitest-happy
|
64
|
+
mocha (~> 0.14.0)
|
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2013 The Hybrid Group
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Artoo Adaptor For Pebble
|
2
|
+
|
3
|
+
This repository contains the Artoo (http://artoo.io/) adaptor for the Pebble smart watch (http://getpebble.com/). It uses the pebblewatch gem (https://github.com/hybridgroup/pebblewatch) to perform all communication.
|
4
|
+
|
5
|
+
Artoo is a open source micro-framework for robotics using Ruby.
|
6
|
+
|
7
|
+
For more information abut Artoo, check out our repo at https://github.com/hybridgroup/artoo
|
8
|
+
|
9
|
+
## Installing
|
10
|
+
|
11
|
+
```
|
12
|
+
gem install artoo-pebble
|
13
|
+
```
|
14
|
+
|
15
|
+
## Connecting to Pebble
|
16
|
+
|
17
|
+
This software requires version 1.11.1 of the Pebble watch firmware.
|
18
|
+
|
19
|
+
### Ubuntu
|
20
|
+
|
21
|
+
You will need to pair with the Pebble, and then you can find the Bluetooth address, for example `00:18:33:86:37:8B`. Once you know the address, you can use the rfcomm program to map a port to the device:
|
22
|
+
|
23
|
+
```
|
24
|
+
sudo rfcomm bind 0 00:18:33:86:37:8B 1
|
25
|
+
sudo chmod 666 /dev/rfcomm0
|
26
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "artoo-pebble/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "artoo-pebble"
|
7
|
+
s.version = Artoo::Pebble::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Ron Evans"]
|
10
|
+
s.email = ["artoo@hybridgroup.com"]
|
11
|
+
s.homepage = "https://github.com/hybridgroup/artoo-pebble"
|
12
|
+
s.summary = %q{Artoo adaptor and driver for Pebble smart watch}
|
13
|
+
s.description = %q{Artoo adaptor and driver for Pebble smart watch}
|
14
|
+
|
15
|
+
s.rubyforge_project = "artoo-pebble"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_runtime_dependency 'artoo', '~> 1.0.0.rc1'
|
23
|
+
s.add_runtime_dependency 'hybridgroup-pebblewatch', '~> 0.1.0'
|
24
|
+
s.add_development_dependency 'minitest', '~> 5.0'
|
25
|
+
s.add_development_dependency 'minitest-happy'
|
26
|
+
s.add_development_dependency 'mocha', '~> 0.14.0'
|
27
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'artoo'
|
2
|
+
|
3
|
+
connection :pebble, :adaptor => :pebble, :port => "/dev/rfcomm0", :id => "378B"
|
4
|
+
device :watch, :driver => :pebble
|
5
|
+
|
6
|
+
work do
|
7
|
+
watch.set_nowplaying_metadata("Artoo", "Hello", Time.now.to_s)
|
8
|
+
every(5.seconds) do
|
9
|
+
watch.set_nowplaying_metadata("Artoo", "Update...", Time.now.to_s)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'artoo'
|
2
|
+
|
3
|
+
connection :pebble, :adaptor => :pebble, :port => "/dev/rfcomm0", :id => "378B"
|
4
|
+
device :watch, :driver => :pebble
|
5
|
+
|
6
|
+
def button_push(*data)
|
7
|
+
puts data[1].button unless data[1].nil?
|
8
|
+
end
|
9
|
+
|
10
|
+
work do
|
11
|
+
on watch, :media_control => :button_push
|
12
|
+
|
13
|
+
watch.set_nowplaying_metadata("Artoo", "Hello", Time.now.to_s)
|
14
|
+
every(5.seconds) do
|
15
|
+
watch.set_nowplaying_metadata("Artoo", "Update...", Time.now.to_s)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'artoo/adaptors/adaptor'
|
2
|
+
|
3
|
+
module Artoo
|
4
|
+
module Adaptors
|
5
|
+
# Connect to a pebble device
|
6
|
+
# @see device documentation for more information
|
7
|
+
class Pebble < Adaptor
|
8
|
+
finalizer :finalize
|
9
|
+
attr_reader :pebble
|
10
|
+
|
11
|
+
# Number of retries when connecting
|
12
|
+
RETRY_COUNT = 5
|
13
|
+
|
14
|
+
# Closes connection with device if connected
|
15
|
+
# @return [Boolean]
|
16
|
+
def finalize
|
17
|
+
if connected?
|
18
|
+
pebble.disconnect
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Creates a connection with device
|
23
|
+
# @return [Boolean]
|
24
|
+
def connect
|
25
|
+
@retries_left = RETRY_COUNT
|
26
|
+
require 'pebble' unless defined?(::Pebble)
|
27
|
+
begin
|
28
|
+
#::Pebble.logger.level = ::Logger::DEBUG
|
29
|
+
@pebble = ::Pebble::Watch.new(parent.connection_id, connect_to)
|
30
|
+
@pebble.connect
|
31
|
+
super
|
32
|
+
return true
|
33
|
+
rescue Errno::EBUSY => e
|
34
|
+
@retries_left -= 1
|
35
|
+
if @retries_left > 0
|
36
|
+
retry
|
37
|
+
else
|
38
|
+
Logger.error e.message
|
39
|
+
Logger.error e.backtrace.inspect
|
40
|
+
return false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# Closes connection with device
|
46
|
+
# @return [Boolean]
|
47
|
+
def disconnect
|
48
|
+
pebble.disconnect
|
49
|
+
super
|
50
|
+
end
|
51
|
+
|
52
|
+
# Uses method missing to call device actions
|
53
|
+
# @see Pebble documentation
|
54
|
+
def method_missing(method_name, *arguments, &block)
|
55
|
+
pebble.send(method_name, *arguments, &block)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'artoo/drivers/driver'
|
2
|
+
|
3
|
+
module Artoo
|
4
|
+
module Drivers
|
5
|
+
# The pebble driver behaviors
|
6
|
+
class Pebble < Driver
|
7
|
+
|
8
|
+
COMMANDS = [:set_nowplaying_metadata]
|
9
|
+
|
10
|
+
# Start driver and any required connections
|
11
|
+
def start_driver
|
12
|
+
begin
|
13
|
+
every(interval) do
|
14
|
+
handle_message_events
|
15
|
+
end
|
16
|
+
|
17
|
+
connection.listen_for_events(false)
|
18
|
+
|
19
|
+
super
|
20
|
+
rescue Exception => e
|
21
|
+
Logger.error "Error starting Pebble driver!"
|
22
|
+
Logger.error e.message
|
23
|
+
Logger.error e.backtrace.inspect
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def handle_message_events
|
28
|
+
while not connection.protocol.messages.empty? do
|
29
|
+
e = connection.protocol.messages.pop
|
30
|
+
publish(event_topic_name(e[0].to_s), e[1])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/artoo-pebble.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
2
|
+
require 'artoo/adaptors/pebble'
|
3
|
+
|
4
|
+
describe Artoo::Adaptors::Pebble do
|
5
|
+
before do
|
6
|
+
@connection = mock('connect')
|
7
|
+
@connection.stubs(:connection_id).returns("F123")
|
8
|
+
@port = Artoo::Port.new('/dev/awesome')
|
9
|
+
@adaptor = Artoo::Adaptors::Pebble.new(:port => @port, :parent => @connection)
|
10
|
+
@pebble = mock('pebble')
|
11
|
+
Pebble::Watch.stubs(:new).returns(@pebble)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'Artoo::Adaptors::Pebble#connect' do
|
15
|
+
@pebble.expects(:connect)
|
16
|
+
@adaptor.connect
|
17
|
+
@adaptor.connected?.must_equal true
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'Artoo::Adaptors::Pebble#disconnect' do
|
21
|
+
@pebble.stubs(:connect)
|
22
|
+
@adaptor.connect
|
23
|
+
|
24
|
+
@pebble.expects(:disconnect)
|
25
|
+
@adaptor.disconnect
|
26
|
+
@adaptor.connected?.must_equal false
|
27
|
+
end
|
28
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: artoo-pebble
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ron Evans
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: artoo
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.0.rc1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.0.rc1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hybridgroup-pebblewatch
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest-happy
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mocha
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.14.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.14.0
|
83
|
+
description: Artoo adaptor and driver for Pebble smart watch
|
84
|
+
email:
|
85
|
+
- artoo@hybridgroup.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- Gemfile
|
91
|
+
- Gemfile.lock
|
92
|
+
- LICENSE
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- artoo-pebble.gemspec
|
96
|
+
- examples/hello_pebble.rb
|
97
|
+
- examples/media_control.rb
|
98
|
+
- lib/artoo-pebble.rb
|
99
|
+
- lib/artoo-pebble/version.rb
|
100
|
+
- lib/artoo/adaptors/pebble.rb
|
101
|
+
- lib/artoo/drivers/pebble.rb
|
102
|
+
- test/adaptors/pebble_adaptor_test.rb
|
103
|
+
- test/drivers/pebble_driver_test.rb
|
104
|
+
- test/test_helper.rb
|
105
|
+
homepage: https://github.com/hybridgroup/artoo-pebble
|
106
|
+
licenses: []
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - '>='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project: artoo-pebble
|
124
|
+
rubygems_version: 2.0.3
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: Artoo adaptor and driver for Pebble smart watch
|
128
|
+
test_files: []
|