}elseif(memcmp(line,CPUINFO_HARDWARE,CPUINFO_HARDWARE_LEN)==0){// We're also going to look for the hardware line in cpuinfo and save it for later in case we don't find the device ID
// We found the hardware ID
token=line+CPUINFO_HARDWARE_LEN;// skip past "Hardware"
while((*token>0&&*token<=32)||*token==':')token++;// skip over all spaces and the colon
if(*token!=0){
token[30]=0;
if(token[strlen(token)-1]==10){// checking for endline chars and dropping them from the end of the string if needed
memset(hardware_id,0,sizeof(hardware_id));
strncpy(hardware_id,token,strlen(token)-1);
}else{
strcpy(hardware_id,token);
}
LOGI("=> hardware id from cpuinfo: '%s'\n",hardware_id);
}
}
}
fclose(fp);
}
if(hardware_id[0]!=0){
LOGW("\nusing hardware id for device id: '%s'\n",hardware_id);
while(fgets(line,sizeof(line),fp)!=NULL){// First step, read the line.
if(memcmp(line,CPUINFO_SERIALNO,CPUINFO_SERIALNO_LEN)==0)// check the beginning of the line for "Serial"
{
// We found the serial number!
token=line+CPUINFO_SERIALNO_LEN;// skip past "Serial"
while((*token>0&&*token<=32)||*token==':')token++;// skip over all spaces and the colon
if(*token!=0){
token[30]=0;
if(token[strlen(token)-1]==10){// checking for endline chars and dropping them from the end of the string if needed
memset(device_id,0,sizeof(device_id));
strncpy(device_id,token,strlen(token)-1);
}else{
strcpy(device_id,token);
}
LOGI("=> serial from cpuinfo: '%s'\n",device_id);
fclose(fp);
new_device_id=sanitize_device_id(device_id);
strcpy(device_id,new_device_id);
free(new_device_id);
return;
}
}elseif(memcmp(line,CPUINFO_HARDWARE,CPUINFO_HARDWARE_LEN)==0){// We're also going to look for the hardware line in cpuinfo and save it for later in case we don't find the device ID
// We found the hardware ID
token=line+CPUINFO_HARDWARE_LEN;// skip past "Hardware"
while((*token>0&&*token<=32)||*token==':')token++;// skip over all spaces and the colon
if(*token!=0){
token[30]=0;
if(token[strlen(token)-1]==10){// checking for endline chars and dropping them from the end of the string if needed
memset(hardware_id,0,sizeof(hardware_id));
strncpy(hardware_id,token,strlen(token)-1);
}else{
strcpy(hardware_id,token);
}
LOGI("=> hardware id from cpuinfo: '%s'\n",hardware_id);
}
}
}
fclose(fp);
}
if(hardware_id[0]!=0){
LOGW("\nusing hardware id for device id: '%s'\n",hardware_id);
strcpy(device_id,hardware_id);
new_device_id=sanitize_device_id(device_id);
strcpy(device_id,new_device_id);
free(new_device_id);
return;
}
strcpy(device_id,"serialno");
LOGE("=> device id not found, using '%s'.",device_id);