From 8f80e3f1a82abefa1302e4afeadd784febe19251 Mon Sep 17 00:00:00 2001 From: tkl Date: Sun, 14 Aug 2016 09:21:43 +0000 Subject: [PATCH] wireless level udp transmission --- udp_socket_client.py | 5 ++++- wireless.py | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/udp_socket_client.py b/udp_socket_client.py index 0ef63fb..0277583 100755 --- a/udp_socket_client.py +++ b/udp_socket_client.py @@ -2,12 +2,15 @@ import socket import time +import wireless target = "192.168.178.21" port = 5005 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) +w = wireless.wireless("wlan0") while 1: - s.sendto("test", (target, port)) + msg = "#WIFI:LEVEL:" + w.level() + s.sendto(msg, (target, port)) time.sleep(1) diff --git a/wireless.py b/wireless.py index 5a9d458..515ec8a 100644 --- a/wireless.py +++ b/wireless.py @@ -16,6 +16,8 @@ class wireless: lst = line.split(" ") self.__link = lst[2] self.__level = lst[3] + if re.match(".*\.$", self.__level): + self.__level = re.sub("\.", "", self.__level) self.__noise = lst[4] break f.close()