Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@embedded-js/wifi-connection-manager

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@embedded-js/wifi-connection-manager

A wifi connection manager for Embedded JS that supports multiple networks and auto-reconnect.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
Maintainers
0
Weekly downloads
 
Created
Source

Embedded : WiFi connection manager

[!IMPORTANT] This module is ESM only and only available for usage with the Moddable SDK as it uses core dependencies. Learn how to setup an Embedded JavaScript project using xs-dev.

A robust solution to manage Wi-Fi connections in embedded systems using the Moddable SDK. WiFiConnectionManager simplifies the process of maintaining an active connection to a Wi-Fi access point.

Features

  • Auto-reconnect: Automatically retries connection if unavailable at startup or dropped during runtime.
  • Connection lifecycle management: Allows clean disconnection using close.
  • Redundant message suppression: Filters out repetitive WiFi.disconnect messages.
  • Convenient readiness check: Use the ready getter to quickly determine if Wi-Fi is connected.
  • Connection timeout handling: Forces a disconnect and retries if no IP address is assigned within a configurable timeout.
  • Graceful recovery: Waits a configurable duration after an unforced disconnect for a clean reconnect.
  • Multiple access points: Attempts connection to access points in order from a provided list.

Installation

npm install @embedded-js/wifi-connection-manager
import Net from "net"; // From moddable SDK
import { WiFiConnectionManager } from "@embedded-js/wifi-connection-manager";

const manager = new WiFiConnectionManager(
  [
    // First access point to attempt
    {
      ssid: "Freebox-ScreamZ",
      password: "invalid!", // Invalid password for testing in a simulator
    },
    // Second access point to attempt
    {
      ssid: "Freebox-ScreamZ",
      password: "good_password",
    },
  ],
  (message) => {
    switch (msg) {
      case WiFiConnectionManager.connected:
        break; // still waiting for IP address
      case WiFiConnectionManager.gotIP:
        trace(`IP address ${Net.get("IP")}\n`);
        break;
      case WiFiConnectionManager.disconnected:
        break; // connection lost
    }
  }
);

// Example: Checking if connected (procedural way)
if (manager.ready) {
  console.log("Wi-Fi is connected!");
}

// Close connection when needed
manager.close();

Keywords

FAQs

Package last updated on 23 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc