Whatever the board configuration the processor is always the same, and it's the hardware responsible for the BT connections, so that does not change a thing. Your problem is definitely caused by BT stack incompatibilities. MySondy does use basic BT functionality, still every BT stack out there seems to have so many bugs in even the most trivial use.
Having a modular system would be in my opinion a nightmare for anybody with no hw skills.
Waiting for TTGO..
-
- Posts: 6
- Joined: Tue Apr 25, 2023 3:37 pm
Re: Waiting for TTGO..
Yeah indeed. Perhaps for the unskilled soldering people the modular approach would be less handy..
Anyway. I've been checking Bluetooth with my TTGO, and this works for me on the Arduino.
It's one of the example files, but without some stuff that was originally added to make connecting iPhones easier. I removed those two lines.
I implemented this in some other code, and my LilyGO TTGO ESP32 T3_v1.6.1 20210104 keeps connected, and i can send strings of text to the board from my Android phone. I can also send from board to Arduino.
Hopefully it helps..
You can also use the good old Bluetooth SPP.
That will work.
It is also much easier to use in code (it's basically the same as a Serial connection).
Greetings..
Anyway. I've been checking Bluetooth with my TTGO, and this works for me on the Arduino.
It's one of the example files, but without some stuff that was originally added to make connecting iPhones easier. I removed those two lines.
I implemented this in some other code, and my LilyGO TTGO ESP32 T3_v1.6.1 20210104 keeps connected, and i can send strings of text to the board from my Android phone. I can also send from board to Arduino.
Hopefully it helps..
Code: Select all
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>
BLEServer *pServer = NULL;
BLECharacteristic * pTxCharacteristic;
bool deviceConnected = false;
bool oldDeviceConnected = false;
uint8_t txValue = 0;
#define SERVICE_UUID "6E400001-B5A3-F393-E0A9-E50E24DCCA9E" // UART service UUID
#define CHARACTERISTIC_UUID_RX "6E400002-B5A3-F393-E0A9-E50E24DCCA9E"
#define CHARACTERISTIC_UUID_TX "6E400003-B5A3-F393-E0A9-E50E24DCCA9E"
class MyServerCallbacks: public BLEServerCallbacks {
void onConnect(BLEServer* pServer) {
deviceConnected = true;
};
void onDisconnect(BLEServer* pServer) {
deviceConnected = false;
}
};
class MyCallbacks: public BLECharacteristicCallbacks {
void onWrite(BLECharacteristic *pCharacteristic) {
std::string rxValue = pCharacteristic->getValue();
if (rxValue.length() > 0) {
String value = rxValue.c_str();
ProcessValue(value); // here goes your own call to a function that handles the string for processing
}
}
};
void BT_server_start() {
BLEDevice::init("MyWorkingSondy");
pServer = BLEDevice::createServer();
pServer->setCallbacks(new MyServerCallbacks());
BLEService *pService = pServer->createService(SERVICE_UUID);
pTxCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID_TX,
BLECharacteristic::PROPERTY_NOTIFY
);
pTxCharacteristic->addDescriptor(new BLE2902());
BLECharacteristic * pRxCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID_RX,
BLECharacteristic::PROPERTY_WRITE
);
pRxCharacteristic->setCallbacks(new MyCallbacks());
pService->start();
pServer->getAdvertising()->start();
}
That will work.
It is also much easier to use in code (it's basically the same as a Serial connection).
Greetings..
-
- Posts: 80
- Joined: Thu May 27, 2021 10:17 pm
Re: Waiting for TTGO..
Sure. I don't know how this code relates to your problem though. The firmware uses SPP, it's just that (very likely) your phone's BT stack has some bug in it so that it can't handle the serial connection properly
-
- Posts: 6
- Joined: Tue Apr 25, 2023 3:37 pm
Re: Waiting for TTGO..
Thanks for your reply buttim.
I settle with the idea that my phone is the root of the problem.
Could it be some power-efficient mode thingy bugging?
It feels my BT-connection does not wake up properly.
There is a connection established, but there is just no data exchanged..
For me, it feels like a change of modes, awakening from standby-mode, and then get stuck, and wait..
Greetings
I settle with the idea that my phone is the root of the problem.
Could it be some power-efficient mode thingy bugging?
It feels my BT-connection does not wake up properly.
There is a connection established, but there is just no data exchanged..
For me, it feels like a change of modes, awakening from standby-mode, and then get stuck, and wait..
Greetings
-
- Posts: 80
- Joined: Thu May 27, 2021 10:17 pm
Re: Waiting for TTGO..
Who knows? It could be everything. Can't remember where I read an article stating that every single Android BT stack is buggy...
Who is online
Users browsing this forum: No registered users and 2 guests