Arduino SoftwareSerial Write蓝牙切断静态短信回写
Arduino SoftwareSerial Write bluetooth cutting off static text message write back
我是 Arduino 的新手,所以这可能是一些我不知道的非常简单的 C/C++ 问题
我正在制作一个 RGB LED 立方体,它是根据 GreatScott 的视频制作的。它工作正常。我决定通过添加蓝牙来改进 wahat 可以用它来完成。我正在使用 DSD tech 的 HM-11。
我可以通过蓝牙从 phone 向 arduino 写入命令,没有任何问题,我用它来交换模式。
我面临的问题是当我尝试通过蓝牙写回我的 phone 时。我正在通过蓝牙发回帮助文本,以便连接到它并发送帮助的任何人都可以找到支持的命令列表。使用 SoftwareSerial,我有以下内容(问题区域的片段):
if(strcmp(command,"help")==0){
Serial.print(F("============== RGBCube Bluetooth Help ==============\n"
"Commands: \n"
" mode:# select mode to operate in \n"
" help pull up help screen (this) \n"
" Mode 4 only: \n"
" reset resets cube to black \n"
" pt:x,y,z=r,g,b sets led at (x,y,z) to rgb \n"
" set:r,g,b;r,g,b... sets entire cube to the \n"
" specified colour \n"
" 64 colours long. Faster \n"
" than 64 pt calls \n"));
BTSerial.print(F("============== RGBCube Bluetooth Help ==============\n"
"Commands: \n"
" mode:# select mode to operate in \n"
" help pull up help screen (this) \n"
" Mode 4 only: \n"
" reset resets cube to black \n"
" pt:x,y,z=r,g,b sets led at (x,y,z) to rgb \n"
" set:r,g,b;r,g,b... sets entire cube to the \n"
" specified colour \n"
" 64 colours long. Faster \n"
" than 64 pt calls \n"));
}
运行时,串口接收:
============== RGBCube Bluetooth Help ==============
Commands:
mode:# select mode to operate in
help pull up help screen (this)
Mode 4 only:
reset resets cube to black
pt:x,y,z=r,g,b sets led at (x,y,z) to rgb
set:r,g,b;r,g,b... sets entire cube to the
specified colour
64 colours long. Faster
than 64 pt calls
但我的 phone 最多收到:
============== RGBCube Bluetooth Help ==============
Commands:
mode:# select mode to operate in
help pull up help screen (this)
Mode 4 only:
reset resets cube to black
pt:x,y,z=r,g,b sets led at (x,y,z) to rgb
set:r,g,b;r,g,b... sets entire cube to the
如您所见,这被截断了。我已经尝试了很多东西,包括将字符串推入 progmem,将它分成更小的 stringsm Char 数组用于循环,强制它保存在闪存中,等等。将它切成更小的字符串有效,但我真的不想那样做,因为接下来我要添加的是从 phone 到 arduino 的相似长度写入。
有时更少的字符也可以,但这是平均值,也是最大值,让我觉得存在某种形式的限制,但它不是 2 的倍数(我最后数过大约 80ish)
如有任何帮助,我们将不胜感激。
看起来您可以在截断之前发送大约 252 个字节。这个数字似乎是关于 BLE 数据包中的最大数据大小。
关于最大数据大小的讨论位于:Maximum packet length for Bluetooth LE?
BLE“长读取”和“日志写入”功能包括一个偏移量以及请求中的句柄,因此特征值可以是 read/written 在多个 request/response 对的连续块中。我不知道 Arduino 库和 HM-11 硬件是否支持该功能。
我是 Arduino 的新手,所以这可能是一些我不知道的非常简单的 C/C++ 问题
我正在制作一个 RGB LED 立方体,它是根据 GreatScott 的视频制作的。它工作正常。我决定通过添加蓝牙来改进 wahat 可以用它来完成。我正在使用 DSD tech 的 HM-11。
我可以通过蓝牙从 phone 向 arduino 写入命令,没有任何问题,我用它来交换模式。
我面临的问题是当我尝试通过蓝牙写回我的 phone 时。我正在通过蓝牙发回帮助文本,以便连接到它并发送帮助的任何人都可以找到支持的命令列表。使用 SoftwareSerial,我有以下内容(问题区域的片段):
if(strcmp(command,"help")==0){
Serial.print(F("============== RGBCube Bluetooth Help ==============\n"
"Commands: \n"
" mode:# select mode to operate in \n"
" help pull up help screen (this) \n"
" Mode 4 only: \n"
" reset resets cube to black \n"
" pt:x,y,z=r,g,b sets led at (x,y,z) to rgb \n"
" set:r,g,b;r,g,b... sets entire cube to the \n"
" specified colour \n"
" 64 colours long. Faster \n"
" than 64 pt calls \n"));
BTSerial.print(F("============== RGBCube Bluetooth Help ==============\n"
"Commands: \n"
" mode:# select mode to operate in \n"
" help pull up help screen (this) \n"
" Mode 4 only: \n"
" reset resets cube to black \n"
" pt:x,y,z=r,g,b sets led at (x,y,z) to rgb \n"
" set:r,g,b;r,g,b... sets entire cube to the \n"
" specified colour \n"
" 64 colours long. Faster \n"
" than 64 pt calls \n"));
}
运行时,串口接收:
============== RGBCube Bluetooth Help ============== Commands:
mode:# select mode to operate in
help pull up help screen (this) Mode 4 only:
reset resets cube to black
pt:x,y,z=r,g,b sets led at (x,y,z) to rgb set:r,g,b;r,g,b... sets entire cube to the
specified colour
64 colours long. Faster
than 64 pt calls
但我的 phone 最多收到:
============== RGBCube Bluetooth Help ============== Commands:
mode:# select mode to operate in
help pull up help screen (this) Mode 4 only:
reset resets cube to black
pt:x,y,z=r,g,b sets led at (x,y,z) to rgb set:r,g,b;r,g,b... sets entire cube to the
如您所见,这被截断了。我已经尝试了很多东西,包括将字符串推入 progmem,将它分成更小的 stringsm Char 数组用于循环,强制它保存在闪存中,等等。将它切成更小的字符串有效,但我真的不想那样做,因为接下来我要添加的是从 phone 到 arduino 的相似长度写入。
有时更少的字符也可以,但这是平均值,也是最大值,让我觉得存在某种形式的限制,但它不是 2 的倍数(我最后数过大约 80ish)
如有任何帮助,我们将不胜感激。
看起来您可以在截断之前发送大约 252 个字节。这个数字似乎是关于 BLE 数据包中的最大数据大小。
关于最大数据大小的讨论位于:Maximum packet length for Bluetooth LE?
BLE“长读取”和“日志写入”功能包括一个偏移量以及请求中的句柄,因此特征值可以是 read/written 在多个 request/response 对的连续块中。我不知道 Arduino 库和 HM-11 硬件是否支持该功能。