{"id":34636744,"url":"https://github.com/entertech/tes-vr","last_synced_at":"2026-05-29T09:31:26.781Z","repository":{"id":276443220,"uuid":"911130931","full_name":"Entertech/tes-vr","owner":"Entertech","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-13T06:07:16.000Z","size":175,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-13T07:22:34.336Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Entertech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-02T10:08:42.000Z","updated_at":"2025-06-13T06:07:19.000Z","dependencies_parsed_at":"2025-02-08T09:31:02.342Z","dependency_job_id":"2fffd2f8-e559-437d-b9ed-906ded4d0d16","html_url":"https://github.com/Entertech/tes-vr","commit_stats":null,"previous_names":["entertech/tes-vr"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Entertech/tes-vr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Entertech%2Ftes-vr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Entertech%2Ftes-vr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Entertech%2Ftes-vr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Entertech%2Ftes-vr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Entertech","download_url":"https://codeload.github.com/Entertech/tes-vr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Entertech%2Ftes-vr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28005408,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-24T17:02:30.488Z","updated_at":"2025-12-24T17:03:52.026Z","avatar_url":"https://github.com/Entertech.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TesDeviceManager SDK 文档\n\n## 简介\n\n`TesDeviceManager` 是一个基于 BLE（蓝牙低功耗）的设备管理类，用于与特定的蓝牙设备进行连接、通信和控制。\\\n它提供了设备连接、消息发送与接收、电流调节、伪刺激模式控制等功能。\n\n***\n\n## 目录\n\n* [集成](#集成)\n* [类概述](#类概述)\n* [构造函数](#构造函数)\n* [主要方法](#主要方法)\n    * [设备连接相关](#设备连接相关)\n    * [消息发送与接收](#消息发送与接收)\n    * [设备控制](#设备控制)\n    * [电流调节](#电流调节)\n    * [伪刺激模式](#伪刺激模式)\n    * [事件监听](#事件监听)\n    * [BaseReceiveTesMsg消息类型](#BaseReceiveTesMsg消息类型)\n* [辅助方法](#辅助方法)\n* [备注](#备注)\n\n***\n\n## 集成\n\n### gradle自动依赖\n\n在项目根目录的build.gradle文件下添加以下依赖：\n\n```groovy\nrepositories {\n    mavenCentral()\n}\n```\n\n在所需的module中的build.gradle文件下添加以下依赖：\n\n```groovy\nimplementation 'cn.entertech.android:ble-device-tes:0.0.3'\n```\n\n***\n\n## 类概述\n\n```kotlin\nclass TesDeviceManager(\n    context: Context,\n    private val deviceToPhoneUUid: String,\n    private val phoneToDeviceUUid: String\n) : BaseBleConnectManager(context)\n```\n\n该类继承 BaseBleConnectManager，用于管理与蓝牙设备的连接与通信。\n\n***\n\n## 构造函数\n\nTesDeviceManager(context: Context, deviceToPhoneUUid: String, phoneToDeviceUUid: String)\n\n参数\n\n* context: Context - Android 应用上下文。\n* deviceToPhoneUUid: String - 设备到手机的 UUID。\n* phoneToDeviceUUid: String - 手机到设备的 UUID。\n\n***\n\n## 主要方法\n\n### 设备连接相关\n\n#### 通过设备的 MAC 地址 进行连接。\n\n    connectDeviceByMac(mac: String, success: (String) -\u003e Unit = {}, failure: (String) -\u003e Unit = {})\n\n参数\n\n* mac: String - 设备的 MAC 地址。\n* success: (String) -\u003e Unit - 连接成功的回调，返回设备地址。\n* failure: (String) -\u003e Unit - 连接失败的回调，返回错误信息。\n\n### 设备状态重置\n\n当设备断开之后需要重置设备标识\n\n    resetDeviceStatus\n\n### 消息发送与接收\n\n#### 发送消息到设备。\n\n    sendMessage(msg: BaseSendTesMsg, needCheckStatus: Boolean = false, success: (ByteArray) -\u003e Unit = {}, failure: (String) -\u003e Unit = {})\n\n参数\n\n* msg: BaseSendTesMsg - 需要发送的消息对象。\n* needCheckStatus: Boolean - 是否需要检查设备状态。\n* success: (ByteArray) -\u003e Unit - 发送成功回调，返回消息字节数组。\n* failure: (String) -\u003e Unit - 发送失败回调，返回错误信息。\n\nBaseSendTesMsg 有以下类型\n\n| 消息类型                       | 命令说明    | 备注 |\n|----------------------------|---------|----|\n| ControlCommandTesMsg       | 控制命令    |    |\n| RegulationCurrentTesMsg    | 调节电流    |    |\n| SettingArgTesMsg           | 设置参数消息  |    |\n| ShakeHandsTesMsg           | 握手消息    |    |\n| StartPseudoStimulateTesMsg | 开始伪刺激模式 |    |\n| StopPseudoStimulateTesMsg  | 停止伪刺激模式 |    |\n\n#### receiveMessage(rawMsgListener: (ByteArray) -\u003e Unit, failure: (String) -\u003e Unit = {})\n\n接收设备消息。\n\n参数\n\n* rawMsgListener: (ByteArray) -\u003e Unit - 监听设备消息的回调，返回字节数组。\n* failure: (String) -\u003e Unit - 失败时的回调，返回错误信息。\n\n### 设备控制\n\n#### 启动设备。\n\n    startDevice(mode: String, time: Int, frequency: Int, success: (ByteArray) -\u003e Unit = {}, failure: (String) -\u003e Unit = {})\n\n参数\n\n* mode: String - 设备模式。\n* time: Int - 运行时间（秒）。\n* frequency: Int - 运行频率。\n* success: (ByteArray) -\u003e Unit - 成功回调。\n* failure: (String) -\u003e Unit - 失败回调。\n\n#### 停止设备。\n\n    stopDevice(success: (ByteArray) -\u003e Unit = {}, failure: (String) -\u003e Unit = {})\n\n参数\n\n* success: (ByteArray) -\u003e Unit - 成功回调。\n* failure: (String) -\u003e Unit - 失败回调。\n\n### 电流调节\n\n#### 增加设备电流。\n\n    increaseCurrent(step: Byte, success: (ByteArray) -\u003e Unit = {}, failure: (String) -\u003e Unit = {})\n\n参数\n• step: Byte - 递增步长。\n• success: (ByteArray) -\u003e Unit - 成功回调。\n• failure: (String) -\u003e Unit - 失败回调。\n\n#### 减少设备电流。\n\n    reduceCurrent(step: Byte, success: (ByteArray) -\u003e Unit = {}, failure: (String) -\u003e Unit = {})\n\n参数\n\n* step: Byte - 递减步长。\n* success: (ByteArray) -\u003e Unit - 成功回调。\n* failure: (String) -\u003e Unit - 失败回调。\n\n### 伪刺激模式\n\n#### 开始伪刺激模式。\n\n    startFakeMode(success: (ByteArray) -\u003e Unit = {}, failure: (String) -\u003e Unit = {})\n\n参数\n\n* success: (ByteArray) -\u003e Unit - 成功回调。\n* failure: (String) -\u003e Unit - 失败回调。\n\n#### 停止伪刺激模式。\n\n    stopFakeMode(success: (ByteArray) -\u003e Unit = {}, failure: (String) -\u003e Unit = {})\n\n参数\n\n* success: (ByteArray) -\u003e Unit - 成功回调。\n* failure: (String) -\u003e Unit - 失败回调。\n\n### 事件监听\n\n#### 添加设备消息监听器。\n\n    addDeviceMessageListener(listener: (BaseReceiveTesMsg?) -\u003e Unit)\n\n参数\n\n* listener: (BaseReceiveTesMsg?) -\u003e Unit - 消息回调。\n\n#### 移除设备消息监听器。\n\n    removeDeviceMessageListener(listener: (BaseReceiveTesMsg?) -\u003e Unit)\n\n参数\n\n* listener: (BaseReceiveTesMsg?) -\u003e Unit - 消息回调。\n\n#### 添加原始数据监听器。\n\n    addDeviceMessageRawDataListener(listener: (ByteArray) -\u003e Unit)\n\n参数\n\n* listener: (ByteArray) -\u003e Unit - 监听回调。\n\n#### 移除原始数据监听器。\n\n    removeDeviceMessageRawDataListener(listener: (ByteArray) -\u003e Unit)\n\n参数\n\n* listener: (ByteArray) -\u003e Unit - 监听回调。\n\n***\n\n### BaseReceiveTesMsg消息类型\n\n#### 控制命令反馈消息 ControlCommandFdTesMsg\n\ncontrolResult 控制指令结果\n\n* CONTROL\\_RESULT\\_SUCCESS 成功\n* CONTROL\\_RESULT\\_FAILURE 失败\n\n#### 调节电流反馈消息RegulationCurrentFbTesMsg\n\n1.regulationType：\n\n* REGULATION\\_CURRENT\\_INCREASE 电流增加\n* REGULATION\\_CURRENT\\_REDUCE 电流减小\n\n2.regulationResult ：调节结果\n\n* REGULATION\\_RESULT\\_SUCCESS 调节成功；\n* REGULATION\\_RESULT\\_TIME\\_NOT\\_ENOUGH:剩余时间不足，无法调至到此模式；\n* REGULATION\\_RESULT\\_DEVICE\\_IN\\_REDUCE:设备正在缓降阶段无法 调节电流;\n* REGULATION\\_RESULT\\_FAILURE:失败\n\n#### 设置参数并启动反馈消息SettingArgFbTesMsg\n\nsetArgResult：\n\n* SETTING\\_ARG\\_RESULT\\_SUCCESS:成功\n* SETTING\\_ARG\\_RESULT\\_FAILURE:失败\n* SETTING\\_ARG\\_RESULT\\_ERROR:参数错误\n\n#### 开始伪刺激反馈消息StartPseudoStimulateFbTesMsg\n\nstartSuccess：true 开始成功；false 开始失败\n\n#### 停止伪刺激反馈消息StopPseudoStimulateFbTesMsg\n\nstopSuccess：true 停止成功；false 停止失败\n\n#### 事件上报反馈消息UploadTesFbMsg\n\n1. newDeviceStatus 设备状态\n\n* DEVICE\\_STATUS\\_IN\\_VALID 无效\n* DEVICE\\_STATUS\\_RUNNING 设备运行中\n* DEVICE\\_STATUS\\_READY 设备就绪中\n* DEVICE\\_STATUS\\_ERROR 设备故障\n* DEVICE\\_STATUS\\_CUR\\_DOWNING\\_NORMAL 设备当前正在正常降压\n* DEVICE\\_STATUS\\_CUR\\_DOWNING\\_CONTROL 设备当前正在控制降压\n* DEVICE\\_STATUS\\_STIMULATE\\_PSEUDO 伪刺激\n\n1. deviceBattery 电池电量\n2. frequency 频率\n3. stimulateRemainTime 剩余刺激时间\n4. impedanceValue 当前阻抗值\n5. currentMode 模式\n\n* TDCS\\_P tDCS 正向\n* tDCS\\_N tDCS 负向\n* TACS TACS\n\n1. setCurrent 设定的电流\n2. setTime 设定的时间 单位s\n3. current 当前电流\n4. stopFlag 停止标识\n\n* STOP\\_FLAG\\_NORMAL：正常周期性发送\n* STOP\\_FLAG\\_STOPING:正在停止中（正常结束缓降）\n* STOP\\_FLAG\\_STOP\\_COMPLETE:停止完成\n* STOP\\_FLAG\\_STOP\\_FAIL：停止失败\n* STOP\\_FLAG\\_STOP\\_RECEIVE:停止命令已经接收到，主动缓降停止\n\n1. currentLevel 电流的阶段\n2. currentLimit 电流限制\n\n### 辅助方法\n\n```\n\nintToLittleEndianBytes(value: Int): ByteArray\n```\n\n将整数转换为小端字节数组。\n\n参数\n\n* value: Int - 需要转换的整数。\n\n返回\n\n* ByteArray - 转换后的字节数组。\n\n***\n\n## 备注\n\n* 确保在调用 sendMessage、receiveMessage、startDevice 等方法之前，设备已成功连接。\n* 设备状态可以通过 getDeviceStatus() 获取，并可以使用 setDeviceStatus(status) 进行设置。\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fentertech%2Ftes-vr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fentertech%2Ftes-vr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fentertech%2Ftes-vr/lists"}