artoo-pebble 1.1.0 → 1.2.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: c42dd7b0cbedf235cdc1de1e6a7bc58146c8c969
4
- data.tar.gz: 3070dbf47b8157a3795709fead12cdbaa660834d
3
+ metadata.gz: 5b0fe323364f1b8d8d8f16ba036d1b47fe0417f0
4
+ data.tar.gz: 876b3ebc8d94e2526aa7894f6a9e5fb77b6e5194
5
5
  SHA512:
6
- metadata.gz: 8eb882849f35a4fb08c7756d5517760de7d673629e679ca7b8022c8430f134329c80141e4f6698666e2e253ee1a6469364a1c6e92e27cc324934451c413986ee
7
- data.tar.gz: 10056e171a13b5318c88b1a1c8c374bca87cbd729844a53dc5ec2e74a478bb146bd018a91dd6be0ed4ac921922d62a54dbe580c18f8120b3435f290a636acf60
6
+ metadata.gz: 9426ee6977de983bb205242faa8bf3f9ea98ff0e2522937c42262d6ac75123829ab6424277dad3af8c564ea924d658b805ac27d471eb4f5c22ea934c9546325f
7
+ data.tar.gz: 2591141a06f6e8785653151ea8e7c871b680888cb7c38c0fdbd591076f6d5a821debba5898b191f45f7c0df5edd763de65683d8c3bf6297b2f253157aac9a29a
data/.travis.yml CHANGED
@@ -2,5 +2,6 @@ language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
4
  - 1.9.3
5
- - jruby-19mode
6
- - rbx-19mode
5
+ - jruby-1.7.9
6
+ - rbx-2.1.1
7
+
data/Gemfile.lock CHANGED
@@ -1,55 +1,54 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- artoo-pebble (1.1.0)
5
- artoo (>= 1.2.2)
6
- hybridgroup-pebblewatch (>= 0.1.2)
4
+ artoo-pebble (1.2.0)
5
+ artoo (>= 1.6.0)
7
6
 
8
7
  GEM
9
8
  remote: http://rubygems.org/
10
9
  specs:
11
- artoo (1.2.2)
10
+ artoo (1.6.0)
12
11
  celluloid (~> 0.15.0)
13
12
  celluloid-io (~> 0.15.0)
14
13
  multi_json (~> 1.6)
15
14
  pry (~> 0.9)
16
15
  rake
17
16
  reel (~> 0.4.0)
17
+ robeaux (~> 0.0.3)
18
18
  thor (~> 0.18.1)
19
- celluloid (0.15.1)
19
+ celluloid (0.15.2)
20
20
  timers (~> 1.1.0)
21
21
  celluloid-io (0.15.0)
22
22
  celluloid (>= 0.15.0)
23
23
  nio4r (>= 0.5.0)
24
- coderay (1.0.9)
24
+ coderay (1.1.0)
25
25
  http (0.5.0)
26
26
  http_parser.rb
27
- http_parser.rb (0.6.0.beta.2)
28
- hybridgroup-pebblewatch (0.1.2)
27
+ http_parser.rb (0.6.0)
29
28
  metaclass (0.0.1)
30
29
  method_source (0.8.2)
31
30
  minitest (5.0.6)
32
31
  minitest-happy (1.0.0)
33
32
  mocha (0.14.0)
34
33
  metaclass (~> 0.0.1)
35
- multi_json (1.8.0)
36
- nio4r (0.5.0)
37
- pry (0.9.12.2)
38
- coderay (~> 1.0.5)
34
+ multi_json (1.8.4)
35
+ nio4r (1.0.0)
36
+ pry (0.9.12.6)
37
+ coderay (~> 1.0)
39
38
  method_source (~> 0.8)
40
39
  slop (~> 3.4)
41
- rake (10.1.0)
40
+ rake (10.1.1)
42
41
  reel (0.4.0)
43
42
  celluloid (>= 0.15.1)
44
43
  celluloid-io (>= 0.15.0)
45
44
  http (>= 0.5.0)
46
45
  http_parser.rb (>= 0.6.0.beta.2)
47
46
  websocket_parser (>= 0.1.4)
48
- slop (3.4.6)
47
+ robeaux (0.0.3)
48
+ slop (3.4.7)
49
49
  thor (0.18.1)
50
50
  timers (1.1.0)
51
- websocket_parser (0.1.4)
52
- http
51
+ websocket_parser (0.1.6)
53
52
 
54
53
  PLATFORMS
