蓝牙设备默认时设备名字 通过nmtui 设置设备网络名字即可
并且nmtui可以设置要连接的设备wifi
也可以通过设置 bluetoothctl的system-alias (无效)
蓝牙设备默认时设备名字 通过nmtui 设置设备网络名字即可
并且nmtui可以设置要连接的设备wifi
也可以通过设置 bluetoothctl的system-alias (无效)
执行蓝牙命令前先确保蓝牙服务开启
执行蓝牙命令进入蓝牙控制台
bluetoothctl
列出蓝牙适配器
list
显示某一个蓝牙设备状态
show
修改设备名字(无效)
system-alias ${name}
蓝牙设备上电
power on
开启蓝牙可发现
discoverable on
设置蓝牙可发现超时时间(0为永不超时)
discoverable-timeout 0
设置蓝牙可匹配
pairable on
设置开启蓝牙广告advertise
advertise on
至此设备ble蓝牙已开启
安装依赖包
sudo apt-get update
sudo apt-get install bluetooth bluez libbluetooth-dev libusb-dev libdbus-1-dev
确保蓝牙开启
sudo systemctl enable bluetooth
sudo systemctl start bluetooth
bluetoothctl 是一个点对点蓝牙控制工具
gatttool 是一个ble蓝牙控制工具
sudo apt-get install bluez-tools
gatttool -b <设备地址> --interactive
python 代码:
sudo apt-get install python3-pip
pip3 install bluepy
from bluepy.btle import Scanner, DefaultDelegate
import time
class ScanDelegate(DefaultDelegate):
def handleDiscovery(self, dev, isNewDev, isNewData):
if isNewDev:
print("Discovered device")
print(" Device %s (%s), RSSI=%d dB" % (dev.addr, dev.addrType, dev.rssi))
elif isNewData:
print(" Updated data: %s" % dev.scanData)
print(" Manufacturer data: %s" % dev.manufacturerData) # Optional: manufacturer data if available. 0x0000FFFF is the default for BLE devices. 0xFFFF is the default for Beacons. 0x004C is the default for iBeacons. 0x0215 is the default for AltBeacons. 0x0242 is the default for Estimote beacons. 0x0015 is the default for Eddystone beacons. 0x02AA is the default for Apple beacons. 0x0118 is the default for Samsung beacons. 0x02AA is the default for Apple beacons. 0x0118 is the default for Samsung beacons. 0x02AA is the default for Apple beacons. 0x0118 is the default for Samsung beacons. 0x02AA is the default for Apple beacons. 0x0118 is the default for Samsung beacons. 0x02AA is the default for Apple beacons. 0x0118 is the default for Samsung beacons. 0x02AA is the default for Apple beacons. 0x0118 is the default for Samsung
相关链接
https://blog.csdn.net/weixin_30598047/article/details/156319564
hostapd:用于创建 WiFi 热点dnsmasq:提供 DNS 和 DHCP 服务git:用于下载 create_ap 工具sudo apt update &&
sudo apt upgrade -y
sudo apt install -y hostapd dnsmasq git
若已经有 create_ap 命令 可跳过
# 克隆仓库
git clone https://github.com/oblique/create_ap.git
cd create_ap
# 安装工具
sudo make install
查看系统中的无线网卡(通常为 wlan0 或 wlx 开头):
找到类似 wlan0 的无线接口名称(确保你的 Orange Pi 5 Max 已安装 WiFi 驱动,能识别无线网卡)。
ip link show
确认有线网卡名称(用于共享网络,通常为 eth0或lo):
ip -br addr show
基本命令格式(替换为你的信息):
sudo create_ap [无线网卡] [有线网卡] [热点名称] [热点密码]
示例(假设无线网卡为 wlan0,有线网卡为 eth0):
sudo create_ap wlan0 eth0 OrangePi_Hotspot 12345678
热点名称:OrangePi_Hotspot(可自定义)
密码:12345678(至少 8 位,可自定义)
先停止当前运行的热点(按 Ctrl+C)。
创建系统服务实现自启:
创建服务文件
sudo nano /etc/systemd/system/orangepi-hotspot.service
粘贴以下内容(根据你的网卡和热点信息修改):
[Unit]
Description=Orange Pi WiFi Hotspot
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/create_ap wlan0 eth0 OrangePi_Hotspot 12345678
Restart=always
[Install]
WantedBy=multi-user.target
启用并启动服务:
sudo systemctl enable orangepi-hotspot
sudo systemctl start orangepi-hotspot
热点启动失败:
检查无线网卡是否被占用(如已连接其他 WiFi),先断开:
sudo nmcli device disconnect wlan0
确认 hostapd 服务未冲突:
sudo systemctl stop hostapd
设备无法连接:
密码长度是否至少 8 位
尝试更换信道:
sudo create_ap wlan0 eth0 OrangePi_Hotspot 12345678 --channel 6
无网络访问:
确认有线网卡 eth0 已连接互联网
检查 IP 转发是否开启:
sudo sysctl -w net.ipv4.ip_forward=1
lsblk # 查看磁盘和分区信息
df -h # 查看文件系统使用情况
输出
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
mmcblk0 179:0 0 64G 0 disk
├─mmcblk0p1 179:1 0 256M 0 part /boot
└─mmcblk0p2 179:2 0 8G 0 part / # 仅用了 8G,剩余空间未分配
/ 代表的就是跟文件系统分区 要扩容就是这个分区扩容
sudo resize2fs /dev/mmcblk0p2 # 扩展 ext4 文件系统
sudo mount -o loop rootfs.img ~/mount_dir
挂载镜像到某个目录
sudo vim /etc/shadow
修改密码文件
root:!:19475:0:99999:7:::
!或*代表该账号无法登录
数据段说明
用户名:加密密码:最后修改时间:最小密码年龄:最大密码年龄:警告期:不活动期:过期时间:保留字段
mkpasswd -m sha-512
执行该命令然后输入密码 替换上面的加密密码段
/etc/ssh/sshd_config
修改配置文件
PermitRootLogin yes # 修改后重启 SSH 服务:sudo systemctl restart sshd
设置允许root 密码登录
在嵌入式Linux系统中,U-Boot、Kernel(内核)和Rootfs(根文件系统) 是三个核心组件,它们分工协作,共同完成系统启动和运行。以下是它们的相互关系和作用:
zImage或uImage)和设备树(dtb)到内存。/ 目录。init 或 systemd,PID=1)。root= 指定Rootfs位置)。/bin、/sbin)。/etc)。/lib)。/usr)。root=/dev/mmcblk0p2)挂载。/sbin/init 或 /lib/systemd/systemd(第一个用户进程)。console=ttyS0 root=/dev/nfs)。init进程,进入用户空间,完成系统启动。/bin/sh缺失)。通过三者协同,嵌入式系统从硬件上电到完整启动,最终运行应用程序。
一般通过命令nmtui设置
一般GPIO初始化是执行
GPIO.setmode(mode) #来进行引脚定义初始化
GPIO.BOARD = 10
GPIO.BCM = 11
GPIO.SUNXI = 12
GPIO.CUSTOM = 13
其实只是一你骄傲的映射关系 没有真正执行任何代码
但是OPI.GPIO 对不同的香橙派版本 引脚定义不充分
CM4为例子
GPIO.setmode(GPIO.BOARD) #会少了很多引脚的映射
C:\Users\15699\AppData\Local\Programs\Python\Python312\Lib\site-packages\OPi\pin_mappings.py
BOARD: {
3: 12,
5: 11,
7: 6,
8: 198,
10: 199,
11: 1,
12: 7,
13: 0,
15: 3,
16: 19,
18: 18,
19: 15,
21: 16,
22: 2,
23: 14,
24: 13,
26: 10
},
这时候要不更改这个库文件 按照GPIO.readall 补充所有引脚映射
要不执行 自定义引脚映射初始化
GPIO.setmode({
3: 140,
5: 141,
7: 147,
8: 25,
10: 24,
11: 118,
12: 119,
13: 128,
15: 130,
16: 131,
18: 129,
19: 138,
21: 136,
22: 132,
23: 139,
24: 134,
26: 135,
27: 32,
28: 33,
29: 133,
31: 124,
32: 144,
33: 127,
35: 120,
36: 125,
37: 123,
38: 122,
40: 121
})
GPIO.getmode
# 返回CUSTOM 自定义引脚映射
安卓系统启动后会执行
/vendor/etc/init/hw/init.rk3588.rc
这个文件来源于
device/rockchip/rk3588/init.rk3588.rc
在on boot后添加执行脚本
on boot
chmod 0666 /dev/mem
chown root system /dev/mem
chmod 0666 /dev/i2c-5
chown root system /dev/i2c-5
以上是启动后 增加几个文件的读写权限
这几个文件跟GPIO控制有关系