add wifi pkt
Change-Id: I6f06bf2f76e402d51ce70098c5f15c3702618eb8
diff --git a/mbtk/include/mbtk/mbtk_wifi_ap.h b/mbtk/include/mbtk/mbtk_wifi_ap.h
index 8b89613..9522e70 100644
--- a/mbtk/include/mbtk/mbtk_wifi_ap.h
+++ b/mbtk/include/mbtk/mbtk_wifi_ap.h
@@ -14,6 +14,16 @@
+typedef struct {
+unsigned long long rx_packets;
+unsigned long long rx_bytes;
+unsigned long long rx_errors;
+unsigned long long rx_dropped;
+unsigned long long tx_packets;
+unsigned long long tx_bytes;
+unsigned long long tx_errors;
+unsigned long long tx_dropped;
+} mbtk_wifi_pkt_stats_t;
int mbtk_wifi_get_setting(const char *path, const char *key, char *value, int value_max_len);
@@ -22,6 +32,8 @@
int mbtk_wifi_ap_stop(void);
int mbtk_wifi_set_file(const char *path, const char *value);
int mbtk_wifi_get_file(const char *path, char *value, int value_max_len);
+int mbtk_wifi_get_pkt(mbtk_wifi_pkt_stats_t* pkt_stat);
+
diff --git a/mbtk/libmbtk_lib/wifi/mbtk_wifi_ap.c b/mbtk/libmbtk_lib/wifi/mbtk_wifi_ap.c
index 74e1c16..3b4de85 100644
--- a/mbtk/libmbtk_lib/wifi/mbtk_wifi_ap.c
+++ b/mbtk/libmbtk_lib/wifi/mbtk_wifi_ap.c
@@ -290,5 +290,55 @@
return 0;
}
+int mbtk_wifi_get_pkt(mbtk_wifi_pkt_stats_t* pkt_stat)
+{
+ if(NULL == pkt_stat)
+ {
+ return -1;
+ }
+
+ char buf[1024] = {0};
+ char* ptr = NULL;
+ char* ptr2 = NULL;
+ unsigned long long ull_temp = 0;
+ FILE* fp = NULL;
+ fp = popen("cat /proc/net/dev | grep wlan0", "r");
+ if(NULL == fgets(buf, 1024, fp))
+ {
+ return -1;
+ }
+ pclose(fp);
+
+ LOGD("pkt:%s, len:%d\n", buf, strlen(buf));
+
+
+ pkt_stat->rx_bytes = strtoull(buf + 7, &ptr, 10);
+
+ pkt_stat->rx_packets = strtoull(ptr, &ptr2, 10);
+
+ pkt_stat->rx_errors = strtoull(ptr2, &ptr, 10);
+
+ pkt_stat->rx_dropped = strtoull(ptr, &ptr2, 10);
+
+ ull_temp = strtoull(ptr2, &ptr, 10);
+
+ ull_temp = strtoull(ptr, &ptr2, 10);
+
+ ull_temp = strtoull(ptr2, &ptr, 10);
+
+ ull_temp = strtoull(ptr, &ptr2, 10);
+
+ pkt_stat->tx_bytes = strtoull(ptr2, &ptr, 10);
+
+ pkt_stat->tx_packets = strtoull(ptr, &ptr2, 10);
+
+ pkt_stat->tx_errors = strtoull(ptr2, &ptr, 10);
+
+ pkt_stat->tx_dropped = strtoull(ptr, &ptr2, 10);
+
+
+
+ return 0;
+}