#!/usr/bin/env python

import rospy
from std_msgs.msg import String

from airi_heatmap.measurement import get_measure

#sudo nmcli -f SSID,BSSID,CHAN,FREQ,RATE,SIGNAL,SECURITY dev wifi rescan
#sudo nmcli -f SSID,BSSID,CHAN,FREQ,RATE,SIGNAL,SECURITY dev wifi

def ros_measure():
    rospy.init_node('measure_node', anonymous=True)
    pub = rospy.Publisher('measure_db', String, queue_size=10)
    rate = rospy.Rate(0.06)  # every ~14 sec
    while not rospy.is_shutdown():
        measure = get_measure('Linux')
        #rospy.loginfo(measure)
        msg = String()
        msg.data = repr(measure)
        pub.publish(msg)
        rate.sleep()

if __name__ == "__main__":
    try:
        ros_measure()
    except rospy.ROSInterruptException as e:
        print(e)
