Hi,
I’m trying to test out whether I can change the sampling interval of an MCU connected to a sensor. I can see on the debug console that we got the MCU/carrier to pick up a number from the server (in this test case ‘456’ which I put in ‘env.sampling_interval’), but I haven’t been able to figure out how to get that number into a variable so that I can use it in my code. I’m pretty sure I’m just not understanding the API correctly.
This is what I have that isn’t working:
if (J *req = (notecard.newRequest("env.get"))) {
J *rsp = notecard.requestAndResponse(req);
notecard.deleteResponse(rsp);
int sampling_interval = JGetNumber(rsp, "sampling_interval");
Serial.print("sampling interval: ");
Serial.println(sampling_interval);
}
output:
15:25:47.895 → {“req”:“env.get”}
15:25:48.029 → {“body”:{“sampling_interval”:“456”,"_<…>"}}
15:25:48.029 → sampling interval: 0