Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of M2XStreamClient by
Diff: StreamParseFunctions.h
- Revision:
- 10:4ce9eba38dbe
- Parent:
- 2:7ea7ab05f120
- Child:
- 13:0d574742208f
diff -r ba0d02be2835 -r 4ce9eba38dbe StreamParseFunctions.h
--- a/StreamParseFunctions.h Sun Sep 07 17:56:18 2014 +0000
+++ b/StreamParseFunctions.h Wed Sep 10 13:07:34 2014 +0000
@@ -3,7 +3,7 @@
// Data structures and functions used to parse stream values
-#define STREAM_BUF_LEN 64
+#define STREAM_BUF_LEN 32
typedef struct {
uint8_t state;
@@ -40,11 +40,13 @@
}
}
-static void on_stream_string_found(jsonlite_callback_context* context,
- jsonlite_token* token)
+static void on_stream_value_found(jsonlite_callback_context* context,
+ jsonlite_token* token,
+ int type)
{
stream_parsing_context_state* state =
(stream_parsing_context_state*) context->client_state;
+
if (TEST_IS_AT(state->state)) {
strncpy(state->at_str, (const char*) token->start,
MIN(token->end - token->start, STREAM_BUF_LEN));
@@ -59,9 +61,21 @@
if (TEST_GOT_STREAM(state->state)) {
state->callback(state->at_str, state->value_str,
- state->index++, state->context);
+ state->index++, state->context, type);
state->state = 0;
}
}
+static void on_stream_string_found(jsonlite_callback_context* context,
+ jsonlite_token* token)
+{
+ on_stream_value_found(context, token, 1);
+}
+
+static void on_stream_number_found(jsonlite_callback_context* context,
+ jsonlite_token* token)
+{
+ on_stream_value_found(context, token, 2);
+}
+
#endif /* StreamParseFunctions_h */
