System get Wifi DAQ status

 1'''
 2System_Wifi - get_Wifi_DAQ_status.py with synchronous mode.
 3
 4This example demonstrates how to get basic information such as RSSI & battery & thermo from WifiDAQE3A.
 5
 6-------------------------------------------------------------------------------------
 7Please change correct serial number or IP and port number BEFORE you run example code.
 8
 9For other examples please check:
10    https://github.com/WPC-Systems-Ltd/WPC_Python_driver_release/tree/main/examples
11See README.md file to get detailed usage of this example.
12
13Copyright (c) 2022-2024 WPC Systems Ltd. All rights reserved.
14'''
15
16## Python
17import time
18
19## WPC
20
21from wpcsys import pywpc
22
23def main():
24    ## Get Python driver version
25    print(f'{pywpc.PKG_FULL_NAME} - Version {pywpc.__version__}')
26
27    ## Create device handle
28    dev = pywpc.WifiDAQE3A()
29
30    ## Connect to device    ## Connect to device
31    try:
32        dev.connect("192.168.5.38") ## Depend on your device
33    except Exception as err:
34        pywpc.printGenericError(err)
35        ## Release device handle
36        dev.close()
37        return
38
39    try:
40        ## Parameters setting
41        timeout = 3 ## second
42
43        ## Get firmware model & version
44        driver_info = dev.Sys_getDriverInfo(timeout)
45        print("Firmware model:" + driver_info[0])
46        print("Firmware version:" + driver_info[-1])
47
48        ## Get RSSI, battery and thermo
49        rssi = dev.Wifi_readRSSI(timeout)
50        battery = dev.Wifi_readBattery(timeout)
51
52        ## Get power & charge status
53        power_status  = dev.Wifi_getPowerGoodStatus(timeout)
54        charge_status = dev.Wifi_getChargeStatus(timeout)
55
56        print(f"RSSI: {rssi} dBm")
57        print(f"Battery: {battery} mV")
58        print(f"Power status: {power_status}")
59        print(f"Charge status: {charge_status}")
60    except Exception as err:
61        pywpc.printGenericError(err)
62
63    ## Disconnect network device
64    dev.disconnect()
65
66    ## Release device handle
67    dev.close()
68
69    return
70
71if __name__ == '__main__':
72    main()