Skip to content

Commit

Permalink
Cleaning API and documentation, more work on serial interface
Browse files Browse the repository at this point in the history
Driver.java
-now extends Runnable, drivers only need to implement ControllerModule or SensorModule
-changed receiveMessage to receiveCommand to match naming convention

LedFlash.java:
-no longer implements Runnable

SimpleDriver.java:
-no longer extends Controller
-no longer implements Runnable

StatefullLed.java:
-no longer implements Runnable

Coordinator.java:
-list of loaded drivers now stored in a hashmap
-added broadcastCommand()
-readSerial implemented (not tested)
-sendCommand() changed to a wrapper method, checks current protocol version and routes message to sendCommandV0() or sendCommandV1()
-added sendCommandV0() to send command as protocol 0 message: [destination | ':' |command | '\n']
-sendCommandV0() re-encodes message as US-ASCII from Unicode
-added sendCommandV1() to send message as protocol 1 message: [start_byte | destination | ':' | command | '\n']
-sendBinary() implemented (needs to be updated to detect protocol version)
-storeData() and readData() broken into text and binary versions

SerialConnection.java:
-attempts to connect to a preferred connection before trying from a static list

SimpleHttpServer.java:
-added empty class for testing
  • Loading branch information
ciasaboark committed Jan 28, 2014
1 parent 26ed40e commit e45afce
Show file tree
Hide file tree
Showing 7 changed files with 393 additions and 109 deletions.
8 changes: 4 additions & 4 deletions Coordinator/drivers/org/apparatus_templi/LedFlash.java
Expand Up @@ -13,7 +13,7 @@
* @author Jonathan Nelson <ciasaboark@gmail.com>
*/

public class LedFlash implements ControllerModule, Runnable {
public class LedFlash implements ControllerModule {
private String moduleName = "LED_FLASH";
private volatile boolean running = true;

Expand Down Expand Up @@ -146,7 +146,7 @@ public void run() {
* Our simple driver will repeatedly send three messages to the
* remote module, sleeping 5 seconds between each message.
*/
for (int i = 3; i < 6; i++) {
for (int i = 3; i < 10; i++) {
Log.d(moduleName, "flashing LED on pin " + i);
Coordinator.sendCommand(moduleName, String.valueOf(i));
try {
Expand All @@ -166,8 +166,8 @@ public void run() {
* We don't care about any response messages.
*/
@Override
public void receiveMessage(String message) {
Log.d(moduleName, "received message, ignoring");
public void receiveCommand(String command) {
Log.d(moduleName, "received command, ignoring");
}

/*
Expand Down
4 changes: 2 additions & 2 deletions Coordinator/drivers/org/apparatus_templi/SimpleDriver.java
@@ -1,6 +1,6 @@
package org.apparatus_templi;

public class SimpleDriver extends Coordinator implements ControllerModule,Runnable {
public class SimpleDriver implements ControllerModule {
private String moduleName = "SimpleDriver";

@Override
Expand Down Expand Up @@ -32,7 +32,7 @@ public void run() {
}

@Override
public void receiveMessage(String message) {
public void receiveCommand(String message) {
// TODO Auto-generated method stub

}
Expand Down
4 changes: 2 additions & 2 deletions Coordinator/drivers/org/apparatus_templi/StatefullLed.java
Expand Up @@ -22,7 +22,7 @@
* @author Jonathan Nelson <ciasaboark@gmail.com>
*/

public class StatefullLed implements ControllerModule, Runnable {
public class StatefullLed implements ControllerModule {
private String moduleName = "StatefullLED";
private boolean running = true;

Expand All @@ -41,7 +41,7 @@ public String getModuleName() {
}

@Override
public void receiveMessage(String message) {
public void receiveCommand(String message) {
//throw away the message for now
Log.d(moduleName, "received message, ignoring");

Expand Down

0 comments on commit e45afce

Please sign in to comment.