首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >HM-10:也许有些AT命令没有实现?

HM-10:也许有些AT命令没有实现?
EN

Stack Overflow用户
提问于 2017-01-10 08:21:58
回答 2查看 920关注 0票数 0

我正在开发一个通过串口连接到HM-10设备的PIC dsPIC33项目.我向设备发送AT命令,但似乎有些AT命令没有在HM-10固件中实现。详细情况:

代码语言:javascript
复制
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

你也有类似的问题吗?非常感谢您的帮助和合作,亲切的问候。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-01-10 08:31:20

看一看数据表。没有AT+VER?AT+VERS命令。他们是AT+VERR?AT+VERS?

我用HC-06做了一些测试,有些命令需要CR,有些则没有。也许这也是你的问题?

我在Arduino草图中使用了以下代码来设置HC-06的BT设备名称:

代码语言:javascript
复制
// 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;
}
票数 1
EN

Stack Overflow用户

发布于 2018-09-20 16:10:38

命令必须毫不停顿地发送!(我想)如果我使用以下代码:(假设send8char *x)是写入串口的函数)

代码语言:javascript
复制
send("AT+NAME");
send("myName"); // id doesn't work

char name[20];     
strcpy(name,"AT+NAME");
strcat(name,"myName");
send(name); // if works!!
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41564222

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档