Sorry to bother you guys - I’d like to reopen: [SOLVED] Bluetooth BLE support for Adafruit Feather Bluefruit LE
Specifically I’m (still) having issues connecting Blynk to the Adafruit Feather 32u4 BLE board to android. The board appears to be transmitting data to the app, but the app doesn’t seem to be parsing everything.
My test is to write data from the board to the app every 10 seconds.
What I observe is that the app doesn’t keep up and eventually the board times out.
I have a hypothesis - I’m seeing out-of-order sends, perhaps this is confusing the Android code. Here’s an example where message 0E is sent before 0D:
[58159] <[06|00|0E|00|00]
[58202] <[14|00|0D|00|06]vw[00]3[00]3
Could this be the issue?
Sketch:
#define BLYNK_DEBUG
#define BLYNK_PRINT Serial
#define BLYNK_USE_DIRECT_CONNECT
#define DBG_ENABLE 1
#include <SoftwareSerial.h>
#include <SPI.h>
#include <Adafruit_BLE.h>
#include <Adafruit_BluefruitLE_SPI.h>
#include <BlynkSimpleSerialBLE.h>
//===============
// Blynk setup
//===============
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "570529042ad34219a964929e2a483f40";
//===============
// BLE setup
//===============
// SHARED SPI SETTINGS (see adafruit webpages for details)
#define BLUEFRUIT_SPI_CS 8
#define BLUEFRUIT_SPI_IRQ 7
#define BLUEFRUIT_SPI_RST 4 // Optional but recommended, set to -1 if unused
#define BLUEFRUIT_VERBOSE_MODE true
Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);
#define INTERVAL 10000
#define POLL_INTERVAL 1000
int thevalue;
long previousMillis;
long previousPollMillis;
void setup() {
delay(1500);
Serial.begin(115200);
Serial.println(F("Dammint why doens't BLE work?"));
ble.begin(BLUEFRUIT_VERBOSE_MODE);
ble.factoryReset(); //Optional
ble.echo(true);
ble.info();
ble.setMode(BLUEFRUIT_MODE_DATA);
unsigned long currentMillis = millis(); //0; //force an initial publish
previousMillis = currentMillis;
previousPollMillis = currentMillis;
Blynk.begin(ble, auth);
}
void pollBLE() {
ble.setMode(BLUEFRUIT_MODE_COMMAND);
ble.println("AT+BLEUARTFIFO");
ble.waitForOK();
ble.setMode(BLUEFRUIT_MODE_DATA);
}
BLYNK_WRITE(V10) //Random
{
int pinData = param.asInt();
Serial.print(F("Button 10 = "));
Serial.println(pinData);
}
void loop() {
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > INTERVAL) {
previousMillis = currentMillis;
dowrites();
}
Blynk.run();
}
void dowrites() {
Serial.println(F("Tick"));
thevalue++;
Blynk.virtualWrite(V0, thevalue);
Blynk.virtualWrite(V1, thevalue);
Blynk.virtualWrite(V2, thevalue);
Blynk.virtualWrite(V3, thevalue);
//ble.flush();
}
Output
[33546] Connecting...
[37724] >[02|00|01|00]
[37769] >570529042ad34219a964929e2a483f40
[37771] Ready
[37771] Free RAM: 2003
[37773] <[00|00|01|00|C8]
Tick
[37883] <[14|00|01|00|06]vw[00]0[00]1
[37996] <[14|00|02|00|06]vw[00]1[00]1
[38109] <[14|00|03|00|06]vw[00]2[00]1
[38221] <[14|00|04|00|06]vw[00]3[00]1
[47773] <[06|00|05|00|00]
Tick
[47884] <[14|00|06|00|06]vw[00]0[00]2
[47996] <[14|00|07|00|06]vw[00]1[00]2
[48109] <[14|00|08|00|06]vw[00]2[00]2
[48156] >[00|00|05|00|C8]
[48222] <[14|00|09|00|06]vw[00]3[00]2
Tick
[57823] <[14|00|0A|00|06]vw[00]0[00]3
[57935] <[14|00|0B|00|06]vw[00]1[00]3
[58048] <[14|00|0C|00|06]vw[00]2[00]3
[58159] <[06|00|0E|00|00]
[58202] <[14|00|0D|00|06]vw[00]3[00]3
[60160] <[06|00|0F|00|00]
[60397] >[00|00|0E|00|C8]
Tick
[67823] <[14|00|10|00|06]vw[00]0[00]4
[67936] <[14|00|11|00|06]vw[00]1[00]4
[68048] <[14|00|12|00|06]vw[00]2[00]4
[68161] <[14|00|13|00|06]vw[00]3[00]4
[68208] >[00|00|0F|00|C8]
Tick
[77824] <[14|00|14|00|06]vw[00]0[00]5
[77938] <[14|00|15|00|06]vw[00]1[00]5
[78051] <[14|00|16|00|06]vw[00]2[00]5
[78163] <[14|00|17|00|06]vw[00]3[00]5
[78211] <[06|00|18|00|00]
[80214] <[06|00|19|00|00]
[82216] <[06|00|1A|00|00]
[84211] Heartbeat timeout: 84211, 68210, 82216
[84213] Connecting...