Git Product home page Git Product logo

kagurazakayashi / easylinkflutter Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 2.0 4.13 MB

📡 对基于 MXCHIP/MXOS 的 IoT WiFi 硬件模组进行无线网络设置的发送工作的 Flutter 插件。

Home Page: https://pub.dev/packages/easylink_flutter

License: GNU Lesser General Public License v3.0

Java 22.14% Ruby 1.22% Objective-C 51.03% Dart 24.93% Kotlin 0.18% Swift 0.51%
mxchip flutter iot

easylinkflutter's Introduction

EasylinkFlutter

EasylinkFlutter

对基于 MXCHIP/MXOS 的 IoT WiFi 硬件模组进行无线网络设置的发送工作的 Flutter 插件。

支持平台: Android, iOS.

使用方法

  1. 引入本插件。
  • 修改 pubspec.yaml 文件,在 dependencies: 里面加入:
  easylink_flutter:
    git:
      url: https://github.com/kagurazakayashi/EasylinkFlutter.git
  1. 向用户索取「位置服务」权限(在 iOS > 12 或 Android > 8 时)。
  • 要获得当前 SSID ,「位置服务」权限是必须的。
  • 如果让用户自己输入网络名,可以跳过本步骤和下一步骤。
  • 示例程序中使用的权限获取插件是 permission_handler
  1. 获取 SSID 。
  • 调用 EasylinkFlutter.getwifiinfo() ,可以获得一个包含各种信息的字典。
  • 该字典(Map)通常包括三个字符串数据 [BSSID,SSID,SSIDDATA]
  • 下面是一个示例:
  Future<void> getssid() async {
    try {
      Map wifiinfo = await EasylinkFlutter.getwifiinfo();
      print(wifiinfo["SSID"]);
    } on PlatformException {
      print("ERROR");
    }
  }
  1. 开始配网。
  • 调用 EasylinkFlutter.linkstart ,该方法需要以下参数:
    • ssid: Wi-Fi 网络名
    • password: Wi-Fi 网络密码
    • mode: EasyLink 的模式,可选项:
      • EASYLINK_V1,EASYLINK_V2,EASYLINK_PLUS,EASYLINK_V2_PLUS,EASYLINK_AWS,EASYLINK_SOFT_AP,EASYLINK_MODE_MAX
      • 示例使用的是 EasyLinkMode.EASYLINK_V2_PLUS,安卓只支持此项(此项包括V1和V2)。
    • timeout: 超时时间
  • 方法会返回一个字符串状态信息。
  • 下面是一个示例:
  await EasylinkFlutter.linkstart(
    ssid: "testwifi",
    password: "testpwd",
    mode: EasyLinkMode.EASYLINK_V2_PLUS,
    timeout: 60
  );
  1. 监听返回通知
  • 使用 EasyLinkNotification.instance.addObserver('linkstate', (object) 来监听通知。
  • objectString 类型,可以返回以下内容:
    • Start: 开始执行
    • Stop: 执行结束、终止、超时
    • Unknown: 状态未知
    • 其他 String: 错误信息
    • JSON: 成功,插件将设备返回的详细信息解析整理为 JSON 返回,内容为字符串字典类型。
  • 下面是一个示例:
  try {
    EasyLinkNotification.instance.addObserver('linkstate', (object) {
      setState(() {
        String cbstr = object;
        if (cbstr != "Stop" && cbstr != "Unknown") {
          EasylinkFlutter.linkstop();
        }
        if (cbstr.substring(0,1) == "{") { //是 JSON
          _jsoninfo = object;
          _displayinfo = "OK!";
        } else {
          _displayinfo = object;
        }
      });
      EasyLinkNotification.instance.removeNotification('linkstate');
    });
  } on PlatformException {
    displayinfo = 'ERROR!';
  }

注意事项

  1. Android 版加入插件前,需要修改 android\app\src\main\AndroidManifest.xml 文件:
  • <manifest> 节点添加 xmlns:tools="http://schemas.android.com/tools"
  • <application> 节点添加 tools:replace="android:label"
  1. 在 iOS > 12 或 Android > 8 时,��要获取 WiFi 网络名称必须先拥有「位置服务」权限。

支持版本

  • EASYLINK_V2
  • EASYLINK_V3
  • EASYLINK_PLUS

不支持 EasylinkP2P

截图(找到设备并返回由设备提供的信息)

Android:

Android

iOS:

iOS

easylinkflutter's People

Contributors

0wew0-gh avatar kagurazakayashi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

easylinkflutter's Issues

回调函数执行多次

非常棒的插件的,正是需要的。
请教一个问题,使用示例代码配置成功后,如果马上再次开始配置,会再次收到回调消息。

iOS iot send error

After sending to ios easylink_aws, udp error occurs when receiving and returning data from the iot device, and the following error occurs on the flutter iOS client.

Runner[40127:5311132] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString bytes]: unrecognized selector sent to instance 0x282173320'
*** First throw call stack:
(0x1a3d8a708 0x1b88947a8 0x1a3c8dbfc 0x1a3d8d260 0x1a3d8f560 0x1a3d37844 0x1005b8184 0x1005b8b48 0x1005b10bc 0x1005a206c 0x1005a1d74 0x1005a230c 0x10059da28 0x1a3d0fa30 0x1a3d04990 0x1a3d0488c 0x1a3d03b90 0x1a3cfdb70 0x1a3cfd308 0x1bb380734 0x1a677b75c 0x1a6780fcc 0x10059d2f4 0x1a39b9cf8)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString bytes]: unrecognized selector sent to instance 0x282173320'
terminating with uncaught exception of type NSException

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.