tmbleflutterplugin

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

tmbleflutterplugin

flutterplugin #
Thinmoo bletooth sdk plugin
Getting Started #
This project is a starting point for a Flutter
plug-in package,
a specialized package that includes platform-specific implementation code for
Android and/or iOS.
For help getting started with Flutter development, view the
online documentation, which offers tutorials,
samples, guidance on mobile development, and a full API reference.
使用: #
以开门接口举例,其他的接口类似
import 'package:tmbleflutterplugin/flutterplugin.dart';

final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.openDoor(devSn, devMac, ekey, 1) ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed to opendoor.';
}
copied to clipboard
initBluetooth #
[功能]
蓝牙初始化接口,返回值详细请参见《附表一》。
[函数]
initBluetooth();
[返回说明]
Json 字符串。code为返回值
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.initBluetooth() ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed to opendoor.';
}
copied to clipboard
openDoor #
[功能]
蓝牙开门接口,返回值详细请参见《附表一》。
[函数]
openDoor(String devSn, String devMac, String devEkey, int keyType);
[参数说明]
devSn: 设备序列号
devMac:设备mac地址
devEkey:设备密钥(一般为长度68的字符串)
keyType: 设备密钥类型(1:门禁蓝牙一体机,2:门禁扩展板一体机/读头,3:梯控读头),一般是1
[返回说明]
Json 字符串。code为返回值
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.openDoor(devSn, devMac, ekey, 1) ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed to opendoor.';
}
copied to clipboard
scanDeviceSort #
[功能]
蓝牙扫描附近设备。返回值详细请参见《附表一》。
[函数]
scanDeviceSort(int time);
[参数说明]
time: 扫描时间,单位毫秒
[返回说明]
Json 字符串。如果有扫描到设备,会在data的devices字段里,格式:{"data":{"devices":[{"1234567890":-70}]}},1234567890是序列号,-70是信号值,信号值越大(越靠近0),信号越强。返回的devices已经是排序好了的,越靠前,信号越强
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.scanDeviceSort(2000) ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed to scan device.';
}
copied to clipboard
syncDeviceTime #
[功能]
同步时间。适用于单片机设备,返回值详细请参见《附表一》。
[函数]
syncDeviceTime(String devSn, String devMac, String devEkey, int keyType, String time);
[参数说明]
devSn,devMac,devEkey,keyType: 设备信息
time: 时间,例如 2023 年 7 月 28 日 10 点 52 分 33 秒星期五,对应格式为2023072810523305
[返回说明]
Json 字符串。code为返回值
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.syncDeviceTime(devSn, devMac, ekey, 1, '2023072810523305') ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed.';
}
copied to clipboard
modifyPwd #
[功能]
修改设备密码。仅适用于单片机的一体机设备,返回值详细请参见《附表一》。
[函数]
modifyPwd(String devSn, String devMac, String devEkey, int keyType, String oldPwd, String newPwd);
[参数说明]
devSn,devMac,devEkey,keyType: 设备信息
oldPwd: 旧密码,6位纯数字,如果没有设置过,则传空字符串即可
newPwd: 新密码,6位纯数字
[返回说明]
Json 字符串。code为返回值
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.modifyPwd(devSn, devMac, ekey, 1, '123456', '666666') ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed.';
}
copied to clipboard
swipeAddCardModel #
[功能]
让设备进入刷卡添加模式。仅适用于单片机的一体机设备,返回值详细请参见《附表一》。
[函数]
swipeAddCardModel(String devSn, String devMac, String devEkey, int keyType);
[参数说明]
devSn,devMac,devEkey,keyType: 设备信息
[返回说明]
Json 字符串。code为返回值
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.swipeAddCardModel(devSn, devMac, ekey, 1) ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed.';
}
copied to clipboard
existSwipeCardAddModel #
[功能]
让设备退出刷卡添加模式。仅适用于单片机的一体机设备,返回值详细请参见《附表一》。
[函数]
existSwipeCardAddModel(String devSn, String devMac, String devEkey, int keyType);
[参数说明]
devSn,devMac,devEkey,keyType: 设备信息
[返回说明]
Json 字符串。code为返回值
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.existSwipeCardAddModel(devSn, devMac, ekey, 1) ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed.';
}
copied to clipboard
swipeCardDeleteModel #
[功能]
让设备进入刷卡删除模式。仅适用于单片机的一体机设备,返回值详细请参见《附表一》。
[函数]
swipeCardDeleteModel(String devSn, String devMac, String devEkey, int keyType)
[参数说明]
devSn,devMac,devEkey,keyType: 设备信息
[返回说明]
Json 字符串。code为返回值
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.swipeCardDeleteModel(devSn, devMac, ekey, 1) ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed.';
}
copied to clipboard
existSwipeCardDeleteModel #
[功能]
让设备退出刷卡删除模式。仅适用于单片机的一体机设备,返回值详细请参见《附表一》。
[函数]
existSwipeCardDeleteModel(String devSn, String devMac, String devEkey, int keyType)
[参数说明]
devSn,devMac,devEkey,keyType: 设备信息
[返回说明]
Json 字符串。code为返回值
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.existSwipeCardDeleteModel(devSn, devMac, ekey, 1) ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed.';
}
copied to clipboard
setDeviceConfig #
[功能]
设置设备配置接口,返回值详细请参见《附表一》。
[函数]
setDeviceConfig(String devSn, String devMac, String devEkey, int keyType, int wiegand, int openDelay, int controlWay)
[参数说明]
devSn,devMac,devEkey,keyType: 设备信息
wiegand:设备韦根格式(韦根 26:wiegand = 26,韦根 34:wiegand = 34)
openDelay: 开门时长 (openDelay>0:单位为秒)
controlWay:控锁方式(电锁控制 0x00,电气控制 0x01)
[返回说明]
Json 字符串。code为返回值
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.setDeviceConfig(devSn, devMac, ekey, 1, 26, 5, 0) ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed.';
}
copied to clipboard
getDeviceConfig #
[功能]
获取当前设备的配置,返回值详细请参见《附表一》。
[函数]
getDeviceConfig(String devSn, String devMac, String devEkey, int keyType)
[参数说明]
devSn,devMac,devEkey,keyType: 设备信息
[返回说明]
Json 字符串。code为返回值,data是设备信息
data字段描述
openDelay:开门时长,单位妙
controlWay:控锁方式(电锁控制 0x00,电气控制 0x01)
cardNums:卡数量
version:版本
maxContainer:卡容量
sectorKey:扇区密钥
doorNo:门编号
sector:扇区
devType:设备类型
serverIP:设备服务器IP
serverPort:设备服务器端口
WiFiName:WiFi名称
WiFiPwd:WiFi密码
function:功能参数
date:设备时间
electricity:电量
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.getDeviceConfig(devSn, devMac, ekey, 1) ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed.';
}
copied to clipboard
deleteDeviceData #
[功能]
删除设备所有数据(卡数据,用户数据),适用于单片机,返回值详细请参见《附表一》。
[函数]
deleteDeviceData(String devSn, String devMac, String devEkey, int keyType)
[参数说明]
devSn,devMac,devEkey,keyType: 设备信息
[返回说明]
Json 字符串。code为返回值
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.deleteDeviceData(devSn, devMac, ekey, 1) ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed.';
}
copied to clipboard
resetDeviceConfig #
[功能]
重置设备配置(开门时长,韦根格式,电锁控制),返回值详细请参见《附表一》。
[函数]
resetDeviceConfig(String devSn, String devMac, String devEkey, int keyType)
[参数说明]
devSn,devMac,devEkey,keyType: 设备信息
[返回说明]
Json 字符串。code为返回值
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.resetDeviceConfig(devSn, devMac, ekey, 1) ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed.';
}
copied to clipboard
writeCard #
[功能]
批量添加卡,适用于单片机设备,返回值详细请参见《附表一》。
[函数]
writeCard(String devSn, String devMac, String devEkey, int keyType, String cards, int append)
[参数说明]
devSn,devMac,devEkey,keyType: 设备信息
cards: 卡号数据,多张卡以","分隔
append:是否为追加,1:是 ,直接添加卡数据,0:否,先清空卡,然后再添加卡数据
[返回说明]
Json 字符串。code为返回值
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.writeCard(devSn, devMac, ekey, 1, '1234,3432', 1) ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed.';
}
copied to clipboard
deleteCard #
[功能]
批量删除卡,适用于单片机设备,返回值详细请参见《附表一》。
[函数]
deleteCard(String devSn, String devMac, String devEkey, int keyType, String cards)
[参数说明]
devSn,devMac,devEkey,keyType: 设备信息
cards: 卡号数据,多张卡以","分隔
[返回说明]
Json 字符串。code为返回值
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.deleteCard(devSn, devMac, ekey, 1, '1234,3432') ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed.';
}
copied to clipboard
cleanCard #
[功能]
清空卡,适用于单片机设备,返回值详细请参见《附表一》。
[函数]
cleanCard(String devSn, String devMac, String devEkey, int keyType)
[参数说明]
devSn,devMac,devEkey,keyType: 设备信息
[返回说明]
Json 字符串。code为返回值
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.cleanCard(devSn, devMac, ekey, 1) ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed.';
}
copied to clipboard
configWifi #
[功能]
配置WiFi,适用于单片机设备,返回值详细请参见《附表一》。
[函数]
configWifi(String devSn, String devMac, String devEkey, int keyType, String serverIP, int serverPort, String WiFiName, String WiFiPwd)
[参数说明]
devSn,devMac,devEkey,keyType: 设备信息
serverIP: 设备连接的服务器ip
serverPort: 设备连接的服务器端口
WiFiName:WiFi名称
WiFiPwd:WiFi密码
[返回说明]
Json 字符串。code为返回值
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.configWifi(devSn, devMac, ekey, 1, '192.168.1.2', 8888, 'wifi', '12345678') ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed.';
}
copied to clipboard
setReadSectorKey #
[功能]
配置设备扇区信息,返回值详细请参见《附表一》。
[函数]
setReadSectorKey(String devSn, String devMac, String devEkey, int keyType, String sectorKey, int doorNo, int sector)
[参数说明]
devSn,devMac,devEkey,keyType: 设备信息
sectorKey: 扇区密钥(十六进制字符串,长度为 12)
doorNo:门编号(值范围:0-255)
sector:扇区(值范围:0-15)
[返回说明]
Json 字符串。code为返回值
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.setReadSectorKey(devSn, devMac, ekey, 1, '232123123432', 2, 1) ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed.';
}
copied to clipboard
setDeviceStaticIP #
[功能]
配置设备静态IP地址。返回值详细请参见《附表一》。
[函数]
setDeviceStaticIP(String devSn, String devMac, String devEkey, int keyType, int staticEnable, String staticIP, String gateway, String mask, String dns);
[参数说明]
devSn,devMac,devEkey,keyType: 设备信息
staticEnable: 1:启用静态ip 0:使用DHCP
staticIP: 静态ip
gateway:网关
mask:子网掩码
dns:DNS服务器
[返回说明]
Json 字符串。code为返回值
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.setDeviceStaticIP(devSn, devMac, ekey, 1, 1, '192.168.1.2', '192.168.1.1', '255.255.255.0', '8.8.8.8') ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed.';
}
copied to clipboard
setServerIP #
[功能]
设置设备服务器地址。返回值详细请参见《附表一》。
[函数]
setServerIP(String devSn, String devMac, String devEkey, int keyType, String serverIP, int serverPort)
[参数说明]
devSn,devMac,devEkey,keyType: 设备信息
serverIP: 设备连接的服务器ip
serverPort: 设备连接的服务器端口
[返回说明]
Json 字符串。code为返回值
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.setServerIP(devSn, devMac, ekey, 1, '192.168.1.2', 8089) ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed.';
}
copied to clipboard
login #
[功能]
登录,返回值详细请参见《附表一》。
[函数]
login(String domain, String appId, String appSecret, String account)
[参数说明]
domain: 服务器地址,默认传空字符串就行
appId: 分配的appId
appSecret: 分配的appSecret
account: app账号
[返回说明]
Json 字符串。code为返回值
[示例]
final _flutterpluginPlugin = Flutterplugin();
try {
String result =
await _flutterpluginPlugin.login(domain, appId, appSecret, account) ?? 'Unknown result';
} on PlatformException {
platformVersion = 'Failed.';
}
copied to clipboard
三. 附录
附表一



