Replies: 1 comment 1 reply
-
This looks like an Android/App issue. There isn't anything in this library that could cause this but maybe someone else has had a similar experience and can help. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I have the code snippet below. I have multiple characteristics Read, Write, Notify. When connection to an IOS, all charactersitics of the advertised service are recogniced from clients side.
When Connecting with Android only 4 Characteristics are recognized. (seems there is a cut off when 4 characteristics are in the stack?)
Here the code:
/*
*/
//#include <BLEDevice.h>
//#include <BLEServer.h>
//#include <BLEUtils.h>
//#include <BLE2902.h>
#include <NimBLEDevice.h>
#include "HX711.h"
#include
#include "driver/timer.h"
#include "esp_gatt_defs.h"
// Send Large Datasets
bool deviceConnected = false;
bool startSending = false;
bool startSampling = false;
bool queueFull = false;
SemaphoreHandle_t queueMutex;
#define QUEUE_LENGTH 1000
#define ITEM_SIZE sizeof(int)
QueueHandle_t dataQueue;
int dataThreshold = 100; // Adjusted threshold for example
const int totalSamples = 1000;
int sampleCounter = 0;
hw_timer_t *timer1 = NULL;
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
// Function prototype
void sendLargeDataTask(void * parameter);
void clearQueue(QueueHandle_t queue);
// BLE Connecton MTU size
const int desiredMTU = 103;
const int defaultMTU = 23;
int actualMTU = 23;
bool mtuNegotiated = false;
// Deep Sleep
#define seconds_to_trigger_DeepSleep 600 // Timer in seconds until sleep mode is triggered
// Timer
#define timer_prescale 64000
hw_timer_t *timer0 = NULL;
int32_t counter = 0;
RTC_DATA_ATTR int bootCount = 0;
#define DEVICE_SERVICE_UUID "DFCD0001-36E1-4688-B7F5-EA07361B26A8"
#define CHARACTERISTIC_UUID_STARTDATA "DFCD000A-36E1-4688-B7F5-EA07361B26A8"
#define CHARACTERISTIC_UUID_STOPDATA "DFCD000B-36E1-4688-B7F5-EA07361B26A8"
#define CHARACTERISTIC_UUID_SENSORDATA "DFCD000C-36E1-4688-B7F5-EA07361B26A8"
#define CHARACTERISTIC_UUID_STARTLARGEDATA "DFCD000D-36E1-4688-B7F5-EA07361B26A8"
#define CHARACTERISTIC_UUID_STARTLARGEDATA "DFCD000D-36E1-4688-B7F5-EA07361B26A8"
#define DEVICE_SERVICE_UUID_1 "DFCD0002-36E1-4688-B7F5-EA07361B26A8"
#define CHARACTERISTIC_UUID_LARGEDATA "DFCD000E-36E1-4688-B7F5-EA07361B26A8"
#define DEVICE_SERVICE_UUID_2 "DFCD0003-36E1-4688-B7F5-EA07361B26A8"
#define CHARACTERISTIC_UUID_SENDFLAG "DFCD000F-36E1-4688-B7F5-EA07361B26A8"
bool sendData = false; // Flag to indicate whether to send sensor data
bool resetDSTimer = false; // Flag to reset DeepSleep timer
BLEServer pServer = NULL;
BLECharacteristic pCharacteristic_R_StartData= NULL;
BLECharacteristic* pCharacteristic_R_StopData= NULL;
BLECharacteristic* pCharacteristic_W_SensorData= NULL;
BLECharacteristic* pCharacteristic_R_StartLargeData= NULL;
BLECharacteristic* pCharacteristic_W_LargeData= NULL;
BLECharacteristic* pCharacteristic_W_SendFlag= NULL;
class MyServerCallbacks : public BLEServerCallbacks {
void onConnect(BLEServer* pServer) {
deviceConnected = true;
// Attempt to set the desired MTU size
//BLEDevice::setMTU(desiredMTU);
//actualMTU = BLEDevice::getMTU();
//Serial.println("actualMTU after Connection");
//Serial.println(actualMTU);
}
};
class MyClientCallbacks : public BLEClientCallbacks {
void onConnect(BLEClient* pClient) {
Serial.println("Client connected");
}
};
class MyCallbacks : public BLECharacteristicCallbacks {
void onWrite(BLECharacteristic* pCharacteristic) {
std::string value = pCharacteristic->getValue();
};
void setupBLE() {
BLEDevice::init("SmartEdge");
pServer = BLEDevice::createServer();
pServer->setCallbacks(new MyServerCallbacks());
}
// Timer based interrupt Service Routines --------------------------------
void IRAM_ATTR onTimer() {
// Sample data and push it to the queue
int hallValue = hallRead(); // Read the Hall sensor value
//Serial.println(hallValue); // Debug print for hallValue
}
void IRAM_ATTR Timer0_ISR()
{
counter++;
esp_deep_sleep_start();
}
void clearQueue(QueueHandle_t queue) {
int dummy;
while (xQueueReceive(queue, &dummy, 0) == pdTRUE) {
// Discarding all items
}
queueFull = false;
}
// Sensor Configuration
long lastMsg = 0;
bool bSensorValue = false; // flag for fetching sensor value
double sensorValue = 0;
String dataToSend;
/*
//HX711 Configuration
HX711 scale; // Initializes library functions.
double calibration_factor = -55080;//-20328; // Defines calibration factor we'll use for calibrating.
// HX711 circuit wiring
#define SDA 21
#define SCL 22
*/
/*
Method to print the reason by which ESP32
has been awaken from sleep
*/
void print_wakeup_reason(){
esp_sleep_wakeup_cause_t wakeup_reason;
wakeup_reason = esp_sleep_get_wakeup_cause();
switch(wakeup_reason)
{
case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by external signal using RTC_IO"); break;
case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break;
case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("Wakeup caused by touchpad"); break;
case ESP_SLEEP_WAKEUP_ULP : Serial.println("Wakeup caused by ULP program"); break;
default : Serial.printf("Wakeup was not caused by deep sleep: %d\n",wakeup_reason); break;
}
}
void setup()
{
Serial.begin(9600);
}
void loop()
{
long now = millis();
}
Beta Was this translation helpful? Give feedback.
All reactions