@@ -44,9 +44,7 @@ SSD1306DisplayDevice* displayTest;
4444
4545HCSR04SensorManager* sensorManager;
4646
47- #ifdef BLUETOOTH_ACTIVATED
4847BluetoothManager* bluetoothManager;
49- #endif
5048
5149String esp_chipid;
5250
@@ -169,20 +167,16 @@ void setup() {
169167 // ##############################################################
170168
171169 // Counter, how often the SD card will be read before writing an error on the display
172- int8_t sdCount = 25 ;
170+ int8_t sdCount = 5 ;
173171
174172 displayTest->showTextOnGrid (2 , 2 , " SD..." );
175- boolean requiresSdCardMount = true ;
176- #ifdef RADMESSER_S_COMPATIBILITY_MODE
177- requiresSdCardMount = false ;
178- #endif
179173 while (!SD.begin ())
180174 {
181175 if (sdCount > 0 ) {
182176 sdCount--;
183177 } else {
184178 displayTest->showTextOnGrid (2 , 2 , " SD... error" );
185- if (!requiresSdCardMount ) {
179+ if (config. simRaMode || digitalRead (PushButton) == HIGH ) {
186180 break ;
187181 }
188182 }
@@ -201,12 +195,7 @@ void setup() {
201195 // ##############################################################
202196
203197 buttonState = digitalRead (PushButton);
204-
205- bool requiresDisplayConnection = true ;
206- #ifdef RADMESSER_S_COMPATIBILITY_MODE
207- requiresDisplayConnection = false ;
208- #endif
209- if (buttonState == HIGH || (requiresDisplayConnection && displayError != 0 ))
198+ if (buttonState == HIGH || (!config.simRaMode && displayError != 0 ))
210199 {
211200 displayTest->showTextOnGrid (2 , 2 , " Start Server" );
212201 esp_bt_mem_release (ESP_BT_MODE_BTDM); // no bluetooth at all here.
@@ -253,12 +242,15 @@ void setup() {
253242
254243 displayTest->showTextOnGrid (2 , 3 , " CSV file..." );
255244
256- writer = new CSVFileWriter;
257- writer->setFileName ();
258- writer->writeHeader ();
259- Serial.println (" File initialised" );
260-
261- displayTest->showTextOnGrid (2 , 3 , " CSV file... ok" );
245+ if (SD.begin ()) {
246+ writer = new CSVFileWriter;
247+ writer->setFileName ();
248+ writer->writeHeader ();
249+ displayTest->showTextOnGrid (2 , 3 , " CSV file... ok" );
250+ Serial.println (" File initialised" );
251+ } else {
252+ displayTest->showTextOnGrid (2 , 3 , " CSV file... skip" );
253+ }
262254
263255 // ##############################################################
264256 // GPS
@@ -267,10 +259,8 @@ void setup() {
267259 displayTest->showTextOnGrid (2 , 4 , " Wait for GPS" );
268260 Serial.println (" Waiting for GPS fix..." );
269261 bool validGPSData = false ;
270- bool requiresGpsConnection = true ;
271- #ifdef RADMESSER_S_COMPATIBILITY_MODE
272- requiresGpsConnection = false ;
273- #endif
262+ readGPSData ();
263+ delay (300 );
274264 while (!validGPSData)
275265 {
276266 Serial.println (" readGPSData()" );
@@ -314,7 +304,9 @@ void setup() {
314304 displayTest->showTextOnGrid (2 , 5 , satellitesString);
315305
316306 buttonState = digitalRead (PushButton);
317- if (buttonState == HIGH)
307+ if (buttonState == HIGH
308+ || (config.simRaMode && gps.passedChecksum () == 0 ) // no module && simRaMode
309+ )
318310 {
319311 Serial.println (" Skipped get GPS..." );
320312 displayTest->showTextOnGrid (2 , 5 , " ...skipped" );
@@ -331,10 +323,12 @@ void setup() {
331323 // ##############################################################
332324 // Bluetooth
333325 // ##############################################################
334- #ifdef BLUETOOTH_ACTIVATED
335- bluetoothManager->init ();
336- bluetoothManager->activateBluetooth ();
337- #endif
326+ if (config.bluetooth ) {
327+ bluetoothManager->init ();
328+ bluetoothManager->activateBluetooth ();
329+ } else {
330+ esp_bt_mem_release (ESP_BT_MODE_BTDM); // no bluetooth at all here.
331+ }
338332
339333 delay (1000 ); // Added for user experience
340334
@@ -388,21 +382,21 @@ void loop() {
388382 lastMeasurements
389383 );
390384
391- # ifdef BLUETOOTH_ACTIVATED
392- auto leftValues = std::list<uint16_t >();
393- auto rightValues = std::list<uint16_t >();
385+ if (config. bluetooth ) {
386+ auto leftValues = std::list<uint16_t >();
387+ auto rightValues = std::list<uint16_t >();
394388
395- if (sensorManager->m_sensors [1 ].rawDistance < MAX_SENSOR_VALUE) {
396- leftValues.push_back (sensorManager->m_sensors [1 ].rawDistance );
397- }
398- if (sensorManager->m_sensors [0 ].rawDistance < MAX_SENSOR_VALUE) {
399- rightValues.push_back (sensorManager->m_sensors [0 ].rawDistance );
400- }
401- if (measurements == 0 || !leftValues.empty () || !rightValues.empty ()) {
402- bluetoothManager->newSensorValues (leftValues, rightValues);
389+ if (sensorManager->m_sensors [1 ].rawDistance < MAX_SENSOR_VALUE) {
390+ leftValues.push_back (sensorManager->m_sensors [1 ].rawDistance );
391+ }
392+ if (sensorManager->m_sensors [0 ].rawDistance < MAX_SENSOR_VALUE) {
393+ rightValues.push_back (sensorManager->m_sensors [0 ].rawDistance );
394+ }
395+ if (measurements == 0 || !leftValues.empty () || !rightValues.empty ()) {
396+ bluetoothManager->newSensorValues (leftValues, rightValues);
397+ }
398+ bluetoothManager->processButtonState (digitalRead (PushButton));
403399 }
404- bluetoothManager->processButtonState (digitalRead (PushButton));
405- #endif
406400
407401 // #######################################################
408402 // Storage
0 commit comments