返回值
返回值说明




通信返回值类



0
操作成功


1
CRC校验错误


2
通信命令格式错误


3
设备管理密码错误


4
ERROR_POWER(仅适用于锁)


5
数据读写错误


6
用户未注册在设备中


7
随机数检测错误


8
获取随机数错误


9
命令长度不匹配


10
未进入添加设备模式


11
devKey检测错误


12
功能不支持


13
容量超过限制


19
主机串口通讯超时


48
通信连接超时


49
蓝牙服务未发现


50
通信数据长度错误,重新添加


51
接受数据为空


52
命令解析错误


53
未获取到随机数


54
未获取到配置子命令


55
未获取数据操作子命令






参数设置返回值



-1
卡号为空


-2
Sn为空


-3
Mac为空


-4
E-Key为空


-5
设备类型为空


-6
设备权限为空


-7
开门方式值错误


-8
验证方式值错误


-9
起始时间格式错误


-10
冻结时间格式错误


-11
使用次数未设置


-12
值未定义


-13
operation 其他功能未开放


-14
非法时间开门,即不在有效期内开门错误


-15
超过设置的开门距离


-16
韦根格式错误,当前仅支持26和34


-17
开门时长值范围错误,仅支持 1-254秒


-18
电器开关参数值错误,仅支持 0电锁控制,1电器开关


-19
密码必须为6位数字


-20
卡号列表不能为空


-21
卡号写入设备,每次不能大于200张卡


-22
扇区密钥必须是16进制字符串,并且长度为12


-23
设备编号范围只能是0-255


-24
卡扇区编号范围只能是 0-15


-25
scanTime 参数不能为空


-41
device不能为null


-42
context不能为null


-43
Device 过期


-44
Device未到使用时间






其余错误返回值



-100
不支持BLE


-101
BLE未打开


-102
指定的SN不存在


-103
蓝牙通信返回值为空


-104
开门失败


-105
设备未反应


-106
设备不在附近


-107
设备正在操作中


-108
sec扫描时间单位错误


-109
设置扫描秒数超出范围


-110
设备已经存在超级用户,必须先初始化设备才能添加设备


-111
设备MAC地址错误


-112
使用蓝牙扫描太频繁(Android 7.0 的限制)


-113
EID连接失败


-114
登录失败


-115
CRC校验失败


-116
命令ID不匹配


-117
用户ID错误


-118
一键开门设备权限为空


-119
一键开门未扫描到任何设备


-120
一键开门匹配不到有权限的设备


-121
扫描设备缺少定位权限


-122
扫描设备缺少定位权限且拒绝不再询问

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.