工具与软件:
SDK 版本: 7.40.00.77
#!/bin/sh #/usr/bin/blescan.sh tty="$(uci -q get tisbl.tisbl.tty)" [ -z "$tty" ] && tty='/dev/ttyMSM1' exec 100>"/var/lock/ble.lock" flock 100 MAX_COUNT=20 count=1 com-wr.sh "$tty" 3 "\x01\x1D\xFC\x01\x00" > /dev/null # this reset command delay time must >= 3, if small than 3, the following commands will be something wrong com-wr.sh "$tty" 1 "\x01\x00\xFE\x08\x02\x00\x00\x00\x00\x00\x00\x00" > /dev/null com-wr.sh "$tty" 1 "\x01\x60\xFE\x04\x01\x00\x20\x00" > /dev/null com-wr.sh "$tty" 1 "\x01\x60\xFE\x04\x01\x01\x20\x00" > /dev/null com-wr.sh "$tty" 1 "\x01\x61\xFE\x02\x01\x02" > /dev/null com-wr.sh "$tty" 1 "\x01\x61\xFE\x02\x01\x03" > /dev/null com-wr.sh "$tty" 1 "\x01\x61\xFE\x02\x01\x04" > /dev/null com-wr.sh "$tty" 1 "\x01\x61\xFE\x02\x01\x05" > /dev/null while [ $count -le $MAX_COUNT ] do com-wr.sh "$tty" 3 "\x01\x51\xFE\x06\x00\x00\x00\x04\x00\x02" | tee /tmp/blescan.data | ble-scan-rx-parser.sh com-wr.sh "$tty" 1 "\x01\x52\xFE\x00" > /dev/null count=$((count + 1)) done exec 100>&-
下面随附的代码介绍了我们如何在每个扫描周期向 CC2652发送命令。
#!/bin/sh # com-wr.sh tty time command parser # example com-wr.sh /dev/ttyMSM1 1 "\x01\x1D\xFC\x01\x00" | hexdump.sh --> send "\x01\x1D\xFC\x01\x00" to /dev/ttyMSM1 and then hexdump receive data until 100ms timeout #command example "\x7E\x03\xD0\xAF und normaler Text" usleep 10000 tty=$1 time=$2 command=$3 parser=$4 stty -F $tty time $time exec 99< $tty echo -en $command > $tty cat $tty exec 99<&-
下面 随附代码介绍了我们向 TTY 发送命令的方式
在当前情况下、是我们通过命令从 UART 接收到的数据 "\x01\x51\xFE\x06\x00\x00\x04\x00\x02" 有限制(约16条记录)。
因此、我们称为命令 "\x01\x51\xFE\x06\x00\x00\x04\x00\x02" 荷电状态。
我们想知道是否有任何方法可以让 CC2652 连续扫描 BLE 信标。
然后、我们可以使用重复的 UART 数据读取、而不是每次都向 CC2652R 发送扫描相关命令。