HM-10:也许有些AT命令没有实现?
问题描述:
我正在开发一个PIC dsPIC33通过串口连接到HM-10设备的项目。 我发送给设备的AT命令,但似乎一些AT命令没有在HM-10固件中实现。 详细说明:HM-10:也许有些AT命令没有实现?
AT+RESET - > OK+RESET : it works
AT+RENEW -> OK+RENEW : it works
AT+NAME? -> OK+NAME:HMSoft : it works
AT+VER? -> no answer : it doesn't work
AT+VERS -> no answer : it doesn't work
AT+NAMEaa -> no answer : it doesn't work
你有没有类似的问题? 非常感谢您的帮助与合作 亲切的问候
答
看一看datasheet。没有AT+VER?
或AT+VERS
命令。他们是AT+VERR?
和AT+VERS?
。
我用HC-06做了一些测试,有些命令需要一个CR,有些则没有。也许这也是你的问题?
我用这个代码在一个Arduino草图来设置蓝牙设备名称为HC-06:
// Enter AT command mode
if (enterATCommandMode() == true)
{
// Set the name. As we don't have an end-of-line mark, we need to wait until the
// timeout is reached and hope for the best. We also check whether the reply starts
// with "OK", so have at least some indication things worked.
hc06.print("AT+NAME" + userInput);
String reply = hc06.readString();
if (reply.equals(""))
{
Serial.println(F("HC-06 didn't reply in time!"));
}
else
{
if (reply.length() < 2 || !reply.substring(0,2).equalsIgnoreCase(F("OK")))
Serial.println("Unexpected answer ('" + reply + "') to AT+NAME command!");
else
Serial.println(F("Name was set successfully."));
}
}
bool enterATCommandMode()
{
// This buffer receives at most 2 characters as the reply (plus terminating \0)
char atReplyBuffer[] = { '\0', '\0', '\0' };
// Send AT command and receive answer
hc06.print(F("AT"));
int bytesRead = hc06.readBytesUntil('\0', atReplyBuffer, 2);
String reply = String(atReplyBuffer);
// Timed out or answer wasn't OK? Error.
if (bytesRead != 2 || !reply.equalsIgnoreCase(F("OK")))
{
if (reply.equals(""))
Serial.println(F("HC-06 didn't reply in time!"));
else
Serial.println("Unexpected reply ('" + reply + "') to AT command");
return false;
}
// Success
return true;
}
感谢您的Thorsten您的信息。也许我有一个错误的旧数据表。现在AT + VERS?命令有效,HM-10回复HMsoft V540字符串。 – Ferrari
谢谢Thorsten提供您的信息。也许我有一个错误的旧数据表。现在AT + VERS?命令有效,HM-10回复HMsoft V540字符串。我还在AT + NAMEaa字符串的末尾添加了'\ r','\ n',但是我没有收到任何来自HM-10的答案 – Ferrari
@Ferrari是否需要像我的例子那样进入AT命令模式?你是否这样做? –