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-2025 WPC Systems Ltd. All rights reserved.
14'''
15
16## WPC
17from wpcsys import pywpc
18
19
20def main():
21    ## Get Python driver version
22    print(f'{pywpc.PKG_FULL_NAME} - Version {pywpc.__version__}')
23
24    ## Create device handle
25    dev = pywpc.WifiDAQE3A()
26
27    ## Connect to device    ## Connect to device
28    try:
29        dev.connect("192.168.5.38")  ## Depend on your device
30    except Exception as err:
31        pywpc.printGenericError(err)
32        ## Release device handle
33        dev.close()
34        return
35
36    try:
37        ## Parameters setting
38        timeout = 3  ## [sec]
39
40        ## Get firmware model & version
41        driver_info = dev.Sys_getDriverInfo(timeout)
42        print("Firmware model:" + driver_info[0])
43        print("Firmware version:" + driver_info[-1])
44
45        ## Get RSSI, battery and thermo
46        rssi = dev.Wifi_readRSSI(timeout)
47        battery = dev.Wifi_readBattery(timeout)
48
49        ## Get power & charge status
50        power_status = dev.Wifi_getPowerGoodStatus(timeout)
51        charge_status = dev.Wifi_getChargeStatus(timeout)
52
53        print(f"RSSI: {rssi} dBm")
54        print(f"Battery: {battery} mV")
55        print(f"Power status: {power_status}")
56        print(f"Charge status: {charge_status}")
57    except Exception as err:
58        pywpc.printGenericError(err)
59
60    finally:
61        ## Disconnect network device
62        dev.disconnect()
63
64        ## Release device handle
65        dev.close()
66
67
68if __name__ == '__main__':
69    main()