diff options
author | Jonathan McCrohan <jmccrohan@gmail.com> | 2012-10-19 19:38:06 +0100 |
---|---|---|
committer | Jonathan McCrohan <jmccrohan@gmail.com> | 2012-10-19 19:38:06 +0100 |
commit | 8f3c91e91b634adaca77dac6cf314445cceefc78 (patch) | |
tree | 8a779a28ccfbbfae413f6f7df21fb0a8650d3747 /zeroconf.c | |
parent | bd7a4f258643bf72d5e97f86f0f2272b381ed1ba (diff) | |
download | libphidget21-8f3c91e91b634adaca77dac6cf314445cceefc78.tar.gz |
Imported Upstream version 2.1.8.20120912upstream/2.1.8.20120912
Diffstat (limited to 'zeroconf.c')
-rw-r--r-- | zeroconf.c | 25 |
1 files changed, 22 insertions, 3 deletions
@@ -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;i<PHIDGET_DEVICE_COUNT;i++)
if(!strcmp(name_copy, Phid_Device_Def[i].pdd_name)) break;
phid->deviceDef = &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;
|