Explaining Bridge.get

H

Here’s my code:

Hard to believe that’s all of it.

How do I know how big the buffer size should be?

Big enough to hold all the data. Perhaps whatever you are get()ting data from should have a means of telling you that.

The “key” should return an int as a string.

There is a limit to how big an int can be, when represented as a string. Make the array that size.

Sorry for not posting it all, but I was just checking if there was an issue with how I was calling the method. I'm at work now, so I can't post the rest till I get home.

So my test variable was initialized like:

char test[3];

Will the bridge.get method break my string of integers into an array? for example: '123' into ['1', '2', '3']? If so, I'm guessing that is why the serial.println(test) still outputs nothing. I'm assuming I have to concatenate the array of chars again to print to serial properly?

I'm also confused by the return value of .get():

The function returns the length of the read byte of the requested value.

Of what use is that?

char test[500];
Bridge.get("my_sales",test,24);

Why is test 474 elements larger than you tell get() about?

I’m also confused by the return value of .get()…The function returns the length of the read byte of the requested value…Of what use is that?

The function appears to not NULL terminate the array. The return value tells you how much oversize your array is, or where to put the NULL.

The test is 474 elements larger than I tell get() about, because I was just messing around with things to see what would happen.

I just tried this:

char test[26];
......

Bridge.get("my_sales",test,26);
Serial.println(test);

Nothing seems to be outputting from this code. Should the whole bridge.get code be contained within a serial.println statement? Is it impossible to print the array of chars without null terminating the array?

Should the whole bridge.get code be contained within a serial.println statement?

No.

Is it impossible to print the array of chars without null terminating the array?

No. To make it print properly is a different story.

get() tells you how many characters it got. Why don't you care? Why don't you at least print that value?