mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-22 16:25:45 +08:00
Changed network interface detection
Added Nextion HMI files
This commit is contained in:
34
Network.cpp
34
Network.cpp
@@ -40,25 +40,40 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
|
||||
struct ifaddrs *ifaddr, *ifa;
|
||||
int family, s, n, ifnr;
|
||||
char host[NI_MAXHOST];
|
||||
char text[50+INET6_ADDRSTRLEN];
|
||||
char interfacelist[IFLISTSIZ][50+INET6_ADDRSTRLEN];
|
||||
char *p;
|
||||
char *dflt, *p;
|
||||
FILE *f;
|
||||
char line[100];
|
||||
|
||||
dflt=NULL;
|
||||
f = fopen("/proc/net/route" , "r");
|
||||
|
||||
while(fgets(line , 100 , f))
|
||||
{
|
||||
dflt = strtok(line , " \t");
|
||||
p = strtok(NULL , " \t");
|
||||
|
||||
if(dflt!=NULL && p!=NULL)
|
||||
{
|
||||
if(strcmp(p , "00000000") == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
strcpy(text,"(interface lookup failed)");
|
||||
for(n=0;n<IFLISTSIZ;n++) {
|
||||
interfacelist[n][0]=0;
|
||||
}
|
||||
ifnr=0;
|
||||
|
||||
if (getifaddrs(&ifaddr) == -1) {
|
||||
strcpy((char*)info,"getifaddrs failure");
|
||||
} else {
|
||||
for (ifa = ifaddr, n = 0; ifa != NULL; ifa = ifa->ifa_next, n++) {
|
||||
if (ifa->ifa_addr == NULL)
|
||||
continue;
|
||||
|
||||
family = ifa->ifa_addr->sa_family;
|
||||
|
||||
if (family == AF_INET || family == AF_INET6) {
|
||||
s = getnameinfo(ifa->ifa_addr,
|
||||
(family == AF_INET) ? sizeof(struct sockaddr_in) :
|
||||
@@ -80,10 +95,15 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info)
|
||||
}
|
||||
}
|
||||
freeifaddrs(ifaddr);
|
||||
|
||||
|
||||
LogInfo(" Default interface is : %s" , dflt);
|
||||
|
||||
for(n=0;n<(ifnr);n++) {
|
||||
p=strchr(interfacelist[n],'%');
|
||||
if (p!=NULL) *p=0;
|
||||
if (strstr(interfacelist[n],"lo")==NULL) {
|
||||
if(strstr(interfacelist[n], dflt) != 0)
|
||||
{
|
||||
strcpy((char*)info,interfacelist[n]);
|
||||
break;
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Nextion_ON7LDS/NX3224T024-ON7LDS.HMI
Normal file
BIN
Nextion_ON7LDS/NX3224T024-ON7LDS.HMI
Normal file
Binary file not shown.
Binary file not shown.
BIN
Nextion_ON7LDS/NX3224T028-ON7LDS.HMI
Normal file
BIN
Nextion_ON7LDS/NX3224T028-ON7LDS.HMI
Normal file
Binary file not shown.
BIN
Nextion_ON7LDS/NX3224T028-ON7LDS.tft
Normal file
BIN
Nextion_ON7LDS/NX3224T028-ON7LDS.tft
Normal file
Binary file not shown.
BIN
Nextion_ON7LDS/NX4024T032-ON7LDS.HMI
Normal file
BIN
Nextion_ON7LDS/NX4024T032-ON7LDS.HMI
Normal file
Binary file not shown.
BIN
Nextion_ON7LDS/NX4024T032-ON7LDS.tft
Normal file
BIN
Nextion_ON7LDS/NX4024T032-ON7LDS.tft
Normal file
Binary file not shown.
BIN
Nextion_ON7LDS/NX4832T035-ON7LDS.HMI
Normal file
BIN
Nextion_ON7LDS/NX4832T035-ON7LDS.HMI
Normal file
Binary file not shown.
BIN
Nextion_ON7LDS/NX4832T035-ON7LDS.tft
Normal file
BIN
Nextion_ON7LDS/NX4832T035-ON7LDS.tft
Normal file
Binary file not shown.
Reference in New Issue
Block a user