mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-03 23:47:08 +00:00
made SBA more robust, added check to test if SBA port is available
This commit is contained in:
parent
89007ccea2
commit
30d108b309
@ -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;
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user