ARM mbed M2X API Client: The ARM mbed client library is used to send/receive data to/from AT&T's M2X service from mbed LPC1768 microcontrollers.

Dependents:   m2x-demo-all M2X_MTS_ACCEL_DEMO M2X_MTS_Accel M2X_K64F_ACCEL ... more

Revision:
22:4d895e732765
Parent:
21:6878944d2ce2
diff -r 6878944d2ce2 -r 4d895e732765 StreamParseFunctions.h
--- a/StreamParseFunctions.h	Sat Jan 02 02:29:43 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-#ifndef StreamParseFunctions_h
-#define StreamParseFunctions_h
-
-// Data structures and functions used to parse stream values
-
-#define STREAM_BUF_LEN 32
-
-typedef struct {
-  uint8_t state;
-  char at_str[STREAM_BUF_LEN + 1];
-  char value_str[STREAM_BUF_LEN + 1];
-  int index;
-
-  stream_value_read_callback callback;
-  void* context;
-} stream_parsing_context_state;
-
-#define WAITING_AT 0x1
-#define GOT_AT 0x2
-#define WAITING_VALUE 0x4
-#define GOT_VALUE 0x8
-
-#define GOT_STREAM (GOT_AT | GOT_VALUE)
-#define TEST_GOT_STREAM(state_) (((state_) & GOT_STREAM) == GOT_STREAM)
-
-#define TEST_IS_AT(state_) (((state_) & (WAITING_AT | GOT_AT)) == WAITING_AT)
-#define TEST_IS_VALUE(state_) (((state_) & (WAITING_VALUE | GOT_VALUE)) == \
-                               WAITING_VALUE)
-
-static void on_stream_key_found(jsonlite_callback_context* context,
-                                jsonlite_token* token)
-{
-  stream_parsing_context_state* state =
-      (stream_parsing_context_state*) context->client_state;
-  if (strncmp((const char*) token->start, "timestamp", 2) == 0) {
-    state->state |= WAITING_AT;
-  } else if ((strncmp((const char*) token->start, "value", 5) == 0) &&
-             (token->start[5] != 's')) { // get rid of "values"
-    state->state |= WAITING_VALUE;
-  }
-}
-
-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));
-    state->at_str[MIN(token->end - token->start, STREAM_BUF_LEN)] = '\0';
-    state->state |= GOT_AT;
-  } else if (TEST_IS_VALUE(state->state)) {
-    strncpy(state->value_str, (const char*) token->start,
-            MIN(token->end - token->start, STREAM_BUF_LEN));
-    state->value_str[MIN(token->end - token->start, STREAM_BUF_LEN)] = '\0';
-    state->state |= GOT_VALUE;
-  }
-
-  if (TEST_GOT_STREAM(state->state)) {
-    state->callback(state->at_str, state->value_str,
-                    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 */