Metadata-Version: 2.4
Name: micropython-websocket
Version: 1.0.5
Summary: A WebSocket client library for MicroPython on ESP32
Author-email: 李一博 <slyb@tju.edu.cn>
License: MIT License
        
        Copyright (c) 2026 李一博
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://gitee.com/slyb2020/micropython-websocket
Keywords: micropython,esp32,websocket,websocket-clinet,iot,embedded
Classifier: Programming Language :: Python :: Implementation :: MicroPython
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: System :: Networking
Classifier: Intended Audience :: Developers
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# micropython-websocket

适用于ESP32的MicroPython WebSocket-client模块。

## 安装方法

在Thonny中安装到ESP32：

1. 用USB将ESP32连接到电脑
2. 打开Thonny，右下角切换为 MicroPython(ESP32)
3. 菜单 Tools → Manage packages
4. 搜索 `micropython-websocket`
5. 点击安装

## 使用示例

```python
import websocket

import network
import websocket

def do_connect():
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    if not wlan.isconnected():
        print("正在连接 Wi-Fi...")
        wlan.connect("你的WiFi名称", "你的WiFi密码")
        while not wlan.isconnected():
            pass
    print("已连接，IP:", wlan.ifconfig()[0])

do_connect()

# 创建连接（替换为你电脑的局域网 IP）
ws = websocket.create_connection("ws://192.168.1.109:8765")

ws.send("Hello, ESP32!")          # 发送文本
reply = ws.recv()                  # 阻塞等待回复
print("收到回复:", reply)

ws.close()                         # 关闭连接
print("连接已关闭")
```
