Changeset d2323a579f283ed7393c20b762697766d2d01e1f
- Timestamp:
- 04/01/07 20:46:16 (6 years ago)
- Children:
- cc418bb14a0cf2615e57971f52b2a2f07868e3a7
- Parents:
- d7c9be1302a434adc8e9472e1bb70ec5eded1b61
- git-author:
- L. Donnie Smith <donnie.smith@…> (04/01/07 20:46:16)
- git-committer:
- dsmith <dsmith@…> (04/01/07 20:46:16)
- Files:
-
- 1 added
- 6 modified
-
ChangeLog (modified) (1 diff)
-
wiimote/Makefile.in (modified) (1 diff)
-
wiimote/bluetooth.c (added)
-
wiimote/connect.c (modified) (2 diffs)
-
wiimote/util.c (modified) (3 diffs)
-
wiimote/wiimote.h (modified) (3 diffs)
-
wiimote/wiimote_internal.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
rd3094f8 rd2323a5 2 2 wmdemo 3 3 * renamed main.c to wmdemo.c 4 5 wiimote 6 * created bluetooth.c 7 * moved wiimote_findfirst to bluetooth.c, renamed to wiimote_find_wiimote, 8 added timeout argument 9 * defined struct wiimote_info 10 * wrote wiimote_get_info_array 4 11 5 12 2007-03-27 L. Donnie Smith <cwiid@abstrakraft.org> -
wiimote/Makefile.in
r055987a rd2323a5 7 7 MAJOR_VER = 0 8 8 MINOR_VER = 1 9 SOURCES = connect.c command.c event.c rw.c util.c queue.c9 SOURCES = connect.c command.c event.c rw.c bluetooth.c util.c queue.c 10 10 LDLIBS += -lbluetooth -lpthread -lrt 11 11 LIB_INST_DIR = @libdir@ -
wiimote/connect.c
r00aa494 rd2323a5 16 16 * 17 17 * ChangeLog: 18 * 04/01/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 * * changed wiimote_findfirst to wiimote_find_wiimote 20 * 18 21 * 03/14/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * changed memcpy to bacmp … … 79 82 /* If BDADDR_ANY is given, find available wiimote */ 80 83 if (bacmp(&bdaddr, BDADDR_ANY) == 0) { 81 if (wiimote_find first(&bdaddr)) {84 if (wiimote_find_wiimote(&bdaddr, 2)) { 82 85 /* TODO: wiimote functions should print their own errors */ 83 86 wiimote_err(wiimote, "Unable to find wiimote"); -
wiimote/util.c
r00aa494 rd2323a5 16 16 * 17 17 * ChangeLog: 18 * 04/01/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 * * removed wiimote_findfirst (moved to bluetooth.c) 20 * 21 * 03/27/2007: L. Donnie Smith <cwiid@abstrakraft.org> 22 * * moved wiimote_findfirst to bluetooth.c 23 * 18 24 * 03/14/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 25 * * audited error checking (coda and error handler sections) … … 35 41 #include <string.h> 36 42 #include <unistd.h> 37 #include <bluetooth/bluetooth.h>38 #include <bluetooth/hci.h>39 #include <bluetooth/hci_lib.h>40 43 #include "wiimote_internal.h" 41 44 … … 160 163 } 161 164 162 #define MAX_RSP 256163 int wiimote_findfirst(bdaddr_t *bdaddr)164 {165 /* TODO: I suppose we'll have to sift through BlueZ source to properly166 * check errors here...167 */168 int dev_id;169 int sock = -1;170 inquiry_info *dev_list = NULL;171 int i;172 int dev_count;173 int ret = -1;174 char dev_name[WIIMOTE_CMP_LEN];175 176 /* Get the first available Bluetooth device */177 if ((dev_id = hci_get_route(NULL)) == -1) {178 wiimote_err(NULL, "No Bluetooth device found");179 ret = -1;180 goto CODA;181 }182 if ((sock = hci_open_dev(dev_id)) == -1) {183 wiimote_err(NULL, "Error opening Bluetooth device");184 ret = -1;185 goto CODA;186 }187 188 /* Get Device List */189 if ((dev_count = hci_inquiry(dev_id, 2, MAX_RSP, NULL, &dev_list,190 IREQ_CACHE_FLUSH)) == -1) {191 wiimote_err(NULL, "Error on device inquiry");192 ret = -1;193 goto CODA;194 }195 196 /* Check class and name for Wiimotes */197 for (i=0; i < dev_count; i++) {198 if ((dev_list[i].dev_class[0] == WIIMOTE_CLASS_0) &&199 (dev_list[i].dev_class[1] == WIIMOTE_CLASS_1) &&200 (dev_list[i].dev_class[2] == WIIMOTE_CLASS_2)) {201 if (hci_remote_name(sock, &dev_list[i].bdaddr, WIIMOTE_CMP_LEN,202 dev_name, 5000)) {203 wiimote_err(NULL, "Error reading device name");204 }205 else if (strncmp(dev_name, WIIMOTE_NAME, WIIMOTE_CMP_LEN) == 0) {206 *bdaddr = dev_list[i].bdaddr;207 ret = 0;208 break;209 }210 }211 }212 213 CODA:214 if (sock != -1) {215 hci_close_dev(sock);216 }217 if (dev_list) {218 free(dev_list);219 }220 return ret;221 }222 -
wiimote/wiimote.h
ra339960 rd2323a5 16 16 * 17 17 * ChangeLog: 18 * 04/01/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 * * added wiimote_info definition and macros 20 * * added wiimote_get_info_array prototype 21 * * changed wiimote_findfirst to wiimote_find_wiimote 22 * 18 23 * 03/05/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 24 * * added wiimote_err_t definition … … 195 200 typedef void wiimote_err_t(int, const char *, ...); 196 201 202 /* getinfo flags */ 203 #define BT_NO_WIIMOTE_FILTER 0x01 204 #define BT_WM_NAME_LEN 32 205 206 struct wiimote_info { 207 bdaddr_t bdaddr; 208 uint8_t class[3]; 209 char name[BT_WM_NAME_LEN]; 210 }; 211 197 212 #ifdef __cplusplus 198 213 extern "C" { … … 211 226 uint16_t len, const void *data); 212 227 /* int wiimote_beep(wiimote_t *wiimote); */ 213 int wiimote_findfirst(bdaddr_t *bdaddr); 228 int wiimote_get_info_array(int dev_id, unsigned int timeout, int max_wm, 229 struct wiimote_info **wm, uint8_t flags); 230 int wiimote_find_wiimote(bdaddr_t *bdaddr, int timeout); 214 231 215 232 #ifdef __cplusplus -
wiimote/wiimote_internal.h
ra339960 rd2323a5 16 16 * 17 17 * ChangeLog: 18 * 04/01/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 * * removed WIIMOTE_CMP_LEN macro and wiimote_findfirst prototype 20 * 18 21 * 03/05/2007: L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * added wiimote parameter to wiimote_err prototype … … 54 57 /* Wiimote specific magic numbers */ 55 58 #define WIIMOTE_NAME "Nintendo RVL-CNT-01" 56 #define WIIMOTE_CMP_LEN sizeof(WIIMOTE_NAME)57 59 #define WIIMOTE_CLASS_0 0x04 58 60 #define WIIMOTE_CLASS_1 0x25 … … 174 176 struct write_seq *seq); 175 177 void free_mesg_array(struct mesg_array *array); 176 int wiimote_findfirst(bdaddr_t *bdaddr);177 178 178 179 #endif
