def _setmethodsignatures(): # return int, take (object, object, object, output unsigned char, output int) # i.e. in python: return (int, char, int), take (object, object, object) objc.setSignatureForSelector( "BBServiceAdvertiser", "addRFCOMMServiceDictionary:withName:UUID:channelID:serviceRecordHandle:", "i@0:@@@o^Co^I", ) # set to take (6-char array, unsigned char, object) # this seems to work even though the selector doesn't take a char aray, # it takes a struct 'BluetoothDeviceAddress' which contains a char array. objc.setSignatureForSelector( "BBBluetoothOBEXClient", "initWithRemoteDeviceAddress:channelID:delegate:", "@@:r^[6C]C@" )
def __init__(self): objc.loadBundle( 'IOBluetooth', self, bundle_path=u'/System/Library/Frameworks/IOBluetooth.framework' ) # Thank you mailing list archives. Figured out how to # do these signatures from a 2005 mailing list post. objc.setSignatureForSelector( 'IOBluetoothSDPServiceRecord', 'getRFCOMMChannelID:', 'i12@0:o^C' ) objc.setSignatureForSelector( 'IOBluetoothDevice', 'openRFCOMMChannelSync:withChannelID:delegate:', 'i16@0:o^@C@' ) objc.setSignatureForSelector( 'IOBluetoothRFCOMMChannel', 'writeSync:length:', 'i16@0:*S' )
raise ImportError("Cannot load LightAquaBlue framework, not found at" + \ _FRAMEWORK_PATH) try: # mac os 10.5 loads frameworks using bridgesupport metadata __bundle__ = objc.initFrameworkWrapper("LightAquaBlue", frameworkIdentifier="com.blammit.LightAquaBlue", frameworkPath=objc.pathForFramework(_FRAMEWORK_PATH), globals=globals()) except AttributeError: # earlier versions use loadBundle() and setSignatureForSelector() objc.loadBundle("LightAquaBlue", globals(), bundle_path=objc.pathForFramework(_FRAMEWORK_PATH)) # return int, take (object, object, object, output unsigned char, output int) # i.e. in python: return (int, char, int), take (object, object, object) objc.setSignatureForSelector("BBServiceAdvertiser", "addRFCOMMServiceDictionary:withName:UUID:channelID:serviceRecordHandle:", "i@0:@@@o^Co^I") # set to take (6-char array, unsigned char, object) # this seems to work even though the selector doesn't take a char aray, # it takes a struct 'BluetoothDeviceAddress' which contains a char array. objc.setSignatureForSelector("BBBluetoothOBEXClient", "initWithRemoteDeviceAddress:channelID:delegate:", '@@:r^[6C]C@') del objc
except (AttributeError, ValueError): # earlier versions use loadBundle() and setSignatureForSelector() objc.loadBundle( "IOBluetooth", globals(), bundle_path=objc.pathForFramework( '/System/Library/Frameworks/IOBluetooth.framework')) # Sets selector signatures in order to receive arguments correctly from # PyObjC methods. These MUST be set, otherwise the method calls won't work # at all, mostly because you can't pass by pointers in Python. # set to return int, and take an unsigned char output arg # i.e. in python: return (int, unsigned char) and accept no args objc.setSignatureForSelector("IOBluetoothSDPServiceRecord", "getRFCOMMChannelID:", "i12@0:o^C") # set to return int, and take an unsigned int output arg # i.e. in python: return (int, unsigned int) and accept no args objc.setSignatureForSelector("IOBluetoothSDPServiceRecord", "getL2CAPPSM:", "i12@0:o^S") # set to return int, and take (output object, unsigned char, object) args # i.e. in python: return (int, object) and accept (unsigned char, object) objc.setSignatureForSelector( "IOBluetoothDevice", "openRFCOMMChannelSync:withChannelID:delegate:", "i16@0:o^@C@") # set to return int, and take (output object, unsigned int, object) args # i.e. in python: return (int, object) and accept (unsigned int, object) objc.setSignatureForSelector("IOBluetoothDevice",
try: # mac os 10.5 loads frameworks using bridgesupport metadata __bundle__ = objc.initFrameworkWrapper( "LightAquaBlue", frameworkIdentifier="com.blammit.LightAquaBlue", frameworkPath=objc.pathForFramework(_FRAMEWORK_PATH), globals=globals()) except AttributeError: # earlier versions use loadBundle() and setSignatureForSelector() objc.loadBundle("LightAquaBlue", globals(), bundle_path=objc.pathForFramework(_FRAMEWORK_PATH)) # return int, take (object, object, object, output unsigned char, output int) # i.e. in python: return (int, char, int), take (object, object, object) objc.setSignatureForSelector( "BBServiceAdvertiser", "addRFCOMMServiceDictionary:withName:UUID:channelID:serviceRecordHandle:", "i@0:@@@o^Co^I") # set to take (6-char array, unsigned char, object) # this seems to work even though the selector doesn't take a char aray, # it takes a struct 'BluetoothDeviceAddress' which contains a char array. objc.setSignatureForSelector( "BBBluetoothOBEXClient", "initWithRemoteDeviceAddress:channelID:delegate:", '@@:r^[6C]C@') del objc
"/System/Library/Frameworks/IOBluetooth.framework"), globals=globals()) except (AttributeError, ValueError): # earlier versions use loadBundle() and setSignatureForSelector() objc.loadBundle("IOBluetooth", globals(), bundle_path=objc.pathForFramework('/System/Library/Frameworks/IOBluetooth.framework')) # Sets selector signatures in order to receive arguments correctly from # PyObjC methods. These MUST be set, otherwise the method calls won't work # at all, mostly because you can't pass by pointers in Python. # set to return int, and take an unsigned char output arg # i.e. in python: return (int, unsigned char) and accept no args objc.setSignatureForSelector("IOBluetoothSDPServiceRecord", "getRFCOMMChannelID:", "i12@0:o^C") # set to return int, and take an unsigned int output arg # i.e. in python: return (int, unsigned int) and accept no args objc.setSignatureForSelector("IOBluetoothSDPServiceRecord", "getL2CAPPSM:", "i12@0:o^S") # set to return int, and take (output object, unsigned char, object) args # i.e. in python: return (int, object) and accept (unsigned char, object) objc.setSignatureForSelector("IOBluetoothDevice", "openRFCOMMChannelSync:withChannelID:delegate:", "i16@0:o^@C@") # set to return int, and take (output object, unsigned int, object) args # i.e. in python: return (int, object) and accept (unsigned int, object) objc.setSignatureForSelector("IOBluetoothDevice", "openL2CAPChannelSync:withPSM:delegate:", "i20@0:o^@I@")