feat: skip WS in AP+no-internet, poll every 5s until network available
Made-with: Cursor
This commit is contained in:
@@ -127,6 +127,16 @@ class ClawClient {
|
||||
_connect() {
|
||||
if (this._stopped) return;
|
||||
|
||||
// AP 模式 + 无网:不建立 WS,5s 后重新检查网络
|
||||
if (this._provisionMgr && this._provisionMgr.isApMode() && !hasInternet()) {
|
||||
led.display.showAP();
|
||||
log.info('clawd', 'AP 模式无网络,5s 后重新检查...');
|
||||
this._backoff = 1_000; // 有网时立即快速重连
|
||||
this._wsFailCount = 0; // 不计入失败
|
||||
setTimeout(() => this._connect(), 5_000);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._hasEverConnected || this._wsFailCount < 3) led.display.showConn();
|
||||
log.info('clawd', `正在连接 ${this._cfg.server} ...`);
|
||||
const ws = new WebSocket(this._cfg.server, {
|
||||
|
||||
Reference in New Issue
Block a user