Permalink
Browse files

refactored structure

  • Loading branch information...
1 parent 9952127 commit 439de82c5106536807db4f0a46b04a9fcf4c552d Horst Mumpitz committed Jul 10, 2012
Showing with 34 additions and 29 deletions.
  1. +1 −1 Gemfile
  2. +33 −28 lib/nxt-rbt-desk.rb
View
@@ -3,4 +3,4 @@ source "http://rubygems.org"
# Specify your gem's dependencies in nxt-rbt-desk.gemspec
gemspec
-gem "mongoid", "~> 3.0.0.rc"
+gem 'sqlite3'
View
@@ -17,34 +17,39 @@
#Mongoid.load!("mongoid.yml")
-nxtInfo = NXTInfo.new
-nxtInfo.deviceAddress = "00165312BBE5"
-com = NXTCommBluecove.new
-com.open(nxtInfo)
-input_stream = BufferedInputStream.new(com.get_input_stream)
-
-#redis = Redis.new(:port => 6380)
-
-message = ""
-
-begin
- b = input_stream.read
- c = b.chr
- #puts "The next byte is #{b.chr}" if (b != -1)
- unless c == ","
- message += b.chr
- else
- #process
- process_message(message)
- message = ""
- end
-end while (b != -1)
-input_stream.close
-
def process_message(message)
- puts message
- parsed_message = message.split(" ")
- #waypoint = Waypoint.new(x: parsed_message[0], y: parsed_message[1], feature: parsed_message[2])
- #waypoint.save
+ puts "Message: #{message}"
+ #parsed_message = message.split(" ")
+ #waypoint = Waypoint.new(x: parsed_message[0], y: parsed_message[1], feature: parsed_message[2])
+ #waypoint.save
+end
+
+def start
+ nxtInfo = NXTInfo.new
+ nxtInfo.deviceAddress = "00165312BBE5"
+ com = NXTCommBluecove.new
+ com.open(nxtInfo)
+ input_stream = BufferedInputStream.new(com.get_input_stream)
+
+ #redis = Redis.new(:port => 6380)
+
+ message = ""
+
+ begin
+ b = input_stream.read
+ c = b.chr
+ unless c == ","
+ message += b.chr
+ else
+ #process
+ process_message(message)
+ message = ""
+ end
+ end while (b != -1)
+ input_stream.close
end
+start
+
+
+

0 comments on commit 439de82

Please sign in to comment.