# android-app-bluetooth-remote-control-car-v1-qt-c **Repository Path**: newbieLQ/android-app-bluetooth-remote-control-car-v1-qt-c ## Basic Information - **Project Name**: android-app-bluetooth-remote-control-car-v1-qt-c - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2025-05-23 - **Last Updated**: 2025-05-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 平台 查看之前配置的开发平台:[QT 5.14.2实现Android开发](https://yanyx.blog.csdn.net/article/details/133792421) # 初衷 因为云端配置了QT for android,没有其他开发安卓的IDE,本着简单事情简单办的原则,在QT 上开发,还可以跨平台部署,很好啊。 # 基本原理 - 首先开发好界面UI,设置好按钮,配置好输出接口的逻辑 - 基于 QT 的蓝牙控制的库,利用socket 进行通信,这其实和CAN socket 通信应该差不多。 # 开始搞 ## 界面 界面划分为三个 QWidget,伸展因子 (Stretch Factor)比例分别是3:2:6. ![demo2](demo2.PNG) ## 输出接口 - 蓝牙打开、搜索和连接 - 接受其他蓝牙发送过来的串口信息 - 发送前进、后退、暂停等串口指令分别发送``1``,``2``,``5``等串口信息,在``Output Value``显示信息 - 发送左右两个标度盘的数值(范围:10-99),在``Lfet Dial Value``和``Right Dial Value``显示标度盘的值。例如左边的标度盘是15,右边刻度盘是50,串口发送``z15y50`` # 建立 蓝牙对象 ``` localDevice = new QBluetoothLocalDevice(); ``` # 扫描蓝牙设备 ``` discoveryAgent = new QBluetoothDeviceDiscoveryAgent(); discoveryAgent->start();//开始扫描蓝牙设备 ``` # 建立socket 进行通信 ```c //给socket分配内存,限定套接字协议 socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol); ``` # 蓝牙连接 ``` socket->connectToService(address, QBluetoothUuid(serviceUuid) ,QIODevice::ReadWrite); ``` # 蓝牙通信 ``` // 发送 const QString &message QByteArray data = message.toUtf8(); socket->write(data.constData(), data.size());} // 接受 QByteArray line = socket->readAll(); ``` # 代码 https://gitee.com/hiyanyx/android-app-bluetooth-remote-control-car-v1-qt-c # 编译后输出的 app https://gitee.com/hiyanyx/android-app-bluetooth-remote-control-car-v1-qt-c/tree/master/%E8%BE%93%E5%87%BA%E8%BD%AF%E4%BB%B6 1、[[QT_042]Qt学习之控件尺寸调整策略(QSizePolicy)](https://blog.csdn.net/kongcheng253/article/details/128769765) 2、蓝牙QT for android 3、公众号:果果小师弟出品,蓝牙小车