使Arduino LilyPad将BlueSmirf v2.11切换至命令模式/从命令模式切换

时间:2020-03-06 14:30:32  来源:igfitidea点击:

电池供电(2 x AA)的Arduino LilyPad应该将BlueSmirf v2.11蓝牙调制解调器切换到命令模式/从命令模式切换(请参见下面的源代码)。 BlueSmirf已设置为9600波特。

如果PC通过蓝牙连接(请参见下面的源代码),则Arduino程序在开始时运行良好(发送多个" ping \ n")。一段时间后,它(LilyPad / BlueSmirf)也开始通过蓝牙连接发送" $$$"和" --- \ n",而不是切换到命令模式。

有任何想法吗?

问候,
坦贝格

// Arduino source code:

void setup () {
  Serial.begin(9600);
}

void loop () {
    Serial.print("$$$");
    delay(2000); // TODO: Inquiry, etc.
    Serial.print("---\n");
    delay(100);
    Serial.print("ping\n");
    delay(2000);
}

// C# source code (runs on PC)

using System;
using System.IO.Ports;

class Program {

    static void Main () {
        SerialPort p = new SerialPort(
            "COM20", 9600, Parity.None, 8, StopBits.One);
        using (p) {
            p.Open();
            while (p.IsOpen) {
                Console.Write((char) p.ReadChar());
            }
        }
    }
}

解决方案

从数据表的第6页:

NOTE1 : You can enter command mode
  locally over the serial port at any
  time when not connected. Once a
  connection is made, you can only enter
  command mode if the config timer has
  not expired. To enable continuous
  configuration, set the config timer to
  255. Also, if the device is in Auto Master mode 3, you will NOT be able to
  enter command mode when connected over
  Bluetooth.

我的猜测是配置计时器即将到期。