#include "system.h"
|
#include "ssid_manager.h"
|
|
#include <string>
|
|
static std::string wifi_history_json;
|
|
static void AppendJsonEscapedString(std::string& output, const std::string& value) {
|
output.push_back('"');
|
for (char ch : value) {
|
if (ch == '"' || ch == '\\') {
|
output.push_back('\\');
|
}
|
output.push_back(ch);
|
}
|
output.push_back('"');
|
}
|
|
extern "C" const char *WIFI_Get_History_List(void) {
|
auto ssid_list = SsidManager::GetInstance().GetSsidList();
|
|
wifi_history_json.clear();
|
wifi_history_json += "{\"count\":";
|
wifi_history_json += std::to_string(ssid_list.size());
|
wifi_history_json += ",\"wifi\":[";
|
|
for (size_t i = 0; i < ssid_list.size(); ++i) {
|
if (i > 0) {
|
wifi_history_json.push_back(',');
|
}
|
wifi_history_json += "{\"index\":";
|
wifi_history_json += std::to_string(i);
|
wifi_history_json += ",\"ssid\":";
|
AppendJsonEscapedString(wifi_history_json, ssid_list[i].ssid);
|
wifi_history_json.push_back('}');
|
}
|
|
wifi_history_json += "]}";
|
return wifi_history_json.c_str();
|
}
|
|
extern "C" void WIFI_Delete_All(void) {
|
SsidManager::GetInstance().Clear();
|
}
|