Set LED status

 1'''
 2System_Wifi - set_LED_status.py with synchronous mode.
 3
 4This example demonstrates how to set LED status 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
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        value = 1
43
44        ## Get firmware model & version
45        driver_info = dev.Sys_getDriverInfo(timeout)
46        print("Model name: " + driver_info[0])
47        print("Firmware version: " + driver_info[-1])
48
49        for i in range(3):
50            ## Reset LED status
51            err = dev.Wifi_resetLED(timeout)
52            print(f"Wifi_resetLED, status: {err}")
53
54            ## Set green LED status
55            err = dev.Wifi_setGreenLED(value, timeout)
56            print(f"Wifi_setGreenLED, status: {err}")
57            time.sleep(1) ## delay [s]
58
59            ## Reset LED status
60            err = dev.Wifi_resetLED(timeout)
61            print(f"Wifi_resetLED, status: {err}")
62
63            ## Set blue LED status
64            err = dev.Wifi_setBlueLED(value, timeout)
65            print(f"Wifi_setBluLeED, status: {err}")
66            time.sleep(1) ## delay [s]
67
68            ## Reset LED status
69            err = dev.Wifi_resetLED(timeout)
70            print(f"Wifi_resetLED, status: {err}")
71
72            ## Set red LED status
73            err = dev.Wifi_setRedLED(value, timeout)
74            print(f"Wifi_setRedLED, status: {err}")
75            time.sleep(1) ## delay [s]
76
77            print("")
78    except Exception as err:
79        pywpc.printGenericError(err)
80
81    ## Disconnect network device
82    dev.disconnect()
83
84    ## Release device handle
85    dev.close()
86
87    return
88
89if __name__ == '__main__':
90    main()