13#include <libssh/libssh.h>
52 return "Data Provider";
57 if (ImGui::InputTextWithHint(
"SSH Host",
"192.168.0.0", &
_sshHost))
63 if (ImGui::InputTextWithHint(
"SSH User",
"admin", &
_sshUser))
123 if (j.contains(
"sshHost"))
127 if (j.contains(
"sshUser"))
131 if (j.contains(
"sshPassword"))
135 if (j.contains(
"sshHostkeys"))
139 if (j.contains(
"sshKeyExchange"))
143 if (j.contains(
"sshPublickeyAcceptedTypes"))
147 if (j.contains(
"outputInterval"))
171 ssh_options_set(
_session, SSH_OPTIONS_HOST,
"192.168.178.45");
172 ssh_options_set(
_session, SSH_OPTIONS_USER,
"admin");
173 ssh_options_set(
_session, SSH_OPTIONS_HOSTKEYS,
"ssh-rsa");
174 ssh_options_set(
_session, SSH_OPTIONS_KEY_EXCHANGE,
"ecdh-sha2-nistp256");
175 ssh_options_set(
_session, SSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES,
"ssh-rsa");
178 if (ssh_connect(
_session) != SSH_OK)
208 if (ssh_channel_open_session(
_channel) != SSH_OK)
219 if (ssh_channel_request_pty(
_channel) != SSH_OK)
230 if (ssh_channel_request_shell(
_channel) != SSH_OK)
254 ssh_channel_write(
_channel,
"exit\n", strlen(
"exit\n"));
268 auto obs = std::make_shared<WiFiObs>();
270 std::array<char, 1024> buffer{};
271 std::string receivedData;
272 size_t bytesRead = 0;
274 ssh_channel_write(node->_channel,
"show ap range scanning-results\n", strlen(
"show ap range scanning-results\n"));
277 bytesRead =
static_cast<size_t>(ssh_channel_read_timeout(node->_channel, buffer.data(),
sizeof(buffer), 0, 10));
280 receivedData.append(buffer.data(), bytesRead);
282 }
while (bytesRead > 0);
284 ssh_channel_write(node->_channel,
"clear range-scanning-result\n", strlen(
"clear range-scanning-result\n"));
287 std::istringstream iss(receivedData);
290 while (std::getline(iss, line) && line.find(
"Peer-bssid") == std::string::npos) {}
293 std::getline(iss, line);
294 std::getline(iss, line);
297 std::regex macRegex(
"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$");
299 while (std::getline(iss, line) && !line.empty())
301 std::istringstream lineStream(line);
303 std::string macAddress;
304 lineStream >> macAddress;
310 lineStream >> rtt >> rssi >> stdValue;
312 std::regex timeRegex(R
"(\d{4}-\d{2}-\d{2})");
313 std::string timeStamp1;
314 std::string timeStamp2;
315 lineStream >> timeStamp1;
316 lineStream >> timeStamp2;
317 while (lineStream >> value)
319 if (std::regex_match(value, timeRegex))
327 double measuredDistance =
static_cast<double>(rtt) * 1e-9 / 2 *
InsConst::C_AIR;
328 double measuredDistanceStd =
static_cast<double>(stdValue) * 1e-9 / 2 *
InsConst::C_AIR;
329 if (std::regex_match(macAddress, macRegex))
331 InsTime_YMDHMS yearMonthDayHMS(std::stoi(timeStamp1.substr(0, 4)), std::stoi(timeStamp1.substr(5, 2)), std::stoi(timeStamp1.substr(8, 2)), std::stoi(timeStamp2.substr(0, 2)), std::stoi(timeStamp2.substr(3, 2)), std::stoi(timeStamp2.substr(6, 2)));
332 InsTime timeOfMeasurement(yearMonthDayHMS,
UTC);
333 std::ranges::transform(macAddress, macAddress.begin(), ::toupper);
334 obs->distance = measuredDistance;
335 obs->distanceStd = measuredDistanceStd;
336 obs->macAddress = macAddress;
337 obs->insTime = timeOfMeasurement;
nlohmann::json json
json namespace
Utility class for logging to console and file.
#define LOG_DEBUG
Debug information. Should not be called on functions which receive observations (spamming)
#define LOG_INFO
Info to the user on the state of the program.
#define LOG_TRACE
Detailled info to trace the execution of the program. Should not be called on functions which receive...
Keeps track of the current real/simulation time.
Espressif Observation Class.
std::string type() const override
String representation of the Class Type.
std::string _sshHost
Ssh options.
ssh_session _session
SSH session.
static constexpr size_t OUTPUT_PORT_INDEX_WIFI_OBS
Flow (WiFiObs)
CallbackTimer _timer
Timer object to handle async data requests.
~ArubaSensor() override
Destructor.
void guiConfig() override
ImGui config window which is shown on double click.
std::string _sshPublickeyAcceptedTypes
Public key type.
static void readSensorDataThread(void *userData)
Function which performs the async data reading.
void restore(const json &j) override
Restores the node from a json object.
void deinitialize() override
Deinitialize the node.
static std::string category()
String representation of the Class Category.
static std::string typeStatic()
String representation of the Class Type.
json save() const override
Saves the node into a json object.
std::string _sshHostkeys
SSH encryption.
std::string _sshPassword
User credentials.
ArubaSensor()
Default constructor.
std::string _sshKeyExchange
Key exchange.
ssh_channel _channel
SSH channel.
bool resetNode() override
Resets the node. It is guaranteed that the node is initialized when this is called.
int _outputInterval
Output interval in ms.
std::string _sshUser
User name.
bool initialize() override
Initialize the node.
static constexpr double C_AIR
Speed of light in air: CGPM defined speed of light divided by approximate refractory index of dry air...
The class is responsible for all time-related tasks.
bool isInitialized() const
Checks if the node is initialized.
bool doDeinitialize(bool wait=false)
Asks the node worker to deinitialize the node.
ImVec2 _guiConfigDefaultWindowSize
Node(std::string name)
Constructor.
std::string nameId() const
Node name and id.
std::string name
Name of the Node.
bool _onlyRealTime
Whether the node can run in post-processing or only real-time.
bool _hasConfig
Flag if the config window should be shown.
static std::string type()
Returns the type of the data class.
OutputPin * CreateOutputPin(Node *node, const char *name, Pin::Type pinType, const std::vector< std::string > &dataIdentifier, OutputPin::PinData data=static_cast< void * >(nullptr), int idx=-1)
Create an Output Pin object.
void ApplyChanges()
Signals that there have been changes to the flow.
@ UTC
Coordinated Universal Time.
Universal Time Coordinated [UTC].