From d1ac61bc9eb772dac1a64cde2c41fa5c9f4f8f93 Mon Sep 17 00:00:00 2001 From: Adam Shapiro Date: Fri, 29 Mar 2024 09:05:56 -0400 Subject: [PATCH] Require a unique ID in the simple_polaris_client examples. --- c/examples/simple_polaris_client.c | 14 ++++++++++++-- examples/simple_polaris_client.cc | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/c/examples/simple_polaris_client.c b/c/examples/simple_polaris_client.c index 27efe5e..d4fc4ba 100644 --- a/c/examples/simple_polaris_client.c +++ b/c/examples/simple_polaris_client.c @@ -28,13 +28,23 @@ void HandleSignal(int sig) { int main(int argc, const char* argv[]) { if (argc < 2 || argc > 4) { P1_fprintf(stderr, - "Usage: %s API_KEY [UNIQUE_ID] [LOG_LEVEL (1=debug, 2=trace)]\n", + "Usage: %s API_KEY UNIQUE_ID [LOG_LEVEL (1=debug, 2=trace)]\n", argv[0]); return 1; } const char* api_key = argv[1]; - const char* unique_id = argc > 2 ? argv[2] : "device12345"; + if (strlen(api_key) == 0) { + P1_fprintf(stderr, + "You must supply a Polaris API key to connect to the server.\n"); + return 1; + } + + const char* unique_id = argv[2]; + if (strlen(unique_id) == 0) { + P1_fprintf(stderr, "You must supply a unique ID for this connection.\n"); + return 1; + } int log_level = argc > 3 ? atoi(argv[3]) : POLARIS_LOG_LEVEL_INFO; Polaris_SetLogLevel(log_level); diff --git a/examples/simple_polaris_client.cc b/examples/simple_polaris_client.cc index ded1fa1..339ca76 100644 --- a/examples/simple_polaris_client.cc +++ b/examples/simple_polaris_client.cc @@ -27,7 +27,7 @@ using namespace point_one::polaris; DEFINE_string(polaris_api_key, "", "The polaris API key. Sign up at app.pointonenav.com."); -DEFINE_string(polaris_unique_id, "device12345", +DEFINE_string(polaris_unique_id, "", "The unique ID to assign to this Polaris connection."); PolarisClient* polaris_client = nullptr; @@ -61,7 +61,7 @@ int main(int argc, char* argv[]) { return 1; } else if (FLAGS_polaris_unique_id.empty()) { - LOG(ERROR) << "You must supply a unique ID to connect to the server."; + LOG(ERROR) << "You must supply a unique ID for this connection."; return 1; }