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

@tikkhun/protocol

v0.0.2

Published

这是协议库,主要定义IOT场景下的相关数据协议。 物联网场景下一般包括以下数据

Readme

protocal

这是协议库,主要定义IOT场景下的相关数据协议。 物联网场景下一般包括以下数据

  • 终端的属性定义与变更
  • 下发动作的数据
  • 下发通知
  • 上报属性变更
  • 上报状态变更
  • 上报事件的数据
  • 上报的告警事件 ...

消息类型(message.type)

  • 动作 query or mutation(action)
  • 动作的响应 queryResponse mutationResponse
  • 事件 event

二级类型(message.supType)

由于上述的消息类型比较抽象,所以搞个二级类型来指定具体类型也就是具体的分类

动作

动作指远程调用终端所具有的能力。

方向上一般是有头(from)有尾(to)的,有指向性,要么下发给分组,下发给某个设备,下发到某个人上。 比较特殊的广播,也是对某个区域的人或全体人进行广播)

动作一般要求响应,所以用 sid 进行关联

动作往往会引起终端实体变化,比如配置、状态、资源的变化等等。

动作分类

  • 具体动作
    • 关机
    • 重启
    • 升级
    • 向服务器注册
  • 抽象动作
    • 消息发送
    • 资源(详见实体)的变更
    • 请求响应

动作一般都可以经历一个请求与响应的过程 其实就是rpc啥的类似

事件

事件:指实体发生变化的时候触发的事件消息。

方向上一般是无向的(也就是说只有from,没有to),所有人都可以去监听

事件的来源(from)包括了设备 服务器 网关等等

事件一般就是发布,不需要响应

事件一般有一个主题,用 tid 事务进行串联,可以将整个主题串联起来

事件分类

  • 状态变更
    • 设备上下线
  • 配置变更
  • 告警
  • 业务事件
  • 通话事件
  • 设备升级事件
  • 设备被发现

实体或者叫模块

实体就是对动作和事件定义的集合,也就是我们可以对这个实体进行某些动作下发,然后具体的应用会产生这个实体的事件,

所有实体都可以包括

  • 状态(status)
  • 配置(props,config)
  • 动作(action)
  • 事件(event)

实体分类

  • 基础实体
    • 设备实体(endpoint)
    • 属性(attrs)
      • 配置(props,config)
      • 状态(status)
        • 连接状态(connection)
  • 其他业务资源
    • 版本控制(version_controll)
    • 人员(person)
    • 组织(org)
    • 位置(location)
    • 门禁(door-access)
    • 通话(calling)

哪些东西不是数据类型?

广播其实只是特殊的消息通知。

告警只是一种特殊的事件,

资源请求只是一种特殊的动作。

他们都可以是动作或者事件的具体分类。

事务

事务就是一个事情可能由多个事件与消息组成,消息通过tid进行事务联系

会话

会话就是一件事情,比如请求和应答,比如更新与更新进度提示,

事务和会话的区别

会话和事务有点类似,都是一堆消息有共同一个主题。

但事务主要是由一个主题下的多种动作和事件的集合,会话只是一个动作(request response)的集合

使用