views:

1007

answers:

1

A battery powered (2 x AA) Arduino LilyPad should switch a BlueSmirf v2.11 Bluetooth modem to/from command mode (see source code below). The BlueSmirf has been set to 9600 baud.

If the PC connects via Bluetooth (see source code below), the Arduino program runs fine at the beginning (sending multiple "ping\n"). After some time it (LilyPad/BlueSmirf) starts to also send "$$$" and "---\n" over the Bluetooth connection instead of switching to/from command mode.

Any ideas?

Regards, tamberg

// 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());
            }
        }
    }
}
+1  A: 

From the datasheet, page 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.

My guess would be that the config timer is expiring.

Craig Trader