wifly 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -21,7 +21,7 @@ Or install it yourself as:
21
21
  ## Usage
22
22
  Create a client by passing in the host, port, and firmware version:
23
23
 
24
- control = Wifly::Control.new('192.168.1.45', 2000, '2.31.7')
24
+ control = Wifly::Control.new('192.168.1.45', 2000, '2.38.3')
25
25
 
26
26
  Read the high pins:
27
27
 
@@ -1,7 +1,5 @@
1
1
  module Wifly
2
2
  class Connection
3
- HELLO = '*HELLO*CMD\r\n'
4
-
5
3
  attr_accessor :address, :port, :version
6
4
 
7
5
  ##
@@ -24,10 +22,10 @@ module Wifly
24
22
  # Since the string has a predictable length, we can do a blocking read.
25
23
  #
26
24
  def send_command(str, return_len=0)
27
- str += '\r'
25
+ str += "\r"
28
26
  socket.write(str)
29
- expected_return_length = str.length + '\r\n#{prompt}'.length + return_len
30
- socket.read(expected_return_length).gsub(prompt,'')
27
+ expected_return_length = str.length + "\r\n#{prompt}".length + return_len
28
+ socket.read(expected_return_length).gsub(prompt,'')
31
29
  end
32
30
 
33
31
  def close
@@ -45,8 +43,8 @@ module Wifly
45
43
 
46
44
  def initialize_socket
47
45
  sock = Socket.tcp(address, port)
48
- sock.write('$$$\r') # enter command mode
49
- sock.read(HELLO.length) # read off the response, "*HELLO*CMD\r\n"
46
+ sock.write(COMMAND_MODE) # enter command mode
47
+ sock.read(HELLO.length) # read off the response
50
48
  sock
51
49
  end
52
50
  end
data/lib/wifly/control.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  module Wifly
2
2
  class Control
3
- AOK = "\r\nAOK"
4
-
5
3
  attr_accessor :connection
6
4
 
7
5
  ##
data/lib/wifly/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wifly
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/wifly.rb CHANGED
@@ -2,3 +2,9 @@ require 'socket'
2
2
  require 'wifly/connection'
3
3
  require 'wifly/control'
4
4
  require 'wifly/version'
5
+
6
+ module Wifly
7
+ AOK = "\r\nAOK"
8
+ HELLO = "*HELLO*CMD\r\n"
9
+ COMMAND_MODE = "$$$\r"
10
+ end
@@ -8,17 +8,17 @@ class Wifly::TestServer
8
8
 
9
9
  def simple_connect
10
10
  @client = @socket.accept
11
- self.input = @client.read('$$$\r'.length)
12
- @client.write(Wifly::Connection::HELLO)
11
+ self.input = @client.read(Wifly::COMMAND_MODE.length)
12
+ @client.write(Wifly::HELLO)
13
13
  @client.close
14
14
  end
15
15
 
16
16
  def receive_command(command, version)
17
17
  @client = @socket.accept
18
18
 
19
- @client.write(Wifly::Connection::HELLO)
20
- @client.read((command + '\r').length)
21
- @client.write(command + '\r\r\n<' + version + '> ')
19
+ @client.write(Wifly::HELLO)
20
+ @client.read((command + "\r").length)
21
+ @client.write(command + "\r\r\n<" + version + '> ')
22
22
  @client.close
23
23
  end
24
24
  end
@@ -41,7 +41,7 @@ describe Wifly::Connection do
41
41
  connection = Wifly::Connection.new('localhost', 2000, '2.3.13')
42
42
  connection.socket
43
43
  t.join
44
- @server.input.should eq('$$$\r')
44
+ @server.input.should eq(Wifly::COMMAND_MODE)
45
45
  connection.close
46
46
  end
47
47
 
@@ -53,7 +53,7 @@ describe Wifly::Connection do
53
53
 
54
54
  result = connection.send_command("lites")
55
55
  t.join
56
- result.should eq('lites\r\r\n')
56
+ result.should eq("lites\r\r\n")
57
57
  connection.close
58
58
  end
59
59
  end
data/spec/control_spec.rb CHANGED
@@ -18,8 +18,8 @@ describe Wifly::Control do
18
18
 
19
19
  it 'should set high and low' do
20
20
  connection = double('connection')
21
- connection.should_receive(:send_command).with("set sys output 0x20 0x20", Wifly::Control::AOK.length)
22
- connection.should_receive(:send_command).with("set sys output 0x00 0x20", Wifly::Control::AOK.length)
21
+ connection.should_receive(:send_command).with("set sys output 0x20 0x20", Wifly::AOK.length)
22
+ connection.should_receive(:send_command).with("set sys output 0x00 0x20", Wifly::AOK.length)
23
23
  control = Wifly::Control.new('localhost', 2000, '1.2', connection)
24
24
  control.set_high(5)
25
25
  control.set_low(5)
data/wifly.gemspec CHANGED
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "pry"
24
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wifly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-04 00:00:00.000000000 Z
12
+ date: 2013-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -59,6 +59,22 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: pry
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
62
78
  description: A small Ruby gem to connect to a WiFly RN-XV device
63
79
  email:
64
80
  - billy.reisinger@govdelivery.com
@@ -95,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
111
  version: '0'
96
112
  segments:
97
113
  - 0
98
- hash: 277051527078828641
114
+ hash: -937417951
99
115
  required_rubygems_version: !ruby/object:Gem::Requirement
100
116
  none: false
101
117
  requirements:
@@ -104,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
120
  version: '0'
105
121
  segments:
106
122
  - 0
107
- hash: 277051527078828641
123
+ hash: -937417951
108
124
  requirements: []
109
125
  rubyforge_project:
110
126
  rubygems_version: 1.8.25