Contains example code to connect the mbed LPC1768 or FRDM-K64F devices to the IBM Internet of Things Cloud service via ethernet.

Dependencies:   C12832 MQTT LM75B MMA7660

Dependents:   MFT_IoT_demo_USB400 IBM_RFID

Committer:
samdanbury
Date:
Wed Aug 20 12:45:14 2014 +0000
Revision:
6:37b6d0d56190
Code completely changed to improve the structure, flow and memory usage of the application

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samdanbury 6:37b6d0d56190 1 /*
samdanbury 6:37b6d0d56190 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
samdanbury 6:37b6d0d56190 3 * All rights reserved.
samdanbury 6:37b6d0d56190 4 *
samdanbury 6:37b6d0d56190 5 * Redistribution and use in source and binary forms, with or without modification,
samdanbury 6:37b6d0d56190 6 * are permitted provided that the following conditions are met:
samdanbury 6:37b6d0d56190 7 *
samdanbury 6:37b6d0d56190 8 * 1. Redistributions of source code must retain the above copyright notice,
samdanbury 6:37b6d0d56190 9 * this list of conditions and the following disclaimer.
samdanbury 6:37b6d0d56190 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
samdanbury 6:37b6d0d56190 11 * this list of conditions and the following disclaimer in the documentation
samdanbury 6:37b6d0d56190 12 * and/or other materials provided with the distribution.
samdanbury 6:37b6d0d56190 13 * 3. The name of the author may not be used to endorse or promote products
samdanbury 6:37b6d0d56190 14 * derived from this software without specific prior written permission.
samdanbury 6:37b6d0d56190 15 *
samdanbury 6:37b6d0d56190 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
samdanbury 6:37b6d0d56190 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
samdanbury 6:37b6d0d56190 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
samdanbury 6:37b6d0d56190 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
samdanbury 6:37b6d0d56190 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
samdanbury 6:37b6d0d56190 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
samdanbury 6:37b6d0d56190 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
samdanbury 6:37b6d0d56190 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
samdanbury 6:37b6d0d56190 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
samdanbury 6:37b6d0d56190 25 * OF SUCH DAMAGE.
samdanbury 6:37b6d0d56190 26 *
samdanbury 6:37b6d0d56190 27 * This file is part of the lwIP TCP/IP stack.
samdanbury 6:37b6d0d56190 28 *
samdanbury 6:37b6d0d56190 29 * Author: Adam Dunkels <adam@sics.se>
samdanbury 6:37b6d0d56190 30 *
samdanbury 6:37b6d0d56190 31 */
samdanbury 6:37b6d0d56190 32
samdanbury 6:37b6d0d56190 33 #ifndef __LWIP_MEMP_H__
samdanbury 6:37b6d0d56190 34 #define __LWIP_MEMP_H__
samdanbury 6:37b6d0d56190 35
samdanbury 6:37b6d0d56190 36 #include "lwip/opt.h"
samdanbury 6:37b6d0d56190 37
samdanbury 6:37b6d0d56190 38 #ifdef __cplusplus
samdanbury 6:37b6d0d56190 39 extern "C" {
samdanbury 6:37b6d0d56190 40 #endif
samdanbury 6:37b6d0d56190 41
samdanbury 6:37b6d0d56190 42 /* Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end */
samdanbury 6:37b6d0d56190 43 typedef enum {
samdanbury 6:37b6d0d56190 44 #define LWIP_MEMPOOL(name,num,size,desc) MEMP_##name,
samdanbury 6:37b6d0d56190 45 #include "lwip/memp_std.h"
samdanbury 6:37b6d0d56190 46 MEMP_MAX
samdanbury 6:37b6d0d56190 47 } memp_t;
samdanbury 6:37b6d0d56190 48
samdanbury 6:37b6d0d56190 49 #if MEM_USE_POOLS
samdanbury 6:37b6d0d56190 50 /* Use a helper type to get the start and end of the user "memory pools" for mem_malloc */
samdanbury 6:37b6d0d56190 51 typedef enum {
samdanbury 6:37b6d0d56190 52 /* Get the first (via:
samdanbury 6:37b6d0d56190 53 MEMP_POOL_HELPER_START = ((u8_t) 1*MEMP_POOL_A + 0*MEMP_POOL_B + 0*MEMP_POOL_C + 0)*/
samdanbury 6:37b6d0d56190 54 MEMP_POOL_HELPER_FIRST = ((u8_t)
samdanbury 6:37b6d0d56190 55 #define LWIP_MEMPOOL(name,num,size,desc)
samdanbury 6:37b6d0d56190 56 #define LWIP_MALLOC_MEMPOOL_START 1
samdanbury 6:37b6d0d56190 57 #define LWIP_MALLOC_MEMPOOL(num, size) * MEMP_POOL_##size + 0
samdanbury 6:37b6d0d56190 58 #define LWIP_MALLOC_MEMPOOL_END
samdanbury 6:37b6d0d56190 59 #include "lwip/memp_std.h"
samdanbury 6:37b6d0d56190 60 ) ,
samdanbury 6:37b6d0d56190 61 /* Get the last (via:
samdanbury 6:37b6d0d56190 62 MEMP_POOL_HELPER_END = ((u8_t) 0 + MEMP_POOL_A*0 + MEMP_POOL_B*0 + MEMP_POOL_C*1) */
samdanbury 6:37b6d0d56190 63 MEMP_POOL_HELPER_LAST = ((u8_t)
samdanbury 6:37b6d0d56190 64 #define LWIP_MEMPOOL(name,num,size,desc)
samdanbury 6:37b6d0d56190 65 #define LWIP_MALLOC_MEMPOOL_START
samdanbury 6:37b6d0d56190 66 #define LWIP_MALLOC_MEMPOOL(num, size) 0 + MEMP_POOL_##size *
samdanbury 6:37b6d0d56190 67 #define LWIP_MALLOC_MEMPOOL_END 1
samdanbury 6:37b6d0d56190 68 #include "lwip/memp_std.h"
samdanbury 6:37b6d0d56190 69 )
samdanbury 6:37b6d0d56190 70 } memp_pool_helper_t;
samdanbury 6:37b6d0d56190 71
samdanbury 6:37b6d0d56190 72 /* The actual start and stop values are here (cast them over)
samdanbury 6:37b6d0d56190 73 We use this helper type and these defines so we can avoid using const memp_t values */
samdanbury 6:37b6d0d56190 74 #define MEMP_POOL_FIRST ((memp_t) MEMP_POOL_HELPER_FIRST)
samdanbury 6:37b6d0d56190 75 #define MEMP_POOL_LAST ((memp_t) MEMP_POOL_HELPER_LAST)
samdanbury 6:37b6d0d56190 76 #endif /* MEM_USE_POOLS */
samdanbury 6:37b6d0d56190 77
samdanbury 6:37b6d0d56190 78 #if MEMP_MEM_MALLOC || MEM_USE_POOLS
samdanbury 6:37b6d0d56190 79 extern const u16_t memp_sizes[MEMP_MAX];
samdanbury 6:37b6d0d56190 80 #endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */
samdanbury 6:37b6d0d56190 81
samdanbury 6:37b6d0d56190 82 #if MEMP_MEM_MALLOC
samdanbury 6:37b6d0d56190 83
samdanbury 6:37b6d0d56190 84 #include "mem.h"
samdanbury 6:37b6d0d56190 85
samdanbury 6:37b6d0d56190 86 #define memp_init()
samdanbury 6:37b6d0d56190 87 #define memp_malloc(type) mem_malloc(memp_sizes[type])
samdanbury 6:37b6d0d56190 88 #define memp_free(type, mem) mem_free(mem)
samdanbury 6:37b6d0d56190 89
samdanbury 6:37b6d0d56190 90 #else /* MEMP_MEM_MALLOC */
samdanbury 6:37b6d0d56190 91
samdanbury 6:37b6d0d56190 92 #if MEM_USE_POOLS
samdanbury 6:37b6d0d56190 93 /** This structure is used to save the pool one element came from. */
samdanbury 6:37b6d0d56190 94 struct memp_malloc_helper
samdanbury 6:37b6d0d56190 95 {
samdanbury 6:37b6d0d56190 96 memp_t poolnr;
samdanbury 6:37b6d0d56190 97 };
samdanbury 6:37b6d0d56190 98 #endif /* MEM_USE_POOLS */
samdanbury 6:37b6d0d56190 99
samdanbury 6:37b6d0d56190 100 void memp_init(void);
samdanbury 6:37b6d0d56190 101
samdanbury 6:37b6d0d56190 102 #if MEMP_OVERFLOW_CHECK
samdanbury 6:37b6d0d56190 103 void *memp_malloc_fn(memp_t type, const char* file, const int line);
samdanbury 6:37b6d0d56190 104 #define memp_malloc(t) memp_malloc_fn((t), __FILE__, __LINE__)
samdanbury 6:37b6d0d56190 105 #else
samdanbury 6:37b6d0d56190 106 void *memp_malloc(memp_t type);
samdanbury 6:37b6d0d56190 107 #endif
samdanbury 6:37b6d0d56190 108 void memp_free(memp_t type, void *mem);
samdanbury 6:37b6d0d56190 109
samdanbury 6:37b6d0d56190 110 #endif /* MEMP_MEM_MALLOC */
samdanbury 6:37b6d0d56190 111
samdanbury 6:37b6d0d56190 112 #ifdef __cplusplus
samdanbury 6:37b6d0d56190 113 }
samdanbury 6:37b6d0d56190 114 #endif
samdanbury 6:37b6d0d56190 115
samdanbury 6:37b6d0d56190 116 #endif /* __LWIP_MEMP_H__ */