1
- #ifdef ESP32
1
+ #if defined( ESP32) && !defined(ARDUINO_SENSEBOX_MCU_ESP32S2)
2
2
#include " phyphoxBLE_ESP32.h"
3
3
#include " Arduino.h"
4
4
#include < stdio.h>
@@ -99,8 +99,8 @@ class MyCharCallback: public BLECharacteristicCallbacks {
99
99
PhyphoxBLE* myServerPointer;
100
100
void onWrite (BLECharacteristic *pCharacteristic) {
101
101
PhyphoxBLE::configHandlerDebug ();
102
-
103
- }
102
+
103
+ }
104
104
};
105
105
106
106
class MyServerCallbacks : public BLEServerCallbacks {
@@ -118,7 +118,7 @@ class MyServerCallbacks: public BLEServerCallbacks {
118
118
void PhyphoxBLE::configHandlerDebug (){
119
119
if (configHandler!=nullptr ){
120
120
(*configHandler)();
121
- }
121
+ }
122
122
}
123
123
124
124
void PhyphoxBLE::eventCharacteristicHandler (){
@@ -132,14 +132,14 @@ void PhyphoxBLE::eventCharacteristicHandler(){
132
132
PhyphoxBLE::experimentTime = swap_int64 (et);
133
133
if (experimentEventHandler!=nullptr ){
134
134
(*experimentEventHandler)();
135
- }
135
+ }
136
136
}
137
137
138
138
void PhyphoxBLE::setMTU (uint16_t mtuSize) {
139
139
BLEDevice::setMTU (mtuSize+3 ); // user mtu size + 3 for overhead
140
-
140
+
141
141
PhyphoxBLE::MTU = mtuSize;
142
- PhyphoxBleExperiment::MTU = mtuSize;
142
+ PhyphoxBleExperiment::MTU = mtuSize;
143
143
}
144
144
145
145
void PhyphoxBLE::start (const char * DEVICE_NAME, uint8_t * exp_pointer, size_t len){
@@ -169,18 +169,18 @@ void PhyphoxBLE::start(const char * DEVICE_NAME)
169
169
PhyphoxBleExperiment::View firstView;
170
170
171
171
// Graph
172
- PhyphoxBleExperiment::Graph firstGraph; // Create graph which will plot random numbers over time
173
- firstGraph.setChannel (0 ,1 );
172
+ PhyphoxBleExperiment::Graph firstGraph; // Create graph which will plot random numbers over time
173
+ firstGraph.setChannel (0 ,1 );
174
174
175
175
// Value
176
176
PhyphoxBleExperiment::Value valueField;
177
177
valueField.setChannel (1 );
178
178
179
179
firstView.addElement (firstGraph);
180
- firstView.addElement (valueField);
180
+ firstView.addElement (valueField);
181
181
defaultExperiment.addView (firstView);
182
-
183
- addExperiment (defaultExperiment);
182
+
183
+ addExperiment (defaultExperiment);
184
184
}
185
185
186
186
BLEDevice::init (DEVICE_NAME);
@@ -192,28 +192,28 @@ void PhyphoxBLE::start(const char * DEVICE_NAME)
192
192
phyphoxBleExperimentCharacteristicUUID,
193
193
BLECharacteristic::PROPERTY_READ |
194
194
BLECharacteristic::PROPERTY_WRITE |
195
- BLECharacteristic::PROPERTY_NOTIFY
196
- );
195
+ BLECharacteristic::PROPERTY_NOTIFY
196
+ );
197
197
eventCharacteristic = phyphoxExperimentService->createCharacteristic (
198
198
phyphoxBleEventCharacteristicUUID,
199
199
BLECharacteristic::PROPERTY_WRITE
200
- );
200
+ );
201
201
202
202
phyphoxDataService = myServer->createService (phyphoxBleDataServiceUUID);
203
203
204
204
dataCharacteristic = phyphoxDataService->createCharacteristic (
205
205
phyphoxBleDataCharacteristicUUID,
206
206
BLECharacteristic::PROPERTY_READ |
207
207
BLECharacteristic::PROPERTY_WRITE |
208
- BLECharacteristic::PROPERTY_NOTIFY
208
+ BLECharacteristic::PROPERTY_NOTIFY
209
209
210
210
);
211
211
212
212
configCharacteristic = phyphoxDataService->createCharacteristic (
213
213
phyphoxBleConfigCharacteristicUUID,
214
214
BLECharacteristic::PROPERTY_READ |
215
215
BLECharacteristic::PROPERTY_WRITE |
216
- BLECharacteristic::PROPERTY_NOTIFY
216
+ BLECharacteristic::PROPERTY_NOTIFY
217
217
);
218
218
219
219
myExperimentDescriptor = new BLE2902 ();
@@ -226,12 +226,12 @@ void PhyphoxBLE::start(const char * DEVICE_NAME)
226
226
myDataDescriptor->setCallbacks (new MyDataCallback ());
227
227
eventCharacteristic->setCallbacks (new MyEventCallback ());
228
228
configCharacteristic->setCallbacks (new MyCharCallback ());
229
-
229
+
230
230
dataCharacteristic->addDescriptor (myDataDescriptor);
231
231
experimentCharacteristic->addDescriptor (myExperimentDescriptor);
232
232
eventCharacteristic->addDescriptor (myEventDescriptor);
233
233
configCharacteristic->addDescriptor (myConfigDescriptor);
234
-
234
+
235
235
236
236
phyphoxExperimentService->start ();
237
237
phyphoxDataService->start ();
@@ -255,7 +255,7 @@ void PhyphoxBLE::poll(int timeout) {
255
255
void PhyphoxBLE::staticStartTask (void * _this){
256
256
PhyphoxBLE::when_subscription_received ();
257
257
delay (1 );
258
- }
258
+ }
259
259
260
260
void PhyphoxBLE::startTask ()
261
261
{
@@ -267,8 +267,8 @@ void PhyphoxBLE::write(float& value)
267
267
{
268
268
/* *
269
269
* \brief Write a single float into characteristic
270
- * The float is parsed to uint8_t*
271
- * because the gattServer write method
270
+ * The float is parsed to uint8_t*
271
+ * because the gattServer write method
272
272
* expects a pointer to uint8_t
273
273
* \param f1 represent a float most likeley sensor data
274
274
*/
@@ -380,40 +380,40 @@ void PhyphoxBLE::when_subscription_received()
380
380
experimentSizeArray[0 ]= (arrayLength >> 24 );
381
381
experimentSizeArray[1 ]= (arrayLength >> 16 );
382
382
experimentSizeArray[2 ]= (arrayLength >> 8 );
383
- experimentSizeArray[3 ]= arrayLength;
383
+ experimentSizeArray[3 ]= arrayLength;
384
384
385
385
uint8_t checksumArray[4 ] = {0 };
386
386
checksumArray[0 ]= (checksum >> 24 ) & 0xFF ;
387
- checksumArray[1 ]= (checksum >> 16 ) & 0xFF ;
387
+ checksumArray[1 ]= (checksum >> 16 ) & 0xFF ;
388
388
checksumArray[2 ]= (checksum >> 8 ) & 0xFF ;
389
- checksumArray[3 ]= checksum & 0xFF ;
389
+ checksumArray[3 ]= checksum & 0xFF ;
390
390
391
391
copy (phyphox, phyphox+7 , header);
392
392
copy (experimentSizeArray, experimentSizeArray+ 4 , header + 7 );
393
- copy (checksumArray, checksumArray + 4 , header +11 );
393
+ copy (checksumArray, checksumArray + 4 , header +11 );
394
394
experimentCharacteristic->setValue (header,sizeof (header));
395
395
experimentCharacteristic->notify ();
396
396
397
397
for (size_t i = 0 ; i < exp_len/20 ; ++i){
398
398
copy (exp+i*20 , exp+i*20 +20 , header);
399
399
experimentCharacteristic->setValue (header,sizeof (header));
400
400
experimentCharacteristic->notify ();
401
- delay (10 );// mh does not work anymore with 1ms delay?!
401
+ delay (10 );// mh does not work anymore with 1ms delay?!
402
402
}
403
-
403
+
404
404
if (exp_len%20 != 0 ){
405
405
const size_t rest = exp_len%20 ;
406
406
uint8_t slice[rest];
407
407
copy (exp + exp_len - rest, exp + exp_len, slice);
408
408
experimentCharacteristic->setValue (slice,sizeof (slice));
409
- experimentCharacteristic->notify ();
409
+ experimentCharacteristic->notify ();
410
410
delay (1 );
411
411
}
412
-
412
+
413
413
414
414
myAdvertising->start ();
415
-
416
-
415
+
416
+
417
417
vTaskDelete ( NULL );
418
418
419
419
}
@@ -423,7 +423,7 @@ void PhyphoxBLE::addExperiment(PhyphoxBleExperiment& exp)
423
423
{
424
424
storage[i]=0 ;
425
425
}
426
-
426
+
427
427
exp.getFirstBytes (EXPARRAY, deviceName);
428
428
for (uint8_t i=0 ;i<phyphoxBleNViews; i++){
429
429
for (int j=0 ; j<phyphoxBleNElements; j++){
@@ -450,8 +450,8 @@ void PhyphoxBLE::begin(HardwareSerial* hwPrint)
450
450
#ifdef DEBUG
451
451
printer = hwPrint;
452
452
if (printer)
453
- printer->begin (115200 );
454
- #endif
453
+ printer->begin (115200 );
454
+ #endif
455
455
}
456
456
457
457
void PhyphoxBLE::printXML (HardwareSerial* printer){
0 commit comments