Support scanning ANSVIS servers device
This commit is contained in:
@@ -20,6 +20,14 @@
|
||||
#include <functional>
|
||||
|
||||
namespace ANSCENTER {
|
||||
// Discovered AIBOX / ANSVIS server on the local network.
|
||||
struct ANSDeviceInfo {
|
||||
std::string ip; // IPv4 address (dotted-decimal)
|
||||
std::string name; // Device name from UDP probe, empty if HTTP-only
|
||||
std::string firmware; // Version string ("-" if device did not report one)
|
||||
int source{ 0 }; // 1 = multicast, 2 = HTTP sweep, 3 = both
|
||||
};
|
||||
|
||||
class ANSULT_API ANSUtilities {
|
||||
private:
|
||||
// Protects all shared mutable data
|
||||
@@ -144,6 +152,20 @@ namespace ANSCENTER {
|
||||
// Unescape double-escaped Unicode: "Th\\u1ee7y" becomes "Th\u1ee7y".
|
||||
// Reverses DoubleEscapeUnicode so other languages can parse \uXXXX correctly.
|
||||
static std::string UnescapeDoubleEscapedUnicode(const std::string& str);
|
||||
|
||||
// Scan the local network for AIBOX / ANSVIS servers.
|
||||
// Runs two strategies in parallel and merges results by IP:
|
||||
// 1) UDP multicast probe to 230.50.200.150:58839 (with subnet
|
||||
// broadcast fallback). App listens on UDP/58838 for replies
|
||||
// in the form "<a>:<b>:<deviceName>:<firmware>".
|
||||
// 2) HTTP /24 subnet sweep on every local IPv4 interface, GETing
|
||||
// http://<host>/ServerApi with up to 64 concurrent connections.
|
||||
// A device is recognized when the JSON body contains
|
||||
// {"OK": true, "Version": "<firmware>"}.
|
||||
// `timeoutMs` is the maximum scan window (default 5000 ms). Shorter
|
||||
// values return faster but may miss slow devices. The call blocks
|
||||
// until the window elapses, then returns the deduplicated list.
|
||||
[[nodiscard]] static std::vector<ANSDeviceInfo> ScanDevices(int timeoutMs = 5000);
|
||||
};
|
||||
// Connection bundle for pool
|
||||
struct S3Connection {
|
||||
@@ -345,6 +367,13 @@ extern "C" ANSULT_API int SendEmail(const char* smtpServer, int port,
|
||||
|
||||
extern "C" ANSULT_API int RebootSystem();
|
||||
|
||||
// Discover AIBOX / ANSVIS servers on the local network.
|
||||
// Returns a JSON array of objects: [{"ip":"...","name":"...","firmware":"...","source":3}, ...]
|
||||
// `source` is 1 = multicast, 2 = HTTP sweep, 3 = both.
|
||||
// `timeoutMs` caps the scan duration (typical: 3000-10000 ms).
|
||||
extern "C" ANSULT_API int ScanANSDevices(int timeoutMs, LStrHandle resultJson);
|
||||
extern "C" ANSULT_API int ScanANSDevicesCpp(int timeoutMs, std::string& resultJson);
|
||||
|
||||
// Unicode conversion utilities for LabVIEW
|
||||
extern "C" ANSULT_API int ANSConvertUTF8ToUTF16LE(const char* utf8Str, LStrHandle result, int includeBOM = 1);
|
||||
extern "C" ANSULT_API int ANSDecodeJsonUnicodeToUTF16LE(const char* escapedStr, LStrHandle result);
|
||||
|
||||
Reference in New Issue
Block a user