Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

WindowsBlueToothSocketMBS.Accept(byref RemoteAddress as String, byref RemotePort as Integer, NewSocket as WindowsBlueToothSocketMBS) as WindowsBlueToothSocketMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Bluetooth MBS Bluetooth Plugin 18.1 No Yes No Yes, Windows only No
Function: Accepts a new incoming connection.
Notes:
Bluetooth uses the accept function to enable incoming connection attempts on a socket.
RemoteAddress and RemotePort are set to address of remote peer.

If you like to pass in your own subclass object for NewSocket, we can use that socket object. Otherwise, we make a new WindowsBlueToothSocketMBS object.

Lasterror is set.

Feedback, Comments & Corrections

WindowsBlueToothSocketMBS.Bind(Port as Integer = -1, BluetoothAddress as string = "")
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Bluetooth MBS Bluetooth Plugin 18.1 No Yes No Yes, Windows only No
Function: Binds to a port and optional address.
Notes:
Lasterror is set.
BindAddress and BindPort are set.
BluetoothAddress: When used with the bind function, must be "" or a valid local radio address.
Port: Must be -1 for automatic or valid port from 1 to 30.

On client applications, the port member must be zero to enable an appropriate local endpoint to be assigned. On server applications, the port member must be a valid port number or kPortAny; ports automatically assigned using kPortAny may be queried subsequently with a call to the getsockname function. The valid range for requesting a specific RFCOMM port is 1 through 30. Server channels are global resource, and only 30 server channels are available for RFCOMM on any Bluetooth device, which must be shared by all Windows Sockets that belong to the Bluetooth address family. If no server channel is available, or if the specified server channel is already reserved, the bind call fails.

Upon successful return from bind, the server channel is reserved until the socket is closed. Use the getsockname function to retrieve the channel number for SDP registration.

Applications should use auto-allocation for the server channel.
The bind function does not automatically advertise the server application using the Bluetooth SDP; applications must call the Publish function.

Feedback, Comments & Corrections

WindowsBlueToothSocketMBS.Close
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Bluetooth MBS Bluetooth Plugin 18.3 No Yes No Yes, Windows only No
Function: Closes socket.
Notes:
Called by destructor.
Does also UnpublishRecord if needed.

Feedback, Comments & Corrections

WindowsBlueToothSocketMBS.Connect(BluetoothAddress as string, Port as Integer, ServiceClassGUID as String = "")
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Bluetooth MBS Bluetooth Plugin 18.1 No Yes No Yes, Windows only No
Function: Connects to a bluetooth device.
Notes:
Valid ports in range 1 to 31.
Lasterror is set.

BluetoothAddress: Address of the target Bluetooth device. If zero, a valid local Bluetooth device address is assigned when the connect or accept function is called. When used with the connect function, a valid remote radio address must be specified.
serviceClassId

Service Class Identifier of the socket. When used with the bind function, serviceClassId is ignored. Also ignored if the port is specified. For the connect function, specifies the unique Bluetooth service class ID of the service to which it wants to connect. If the peer device has more than one port that corresponds to the service class identifier, the connect function attempts to connect to the first valid service; this mechanism can be used without prior SDP queries.
port: RFCOMM channel associated with the socket.

Feedback, Comments & Corrections

WindowsBlueToothSocketMBS.Constructor
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Bluetooth MBS Bluetooth Plugin 18.1 No Yes No Yes, Windows only No
Function: Creates a new socket.
Notes: Socket address type is always AF_BTH, type is SOCK_STREAM and protocol is BTHPROTO_RFCOMM.

Feedback, Comments & Corrections

WindowsBlueToothSocketMBS.Listen(BackLog as Integer = 2)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Bluetooth MBS Bluetooth Plugin 18.1 No Yes No Yes, Windows only No
Function: Listens for connections on this socket.
Notes: Lasterror is set.

Feedback, Comments & Corrections

WindowsBlueToothSocketMBS.Poll
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Bluetooth MBS Bluetooth Plugin 18.1 No Yes No Yes, Windows only No
Function: Polls for new events.
Notes:
May call NewConnection or DataAvailable event if data is available.
Calls SendComplete when sending is done.
Calls Error event when an error occurred.

This is normally called automatically by a timer for you.
But if you are in a tight loop, you can call it manually.

Feedback, Comments & Corrections

WindowsBlueToothSocketMBS.PublishRecord(SDPRecord as MemoryBlock)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Bluetooth MBS Bluetooth Plugin 18.1 No Yes No Yes, Windows only No
Function: Publish service record.
Notes:
Lasterror is set.
Sets the SDPRecordID property.

Feedback, Comments & Corrections

WindowsBlueToothSocketMBS.Read(size as integer, peek as boolean = false) as String
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Bluetooth MBS Bluetooth Plugin 18.1 No Yes No Yes, Windows only No
Function: Reads data.
Notes:
Please pass in size of desired data length to read.
Lasterror is set.
New data is returned (maybe shorter).
If peek is true, data is not removed from buffers.

Feedback, Comments & Corrections

WindowsBlueToothSocketMBS.ReadAll(peek as boolean = false) as String
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Bluetooth MBS Bluetooth Plugin 18.1 No Yes No Yes, Windows only No
Function: Reads all available data.
Notes:
Lasterror is set.
New data is returned.
If peek is true, data is not removed from buffers.

Feedback, Comments & Corrections

WindowsBlueToothSocketMBS.RegisterService(ServiceClassGUID as String, InstanceName as String, Comment as String = "")
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Bluetooth MBS Bluetooth Plugin 18.1 No Yes No Yes, Windows only No
Function: Registers service.
Notes: Lasterror is set.

Feedback, Comments & Corrections

WindowsBlueToothSocketMBS.Send(data as MemoryBlock) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Bluetooth MBS Bluetooth Plugin 18.1 No Yes No Yes, Windows only No
Function: Sends data.
Notes:
Lasterror is set.
Returns number of bytes sent.
Later raises SendComplete event when sending is done.

See also:

Feedback, Comments & Corrections

WindowsBlueToothSocketMBS.Send(data as String) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Bluetooth MBS Bluetooth Plugin 18.1 No Yes No Yes, Windows only No
Function: Sends data.
Notes:
Lasterror is set.
Returns number of bytes sent.
Later raises SendComplete event when sending is done.

See also:

Feedback, Comments & Corrections

WindowsBlueToothSocketMBS.UnpublishRecord
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Bluetooth MBS Bluetooth Plugin 18.1 No Yes No Yes, Windows only No
Function: Unpublish service record.
Notes:
Lasterror is set.
Clears SDPRecordID property.

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Bluetooth Plugin.




Links
MBS Xojo tutorial videos