SensESP - changed get_permission_string to array of strings
@@ -34,6 +34,8 @@ void SetupSerialDebug(uint32_t baudrate) {
debugI("\nSerial debug enabled");
}
+static char* permission_strings[] = {"readonly", "readwrite", "admin"};
+
SensESPApp::SensESPApp(String preset_hostname, String ssid,
String wifi_password, String sk_server_address,
uint16_t sk_server_port, StandardSensors sensors,
@@ -85,9 +87,9 @@ SensESPApp::SensESPApp(String preset_hostname, String ssid,
}
};
auto ws_delta_cb = [this]() { this->led_blinker->flip(); };
- this->ws_client =
- new WSClient("/system/sk", sk_delta, sk_server_address, sk_server_port,
- ws_connected_cb, ws_delta_cb, get_permission_string(permissions));
+ this->ws_client = new WSClient("/system/sk", sk_delta, sk_server_address,
+ sk_server_port, ws_connected_cb, ws_delta_cb,
+ permission_strings[(int)permissions]);
}
void SensESPApp::setup_standard_sensors(ObservableValue<String>* hostname,
@@ -182,26 +184,6 @@ void SensESPApp::reset() {
app.onDelay(1000, []() { ESP.restart(); });
}
-String SensESPApp::get_permission_string(SKPermissions permission)
-{
- if(permission == READONLY)
- {
- return "readonly";
- }
- else if(permission == READWRITE)
- {
- return "readwrite";
- }
- else if(permission == ADMIN)
- {
- return "admin";
- }
- else
- {
- return "";
- }
-}
-
String SensESPApp::get_hostname() { return networking->get_hostname()->get(); }
SensESPApp* sensesp_app;
