FreeBSD Bugzilla – Attachment 213611 Details for
Bug 245769
[PATCH] Bring hccontrol le commands more into line with the other commands
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to bring le.c more into line with the rest. (Without other changes)
hccontrol_le_c_cleanup.diff (text/plain), 5.83 KB, created by
Marc Veldman
on 2020-04-20 17:56:11 UTC
(
hide
)
Description:
Patch to bring le.c more into line with the rest. (Without other changes)
Filename:
MIME Type:
Creator:
Marc Veldman
Created:
2020-04-20 17:56:11 UTC
Size:
5.83 KB
patch
obsolete
>Index: usr.sbin/bluetooth/hccontrol/le.c >=================================================================== >--- usr.sbin/bluetooth/hccontrol/le.c (revision 360121) >+++ usr.sbin/bluetooth/hccontrol/le.c (working copy) >@@ -66,13 +66,13 @@ > int window; > int adrtype; > int policy; >- int e, n; >+ int n; > > ng_hci_le_set_scan_parameters_cp cp; > ng_hci_le_set_scan_parameters_rp rp; > > if (argc != 5) >- return USAGE; >+ return (USAGE); > > if (strcmp(argv[0], "active") == 0) > type = 1; >@@ -79,7 +79,7 @@ > else if (strcmp(argv[0], "passive") == 0) > type = 0; > else >- return USAGE; >+ return (USAGE); > > interval = (int)(atof(argv[1])/0.625); > interval = (interval < 4)? 4: interval; >@@ -91,7 +91,7 @@ > else if (strcmp(argv[3], "random") == 0) > adrtype = 1; > else >- return USAGE; >+ return (USAGE); > > if (strcmp(argv[4], "all") == 0) > policy = 0; >@@ -98,7 +98,7 @@ > else if (strcmp(argv[4], "whitelist") == 0) > policy = 1; > else >- return USAGE; >+ return (USAGE); > > cp.le_scan_type = type; > cp.le_scan_interval = interval; >@@ -106,11 +106,19 @@ > cp.le_scan_window = window; > cp.scanning_filter_policy = policy; > n = sizeof(rp); >- e = hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, >+ >+ if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, > NG_HCI_OCF_LE_SET_SCAN_PARAMETERS), >- (void *)&cp, sizeof(cp), (void *)&rp, &n); >+ (void *)&cp, sizeof(cp), (void *)&rp, &n) == ERROR) >+ return (ERROR); > >- return 0; >+ if (rp.status != 0x00) { >+ fprintf(stdout, "Status: %s [%#02x]\n", >+ hci_status2str(rp.status), rp.status); >+ return (FAILED); >+ } >+ >+ return (OK); > } > > static int >@@ -118,27 +126,35 @@ > { > ng_hci_le_set_scan_enable_cp cp; > ng_hci_le_set_scan_enable_rp rp; >- int e, n, enable = 0; >+ int n, enable = 0; > > if (argc != 1) >- return USAGE; >+ return (USAGE); > > if (strcmp(argv[0], "enable") == 0) > enable = 1; > else if (strcmp(argv[0], "disable") != 0) >- return USAGE; >+ return (USAGE); > > n = sizeof(rp); > cp.le_scan_enable = enable; > cp.filter_duplicates = 0; >- e = hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, >+ if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, > NG_HCI_OCF_LE_SET_SCAN_ENABLE), >- (void *)&cp, sizeof(cp), (void *)&rp, &n); >+ (void *)&cp, sizeof(cp), >+ (void *)&rp, &n) == ERROR) >+ return (ERROR); > >- if (e != 0 || rp.status != 0) >- return ERROR; >+ if (rp.status != 0x00) { >+ fprintf(stdout, "Status: %s [%#02x]\n", >+ hci_status2str(rp.status), rp.status); >+ return (FAILED); >+ } > >- return OK; >+ fprintf(stdout, "LE Scan: %s\n", >+ enable? "Enabled" : "Disabled"); >+ >+ return (OK); > } > > static int >@@ -193,7 +209,7 @@ > done: > *len = curbuf - buf; > >- return OK; >+ return (OK); > } > > static int >@@ -202,7 +218,6 @@ > ng_hci_le_set_scan_response_data_cp cp; > ng_hci_le_set_scan_response_data_rp rp; > int n; >- int e; > int len; > char buf[NG_HCI_ADVERTISING_DATA_SIZE]; > >@@ -212,13 +227,19 @@ > cp.scan_response_data_length = len; > memcpy(cp.scan_response_data, buf, len); > n = sizeof(rp); >- e = hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, >+ if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, > NG_HCI_OCF_LE_SET_SCAN_RESPONSE_DATA), >- (void *)&cp, sizeof(cp), (void *)&rp, &n); >+ (void *)&cp, sizeof(cp), >+ (void *)&rp, &n) == ERROR) >+ return (ERROR); > >- printf("SET SCAN RESPONSE %d %d %d\n", e, rp.status, n); >+ if (rp.status != 0x00) { >+ fprintf(stdout, "Status: %s [%#02x]\n", >+ hci_status2str(rp.status), rp.status); >+ return (FAILED); >+ } > >- return OK; >+ return (OK); > } > > static int >@@ -255,7 +276,7 @@ > buffer, sizeof(buffer))); > fprintf(stdout, "\n"); > >- return OK; >+ return (OK); > } > > static int >@@ -286,7 +307,7 @@ > { > ng_hci_le_set_event_mask_cp semc; > ng_hci_le_set_event_mask_rp rp; >- int i, n ,e; >+ int i, n; > > n = sizeof(rp); > >@@ -294,11 +315,18 @@ > semc.event_mask[i] = mask&0xff; > mask >>= 8; > } >- e = hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, >+ if(hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, > NG_HCI_OCF_LE_SET_EVENT_MASK), >- (void *)&semc, sizeof(semc), (void *)&rp, &n); >+ (void *)&semc, sizeof(semc), (void *)&rp, &n) == ERROR) >+ return (ERROR); >+ >+ if (rp.status != 0x00) { >+ fprintf(stdout, "Status: %s [%#02x]\n", >+ hci_status2str(rp.status), rp.status); >+ return (FAILED); >+ } > >- return 0; >+ return (OK); > } > > static int >@@ -306,7 +334,7 @@ > { > ng_hci_set_event_mask_cp semc; > ng_hci_set_event_mask_rp rp; >- int i, n, e; >+ int i, n; > > n = sizeof(rp); > >@@ -314,29 +342,48 @@ > semc.event_mask[i] = mask&0xff; > mask >>= 8; > } >- e = hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, >+ if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, > NG_HCI_OCF_SET_EVENT_MASK), >- (void *)&semc, sizeof(semc), (void *)&rp, &n); >+ (void *)&semc, sizeof(semc), (void *)&rp, &n) == ERROR) >+ return (ERROR); >+ >+ if (rp.status != 0x00) { >+ fprintf(stdout, "Status: %s [%#02x]\n", >+ hci_status2str(rp.status), rp.status); >+ return (FAILED); >+ } > >- return 0; >+ return (OK); > } > > static > int le_enable(int s, int argc, char *argv[]) > { >+ int result; >+ > if (argc != 1) >- return USAGE; >+ return (USAGE); > > if (strcasecmp(argv[0], "enable") == 0) { >- set_event_mask(s, NG_HCI_EVENT_MASK_DEFAULT | >+ result = set_event_mask(s, NG_HCI_EVENT_MASK_DEFAULT | > NG_HCI_EVENT_MASK_LE); >- set_le_event_mask(s, NG_HCI_LE_EVENT_MASK_ALL); >- } else if (strcasecmp(argv[0], "disable") == 0) >- set_event_mask(s, NG_HCI_EVENT_MASK_DEFAULT); >- else >- return USAGE; >- >- return OK; >+ if (result != OK) >+ return result; >+ result = set_le_event_mask(s, NG_HCI_LE_EVENT_MASK_ALL); >+ if (result == OK) { >+ fprintf(stdout, "LE enabled\n"); >+ return (OK); >+ } else >+ return result; >+ } else if (strcasecmp(argv[0], "disable") == 0) { >+ result = set_event_mask(s, NG_HCI_EVENT_MASK_DEFAULT); >+ if (result == OK) { >+ fprintf(stdout, "LE disabled\n"); >+ return (OK); >+ } else >+ return result; >+ } else >+ return (USAGE); > } > > struct hci_command le_commands[] = {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 245769
:
213610
| 213611 |
213800