前言
安卓小白,想了解一下蓝牙通信,就做了这个东西
蓝牙模块
采用的是HC-05型号的蓝牙模块
用 usb-ttl 与 蓝牙模块 连接
VCC接VCC GND接GND Tx Rx交叉连接
使用串口助手调试 波特率为9600
android端
先上效果图
界面搭建
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:background="#199fff"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<TextView
android:id="@+id/show_connection_device"
android:text="未连接"
android:layout_marginLeft="20dp"
android:textColor="#ffffff"
android:textSize="25sp"
android:layout_centerInParent="true"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/show_menu_list"
android:layout_centerInParent="true"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:src="@drawable/menu_img"
android:layout_width="30dp"
android:layout_height="30dp" />
</RelativeLayout>
<include layout="@layout/content_main" />
</LinearLayout>
c