From 8f3c91e91b634adaca77dac6cf314445cceefc78 Mon Sep 17 00:00:00 2001 From: Jonathan McCrohan Date: Fri, 19 Oct 2012 19:38:06 +0100 Subject: Imported Upstream version 2.1.8.20120912 --- zeroconf.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'zeroconf.c') diff --git a/zeroconf.c b/zeroconf.c index 81b030c..c4a3c05 100644 --- a/zeroconf.c +++ b/zeroconf.c @@ -229,6 +229,13 @@ void PhidFromTXT(CPhidgetHandle phid, uint16_t txtLen, const char *txtRecord) ZEROMEM(phid->networkInfo->zeroconf_server_id, valLen+1); memcpy(phid->networkInfo->zeroconf_server_id, valPtr, valLen); + if(txtver >= 3) + { + //USB Product String + if(!(valPtr = TXTRecordGetValuePtrPtr(txtLen, txtRecord, "usbstr", &valLen))) return; + memcpy(phid->usbProduct, valPtr, valLen); + } + // things added in version 2 of the txt if(txtver >= 2) { @@ -250,8 +257,9 @@ void PhidFromTXT(CPhidgetHandle phid, uint16_t txtLen, const char *txtRecord) phid->deviceID = strtol(temp, NULL, 10); phid->deviceType = Phid_DeviceName[phid->deviceID]; } + //Old version uses string searching, but some devices have the same name with different IDs - else + if(txtver == 1) { char *name = NULL; char *type = NULL; @@ -284,6 +292,7 @@ void PhidFromTXT(CPhidgetHandle phid, uint16_t txtLen, const char *txtRecord) } phid->deviceUID = CPhidget_getUID(phid->deviceIDSpec, phid->deviceVersion); + phid->networkInfo->mdns = PTRUE; } @@ -511,7 +520,18 @@ void DNSServiceBrowse_Phidget_CallBack(DNSServiceRef service, { //have to fill in phid manually from just the name int i; - char *name_copy = strdup(name); + char *name_copy; + + //Look to see if this is a 'firmware upgrade' device. + if(name[0] == '1') + { + char *realname = strchr(name, ' '); + if(!realname) + return; + name_copy = strdup(&realname[1]); + } + else + name_copy = strdup(name); for(i=0;i<(int)strlen(name_copy);i++) if(name_copy[i] == '(') break; if(i<=1) return; @@ -523,7 +543,6 @@ void DNSServiceBrowse_Phidget_CallBack(DNSServiceRef service, for(i = 0;ideviceDef = &Phid_Device_Def[i]; - //phid->deviceIDSpec = Phid_Device_Def[i].pdd_sdid; phid->deviceIDSpec = 0; //Needs to be 0 because the name can be ambiguous (ie 1018/1200) - we will still match on serial/device class, which is enough for uniqueness phid->attr = Phid_Device_Def[i].pdd_attr; phid->deviceID = Phid_Device_Def[i].pdd_did; -- cgit v1.2.3