Skip to content

Commit

Permalink
Require a unique ID in the simple_polaris_client examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamshapiro0 committed Mar 29, 2024
1 parent c865926 commit d1ac61b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions c/examples/simple_polaris_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions examples/simple_polaris_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit d1ac61b

Please sign in to comment.