mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-16 01:57:09 +00:00
Wifi (#660)
* Work for #17 : Now we have ssid * Since we are using Objective-C++ NSStrings, we need to link to Foundation.framework, too! * If interface is UP use the interface SSID; otherwise "off/any" following the Linux implementation. Add more * More * cleanup
This commit is contained in:
parent
30c19a14f5
commit
1e2a29654f
@ -139,7 +139,9 @@ endif(BUILD_NCURSES AND OS_DARWIN)
|
|||||||
|
|
||||||
if(BUILD_WLAN AND OS_DARWIN)
|
if(BUILD_WLAN AND OS_DARWIN)
|
||||||
find_library(CW CoreWLAN)
|
find_library(CW CoreWLAN)
|
||||||
|
find_library(NS Foundation)
|
||||||
set(conky_libs ${conky_libs} ${CW})
|
set(conky_libs ${conky_libs} ${CW})
|
||||||
|
set(conky_libs ${conky_libs} ${NS})
|
||||||
endif(BUILD_WLAN AND OS_DARWIN)
|
endif(BUILD_WLAN AND OS_DARWIN)
|
||||||
|
|
||||||
if(OS_DARWIN AND BUILD_IPGFREQ)
|
if(OS_DARWIN AND BUILD_IPGFREQ)
|
||||||
|
@ -652,10 +652,68 @@ int update_meminfo() {
|
|||||||
#ifdef BUILD_WLAN
|
#ifdef BUILD_WLAN
|
||||||
|
|
||||||
void update_wlan_stats(struct net_stat *ns) {
|
void update_wlan_stats(struct net_stat *ns) {
|
||||||
|
CWWiFiClient *client = [CWWiFiClient sharedWiFiClient];
|
||||||
|
CWInterface *interface = [client interfaceWithName:[NSString stringWithUTF8String:ns->dev]];
|
||||||
|
|
||||||
|
if (!interface)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const char *essid = (ns->up) ? [interface ssid].UTF8String : "off/any";
|
||||||
|
const char *freq = "Unknown";
|
||||||
|
const char *bitrate = [NSString stringWithFormat:@"%f", [interface transmitRate]].UTF8String;
|
||||||
|
const char *mode = "Unknown";
|
||||||
|
const char *ap = [interface hardwareAddress].UTF8String;
|
||||||
|
|
||||||
|
if (essid == nullptr || bitrate == nullptr || ap == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Freq
|
||||||
|
*/
|
||||||
|
switch ([interface wlanChannel].channelBand) {
|
||||||
|
case kCWChannelBand2GHz:
|
||||||
|
freq = "2 GHz";
|
||||||
|
break;
|
||||||
|
case kCWChannelBand5GHz:
|
||||||
|
freq = "5 GHz";
|
||||||
|
break;
|
||||||
|
case kCWChannelBandUnknown:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Mode
|
||||||
|
*/
|
||||||
|
switch ([interface interfaceMode]) {
|
||||||
|
case kCWInterfaceModeStation:
|
||||||
|
mode = "Managed";
|
||||||
|
break;
|
||||||
|
case kCWInterfaceModeIBSS:
|
||||||
|
mode = "Ad-Hoc";
|
||||||
|
break;
|
||||||
|
case kCWInterfaceModeHostAP:
|
||||||
|
mode = "Master";
|
||||||
|
break;
|
||||||
|
case kCWInterfaceModeNone:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Setup
|
||||||
|
*/
|
||||||
|
memcpy(ns->essid, essid, sizeof(char)*strlen(essid));
|
||||||
|
ns->channel = interface.wlanChannel.channelNumber;
|
||||||
|
memcpy(ns->freq, freq, sizeof(char)*strlen(freq));
|
||||||
|
memcpy(ns->bitrate, bitrate, sizeof(char)*strlen(bitrate));
|
||||||
|
memcpy(ns->mode, mode, sizeof(char)*strlen(mode));
|
||||||
|
ns->link_qual = 0;
|
||||||
|
ns->link_qual_max = 0;
|
||||||
|
memcpy(ns->ap, ap, sizeof(char)*strlen(ap));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* BUILD_WLAN */
|
||||||
|
|
||||||
int update_net_stats() {
|
int update_net_stats() {
|
||||||
struct net_stat *ns;
|
struct net_stat *ns;
|
||||||
|
Loading…
Reference in New Issue
Block a user