-
大小: 61KB文件类型: .zip金币: 2下载: 0 次发布日期: 2021-05-12
- 语言: Java
- 标签: RaspberryPi Bluetooth Serial
资源简介
手机蓝牙控制树莓派,文件包含树莓派端代码以及手机端App(IOS和Android)

代码片段和文件信息
#include “GoBLE.h“
_GoBLE Goble;
int fd;
/*
* The following constants tell for each accelerometer
* axis which values are returned when the axis measures
* zero acceleration.
*/
_GoBLE::_GoBLE() {
if (-1 == wiringPiSetup()) {
cerr << “set up error“ << endl;
exit(-1);
}
}
void _GoBLE::begin() {
fd = serialOpen(“/dev/ttyAMA0“ 115200);
initRecvDataPack();
_joystickX = 127;
_joystickY = 127;
for (int i = 0; i < MAXBUTTONID; i++) {
_button[i] = RELEASED;
}
for (int i = 0; i < 20; i++) bleQueue.push(0x00);
for (int i = 0; i < 20; i++) bleQueue.pop();
}
void _GoBLE::begin(unsigned int baudrate) {
fd = serialOpen(“/dev/ttyAMA0“ baudrate);
initRecvDataPack();
_joystickX = 127;
_joystickY = 127;
for (int i = 0; i < MAXBUTTONID; i++) {
_button[i] = RELEASED;
}
}
bool _GoBLE::available() {
/*
function introduction:
* push the new valid data to the data buffer package
* throw away the invalid byte
* parse the data package when the command length is matching the protocol
*/
if (serialDataAvail(fd) > 0) bleDataReceiver();
if (DEBUGPARSER) {
printf(“%s“ “GoBLE availalbe -> bleQueue Counter: “);
printf(“%d\n“ bleQueue.size());
}
if (rDataPack.commandFlag && bleQueue.size() == rDataPack.commandLength) {
rDataPack.parseState = bleDataPackageParser();
if (rDataPack.parseState == PARSESUCCESS) {
updateJoystickVal();
updateButtonState();
return true;
}
}
return false;
}
int _GoBLE::readJoystickX() {
return _joystickX;
}
int _GoBLE::readJoystickY() {
return _joystickY;
}
bool _GoBLE::readSwitchUp() {
return _button[SWITCH_UP];
}
bool _GoBLE::readSwitchDown() {
return _button[SWITCH_DOWN];
}
bool _GoBLE::readSwitchLeft() {
return _button[SWITCH_LEFT];
}
bool _GoBLE::readSwitchRight() {
return _button[SWITCH_RIGHT];
}
bool _GoBLE::readSwitchSelect() {
return _button[SWITCH_SELECT];
}
bool _GoBLE::readSwitchStart() {
return _button[SWITCH_START];
}
// Private functions
int _GoBLE::bleDataPackageParser() {
/*
0x10 - Parse success
0x11 - Wrong header charactors
0x12 - Wrong button number
0x13 - Check Sum Error
*/
byte calculateSum = 0;
rDataPack.header1 = bleQueue.front() bleQueue.pop() calculateSum += rDataPack.header1;
rDataPack.header2 = bleQueue.front() bleQueue.pop() calculateSum += rDataPack.header2;
if (rDataPack.header1 != DEFAULTHEADER1) return 0x11;
if (rDataPack.header2 != DEFAULTHEADER2) return 0x11;
rDataPack.address = bleQueue.front() bleQueue.pop() calculateSum += rDataPack.address;
rDataPack.latestDigitalButtonNumber = rDataPack.digitalButtonNumber;
rDataPack.digitalButtonNumber = bleQueue.front() bleQueue.pop() calculateSum += rDataPack.digitalButtonNumber;
int digitalButtonLength = rDataPack.digitalButtonNumber;
if (DEBUGCHECKSUM) {
printf(“%s“ “Parser -> digitalButtonLeng
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-09-26 17:32 RaspiBLE\
目录 0 2018-09-26 17:32 RaspiBLE\代码\
文件 6067 2018-09-26 17:08 RaspiBLE\代码\GoBLE.cpp
文件 2622 2018-09-26 17:08 RaspiBLE\代码\GoBLE.h
文件 1231 2018-09-26 17:33 RaspiBLE\代码\main.cpp
文件 104 2018-09-26 17:33 RaspiBLE\代码\Readme.txt
目录 0 2018-09-26 17:30 RaspiBLE\软件\
文件 77952 2018-09-05 22:15 RaspiBLE\软件\GOBLE_V2.apk
文件 23 2018-09-26 17:31 RaspiBLE\软件\IOS.txt
相关资源
- Android蓝牙和Cors网络开发源码
- Java串口调试工具源码
- 安全测试工具ysoserial
- 好用的支持android 6.0以上的libserial_p
- Android蓝牙遥控器字符串形式应用例程
- Android蓝牙设备之间通过UUID通信
- Android串口(AndroidSerialPort)通信代码
- 基于蓝牙的PC与Android端通讯DEMO
- android手机bluetooth通信测试代码
- 蓝牙聊天程序
- Arduino bluetooth controller_v1.3_apkpure.com.
- Android串口通讯库
- android studio 蓝牙 socket 范例
- android下的串口读写及数据保存
- 安卓打印驱动最全驱动源码库(usbS
- Unity蓝牙插件,最新版2019年10月7号更
- android 蓝牙4.0 和2.0
- BluetoothHelper
- 蓝牙通信插件最新版Bluetooth LE for iO
- android BlueToothDemo 蓝牙搜索,配对,连
- ysoserial.jar
- AndroidStudio蓝牙接收数据绘图
- android_serialport_api串口通讯demo
- ysoserial-0.0.4-all.jar
- 蓝牙坐标控制
- android 蓝牙连接通信
- HBuilder实现蓝牙通讯 - 亲测可用html5
- Android studio3.2类似蓝牙控制LED开关的程
- Android studio蓝牙遥控
- Bluetooth之打开、关闭、搜索、允许搜
评论
共有 条评论