Chris Attebery <[email protected]> writes:

> Well, that was it. I fired up the TeleBT then turned on the tablet. Once
> the tablet booted up I fired up AltosDroid and the TeleBT connected
> immediately. I need to put a note on the TeleBT to fire it up before I
> start the app.

Yeah, I tried (without success) to fix this. It's a bit better with
current AltosDroid, but it still fails far too often. Let me describe
the bug so you understand why it does what it does.

We're using a bluetooth module in TeleBT which connects over a serial
port to the processor (cc1111 for TBT v1, ARM for TBT v3 and newer). The
BT module is actually a stand-alone computer (yay, more computers!)
running the BT protocol.

The BT module in v1 and v3 is controlled with AT codes on the serial
port (If you've ever used a modem, you may know what AT codes are). The
trouble is that these commands are 'in-band', which means that you use
the same wires to send the commands as you use to communicate with the
remote device once connected. However, when connected, it's ignoring the
AT commands.

The specifications for this BT module say that it can take 'several
seconds' after power on before the device is ready to accept commands,
and that if you try to send commands early, you may confuse it. So, we
wait for about 5 seconds after power on before trying to talk to the BT
module to configure it for use.

The BT module configuration parameters are saved in flash within the BT
module, so we really only need to perform that configuration once, but
there's no way to know if we've already configured it because TeleBT
doesn't have any persistent memory itself. So at startup time, we need
to check the BT module configuration, and set it if it hasn't been set
before.

As soon as the BT module is configured, it will be detected by the
AltosDroid software when trying to connect.

So, what happens to break things is that you power up AltosDroid and
attempt to connect to the device. It sits there looking for the BT
module, waiting for it to appear.

You power up TeleBT, and while we wait for the module to be ready to
talk to the processor, if it's already configured (which it will be
after the first time you power on TeleBT), it suddenly appears to
AltosDroid and gets connected.

This *disables* our ability to check the configuration on the module;
the AT commands we're sending to talk to it get ignored. Attempts to
force the device back to command mode (with the classic '+++') only
serve to make Android re-connect before we get a chance to send any
configuration commands.

What I've done to try and work around this is to have AltosDroid notice
that it can't communicate with TeleBT's processor and disconnect 'for a
while' to give TeleBT time to reset the BT module and configure it. That
depends on having a time which is long enough for TeleBT to figure out
that things are wedged, send the '+++' sequence and then attempt to
configure it again. Right now, AltosDroid waits 4 seconds; that's
clearly not long enough in your case.

The new BT module in TeleBT v4 has a separate pin which controls command
vs data mode, so we can simply hold the device in command mode while
configuring it, avoiding this problem nicely.

-- 
-keith

Attachment: signature.asc
Description: PGP signature

_______________________________________________
altusmetrum mailing list
[email protected]
http://lists.gag.com/mailman/listinfo/altusmetrum

Reply via email to