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 🙏

© 2024 – Pkg Stats / Ryan Hefner

jkyy_lefu_bodyfat_bluewifi_sdk

v1.0.9

Published

健康有益乐福体脂秤蓝牙模块SDK支持微信、uni-app

Downloads

13

Readme

健康有益科技有限责任公司

益云-乐福体脂秤小程序接入 SDK,支持微信小程序,uni-app

安装

npm install jkyy_lefu_bodyfat_bluewifi_sdk -S
# 或
yarn add jkyy_lefu_bodyfat_bluewifi_sdk

使用

// 初始化
this.LEFUWIFI = new LEFUWIFI({
  debug: false,
  tokenUrl: "",
  appId: "",
  apiKey: "",
  ttl: "",
  bizType: "",
  baseUrl: "",
  userId: "",
  nickname: "",
  userImageUrl: "",
  mobileNo: "",
  gender: "1",
  weight: "65",
  height: "175",
});
/**
 * @des 乐福体脂秤设备绑定列表
 * @param {string} userId 用户id
 * @param {string} isLoading 默认false,是否展示loading
 *
 * @return {Promise<Array>}
 * @property {String} deviceName 设备名称
 * @property {String} deviceSn mac地址,安卓直连唯一标识
 * @property {String} deviceId uuid,ios直连唯一标识
 */
this.LEFUWIFI.apiBindList(userId, isLoading);
// 解除绑定的设备
this.LEFUWIFI.apiDeviceUnbind;
// 注册状态回调
this.LEFUWIFI.registerDidUpdateConnectStatus(
  this.didUpdateConnectStatus.bind(this)
);
// 注册发现外设回调
this.LEFUWIFI.registerDidDiscoverDevice(this.didDiscoverDevice.bind(this));

// 扫描
this.LEFUWIFI.scan();
// 停止扫描
this.LEFUWIFI.stopScan();
// 连接设备
this.LEFUWIFI.connect();
// 断开连接
this.LEFUWIFI.disconnect();
// 同步手环时间
this.LEFUWIFI.setDeviceTime((__) => __);
/**
 * @des 同步设备获取体重历史数据
 * @param {String} lastTime 大于某时间点的记录; 无就拉取所有历史数据
 */
this.LEFUWIFI.getHistoryData((__) => __, lastTime);
/**
 * @des 获取当前体重测量结果回调
 * @param {String} lastTime 从哪天开始同步,最多支持同步最近7天
 */
this.LEFUWIFI.getCurrentData((__) => __);

参数说明

| 参数 | 类型 | 是否必填 | 描述 | | :----------------: | :-----: | :------: | :------------------------------: | | debug | Boolean | 否 | 开启 debug 模式,默认 false | | automaticUnbinding | Boolean | 否 | 是否自动解绑,默认 false | | tokenUrl | String | 是 | 由健康有益提供 | | bizType | String | 是 | 由健康有益提供 | | appId | String | 是 | 由健康有益提供 | | apiKey | String | 是 | 由健康有益提供 | | ttl | String | 是 | token 过期时间 | | userId | String | 是 | 用户唯一 id 绑定设备时使用 | | nickname | String | 否 | 用户名 | | userImageUrl | String | 否 | 用户头像 | | mobileNo | String | 否 | 手机号 | | gender | String | 是 | 性别,用做换算卡路里,1 男,2 女 | | weight | String | 是 | 身高,用做换算卡路里,单位 kg | | height | String | 是 | 体重,用做换算卡路里,单位 cm |

类属性

| 类属性 | 类型 | 描述 | | :------------------: | :-----: | :--------------------------------------------------------------------------------------: | | deviceInfo | Object | 设备信息 | | connectStatus | String | 连接状态:0 未连接或连接断开,允许连接;1 正在连接,不允许再连接;2 已连接,不允许再连接 | | isInitializedAdapter | Boolean | 蓝牙适配器是否初始化完成 | | isAvailableAdapter | Boolean | 蓝牙适配器是否可用 | | HTTP | Class | 请求服务 |

类方法

| 类方法 | 入参 | 返回 | 描述 | | :-------------------------------------: | :--------------------------: | :----------: | :----------------------------------------------------------------------------------------------------------------------------------------------------: | | openAndListenBluetoothAdapter | - | Promise 对象 | 打开和监听蓝牙适配器(SDK 在传进类的时候已经自动初始化) | | scan | scanParams | Promise 对象 | 扫描外设 android 需要确保手机开启定位权限,才能扫描成功 | | stopScan | - | Promise 对象 | 停止扫描 | | connect | connectParams | Promise 对象 | 连接外设,连接指定的外设,需要传入外设对象。注意实现返回对象的 then 和 catch 方法,监听接口是否调用成功。android 需要确保手机开启定位权限,才能连接成功 | | disconnect | - | Promise 对象 | 断开连接 | | read | readParams | Promise 对象 | 读某个服务下的某个特征值。 | | write | writeParams | Promise 对象 | 向蓝牙模块写入数据 | | notify | notifyParams | Promise 对象 | 监听特征值改变 | | registerDidUpdateConnectStatus | cb 回调函数 | - | 连接状态发生改变时,回调此方法。 | | registerDidDiscoverDevice | cb 回调函数 | - | 当扫描到设备时回调此方法 | | registerDidUpdateValueForCharacteristic | cb 回调函数 | - | 当监听的特征值改变时回调此方法 |

