Debug Mode

In Debug Mode, developers can use Thonny to connect to the gateway remotely via WebREPL, executing MicroPython code in real time, debugging APP logic, or invoking APIs interactively on the gateway.

Enter Debug Mode

  1. Go to the Other page and navigate to the Micro APP section.

  2. Set Debug Mode to Yes.

  3. Click the Apply button to save the configuration.

Caution

  • Debug Mode is intended only for development and integration testing. Do not keep it enabled in production environments.

../_images/image-1.png

Configure Thonny

Thonny is a lightweight Python IDE with built-in MicroPython support, which can connect to the gateway directly via WebREPL.

  1. Open Thonny and select the RunConfigure interpreterInterpreter tab.

  2. For Which kind of interpreter should Thonny use for running your code?, select MicroPython (ESP32).

  3. For Port or WebREPL, select < WebREPL >.

  4. Fill in URL with ws://<gateway-IP>:8266/. The default Password is cassia.

  5. Click OK to save the configuration.

Note

<gateway-IP> is the IP address of the gateway on the local network. Replace it with the actual value.

../_images/image-2.png

Code Debugging

Write Python scripts in the Thonny editor; they will be executed directly on the gateway, and the output is displayed in the Shell panel.

  1. Write your code in the editor, for example a file named hello.py with the following content:

    print("hello")
    
  2. Click the Run button (the green triangle) in the toolbar to run the script.

  3. Check the result in the Shell panel. WebREPL connected indicates a successful connection, and hello is the script’s output.

../_images/image-3.png

Interactive Mode

You can enter MicroPython statements directly in Thonny’s Shell panel. Statements are executed line by line and the return values are shown immediately, which is convenient for quickly verifying APIs.

  1. Enter a statement directly after the >>> prompt, for example print("hello").

  2. Import an SDK module to call its API and inspect the return value, for example:

    >>> import cassiasys
    >>> print(cassiasys.gateway_mac())
    CC:1B:E0:E4:C8:94
    
../_images/image-4.png