-
大小: 61KB文件类型: .zip金币: 1下载: 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
相关资源
- gnu.io.SerialPort( rxtx-2.1.7.jar)串口通讯
- android串口demo
- Bluetooth LE for iOS and Android v2.3.unitypac
- Unity插件Bluetooth LE For iOS and Android
- 安卓6.0串口库文件libserial_port.so
- SerialPortDemo
- Android 蓝牙4.0 ble 官方绿色源码 demo
- serialPort_demo.rar
- Bluetooth LE for iOS tvOS and Android
- bluecove2.1.2
- 串口通信的RXTX的jar包,64位系统Seri
- android Serializeable与Parcelable 数据对象传
- android activity之间传值(通过Intent的
- JSerializable
- android-serialport-api(android-sercd)
- java串口通信SerialPortDemo,打开射频,
- 蓝牙串口调试助手源码android Bluetoot
- android蓝牙传输文件
- Bluetooth.apk
- Android中蓝牙的基本使用----BluetoothAd
- rxtxParallel.dll和rxtxSerial.dll
- Android串口通信开发Google官方android-s
- 实现android手机蓝牙连接demo
- Linux Java RXTXcomm
- Java 串口通信 SerialPort
- Bluetooth_4.3 BLE蓝牙通信
- bluetooth 蓝牙demo (ble)
- Android Bluetooth 蓝牙
- android 蓝牙传输BluetoothGet
- android-BluetoothChat 蓝牙2.0版的通信
评论
共有 条评论