scanParams

| 参数 | 类型 | 描述 | | :----------------: | :--------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | | services | Array | 要搜索的蓝牙设备主 service 的 uuid 列表。某些蓝牙设备会广播自己的主 service 的 uuid。如果设置此参数,则只搜索广播包有对应 uuid 的主服务的蓝牙设备。建议主要通过该参数过滤掉周边不需要处理的其他蓝牙设备。 | | allowDuplicatesKey | Boolean | 是否允许重复上报同一设备。如果允许重复上报,则 wx.onBlueToothDeviceFound 方法会多次上报同一设备,但是 RSSI 值会有不同。 | | interval | Number | 上报设备的间隔。0 表示找到新设备立即上报,其他数值根据传入的间隔上报。 | | powerLevel | String | 默认 medium 扫描模式,越高扫描越快,也越耗电, 仅安卓 7.0.12 及以上支持。 | | timeout | Number | 扫描超时时间,毫秒。在该时间内未扫描到符合要求的设备,上报超时。默认 1500ms,-1 表示无限超时 | | deviceName | String | 通过蓝牙名称过滤,需要匹配的设备名称 | | containName | String | 通过蓝牙名称过滤,需要包含的设备名称 |

optionsServices

| 参数 | 类型 | 描述 | | :-------: | :----: | :-------------------: | | uuid | String | 服务 uuid | | serviceId | String | 筛选哪个服务用到的 id |

connectParams

| 参数 | 类型 | 描述 | | :-----: | :------------------: | :-----------------------------------------------------------------------: | | device | deviceObject | 指定连接的外设对象,从 registerDidDiscoverDeviceCallback 注册的回调中得到 | | timeout | Number | 连接超时时间,毫秒,默认 15000ms |

device

| 参数 | 类型 | 描述 | | :------: | :----: | :-------------------------------------------------------------------------------------------: | | deviceId | String | 蓝牙连接唯一标识 ios 的 uuid,传这个值 | | deviceSn | String | 蓝牙连接唯一标识 android 的 mac 地址,传这个值,这样 就可以做到,ios android 跳过扫描直接连接 |

readParams

| 参数 | 类型 | 描述 | | :---: | :----: | :-----------------: | | suuid | String | 特征对应的服务 uuid | | cuuid | String | 写入特征 uuid |

writeParams

| 参数 | 类型 | 描述 | | :---: | :--------: | :-----------------: | | suuid | String | 特征对应的服务 uuid | | cuuid | String | 写入特征 uuid | | value | Hex string | 16 进制字符串 |

notifyParams

| 参数 | 类型 | 描述 | | :---: | :--------: | :----------------------------------------------------------: | | suuid | String | 特征对应的服务 uuid | | cuuid | String | 写入特征 uuid | | state | Hex string | 是否启用 notify,可以通过重复调用接口改变此属性打开/关闭监听 |

enum.js

所有错误的集合包括微信的错误和自己定义的错误

| code | message | | :--: | :----------------------------------------------------------------: | | 210 | 发现外设 | | 211 | 扫描完成 | | 220 | 蓝牙打开 | | 221 | 正在连接 | | 222 | 连接成功 | | 223 | 断开成功 | | 410 | 扫描超时 | | 420 | 蓝牙关闭 | | 421 | 连接失败 | | 422 | 连接断开 | | 2010 |  扫描接口成功调用 | | 2020 |  停止扫描接口成功调用 | | 2030 |  连接接口成功调用 | | 2040 |  断开接口成功调用 | | 2050 |  读特征值接口成功调用 | | 2060 |  写入数据接口成功调用 | | 2070 |  监听特征值接口成功调用 | | 4000 | 当前基础库版本低,请更新微信版本 | | 4010 | 扫描失败,请稍后重试 | | 4011 | 请打开手机蓝牙后再试 | | 4012 | 没有找到指定的蓝牙服务 | | 4013 | 请打开手机蓝牙,并进入手机应用设置开启微信的蓝牙授权,方可查找设备 | | 4020 | 停止蓝牙扫描失败 | | 4021 | 请打开手机蓝牙后再试 | | 4030 | 蓝牙连接失败,请稍后重试 | | 4031 | 请开启手机蓝牙后再试 | | 4032 | 蓝牙正在连接 | | 4033 | 蓝牙连接超时,请稍后重试 | | 4034 | 蓝牙连接设备 id 不能为空 | | 4040 | 蓝牙断开失败 | | 4050 |  读特征值失败 | | 4051 | 蓝牙未连接 | | 4052 | 当前特征不支持读操作 | | 4053 | 没有找到指定服务 | | 4054 | 没有找到指定特征值 | | 4060 |  写入数据失败 | | 4061 | 蓝牙未连接 | | 4062 | 当前特征不支持写操作 | | 4063 | 没有找到指定服务 | | 4064 | 没有找到指定特征值 | | 4070 |  监听特征值失败 | | 4071 | 蓝牙未连接 | | 4072 | 当前特征不支持监听操作 | | 4073 | 没有找到指定服务 | | 4074 | 没有找到指定特征值 |