【问题标题】:HM-10: maybe some AT commands are not implemented?HM-10:可能有些 AT 指令没有执行?
【发布时间】:2017-05-24 16:05:40
【问题描述】:

我正在开发一个项目,其中 PIC dsPIC33 通过串行端口连接到 HM-10 设备。 我向设备发送 AT 命令,但似乎某些 AT 命令未在 HM-10 固件中实现。 详细:

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

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

【问题讨论】:

    标签: at-command hm-10 dspic


    【解决方案1】:

    看看datasheet。没有AT+VER?AT+VERS 命令。他们是AT+VERR?AT+VERS?

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

    我在 Arduino 草图中使用此代码为 HC-06 设置 BT 设备名称:

    // 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 字符串回复。
    • 感谢 Thorsten 提供的信息。也许我有一个错误的旧数据表。现在是 AT+VERS?命令有效,HM-10 使用 HMsoft V540 字符串回复。我还在 AT+NAMEaa 字符串的末尾添加了 '\r', '\n' 但我没有收到来自 HM-10 的任何答复
    • @Ferrari 有必要像我的例子那样进入 AT 命令模式吗?你这样做了吗?
    • 是的,我做到了。我还注意到,在发送 AT+NAMEaaa\r\n 命令后,HM-10 停止工作。它不再接受任何命令(即 AT+NAME? 或 AT+RESET 不响应
    • 解决了!我修复了 AT+NAME 程序以更改 HC-06 的名称。我认为错误在于我将命令分为两部分。
    【解决方案2】:

    命令必须在没有任何暂停的情况下发送! (我想)。如果我使用以下代码:(假设 send8char *x) 是写入串口的函数)

    send("AT+NAME");
    send("myName"); // id doesn't work
    
    char name[20];     
    strcpy(name,"AT+NAME");
    strcat(name,"myName");
    send(name); // if works!!
    

    【讨论】:

      猜你喜欢
      • 2016-11-25
      • 2018-06-30
      • 2021-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-18
      • 1970-01-01
      相关资源
      最近更新 更多