javascript - 在 base64 中编码一个整数以通过 BLE 发送
问题描述
我正在开发这个应用程序,我正在使用蓝牙库(https://github.com/Polidea/react-native-ble-plx),我需要使用 base64 (https://github.com/eranbo /react-native-base64#readme ) 将一个整数作为状态保存到 BLE 模块。有没有办法使用base64发送整数?
根据文档,我们需要编写以下内容 -
device.writeCharacteristicWithResponseForService(
serviceUUID: UUID,
characteristicUUID: UUID,
valueBase64: Base64)
然后写入模块:
device.writeCharacteristicWithResponseForService('uuidServ', 'uuidCharc', base64Data)
这是我到目前为止所尝试的:
const base64Data = base64.encode(bytes(this.state.totalSec));
console.log(base64Data);
有没有办法获取 base64 数据以便我可以将其发送到 BLE 模块?
解决方案
推荐阅读
- mysql - Mysql:相同的查询,相同数量的结果行,没有连接,慢 10 倍?
- php - 无法比较在 php 中创建的 cookie 的时间
- mysql - 从 MySQL 8.0.16 迁移到 MySQL 5.5 - 错误的重音和特殊字符
- node.js - Socket.io why very slow?
- react-native - Snapshot unit test fail for react-native-modal-datetime-picker
- regex - .NET Regex Balancing Groups and syntax matching
- css - 如何选择名称属性中带有 [] 的元素?
- spring-boot - 带有 Spring 数据的通用 Dao
- teamcity - How to run unit tests on TeamCity with multiple agents?
- javascript - Access Data on click event from table