Build against ruffy b916a900c0899ef58ad58c7427d1c30d3c8731f4.
This commit is contained in:
parent
bc68f2cc1b
commit
4046305380
4 changed files with 15 additions and 41 deletions
|
@ -10,17 +10,12 @@ interface IRTHandler {
|
||||||
void fail(String message);
|
void fail(String message);
|
||||||
|
|
||||||
void requestBluetooth();
|
void requestBluetooth();
|
||||||
boolean canDisconnect();
|
|
||||||
void rtStopped();
|
void rtStopped();
|
||||||
void rtStarted();
|
void rtStarted();
|
||||||
|
|
||||||
void rtClearDisplay();
|
void rtClearDisplay();
|
||||||
void rtUpdateDisplay(in byte[] quarter, int which);
|
void rtUpdateDisplay(in byte[] quarter, int which);
|
||||||
|
|
||||||
void rtDisplayHandleMenu(in Menu menu, in int sequence);
|
void rtDisplayHandleMenu(in Menu menu);
|
||||||
void rtDisplayHandleNoMenu(in int sequence);
|
void rtDisplayHandleNoMenu();
|
||||||
|
|
||||||
void keySent(in int sequence);
|
|
||||||
|
|
||||||
String getServiceIdentifier();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,22 +6,18 @@ import org.monkey.d.ruffy.ruffy.driver.IRTHandler;
|
||||||
|
|
||||||
interface IRuffyService {
|
interface IRuffyService {
|
||||||
|
|
||||||
void addHandler(IRTHandler handler);
|
void setHandler(IRTHandler handler);
|
||||||
void removeHandler(IRTHandler handler);
|
|
||||||
|
|
||||||
/** Connect to the pump
|
/** Connect to the pump
|
||||||
*
|
*
|
||||||
* @return 0 if successful, -1 otherwise
|
* @return 0 if successful, -1 otherwise
|
||||||
*/
|
*/
|
||||||
int doRTConnect(IRTHandler handler);
|
int doRTConnect();
|
||||||
|
|
||||||
/** Disconnect from the pump */
|
/** Disconnect from the pump */
|
||||||
void doRTDisconnect(IRTHandler handler);
|
void doRTDisconnect();
|
||||||
|
|
||||||
/*What's the meaning of 'changed'?
|
|
||||||
* changed means if a button state has been changed, like btton pressed is a change and button release another*/
|
|
||||||
void rtSendKey(byte keyCode, boolean changed);
|
void rtSendKey(byte keyCode, boolean changed);
|
||||||
void resetPairing();
|
void resetPairing();
|
||||||
boolean isConnected();
|
boolean isConnected();
|
||||||
boolean isBoundToPump();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
//b916a900c0899ef58ad58c7427d1c30d3c8731f4
|
|
@ -51,6 +51,7 @@ public class RuffyScripter {
|
||||||
|
|
||||||
public void start(IRuffyService newService) {
|
public void start(IRuffyService newService) {
|
||||||
try {
|
try {
|
||||||
|
/*
|
||||||
if (ruffyService != null) {
|
if (ruffyService != null) {
|
||||||
try {
|
try {
|
||||||
ruffyService.removeHandler(mHandler);
|
ruffyService.removeHandler(mHandler);
|
||||||
|
@ -58,6 +59,7 @@ public class RuffyScripter {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
if (newService != null) {
|
if (newService != null) {
|
||||||
this.ruffyService = newService;
|
this.ruffyService = newService;
|
||||||
// TODO this'll be done better in v2 via ConnectionManager
|
// TODO this'll be done better in v2 via ConnectionManager
|
||||||
|
@ -65,7 +67,7 @@ public class RuffyScripter {
|
||||||
idleDisconnectMonitorThread.start();
|
idleDisconnectMonitorThread.start();
|
||||||
}
|
}
|
||||||
started = true;
|
started = true;
|
||||||
newService.addHandler(mHandler);
|
newService.setHandler(mHandler);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Unhandled exception starting RuffyScripter", e);
|
log.error("Unhandled exception starting RuffyScripter", e);
|
||||||
|
@ -95,7 +97,7 @@ public class RuffyScripter {
|
||||||
log.debug("Disconnecting after " + (connectionTimeOutMs / 1000) + "s inactivity timeout");
|
log.debug("Disconnecting after " + (connectionTimeOutMs / 1000) + "s inactivity timeout");
|
||||||
lastDisconnected = now;
|
lastDisconnected = now;
|
||||||
canDisconnect = true;
|
canDisconnect = true;
|
||||||
ruffyService.doRTDisconnect(mHandler);
|
ruffyService.doRTDisconnect();
|
||||||
connected = false;
|
connected = false;
|
||||||
// don't attempt anything fancy in the next 10s, let the pump settle
|
// don't attempt anything fancy in the next 10s, let the pump settle
|
||||||
SystemClock.sleep(10 * 1000);
|
SystemClock.sleep(10 * 1000);
|
||||||
|
@ -132,11 +134,6 @@ public class RuffyScripter {
|
||||||
log.trace("Ruffy invoked requestBluetooth callback");
|
log.trace("Ruffy invoked requestBluetooth callback");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canDisconnect() throws RemoteException {
|
|
||||||
return canDisconnect;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rtStopped() throws RemoteException {
|
public void rtStopped() throws RemoteException {
|
||||||
log.debug("rtStopped callback invoked");
|
log.debug("rtStopped callback invoked");
|
||||||
|
@ -159,7 +156,7 @@ public class RuffyScripter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rtDisplayHandleMenu(Menu menu, int sequence) throws RemoteException {
|
public void rtDisplayHandleMenu(Menu menu) throws RemoteException {
|
||||||
// method is called every ~500ms
|
// method is called every ~500ms
|
||||||
log.debug("rtDisplayHandleMenu: " + menu);
|
log.debug("rtDisplayHandleMenu: " + menu);
|
||||||
|
|
||||||
|
@ -182,26 +179,9 @@ public class RuffyScripter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rtDisplayHandleNoMenu(int sequence) throws RemoteException {
|
public void rtDisplayHandleNoMenu() throws RemoteException {
|
||||||
log.debug("rtDisplayHandleNoMenu callback invoked");
|
log.debug("rtDisplayHandleNoMenu callback invoked");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void keySent(int sequence) throws RemoteException {
|
|
||||||
synchronized (keylock) {
|
|
||||||
if (keynotwait > 0)
|
|
||||||
keynotwait--;
|
|
||||||
else
|
|
||||||
keylock.notify();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getServiceIdentifier() throws RemoteException {
|
|
||||||
return this.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public boolean isPumpBusy() {
|
public boolean isPumpBusy() {
|
||||||
|
@ -209,12 +189,14 @@ public class RuffyScripter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unbind() {
|
public void unbind() {
|
||||||
|
/*
|
||||||
if (ruffyService != null)
|
if (ruffyService != null)
|
||||||
try {
|
try {
|
||||||
ruffyService.removeHandler(mHandler);
|
ruffyService.removeHandler(mHandler);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
this.ruffyService = null;
|
this.ruffyService = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,7 +360,7 @@ public class RuffyScripter {
|
||||||
}
|
}
|
||||||
|
|
||||||
canDisconnect = false;
|
canDisconnect = false;
|
||||||
boolean connectInitSuccessful = ruffyService.doRTConnect(mHandler) == 0;
|
boolean connectInitSuccessful = ruffyService.doRTConnect() == 0;
|
||||||
log.debug("Connect init successful: " + connectInitSuccessful);
|
log.debug("Connect init successful: " + connectInitSuccessful);
|
||||||
log.debug("Waiting for first menu update to be sent");
|
log.debug("Waiting for first menu update to be sent");
|
||||||
// Note: there was an 'if(currentMenu == null)' around the next call, since
|
// Note: there was an 'if(currentMenu == null)' around the next call, since
|
||||||
|
|
Loading…
Reference in a new issue