ronaldoussoren / pyobjc

The Python <-> Objective-C Bridge with bindings for macOS frameworks
https://pyobjc.readthedocs.io
563 stars 47 forks source link

Question about delegate(IOBluetooth) #614

Open Realbuber opened 4 months ago

Realbuber commented 4 months ago

sorry I am a begineer here,

    @objc.typedSelector(b"v@:@^vQ")
    def rfcommChannelData_data_length_(self, channel, data, length):
        print(f"DATA::{data}")

    @objc.typedSelector(b'v@:@@I')
    def rfcommChannelWriteComplete_refcon_status_(self, rfcommChannel, refcon, status):
        if status == 0:  # kIOReturnSuccess
            print("Data sent successfully.")
        else:
            print("Failed to send data.")

I've tried a lot of way, rfcomm channel can connect and open successfully, also I can send the data to my device and get the call back in delegate method(rfcommChannelWriteComplete_refconstatus), but the read data always failed, I don't know how to trigger the rfcommChannelData_datalength method, am I miss something?