55
54
  ruby
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Artoo Adaptor For Pebble
2
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.
3
+ This repository contains the Artoo (http://artoo.io/) adaptor and driver for the Pebble smart watch (http://getpebble.com/). It uses the Pebble 2.0 SDK, and requires the 2.0 iOS or Android app, and that the "Chomps" app (https://github.com/hybridgroup/chomps) has been installed on the Pebble watch.
4
4
 
5
5
  Artoo is a open source micro-framework for robotics using Ruby.
6
6
 
@@ -19,74 +19,45 @@ gem install artoo-pebble
19
19
  ```ruby
20
20
  require 'artoo'
21
21
 
22
- connection :pebble, :adaptor => :pebble, :port => "127.0.0.1:4567", :id => "378B"
22
+ connection :pebble, :adaptor => :pebble
23
23
  device :watch, :driver => :pebble
24
24
 
25
- def button_push(*data)
26
- puts data[1].button unless data[1].nil?
27
- end
28
-
29
25
  work do
30
- on watch, :media_control => :button_push
31
-
32
- watch.set_nowplaying_metadata("Artoo", "Hello", Time.now.to_s)
33
- every(5.seconds) do
34
- watch.set_nowplaying_metadata("Artoo", "Update...", Time.now.to_s)
26
+ c = 100
27
+ every 1.second do
28
+ c++
29
+ str = "c: \#{c}"
30
+ pebble.message_queue.push(str)
31
+ Logger.info(pebble.last_message)
35
32
  end
36
33
  end
37
34
  ```
38
35
 
39
36
  ## Connecting to Pebble
40
37
 
41
- This software requires version 1.12.0 of the Pebble watch firmware.
42
-
43
- ### OSX
44
-
45
- The main steps are:
46
- - Pair your computer and the Pebble
47
- - Use a socket to serial connection to map a TCP socket to the local port
48
- - Connect to the device via Artoo
49
-
50
- To figure out which port your pebble is connected to, use the `artoo connect scan` command:
51
-
52
- ```
53
- $ artoo connect scan
54
- ```
55
-
56
- Now you are ready to connect to the Sphero using the socket, in this example port 4567:
57
-
58
- ```
59
- artoo connect serial pebble 4567
60
- ```
61
-
62
- ### Ubuntu
38
+ Communication between the Pebble watch and Artoo takes place entirely using the Artoo API. This adaptor uses the Pebble 2.0 SDK, and requires the 2.0 iOS or Android app, and that the "Chomps" app (https://github.com/hybridgroup/chomps) has been installed on the Pebble watch.
63
39
 
64
- The main steps are:
65
- - Pair your computer and the Pebble
66
- - Map your device to a port
67
- - Use a socket to serial connection to map a TCP socket to the local port
68
- - Connect to the device via Artoo
40
+ ## Documentation
69
41
 
70
- You will need to pair with the Pebble, entering any needed password.
42
+ Check out our [documentation](http://artoo.io/documentation/) for lots of information about how to use Artoo.
71
43
 
72
- Then you can find the Bluetooth address, for example `00:18:33:86:37:8B`, by using the `artoo connect scan` command:
44
+ ## IRC
73
45
 
74
- ```
75
- $ artoo connect scan
76
- ```
46
+ Need more help? Just want to say "Hello"? Come visit us on IRC freenode #artoo
77
47
 
78
- Once you know the address, you can use the `artoo connect bind` command to map a port to the device:
48
+ ## Contributing
79
49
 
80
- ```
81
- artoo connect bind 00:18:33:86:37:8B pebble
82
- ```
83
-
84
- Now you are ready to connect to the Pebble using a socket, in this example port 4567:
85
-
86
- ```
87
- artoo connect serial pebble 4567
88
- ```
50
+ * All patches must be provided under the Apache 2.0 License
51
+ * Please use the -s option in git to "sign off" that the commit is your work and you are providing it under the Apache 2.0 License
52
+ * Submit a Github Pull Request to the appropriate branch and ideally discuss the changes with us in IRC.
53
+ * We will look at the patch, test it out, and give you feedback.
54
+ * Avoid doing minor whitespace changes, renamings, etc. along with merged content. These will be done by the maintainers from time to time but they can complicate merges and should be done seperately.
55
+ * Take care to maintain the existing coding style.
56
+ * Add unit tests for any new or changed functionality.
57
+ * All pull requests should be "fast forward"
58
+ * If there are commits after yours use “git rebase -i <new_head_branch>”
59
+ * If you have local changes you may need to use “git stash”
60
+ * For git help see [progit](http://git-scm.com/book) which is an awesome (and free) book on git
89
61
 
90
- ### Windows
91
62
 
92
- We are currently working with the Celluloid team to add Windows support. Please check back soon!
63
+ (c) 2012-2014 The Hybrid Group
data/artoo-pebble.gemspec CHANGED
@@ -19,8 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_runtime_dependency 'artoo', '>= 1.2.2'
23
- s.add_runtime_dependency 'hybridgroup-pebblewatch', '>= 0.1.2'
22
+ s.add_runtime_dependency 'artoo', '>= 1.6.0'
24
23
  s.add_development_dependency 'minitest', '>= 5.0'
25
24
  s.add_development_dependency 'minitest-happy'
26
25
  s.add_development_dependency 'mocha', '>= 0.14.0'
data/docs/commands.md ADDED
@@ -0,0 +1,17 @@
1
+ # Commands
2
+
3
+ ## message_queue
4
+
5
+ Used to add or access the queue of strings being passed to the Pebble watch.
6
+
7
+ ##### Returns
8
+
9
+ `Array` with all message strings
10
+
11
+ ## last_message
12
+
13
+ Returns and removes the string with the last message from the queue of messages being passed with the Pebble watch.
14
+
15
+ ##### Returns
16
+
17
+ `String` with the last message on the queue.
data/docs/events.md ADDED
@@ -0,0 +1,5 @@
1
+ # Events
2
+
3
+ ## start_driver
4
+
5
+ Starts the driver.
@@ -1,11 +1,14 @@
1
1
  require 'artoo'
2
2
 
3
- connection :pebble, :adaptor => :pebble, :port => "127.0.0.1:4567", :id => "E36E"
3
+ connection :pebble, :adaptor => :pebble
4
4
  device :watch, :driver => :pebble
5
5
 
6
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)
7
+ c = 100
8
+ every(1.second) do
9
+ c++
10
+ str = "c: \#{c}"
11
+ pebble.message_queue.push(str)
12
+ Logger.info(pebble.last_message)
10
13
  end
11
14
  end
@@ -1,5 +1,5 @@
1
1
  module Artoo
2
2
  module Pebble
3
- VERSION = '1.1.0'
3
+ VERSION = '1.2.0'
4
4
  end
5
5
  end
@@ -5,45 +5,6 @@ module Artoo
5
5
  # Connect to a pebble device
6
6
  # @see device documentation for more information
7
7
  class Pebble < Adaptor
8
- attr_reader :pebble
9
-
10
- # Number of retries when connecting
11
- RETRY_COUNT = 5
12
-
13
- # Creates a connection with device
14
- # @return [Boolean]
15
- def connect
16
- @retries_left = RETRY_COUNT
17
- require 'pebble' unless defined?(::Pebble)
18
- begin
19
- @pebble = ::Pebble::Watch.new(parent.connection_id, connect_to)
20
- @pebble.connect
21
- super
22
- return true
23
- rescue Errno::EBUSY, Errno::ECONNREFUSED => e
24
- @retries_left -= 1
25
- if @retries_left > 0
26
- retry
27
- else
28
- Logger.error e.message
29
- Logger.error e.backtrace.inspect
30
- return false
31
- end
32
- end
33
- end
34
-
35
- # Closes connection with device
36
- # @return [Boolean]
37
- def disconnect
38
- pebble.disconnect
39
- super
40
- end
41
-
42
- # Uses method missing to call device actions
43
- # @see Pebble documentation
44
- def method_missing(method_name, *arguments, &block)
45
- pebble.send(method_name, *arguments, &block)
46
- end
47
8
  end
48
9
  end
49
10
  end
@@ -5,32 +5,22 @@ module Artoo
5
5
  # The pebble driver behaviors
6
6
  class Pebble < Driver
7
7
 
8
- COMMANDS = [:ping, :notification_sms, :notification_email, :set_nowplaying_metadata,
9
- :get_versions, :get_installed_apps, :remove_app, :get_time, :set_time,
10
- :system_message, :reset]
8
+ COMMANDS = [:message_queue, :last_message]
11
9
 
12
10
  # Start driver and any required connections
11
+ # Public: Starts the driver.
12
+ #
13
+ # Returns null.
13
14
  def start_driver
14
- begin
15
- every(interval) do
16
- handle_message_events
17
- end
18
-
19
- connection.listen_for_events(false)
15
+ @messages = []
16
+ end
20
17
 
21
- super
22
- rescue Exception => e
23
- Logger.error "Error starting Pebble driver!"
24
- Logger.error e.message
25
- Logger.error e.backtrace.inspect
26
- end
18
+ def message_queue
19
+ @messages
27
20
  end
28
21
 
29
- def handle_message_events
30
- while not connection.protocol.messages.empty? do
31
- e = connection.protocol.messages.pop
32
- publish(event_topic_name(e[0].to_s), e[1])
33
- end
22
+ def last_message
23
+ @messages.pop
34
24
  end
35
25
  end
36
26
  end
@@ -4,24 +4,16 @@ require 'artoo/adaptors/pebble'
4
4
  describe Artoo::Adaptors::Pebble do
5
5
  before do
6
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)
7
+ @adaptor = Artoo::Adaptors::Pebble.new(:parent => @connection)
12
8
  end
13
9
 
14
10
  it 'Artoo::Adaptors::Pebble#connect' do
15
- @pebble.expects(:connect)
16
11
  @adaptor.connect
17
12
  @adaptor.connected?.must_equal true
18
13
  end
19
14
 
20
15
  it 'Artoo::Adaptors::Pebble#disconnect' do
21
- @pebble.stubs(:connect)
22
16
  @adaptor.connect
23
-
24
- @pebble.expects(:disconnect)
25
17
  @adaptor.disconnect
26
18
  @adaptor.connected?.must_equal false
27
19
  end
data/test/test_helper.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'artoo/robot'
2
- require 'pebble'
3
2
 
4
3
  require 'minitest/autorun'
5
4
  require 'mocha/setup'
metadata CHANGED
@@ -1,83 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artoo-pebble
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ron Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-18 00:00:00.000000000 Z
11
+ date: 2014-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: artoo
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.2
19
+ version: 1.6.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2.2
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.2
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.2
26
+ version: 1.6.0
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: minitest
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - '>='
31
+ - - ">="
46
32
  - !ruby/object:Gem::Version
47
33
  version: '5.0'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - '>='
38
+ - - ">="
53
39
  - !ruby/object:Gem::Version
54
40
  version: '5.0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: minitest-happy
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - '>='
45
+ - - ">="
60
46
  - !ruby/object:Gem::Version
61
47
  version: '0'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - '>='
52
+ - - ">="
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: mocha
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - '>='
59
+ - - ">="
74
60
  - !ruby/object:Gem::Version
75
61
  version: 0.14.0
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - '>='
66
+ - - ">="
81
67
  - !ruby/object:Gem::Version
82
68
  version: 0.14.0
83
69
  description: Artoo adaptor and driver for Pebble smart watch
@@ -87,16 +73,17 @@ executables: []
87
73
  extensions: []
88
74
  extra_rdoc_files: []
89
75
  files:
90
- - .gitignore
91
- - .travis.yml
76
+ - ".gitignore"
77
+ - ".travis.yml"
92
78
  - Gemfile
93
79
  - Gemfile.lock
94
80
  - LICENSE
95
81
  - README.md
96
82
  - Rakefile
97
83
  - artoo-pebble.gemspec
84
+ - docs/commands.md
85
+ - docs/events.md
98
86
  - examples/hello_pebble.rb
99
- - examples/media_control.rb
100
87
  - lib/artoo-pebble.rb
101
88
  - lib/artoo-pebble/version.rb
102
89
  - lib/artoo/adaptors/pebble.rb
@@ -113,17 +100,17 @@ require_paths:
113
100
  - lib
114
101
  required_ruby_version: !ruby/object:Gem::Requirement
115
102
  requirements:
116
- - - '>='
103
+ - - ">="
117
104
  - !ruby/object:Gem::Version
118
105
  version: '0'
119
106
  required_rubygems_version: !ruby/object:Gem::Requirement
120
107
  requirements:
121
- - - '>='
108
+ - - ">="
122
109
  - !ruby/object:Gem::Version
123
110
  version: '0'
124
111
  requirements: []
125
112
  rubyforge_project: artoo-pebble
126
- rubygems_version: 2.0.3
113
+ rubygems_version: 2.2.1
127
114
  signing_key:
128
115
  specification_version: 4
129
116
  summary: Artoo adaptor and driver for Pebble smart watch
@@ -1,17 +0,0 @@
1
- require 'artoo'
2
-
3
- connection :pebble, :adaptor => :pebble, :port => "127.0.0.1:4567", :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