Open a Serial Port Profile (SPP) server.
int bt_spp_open_server(char *service_name, char *service_uuid, bool nonblock, void(*callback)(long param, int fd), long param)
The name of the service to appear in the service's Service Discovery Protocol (SDP) record. The maximal length is 50 including the terminating NULL character. If this argument is empty or set to NULL, the default service name that appears in the SDP record is "SPP Service".
The Universally Unique Identifier (UUID) of the service to register. Note that this is the service ID defined by the developer, not the Service Class ID assigned by the Bluetooth organization. For example, the SPP profile has a 4-digit Service Class ID of 0x1101. A developer can create multiple services for this service class, and must define a unique service ID for each of the services. The service ID must be in the following format: 8-4-4-4-12, where each digit indicates the number of hexadecimal digits. For example, a valid service ID can be: 00001101-1111-2222-3333-444444444444. UUID 00001101-0000-1000-8000-00805f9b34fb is reserved by the Bluetooth organization as the Service Class ID for SPP. We do not recommend that you use it on the server side as the service ID for a newly defined service, as it cannot guarantee the uniqueness of the service.
A flag that specifies whether to open a mount point of the connection in non-blocking mode. A value of true will open the connection in non-blocking mode.
The user's parameter as the first argument of the returned callback.
A pointer to a valid callback function that provides the mount point file descriptor. The mount point file descriptor is available when the SPP server has accepted incoming connections. In case of a failure, the file descriptor returns with a value of -1 and errno is set with the reason.
Library:libbtapi (For the qcc command, use the -l btapi option to link against this library)
This function registers a service record and starts a thread to listen for incoming connections. When an incoming connection is accepted, a callback gets called with a valid mount point file descriptor as the argument. If the connection is not accepted, the callback returns an invalid file descriptor (-1). You cannot register two services with the same UUID even if the service names are different.
- EINVAL: Invalid arguments were specified.
- EPERM: The bt_spp_init() function has not been called or has failed.
- ENONMEM: There is insufficient memory to allocate to complete the function.
- ESRVRFAULT: The operation was aborted by the user.
- EBADMSG: There was an error parsing the incoming message.
- EMLINK: A service with the same service_uuid has already been registered.
- ENODATA: A failure occurred because an error occurred on the stack.
Last modified: 2014-05-14