npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

meoser

v0.4.2

Published

meos protocol engine

Readme

更新说明

2018-10-22 [email protected] @0.4.0修复仍然存在bug。

2018-9-12 [email protected] fix: Emitter 未正确实例化。除此外无功能接口变化。

2018-8-20 [email protected] fix bug of online interface

2018-8-06 [email protected] 支持更多 rocky 传感器,同时完善在线读值块、帽子监听块接口

2018-7-26 [email protected] 延长通信的超时时间到5000ms,增加codey,rocky在线读值的接口

2018-6-20 [email protected] 延长通信的超时时间到2000ms,以应对某些设备通信过慢的问题

2018-6-19 [email protected] fix bug of readMacAddr

2018-4-04 [email protected] 重构 dispatch 模块,移除 meoser.online 命名空间

2018-3-23 [email protected] 支持 codey 在离线、在线模式下rocky颜色传感器、陀螺仪的校正。校正时程序会停止运行。

2018-3-15 [email protected] codey 广播、通信变量等支持中文

2018-1-25 [email protected] 实现 codey 在线模式;另一个重要的调整是:将 file uploader 相关的接口整合进 uploader 对象中

2017-11-28 [email protected] 修复一个严重的拼写错误:deReceived 错误写成 deRecevied

2017-11-20 [email protected] 代码结构优化重构。另新增 getReadyStatus,getCommChannel接口,增强上位机对硬件状态的了解

2017-11-06 [email protected] 烧录文件默认错误重试2次 & 新增 setCommVarCache 接口

2017-11-03 [email protected] 新增 DTR 握手协议的接口及实现 & clean 了一下 code

2017-10-31 [email protected] 修复内部事件在下位机异常响应时未被移除,从而导致重复绑定的错误

2017-10-23 [email protected] 调整 uploadContent 接口,支持上传音乐

2017-10-18 [email protected] 新增 log 日志接口

2017-10-18 [email protected] 新增查询mac地址、查询固件版本号的接口实现

2017-10-13 [email protected] 新增广播协议及接口实现

API 简述

设置连接

设置连接的 API 用于设置发送协议的方法和绑定接收协议的回调。连接方式包括蓝牙(Ble)、WIFI、串口(serialport) 等。

设置协议发送方式:meos.setSender(sender)

mEos 接收返回协议:meos.doReceived(buf)

let meos = new Meos();
//假设使用 socket
socket.on('receive_buf', function (buf) {
    meos.doReceived(JSON.parse(buf));
});
let sender = (buf) => {
    socket.emit('send_buf', { buf: JSON.stringify(buf) });
}
meos.setSender(sender);

上传文件

与 mEos 主控建立连接之后,就可以上传文件了。只需两步调用:

// 设置内容
meos.content = 'here is a string of python code';
// 开始上传
meos.uploadContent()

上传音乐和上传文件同用该一套接口。

此外,还有一些相关接口丰富上传文件的交互形式:

meos.blockLength = 100 可以设置一次消息块的大小调整上传速度。

meos.onUploadProgress(hanlder) 传入的事件句柄 handler 可以获取到文件总大小及上传大小等信息。

删除文件

deleteFile(filename) 删除 mEos 中已上传的文件。

meos.deleteFile('./flash/main.py').then((result) => {
  console.log(result);
});

传感器读值

传感器读值,分两步完成:1、发送请求协议;2、调用接口获取读值

请求读值:requestRead(sensor_id)

// 发出请求,请求读取声音强度的值
// 声音强度传感器的 sensor_id 为: 1
meos.requestRead(1).then((req_result) => {
  console.log(req_result);
})

请求中断读值:requestUnRead(sensor_id)

// 发出请求,请求停止读取声音强度
meos.requestUnRead(1).then((result) => {
  console.log(result);
})

读取传感器的值:readSensor(sensor_id)

let value = meos.readSensor(1);

通信变量

读取变量是读取 mEos 主控中的脚本变量,写入变量是将软件端的变量写入到 mEos 主控中。 如果将上位机和 mEos 看成同一个编程环境,就很容易理解这个超全局的通信变量了。

读取通信变量的值:readCommVar(var_name)

// 读取下位机 speed 变量值
meos.readCommVar('speed')

// 读取下位机 name 变量值
let name = meos.readCommVar('name')

写入通信变量的值:writeCommVar(var_name, var_value)

// 设置下位机 speed 变量值为 50
meos.writeCommVar('speed', 50)

// 设置下位机 name 变量值为 'rick'
meos.writeCommVar('name', 'rick')

消息广播

向 mEos 发送广播消息:sendBroadcast(msg)

meos.sendBroadcast('hello')

添加 mEos 广播句柄:addBroadcastHandler(handler)

meos.addBroadcastHandler((msg) => {
  console.log('接收到 mEos 的广播:', msg);
})

读取 MAC 地址, 固件版本号

读取 mEos 的 MAC 地址:readMacAddr(typeNumber)

// wifi 连接时
meos.readMacAddr(1).then((res) => console.log(res.mac, res.type))

// ble 连接时
meos.readMacAddr(2).then((res) => console.log(res.mac, res.type))

读取 mEos 固件版本号:readVersion()

meos.readVersion().then((res) => console.log(res.version, res.name))