I appreciate getting some direction here; I’m not sure at all what these errors mean.
When I run “particle compile p *” I get:
…
Compile failed. Exiting.
../../../build/target/services-dynalib/arm//libservices-dynalib.a(services_dynalib.o): In function `jsmn_init':
/spark/compile_service/shared/workspace/6_platform_6_24_2/firmware/services-dynalib/../services/inc/services_dynalib.h:45: multiple definition of `jsmn_init'
../../../build/target/user/platform-6/libuser.a(jsmn.o):jsmn.c:307: first defined here
../../../build/target/services-dynalib/arm//libservices-dynalib.a(services_dynalib.o): In function `jsmn_parse':
/spark/compile_service/shared/workspace/6_platform_6_24_2/firmware/services-dynalib/../services/inc/services_dynalib.h:46: multiple definition of `jsmn_parse'
../../../build/target/user/platform-6/libuser.a(jsmn.o):jsmn.c:152: first defined here
collect2: error: ld returned 1 exit status
make: *** [0c4048cbdd82f7e65953889586c223607d16e955a65f1c6aa66de7683a51.elf] Error 1
I’ve narrowed it down to this class:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "Switchjson.hpp"
#include "application.h"
#include "jsmn.h"
Switchjson::Switchjson(){}
String Switchjson::get_value(String message, String key) {
int i;
int r;
const char *msg = message;
const char *ky = key;
String value;
jsmn_parser p;
jsmntok_t t[60];
jsmn_init(&p);
r = jsmn_parse(&p, msg, strlen(msg), t, sizeof(t)/sizeof(t[0]));
for (i = 1; i < r; i++) {
if (jsoneq(msg, &t[i], ky) == 0) {
value = message.substring(t[i+1].start, t[i+1].end);
i++;
}
}
return value;
}
int Switchjson::jsoneq(const char *json, jsmntok_t *tok, const char *s) {
if (tok->type == JSMN_STRING && (int) strlen(s) == tok->end - tok->start &&
strncmp(json + tok->start, s, tok->end - tok->start) == 0) {
return 0;
}
return -1;
}
Hopefully I’m just doing something very dumb.
Thanks,