Axeda Ready Demo for Freescale FRDM-KL46Z as accident alert system

Dependencies:   FRDM_MMA8451Q KL46Z-USBHost MAG3110 SocketModem TSI mbed FATFileSystem

Fork of AxedaGo-Freescal_FRDM-KL46Z by Axeda Corp

Committer:
AxedaCorp
Date:
Wed Jul 02 19:57:37 2014 +0000
Revision:
2:2f9019c5a9fc
Parent:
0:65004368569c
ip switch

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AxedaCorp 0:65004368569c 1 /*
AxedaCorp 0:65004368569c 2 Copyright (c) 2009 Dave Gamble
AxedaCorp 0:65004368569c 3
AxedaCorp 0:65004368569c 4 Permission is hereby granted, free of charge, to any person obtaining a copy
AxedaCorp 0:65004368569c 5 of this software and associated documentation files (the "Software"), to deal
AxedaCorp 0:65004368569c 6 in the Software without restriction, including without limitation the rights
AxedaCorp 0:65004368569c 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
AxedaCorp 0:65004368569c 8 copies of the Software, and to permit persons to whom the Software is
AxedaCorp 0:65004368569c 9 furnished to do so, subject to the following conditions:
AxedaCorp 0:65004368569c 10
AxedaCorp 0:65004368569c 11 The above copyright notice and this permission notice shall be included in
AxedaCorp 0:65004368569c 12 all copies or substantial portions of the Software.
AxedaCorp 0:65004368569c 13
AxedaCorp 0:65004368569c 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
AxedaCorp 0:65004368569c 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
AxedaCorp 0:65004368569c 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AxedaCorp 0:65004368569c 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
AxedaCorp 0:65004368569c 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
AxedaCorp 0:65004368569c 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
AxedaCorp 0:65004368569c 20 THE SOFTWARE.
AxedaCorp 0:65004368569c 21 */
AxedaCorp 0:65004368569c 22
AxedaCorp 0:65004368569c 23 #ifndef cJSON__h
AxedaCorp 0:65004368569c 24 #define cJSON__h
AxedaCorp 0:65004368569c 25
AxedaCorp 0:65004368569c 26 #ifdef __cplusplus
AxedaCorp 0:65004368569c 27 extern "C"
AxedaCorp 0:65004368569c 28 {
AxedaCorp 0:65004368569c 29 #endif
AxedaCorp 0:65004368569c 30
AxedaCorp 0:65004368569c 31 #include <string.h>
AxedaCorp 0:65004368569c 32 #include <stdio.h>
AxedaCorp 0:65004368569c 33 #include <math.h>
AxedaCorp 0:65004368569c 34 #include <stdlib.h>
AxedaCorp 0:65004368569c 35 #include <float.h>
AxedaCorp 0:65004368569c 36 #include <limits.h>
AxedaCorp 0:65004368569c 37 #include <ctype.h>
AxedaCorp 0:65004368569c 38
AxedaCorp 0:65004368569c 39 /* cJSON Types: */
AxedaCorp 0:65004368569c 40 #define cJSON_False 0
AxedaCorp 0:65004368569c 41 #define cJSON_True 1
AxedaCorp 0:65004368569c 42 #define cJSON_NULL 2
AxedaCorp 0:65004368569c 43 #define cJSON_Number 3
AxedaCorp 0:65004368569c 44 #define cJSON_String 4
AxedaCorp 0:65004368569c 45 #define cJSON_Array 5
AxedaCorp 0:65004368569c 46 #define cJSON_Object 6
AxedaCorp 0:65004368569c 47
AxedaCorp 0:65004368569c 48 #define cJSON_IsReference 256
AxedaCorp 0:65004368569c 49
AxedaCorp 0:65004368569c 50 /* The cJSON structure: */
AxedaCorp 0:65004368569c 51 typedef struct cJSON {
AxedaCorp 0:65004368569c 52 struct cJSON *next,*prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
AxedaCorp 0:65004368569c 53 struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
AxedaCorp 0:65004368569c 54
AxedaCorp 0:65004368569c 55 int type; /* The type of the item, as above. */
AxedaCorp 0:65004368569c 56
AxedaCorp 0:65004368569c 57 char *valuestring; /* The item's string, if type==cJSON_String */
AxedaCorp 0:65004368569c 58 int valueint; /* The item's number, if type==cJSON_Number */
AxedaCorp 0:65004368569c 59 double valuedouble; /* The item's number, if type==cJSON_Number */
AxedaCorp 0:65004368569c 60
AxedaCorp 0:65004368569c 61 char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
AxedaCorp 0:65004368569c 62 } cJSON;
AxedaCorp 0:65004368569c 63
AxedaCorp 0:65004368569c 64 typedef struct cJSON_Hooks {
AxedaCorp 0:65004368569c 65 void *(*malloc_fn)(size_t sz);
AxedaCorp 0:65004368569c 66 void (*free_fn)(void *ptr);
AxedaCorp 0:65004368569c 67 } cJSON_Hooks;
AxedaCorp 0:65004368569c 68
AxedaCorp 0:65004368569c 69 /* Supply malloc, realloc and free functions to cJSON */
AxedaCorp 0:65004368569c 70 extern void cJSON_InitHooks(cJSON_Hooks* hooks);
AxedaCorp 0:65004368569c 71
AxedaCorp 0:65004368569c 72
AxedaCorp 0:65004368569c 73 /* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
AxedaCorp 0:65004368569c 74 extern cJSON *cJSON_Parse(const char *value);
AxedaCorp 0:65004368569c 75 /* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
AxedaCorp 0:65004368569c 76 extern char *cJSON_Print(cJSON *item);
AxedaCorp 0:65004368569c 77 /* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */
AxedaCorp 0:65004368569c 78 extern char *cJSON_PrintUnformatted(cJSON *item);
AxedaCorp 0:65004368569c 79 /* Delete a cJSON entity and all subentities. */
AxedaCorp 0:65004368569c 80 extern void cJSON_Delete(cJSON *c);
AxedaCorp 0:65004368569c 81
AxedaCorp 0:65004368569c 82 /* Returns the number of items in an array (or object). */
AxedaCorp 0:65004368569c 83 extern int cJSON_GetArraySize(cJSON *array);
AxedaCorp 0:65004368569c 84 /* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
AxedaCorp 0:65004368569c 85 extern cJSON *cJSON_GetArrayItem(cJSON *array,int item);
AxedaCorp 0:65004368569c 86 /* Get item "string" from object. Case insensitive. */
AxedaCorp 0:65004368569c 87 extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
AxedaCorp 0:65004368569c 88
AxedaCorp 0:65004368569c 89 /* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
AxedaCorp 0:65004368569c 90 extern const char *cJSON_GetErrorPtr();
AxedaCorp 0:65004368569c 91
AxedaCorp 0:65004368569c 92 /* These calls create a cJSON item of the appropriate type. */
AxedaCorp 0:65004368569c 93 extern cJSON *cJSON_CreateNull();
AxedaCorp 0:65004368569c 94 extern cJSON *cJSON_CreateTrue();
AxedaCorp 0:65004368569c 95 extern cJSON *cJSON_CreateFalse();
AxedaCorp 0:65004368569c 96 extern cJSON *cJSON_CreateBool(int b);
AxedaCorp 0:65004368569c 97 extern cJSON *cJSON_CreateNumber(double num);
AxedaCorp 0:65004368569c 98 extern cJSON *cJSON_CreateString(const char *string);
AxedaCorp 0:65004368569c 99 extern cJSON *cJSON_CreateArray();
AxedaCorp 0:65004368569c 100 extern cJSON *cJSON_CreateObject();
AxedaCorp 0:65004368569c 101
AxedaCorp 0:65004368569c 102 /* These utilities create an Array of count items. */
AxedaCorp 0:65004368569c 103 extern cJSON *cJSON_CreateIntArray(int *numbers,int count);
AxedaCorp 0:65004368569c 104 extern cJSON *cJSON_CreateFloatArray(float *numbers,int count);
AxedaCorp 0:65004368569c 105 extern cJSON *cJSON_CreateDoubleArray(double *numbers,int count);
AxedaCorp 0:65004368569c 106 extern cJSON *cJSON_CreateStringArray(const char **strings,int count);
AxedaCorp 0:65004368569c 107
AxedaCorp 0:65004368569c 108 /* Append item to the specified array/object. */
AxedaCorp 0:65004368569c 109 extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
AxedaCorp 0:65004368569c 110 extern void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item);
AxedaCorp 0:65004368569c 111 /* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
AxedaCorp 0:65004368569c 112 extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
AxedaCorp 0:65004368569c 113 extern void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item);
AxedaCorp 0:65004368569c 114
AxedaCorp 0:65004368569c 115 /* Remove/Detatch items from Arrays/Objects. */
AxedaCorp 0:65004368569c 116 extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which);
AxedaCorp 0:65004368569c 117 extern void cJSON_DeleteItemFromArray(cJSON *array,int which);
AxedaCorp 0:65004368569c 118 extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string);
AxedaCorp 0:65004368569c 119 extern void cJSON_DeleteItemFromObject(cJSON *object,const char *string);
AxedaCorp 0:65004368569c 120
AxedaCorp 0:65004368569c 121 /* Update array items. */
AxedaCorp 0:65004368569c 122 extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem);
AxedaCorp 0:65004368569c 123 extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
AxedaCorp 0:65004368569c 124
AxedaCorp 0:65004368569c 125 #define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull())
AxedaCorp 0:65004368569c 126 #define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
AxedaCorp 0:65004368569c 127 #define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
AxedaCorp 0:65004368569c 128 #define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
AxedaCorp 0:65004368569c 129 #define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
AxedaCorp 0:65004368569c 130
AxedaCorp 0:65004368569c 131 #ifdef __cplusplus
AxedaCorp 0:65004368569c 132 }
AxedaCorp 0:65004368569c 133 #endif
AxedaCorp 0:65004368569c 134
AxedaCorp 0:65004368569c 135 #endif
AxedaCorp 0:65004368569c 136