* [Bluez-devel] hcitool feature patch
@ 2005-12-05 18:14 Jim Wyllie
2005-12-05 18:44 ` Albert Huang
0 siblings, 1 reply; 3+ messages in thread
From: Jim Wyllie @ 2005-12-05 18:14 UTC (permalink / raw)
To: bluez-devel
[-- Attachment #1: Type: text/plain, Size: 365 bytes --]
I had to write a program which changed the flush timeout for a Bluetooth
connection. I integrated it into my version of hcitool since that
seemed the appropriate place for it. The patch applies to hcitool in
bluez-utils 2.22, and adds the 'ftmo' option (for flush timeout). Let
me know if you want me to make any changes.
Jim Wyllie
IRG Lab
Ohio University
[-- Attachment #2: hcitool.patch --]
[-- Type: text/plain, Size: 2753 bytes --]
966a967,1089
> /* Alter connection timeout (for all connections, unfortunately) */
>
> static struct option ftmo_options[] = {
> { "help", 0, 0, 'h' },
> { "tmout", 1, 0, 't' },
> { 0, 0, 0, 0 }
> };
>
> static char *ftmo_help =
> "Usage:\n"
> "\tftmo --tmout=value bdaddr\n"
> "Sets the flush timeout value to 0.625msec * value for bdaddr\n"
> "Will change reliability for all connections from microcontroller\n";
>
> static void cmd_ftmo(int dev_id, int argc, char **argv)
> {
> int err = 0, dd, opt, timeout;
> struct hci_conn_info_req *cr = 0;
> struct hci_request rq = { 0 };
> bdaddr_t *ba;
>
> struct {
> uint16_t handle;
> uint16_t flush_timeout;
> } cmd_param;
>
> struct {
> uint8_t status;
> uint16_t handle;
> } cmd_response;
>
> for_each_opt(opt, ftmo_options, NULL) {
> switch (opt) {
>
> case 't':
> timeout = atoi( optarg );
>
> if( timeout < 0) {
> printf("Must be 1 or greater, or 0 for no timeout\n");
> printf(ftmo_help);
> }
>
> break;
>
> default:
> printf(ftmo_help);
> return;
> }
> }
>
> argc -= optind;
> argv += optind;
>
> if (argc < 1) {
> printf(ftmo_help);
> return;
> }
>
> ba = (bdaddr_t *)malloc( sizeof( bdaddr_t ) );
> str2ba(argv[0], ba);
>
> if (dev_id < 0) {
> dev_id = hci_get_route(ba);
> if (dev_id < 0) {
> perror("Error in obtaining route to device\n");
> return;
> }
> }
>
> // find the connection handle to the specified bluetooth device
> cr = (struct hci_conn_info_req*) malloc(
> sizeof(struct hci_conn_info_req) +
> sizeof(struct hci_conn_info));
>
> bacpy( &cr->bdaddr, ba );
>
> cr->type = ACL_LINK;
>
> dd = hci_open_dev( dev_id );
>
> if( dd < 0 ) {
> err = dd;
> goto cleanup;
> }
>
> err = ioctl(dd, HCIGETCONNINFO, (unsigned long) cr );
>
> if( err ) {
> fprintf(stderr, "Could not get connection handle, is one established yet?\n");
> goto cleanup;
> }
>
> // build a command packet to send to the bluetooth microcontroller
> cmd_param.handle = cr->conn_info->handle;
> cmd_param.flush_timeout = htobs(timeout);
> rq.ogf = OGF_HOST_CTL;
> rq.ocf = 0x28;
> rq.cparam = &cmd_param;
> rq.clen = sizeof(cmd_param);
> rq.rparam = &cmd_response;
> rq.rlen = sizeof(cmd_response);
> rq.event = EVT_CMD_COMPLETE;
>
> // send the command and wait for the response
> err = hci_send_req( dd, &rq, 0 );
>
> if( err ) {
> perror("Could not send request to the microcontroller");
> goto cleanup;
> }
>
> if( cmd_response.status ) {
> err = -1;
> errno = bt_error(cmd_response.status);
> }
>
> cleanup:
> free(cr);
> if( dd >= 0)
> close(dd);
> return;
> }
>
2055a2179
> { "ftmo", cmd_ftmo, "Modify microcontroller flush timeout" },
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Bluez-devel] hcitool feature patch
2005-12-05 18:14 [Bluez-devel] hcitool feature patch Jim Wyllie
@ 2005-12-05 18:44 ` Albert Huang
2005-12-05 21:30 ` Marcel Holtmann
0 siblings, 1 reply; 3+ messages in thread
From: Albert Huang @ 2005-12-05 18:44 UTC (permalink / raw)
To: bluez-devel
[-- Attachment #1: Type: text/plain, Size: 4520 bytes --]
oh gee, I dunno. Marcel hates my coding style ;)
better might be to patch the bluez-libs and then patch hcitool to call a
library function.
-albert
On 12/5/05, Jim Wyllie <jwyllie@masaka.cs.ohiou.edu> wrote:
>
> I had to write a program which changed the flush timeout for a Bluetooth
> connection. I integrated it into my version of hcitool since that
> seemed the appropriate place for it. The patch applies to hcitool in
> bluez-utils 2.22, and adds the 'ftmo' option (for flush timeout). Let
> me know if you want me to make any changes.
>
> Jim Wyllie
> IRG Lab
> Ohio University
>
>
> 966a967,1089
> > /* Alter connection timeout (for all connections, unfortunately) */
> >
> > static struct option ftmo_options[] = {
> > { "help", 0, 0, 'h' },
> > { "tmout", 1, 0, 't' },
> > { 0, 0, 0, 0 }
> > };
> >
> > static char *ftmo_help =
> > "Usage:\n"
> > "\tftmo --tmout=value bdaddr\n"
> > "Sets the flush timeout value to 0.625msec * value for bdaddr\n"
> > "Will change reliability for all connections from
> microcontroller\n";
> >
> > static void cmd_ftmo(int dev_id, int argc, char **argv)
> > {
> > int err = 0, dd, opt, timeout;
> > struct hci_conn_info_req *cr = 0;
> > struct hci_request rq = { 0 };
> > bdaddr_t *ba;
> >
> > struct {
> > uint16_t handle;
> > uint16_t flush_timeout;
> > } cmd_param;
> >
> > struct {
> > uint8_t status;
> > uint16_t handle;
> > } cmd_response;
> >
> > for_each_opt(opt, ftmo_options, NULL) {
> > switch (opt) {
> >
> > case 't':
> > timeout = atoi( optarg );
> >
> > if( timeout < 0) {
> > printf("Must be 1 or greater, or 0 for no
> timeout\n");
> > printf(ftmo_help);
> > }
> >
> > break;
> >
> > default:
> > printf(ftmo_help);
> > return;
> > }
> > }
> >
> > argc -= optind;
> > argv += optind;
> >
> > if (argc < 1) {
> > printf(ftmo_help);
> > return;
> > }
> >
> > ba = (bdaddr_t *)malloc( sizeof( bdaddr_t ) );
> > str2ba(argv[0], ba);
> >
> > if (dev_id < 0) {
> > dev_id = hci_get_route(ba);
> > if (dev_id < 0) {
> > perror("Error in obtaining route to device\n");
> > return;
> > }
> > }
> >
> > // find the connection handle to the specified bluetooth device
> > cr = (struct hci_conn_info_req*) malloc(
> > sizeof(struct hci_conn_info_req) +
> > sizeof(struct hci_conn_info));
> >
> > bacpy( &cr->bdaddr, ba );
> >
> > cr->type = ACL_LINK;
> >
> > dd = hci_open_dev( dev_id );
> >
> > if( dd < 0 ) {
> > err = dd;
> > goto cleanup;
> > }
> >
> > err = ioctl(dd, HCIGETCONNINFO, (unsigned long) cr );
> >
> > if( err ) {
> > fprintf(stderr, "Could not get connection handle, is one
> established yet?\n");
> > goto cleanup;
> > }
> >
> > // build a command packet to send to the bluetooth microcontroller
> > cmd_param.handle = cr->conn_info->handle;
> > cmd_param.flush_timeout = htobs(timeout);
> > rq.ogf = OGF_HOST_CTL;
> > rq.ocf = 0x28;
> > rq.cparam = &cmd_param;
> > rq.clen = sizeof(cmd_param);
> > rq.rparam = &cmd_response;
> > rq.rlen = sizeof(cmd_response);
> > rq.event = EVT_CMD_COMPLETE;
> >
> > // send the command and wait for the response
> > err = hci_send_req( dd, &rq, 0 );
> >
> > if( err ) {
> > perror("Could not send request to the microcontroller");
> > goto cleanup;
> > }
> >
> > if( cmd_response.status ) {
> > err = -1;
> > errno = bt_error(cmd_response.status);
> > }
> >
> > cleanup:
> > free(cr);
> > if( dd >= 0)
> > close(dd);
> > return;
> > }
> >
> 2055a2179
> > { "ftmo", cmd_ftmo, "Modify microcontroller flush timeout" },
>
>
>
[-- Attachment #2: Type: text/html, Size: 10094 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Bluez-devel] hcitool feature patch
2005-12-05 18:44 ` Albert Huang
@ 2005-12-05 21:30 ` Marcel Holtmann
0 siblings, 0 replies; 3+ messages in thread
From: Marcel Holtmann @ 2005-12-05 21:30 UTC (permalink / raw)
To: bluez-devel
Hi Albert,
> better might be to patch the bluez-libs and then patch hcitool to call
> a library function.
correct and please use unified diffs.
Regards
Marcel
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&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-12-05 21:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-05 18:14 [Bluez-devel] hcitool feature patch Jim Wyllie
2005-12-05 18:44 ` Albert Huang
2005-12-05 21:30 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).