Skip to content

Commit

Permalink
Added option to C example applications to enable debug prints.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamshapiro0 committed Apr 17, 2021
1 parent 27cffc0 commit 79a316a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion c/examples/connection_retry.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
******************************************************************************/

#include <signal.h>
#include <stdlib.h> // For atoi()

#include "point_one/polaris/polaris.h"
#include "point_one/polaris/portability.h"
Expand All @@ -26,13 +27,16 @@ void HandleSignal(int sig) {

int main(int argc, const char* argv[]) {
if (argc < 2 || argc > 3) {
P1_fprintf(stderr, "Usage: %s API_KEY [UNIQUE_ID]\n", argv[0]);
P1_fprintf(stderr, "Usage: %s API_KEY [UNIQUE_ID] [LOG_LEVEL]\n", argv[0]);
return 1;
}

const char* api_key = argv[1];
const char* unique_id = argc > 2 ? argv[2] : "device12345";

int log_level = argc > 3 ? atoi(argv[3]) : POLARIS_LOG_LEVEL_INFO;
Polaris_SetLogLevel(log_level);

const int MAX_RECONNECTS = 2;
int auth_valid = 0;
int reconnect_count = 0;
Expand Down
6 changes: 5 additions & 1 deletion c/examples/simple_polaris_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
******************************************************************************/

#include <signal.h>
#include <stdlib.h> // For atoi()

#include "point_one/polaris/polaris.h"
#include "point_one/polaris/portability.h"
Expand All @@ -26,13 +27,16 @@ void HandleSignal(int sig) {

int main(int argc, const char* argv[]) {
if (argc < 2 || argc > 3) {
P1_fprintf(stderr, "Usage: %s API_KEY [UNIQUE_ID]\n", argv[0]);
P1_fprintf(stderr, "Usage: %s API_KEY [UNIQUE_ID] [LOG_LEVEL]\n", argv[0]);
return 1;
}

const char* api_key = argv[1];
const char* unique_id = argc > 2 ? argv[2] : "device12345";

int log_level = argc > 3 ? atoi(argv[3]) : POLARIS_LOG_LEVEL_INFO;
Polaris_SetLogLevel(log_level);

// Retrieve an access token using the specified API key.
if (Polaris_Init(&context) != POLARIS_SUCCESS) {
return 2;
Expand Down

0 comments on commit 79a316a

Please sign in to comment.