Giter Site home page Giter Site logo

xiaomifun / protocol-plugin-tgn52 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sagoo-cloud/protocol-plugin-tgn52

0.0 0.0 0.0 22 KB

在SagooIOT系统中使用的私有协议插件。TG-N5 设备私有协议插件。

Home Page: https://iotdoc.sagoo.cn

Go 93.56% Makefile 6.44%

protocol-plugin-tgn52's Introduction

TG-N5 设备说明

协议格式:

NB1;1234567;1;2;+25.5;00;030;+21;+22
HeadStr        //字头
DeviceID       //设备ID
Signal         //信号质量
Battery        //电池电量
Temperature    //温度
Humidity       //湿度
Cycle          //周期
Update      []string //待上传

电量和信号都是123, 分别代表低中高

断点续传功能,说明之前有因如信号不稳定等因素,造成上传不成功的数据。缓存起来,有上传条件时,一起上传。先进先出原则:即先发送的温度数据为先存储的不成功数据,距离目前时间点较远。每个数据时间间隔为上传周期。上面例子中的就是30分钟

编译插件

在Makefile脚本执行插件的编译,本地编译,或是交叉编译。

插件部署

将编译好的插件文件复制到主项目的plugins/built目录下即可

在SagooIOT平台上使用

  1. 打包上传到平台

打包成zip格式文件,到平台插件管理功能,上传插件。

  1. 在网络组件中创建TCP服务

只需要设备端口号与注册码就可以,并选择tgn52协议。 注册包的正则为:

^NB1;([^;]*)
  1. 添加产品与设备

需要先添加产品,设置物模型,然后添加设备。

  1. 设备数据上传

打开设备进行数据上传。

也可以用tcp测试工具进行测试。 发送数据格式为:

NB1;1234567;1;2;+25.5;00;030;+21;+22

模拟测试

在plugin_test.go测试程序中,运行 TestProtocolPluginServer 这个测试服务。找一个tcp客户端,采用文本的方式,按上面的协议格式进行测试数据发送。

就可以看到解析效果。

注意:

如果插件有修改,需要重新编译再测试,测试的时候,调用的是编译后的插件文件。

protocol-plugin-tgn52's People

Contributors

xinjiayu avatar

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.