made SBA more robust, added check to test if SBA port is available

This commit is contained in:
matthias.ringwald 2011-02-02 21:35:05 +00:00
parent 89007ccea2
commit 30d108b309
2 changed files with 19 additions and 2 deletions

View File

@ -42,8 +42,8 @@
static CFMessagePortRef springBoardAccessMessagePort = 0;
static int SBA_sendMessage(UInt8 cmd, UInt16 dataLen, UInt8 *data, CFDataRef *resultData){
static void SBA_refresh(){
// still valid
if (springBoardAccessMessagePort && !CFMessagePortIsValid(springBoardAccessMessagePort)){
CFRelease(springBoardAccessMessagePort);
@ -53,6 +53,18 @@ static int SBA_sendMessage(UInt8 cmd, UInt16 dataLen, UInt8 *data, CFDataRef *re
if (!springBoardAccessMessagePort) {
springBoardAccessMessagePort = CFMessagePortCreateRemote(NULL, CFSTR(SBA_MessagePortName));
}
}
int SBA_available(){
SBA_refresh();
if (springBoardAccessMessagePort) return 1;
return 0;
}
static int SBA_sendMessage(UInt8 cmd, UInt16 dataLen, UInt8 *data, CFDataRef *resultData){
SBA_refresh();
// well, won't work
if (!springBoardAccessMessagePort) {
return kCFMessagePortIsInvalid;

View File

@ -74,3 +74,8 @@ int SBA_getBluetoothEnabled();
* @returns CFMessagePortSendRequest error: 0 = ok
*/
int SBA_setBluetoothEnabled(int on);
/**
* Tests if SpringBoardAccess server is available
*/
int SBA_available();