* [Bluez-devel] gumstix & bluez (infineon) @ 2005-04-09 19:24 Brad Midgley 2005-04-10 22:15 ` [Bluez-devel] RFCOMM non-blocking support Victor Shcherbatyuk 0 siblings, 1 reply; 3+ messages in thread From: Brad Midgley @ 2005-04-09 19:24 UTC (permalink / raw) To: BlueZ Mailing List Hey I like the specs of the x-scale gumstix 400f-bt for building something like a homebrew bluetooth access point etc. I don't like the fact that it's using a class 2 infineon bluetooth radio. Has anyone had success with infineon and btsco for example? The other alternative is to get a csr class 1 (bluecore4/bt2.0?) chip and tie it into one of the gumstix uarts. I don't have the first clue about getting csr hardware directly... Has anyone else caught the embedded "bug" or is it just me :) Brad ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bluez-devel] RFCOMM non-blocking support 2005-04-09 19:24 [Bluez-devel] gumstix & bluez (infineon) Brad Midgley @ 2005-04-10 22:15 ` Victor Shcherbatyuk 2005-04-11 12:56 ` Marcel Holtmann 0 siblings, 1 reply; 3+ messages in thread From: Victor Shcherbatyuk @ 2005-04-10 22:15 UTC (permalink / raw) To: bluez-devel [-- Attachment #1: Type: text/plain, Size: 510 bytes --] Hi Marcel, This was already discussed a year ago: question: http://sourceforge.net/mailarchive/message.php?msg_id=8643791 reply: http://sourceforge.net/mailarchive/message.php?msg_id=8643793 I have exactly the same problem, I guess. Instead of EINPROGRESS non-blocking connect() returns EAGAIN (Resource temporarily unavailable). The rest seem to be OK (see the source). Select waits till the connection is established or an error occurs (at least as it looks from hcidump log). Regards, Victor. [-- Attachment #2: bluetest.c --] [-- Type: application/octet-stream, Size: 1962 bytes --] #include <stdio.h> #include <errno.h> #include <unistd.h> #include <fcntl.h> #include <sys/socket.h> #include <bluetooth/bluetooth.h> #include <bluetooth/hci.h> #include <bluetooth/hci_lib.h> #include <bluetooth/rfcomm.h> int btopen( const char* addr, int chan ) { struct sockaddr_rc remote_addr, local_addr; bdaddr_t bdaddr; int s, r; str2ba(addr, &bdaddr); if ((s = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)) < 0) { perror("socket()"); return -1; } memset(&local_addr, 0, sizeof(local_addr)); local_addr.rc_family = AF_BLUETOOTH; bacpy(&local_addr.rc_bdaddr, BDADDR_ANY); if (bind(s, (struct sockaddr *)&local_addr, sizeof(local_addr)) < 0) { perror("bind()"); close(s); return -1; } if ( fcntl( s, F_SETFL, fcntl( s, F_GETFL ) | O_NONBLOCK ) < 0 ) perror("fcntl()"); memset(&remote_addr, 0, sizeof(remote_addr)); remote_addr.rc_family = AF_BLUETOOTH; bacpy(&remote_addr.rc_bdaddr, &bdaddr); remote_addr.rc_channel = chan; if ( r = connect(s, (struct sockaddr *)&remote_addr, sizeof(remote_addr)) < 0) perror("connect()"); //here returns -1 with EAGAIN (11) = Resource temporarily unavailable //EINPROGRESS is expected??? return s; } int main( int argc, char** argv ) { int fd, r; fd_set wfds; socklen_t optlen; if ( argc < 3 ) { printf("Use: bluetalk <address> <channel>\n"); exit( 1 ); } printf("Opening socket...\n"); if ( ( fd = btopen( argv[1], atoi( argv[2] ) ) ) < 0 ) exit(1); printf("Waiting for open completion...\n"); r = select(fd + 1, NULL, &wfds, NULL, &tv); if (r<0){ perror("select()"); close(fd); exit(1); } else printf("success\n"); //check if connect() succeded getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&r, &optlen); //here r=0 in case of success or r=errno otherwise printf("len=%d, r=%d\n", optlen, r); printf("Closing socket...\n"); close( fd ); return 0; } ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Bluez-devel] RFCOMM non-blocking support 2005-04-10 22:15 ` [Bluez-devel] RFCOMM non-blocking support Victor Shcherbatyuk @ 2005-04-11 12:56 ` Marcel Holtmann 0 siblings, 0 replies; 3+ messages in thread From: Marcel Holtmann @ 2005-04-11 12:56 UTC (permalink / raw) To: bluez-devel Hi Victor, > This was already discussed a year ago: > question: > http://sourceforge.net/mailarchive/message.php?msg_id=8643791 > reply: > http://sourceforge.net/mailarchive/message.php?msg_id=8643793 > > I have exactly the same problem, I guess. > > Instead of EINPROGRESS non-blocking connect() returns EAGAIN (Resource > temporarily unavailable). The rest seem to be OK (see the source). Select > waits till the connection is established or an error occurs (at least as it > looks from hcidump log). I just checked the code and the problem is the bt_sock_wait_state() function. In the case of O_NONBLOCK we give it a timeout of 0 and this means that it will exit with EAGAIN if sk->sk_state != state. This actually means that also L2CAP is not working correct in the non blocking case. How do we should fix this? The easiest way seems to add another check to bt_sock_wait_state() before entering the while loop: if (!timeo && sk->sk_state != state) return -EINPROGRESS; Another way is to add a flags parameter to this function or deal with it in the L2CAP/RFCOMM connect functions. Regards Marcel ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-04-11 12:56 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-04-09 19:24 [Bluez-devel] gumstix & bluez (infineon) Brad Midgley 2005-04-10 22:15 ` [Bluez-devel] RFCOMM non-blocking support Victor Shcherbatyuk 2005-04-11 12:56 ` Marcel Holtmann
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.