*/
int socket_connect(oal_sock_type_t sock_type, oal_uuid_t* p_uuid, int channel, bt_address_t* bd);
+/**
+ * @fn int socket_listen(oal_sock_type_t sock_type, oal_uuid_t *p_uuid, char *svc_name, int channel);
+ * @brief Creates server socket and start listen for incomming connection.
+ *
+ * This API creates Server socket. It takes UUID and service name.
+ * It returns the server FD on success. There can be multiple SERVERs, with each server having its
+ * unique FD. This function is a synchronous call.
+ *
+ * @param[in] sock_type Bluetooth socket type to be connected
+ * @param[in] p_uuid UUID of the RFCOMM SERVER to be created
+ * @param[in] channel channel
+ * @param[in] svc_name Name for the server
+ * @return Server Socket FD - Success
+ * @remark None
+ */
+int socket_listen(oal_sock_type_t sock_type, oal_uuid_t *p_uuid, char *svc_name, int channel);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
return sock_fd;
}
+int socket_listen(oal_sock_type_t sock_type, oal_uuid_t *p_uuid, char *svc_name, int channel)
+{
+ int sock_fd = -1;
+ int srv_channel;
+ int ret = BT_STATUS_FAIL;
+
+ CHECK_OAL_SOCKET_ENABLED();
+ OAL_CHECK_PARAMETER(svc_name, return);
+ API_TRACE("svc_name: %s", svc_name);
+
+ switch (sock_type) {
+ case OAL_SOCK_RFCOMM:
+ if(channel < 0 )
+ ret = socket_api->listen(BTSOCK_RFCOMM,
+ svc_name, p_uuid->uuid, 0, &sock_fd, 0);
+ else
+ ret = socket_api->listen(BTSOCK_RFCOMM,
+ svc_name, p_uuid->uuid, channel, &sock_fd, 0);
+ break;
+ default:
+ BT_ERR("Socket type: %d not supported");
+ }
+
+ if(sock_fd < 0 || ret != BT_STATUS_SUCCESS) {
+ BT_ERR("Bluetooth socket creation failed");
+ return sock_fd;
+ }
+
+ BT_INFO("Bluetooth server socket created, sock_fd=%d", sock_fd);
+
+ /* Read server channel number sent by stack */
+ srv_channel = sock_wait_for_channel(sock_fd);
+ if(srv_channel < 0) {
+ BT_ERR("incorrect channel= %d", srv_channel);
+ return -1;
+ }
+
+ BT_INFO("server channel= %d", srv_channel);
+
+ return sock_fd;
+}
+
oal_status_t socket_enable()
{
const bt_interface_t *blued_api;