Re: serial over bluetooth question
Maksim Yevmenkin <[email protected]>
| Newsgroups | gmane.os.freebsd.devel.mobile |
|---|---|
| Message-ID | <[email protected]> |
Pav Lucistnik wrote: > two questions: > > 1, how can i open serial connection to remote bluetooth device and how > to use such connection (terminal, gnokii, pilot-link ...) assuming you mean RFCOMM :) to open RFCOMM connection: s = socket(AF_BLUETOOTH, BLUETOOTH_PROTO_RFCOMM); local.rfcomm_len = sizeof(local); local.rfcomm_family = AF_BLUETOOTH memcpy(&local.rfcomm_bdaddr, NG_HCI_BDADDR_ANY, sizeof(bdaddr_t)); local.rfcomm_channel = 0; bind(s, (struct sockaddr *) &local, sizeof(local)); remote.rfcomm_len = sizeof(remote); remote.rfcomm_family = AF_BLUETOOTH; memcpy(&remote.rfcomm_bdaddr, <remote_BD_ADDR>, sizeof(bdaddr_t)); remote.rfcomm_channel = <remote_RFCOMM_channel>; connect(s, (struct sockaddr *) &remote, sizeof(remote)); now <s> is connected to via RFCOMM to the serial port on the other side :) just to read(2)/write(2) to send/receive data. check the sources for rfcomm_pppd(8). what it does is 1) open RFCOMM connection (socket) 2) fork()s 3) redirects RFCOMM socket to stdin/stdout 4) executes PPP in -direct mode (i.e. PPP uses stdin/stdout) if gnokii, pilot-link etc. support "-direct" mode (i.e. they can use stdin/stdout) then you simply repeat steps 1-3 above and execute gnokii, pilot-link etc. in step 4. if not then you can use nmdm(4) driver. connect master side to the RFCOMM socket and use slave side in gnokii, pilot-link etc. > 2, what is hcseriald good for? hcseriald(8) is for supervising serial (i.e. UART-based) Bluetooth devices. such Bluetooth devices (for example Xircom CBT card) are recognized as serial ports (modems) by sio(4) driver. hcseriald(8) opens /dev/cuaa### and pushes H4 line discipline thus coverting serial device into Netgraph node. thanks, max To Unsubscribe: send mail to [email protected] with "unsubscribe freebsd-mobile" in the body of the message