#include "Sensors.h" SensorType AllSensors::getTypeFromText(const char* input) { SensorType whichSensor = SENSOR_COUNT; uint8_t maxWordsFound = 0; // Iterate over all posible sensor types for (uint8_t i=0; i(i); // How many words match in Sensor title uint8_t matchedWords = countMatchedWords(thisSensor, input); // Keep the one that matched more words if (matchedWords > maxWordsFound) { maxWordsFound = matchedWords; whichSensor = thisSensor; } } return whichSensor; } uint8_t AllSensors::countMatchedWords(SensorType whichSensor, const char* input) { uint8_t matched = 0; // Make a copy of sensor title in lowercase size_t titleLen = strlen(list[whichSensor].title) + 1; char titleCompare[titleLen]; for (uint8_t i=0; i(ii); if (list[thisSensorType].priority == i) { prioSortedList[sensorCount] = thisSensorType; sensorCount++; } } } sorted = true; } return prioSortedList[index]; }