Bonjour,

J'ai trouvé un exemple de client Bluetooth RFCOMM pour macOS sur GitHub.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
sppServiceUUID = [IOBluetoothSDPUUID uuid16:kBluetoothSDPUUID16ServiceClassSerialPort];
[deviceSelector addAllowedUUID:sppServiceUUID];
if ( [deviceSelector runModal] != kIOBluetoothUISuccess ) {
    [self log: @"User has cancelled the device selection.\n" ];
    return;
}
deviceArray = [deviceSelector getResults];
if ( ( deviceArray == nil ) || ( [deviceArray count] == 0 ) ) {
    [self log: @"Error - no selected device.  ***This should never happen.***\n" ];
    return;
}
IOBluetoothDevice *device = [deviceArray objectAtIndex:0];
IOBluetoothSDPServiceRecord *sppServiceRecord = [device getServiceRecordForUUID:sppServiceUUID];
if ( sppServiceRecord == nil ) {
    [self log: @"Error - no spp service in selected device.  ***This should never happen since the selector forces the user to select only devices with spp.***\n" ];
    return;
}
// To connect we need a device to connect and an RFCOMM channel ID to open on the device:
UInt8   rfcommChannelID;
if ( [sppServiceRecord getRFCOMMChannelID:&rfcommChannelID] != kIOReturnSuccess ) {
    [self log: @"Error - no spp service in selected device.  ***This should never happen an spp service must have an rfcomm channel id.***\n" ];
    return;
}
// Open asyncronously the rfcomm channel when all the open sequence is completed my implementation of "rfcommChannelOpenComplete:" will be called.
if ( ( [device openRFCOMMChannelAsync:&chan withChannelID:rfcommChannelID delegate:self] != kIOReturnSuccess ) && ( chan != nil ) ) {
    // Something went bad (looking at the error codes I can also say what, but for the moment let's not dwell on
    // those details). If the device connection is left open close it and return an error:
    [self log: @"Error - open sequence failed.***\n" ];
    [self close:device];
    return;
}
mRFCOMMChannel = chan;
je me connecte à un serveur Bluetooth RFCOMM sous Windows
maintenant je voudrais trouver un exemple de serveur Bluetooth RFCOMM pour macOS (difficile à trouver).

Merci