X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=libaltos%2Flibaltos_windows.c;h=33eb77c7ac7c1149f4e03823e8218ca49e399989;hp=03c2958f52bc1a63b1a0dc71c01eb43a82472e8a;hb=3ed101d634968666cd3ee2d8c49737970caf406b;hpb=91ab3acc113dc24e1ebce89875def646e590fb12 diff --git a/libaltos/libaltos_windows.c b/libaltos/libaltos_windows.c index 03c2958f..33eb77c7 100644 --- a/libaltos/libaltos_windows.c +++ b/libaltos/libaltos_windows.c @@ -131,6 +131,16 @@ altos_ftdi_list_start(void) return list; } +static struct { + unsigned int vid, pid; + char *name; +} name_map[] = { + { .vid = 0xfffe, .pid = 0x000d, .name = "EasyTimer" }, + { .vid = 0xfffe, .pid = 0x0028, .name = "EasyMega" }, + { .vid = 0xfffe, .pid = 0x002c, .name = "EasyMotor" }, + { .name = NULL }, +}; + PUBLIC int altos_list_next(struct altos_list *list, struct altos_device *device) { @@ -148,6 +158,7 @@ altos_list_next(struct altos_list *list, struct altos_device *device) DWORD friendlyname_len; char instanceid[1024]; DWORD instanceid_len; + int i; dev_info_data.cbSize = sizeof (SP_DEVINFO_DATA); while(SetupDiEnumDeviceInfo(list->dev_info, list->index, @@ -230,6 +241,23 @@ altos_list_next(struct altos_list *list, struct altos_device *device) altos_set_last_windows_error(); continue; } + + 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; device->serial = serial; @@ -729,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) { @@ -747,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));