X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=libaltos%2Flibaltos_windows.c;h=33eb77c7ac7c1149f4e03823e8218ca49e399989;hb=01b5d271d21e0c60508c06f4af1ff34bf75bf9fe;hp=0c1f6782fd58f167be01d53a112dede4d04a426f;hpb=4e07392c65ec512e3309d89c7465c1406a941b66;p=fw%2Faltos diff --git a/libaltos/libaltos_windows.c b/libaltos/libaltos_windows.c index 0c1f6782..33eb77c7 100644 --- a/libaltos/libaltos_windows.c +++ b/libaltos/libaltos_windows.c @@ -132,12 +132,13 @@ altos_ftdi_list_start(void) } static struct { - char *windows; - char *real; + unsigned int vid, pid; + char *name; } name_map[] = { - { .windows = "AltusMetrum28", .real = "EasyMega" }, - { .windows = "AltusMetrum2c", .real = "EasyMotor" }, - { 0, 0 }, + { .vid = 0xfffe, .pid = 0x000d, .name = "EasyTimer" }, + { .vid = 0xfffe, .pid = 0x0028, .name = "EasyMega" }, + { .vid = 0xfffe, .pid = 0x002c, .name = "EasyMotor" }, + { .name = NULL }, }; PUBLIC int @@ -240,11 +241,22 @@ altos_list_next(struct altos_list *list, struct altos_device *device) altos_set_last_windows_error(); continue; } - for (i = 0; name_map[i].windows; i++) - if (!strcmp(name_map[i].windows, friendlyname)) { - strcpy(friendlyname, name_map[i].real); + + char *space = friendlyname; + while (*space) { + if (*space == ' ') { + *space = '\0'; break; } + space++; + } + + for (i = 0; name_map[i].name; i++) { + if (name_map[i].vid == vid && name_map[i].pid == pid) { + strcpy(friendlyname, name_map[i].name); + break; + } + } device->vendor = vid; device->product = pid; @@ -745,6 +757,7 @@ altos_bt_open(struct altos_bt_device *device) struct altos_file_windows *file; SOCKADDR_BTH sockaddr_bth; int ret; + int channel = 0; file = calloc(1, sizeof (struct altos_file_windows)); if (!file) { @@ -763,7 +776,12 @@ altos_bt_open(struct altos_bt_device *device) memset(&sockaddr_bth, '\0', sizeof (sockaddr_bth)); sockaddr_bth.addressFamily = AF_BTH; sockaddr_bth.btAddr = str2ba(device->addr); - sockaddr_bth.port = altos_bt_port(device); + + channel = altos_bt_port(device); + if (channel == 0) + channel = BT_PORT_DEFAULT; + + sockaddr_bth.port = channel; ret = connect(file->socket, (SOCKADDR *) &sockaddr_bth, sizeof (sockaddr_bth));