/** * Force Bluetooth stack to listen for incoming client connections. * * Note: the method gets native connection handle directly from * <code>handle<code> field of <code>L2CAPNotifierImpl</code> object. * * @throws IOException if an I/O error occurs */ KNIEXPORT KNI_RETURNTYPE_VOID Java_com_sun_midp_io_j2me_btl2cap_L2CAPNotifierImpl_listen0(void) { javacall_handle handle = BT_INVALID_HANDLE; REPORT_INFO(LC_PROTOCOL, "btl2cap_notif::listen"); KNI_StartHandles(1); KNI_DeclareHandle(thisHandle); KNI_GetThisPointer(thisHandle); if (KNI_GetIntField(thisHandle, pushHandleID) == BT_INVALID_PUSH_HANDLE) { handle = (javacall_handle)KNI_GetIntField(thisHandle, notifHandleID); /* force listening */ if (javacall_bt_l2cap_listen(handle) == JAVACALL_FAIL) { javacall_bt_l2cap_close(handle); REPORT_ERROR(LC_PROTOCOL, "L2CAP notifier listen failed in btl2cap_notif::listen"); KNI_ThrowNew(midpIOException, EXCEPTION_MSG("L2CAP notifier listen failed")); } else { REPORT_INFO(LC_PROTOCOL, "btl2cap_notif::listen done!"); } } KNI_EndHandles(); KNI_ReturnVoid(); }
javacall_handle bt_push_start_server(const bt_port_t *port) { int psm, cn; bt_params_t *params; bt_push_t *push = find_push(port, NULL); if (push == NULL || push->server != BT_INVALID_HANDLE) { return BT_INVALID_HANDLE; } if (javacall_bt_sddb_update_record(&push->record.id, push->record.classes, push->record.data, push->record.size) != JAVACALL_OK) { return BT_INVALID_HANDLE; } params = &push->params; switch (port->protocol) { case BT_L2CAP: if (javacall_bt_l2cap_create_server(params->rmtu, params->tmtu, params->authenticate, params->authorize, params->encrypt, params->master, &push->server, &psm) != JAVACALL_OK) { return BT_INVALID_HANDLE; } javacall_bt_sddb_update_psm(push->record.id, psm); javacall_bt_l2cap_listen(push->server); break; case BT_SPP: case BT_GOEP: if (javacall_bt_rfcomm_create_server(params->authenticate, params->authorize, params->encrypt, params->master, &push->server, &cn) != JAVACALL_OK) { return BT_INVALID_HANDLE; } javacall_bt_sddb_update_channel(push->record.id, cn); javacall_bt_rfcomm_listen(push->server); break; default: return BT_INVALID_HANDLE; } javacall_bt_stack_set_service_classes(javacall_bt_sddb_get_service_classes(0)); return push->server; }
/** * Puts server connection to listening mode. * * @param handle server connection handle * @retval JAVACALL_OK on success, * @retval JAVACALL_FAIL otherwise */ javacall_result javacall_bt_rfcomm_listen( javacall_handle handle) { return javacall_bt_l2cap_listen(handle); }