TwitterExample with newer library (2012Aug)

Dependencies:   EthernetNetIf HTTPClient mbed

Committer:
nxpfan
Date:
Wed Aug 29 03:50:19 2012 +0000
Revision:
0:075157567b0c
simple twitter example with newer library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nxpfan 0:075157567b0c 1 /*
nxpfan 0:075157567b0c 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
nxpfan 0:075157567b0c 3 * All rights reserved.
nxpfan 0:075157567b0c 4 *
nxpfan 0:075157567b0c 5 * Redistribution and use in source and binary forms, with or without modification,
nxpfan 0:075157567b0c 6 * are permitted provided that the following conditions are met:
nxpfan 0:075157567b0c 7 *
nxpfan 0:075157567b0c 8 * 1. Redistributions of source code must retain the above copyright notice,
nxpfan 0:075157567b0c 9 * this list of conditions and the following disclaimer.
nxpfan 0:075157567b0c 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
nxpfan 0:075157567b0c 11 * this list of conditions and the following disclaimer in the documentation
nxpfan 0:075157567b0c 12 * and/or other materials provided with the distribution.
nxpfan 0:075157567b0c 13 * 3. The name of the author may not be used to endorse or promote products
nxpfan 0:075157567b0c 14 * derived from this software without specific prior written permission.
nxpfan 0:075157567b0c 15 *
nxpfan 0:075157567b0c 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
nxpfan 0:075157567b0c 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
nxpfan 0:075157567b0c 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
nxpfan 0:075157567b0c 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
nxpfan 0:075157567b0c 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
nxpfan 0:075157567b0c 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
nxpfan 0:075157567b0c 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
nxpfan 0:075157567b0c 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
nxpfan 0:075157567b0c 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
nxpfan 0:075157567b0c 25 * OF SUCH DAMAGE.
nxpfan 0:075157567b0c 26 *
nxpfan 0:075157567b0c 27 * This file is part of the lwIP TCP/IP stack.
nxpfan 0:075157567b0c 28 *
nxpfan 0:075157567b0c 29 * Author: Adam Dunkels <adam@sics.se>
nxpfan 0:075157567b0c 30 *
nxpfan 0:075157567b0c 31 */
nxpfan 0:075157567b0c 32 #ifndef __LWIP_TCPIP_H__
nxpfan 0:075157567b0c 33 #define __LWIP_TCPIP_H__
nxpfan 0:075157567b0c 34
nxpfan 0:075157567b0c 35 #include "lwip/opt.h"
nxpfan 0:075157567b0c 36
nxpfan 0:075157567b0c 37 #if !NO_SYS /* don't build if not configured for use in lwipopts.h */
nxpfan 0:075157567b0c 38
nxpfan 0:075157567b0c 39 #include "lwip/api_msg.h"
nxpfan 0:075157567b0c 40 #include "lwip/netifapi.h"
nxpfan 0:075157567b0c 41 #include "lwip/pbuf.h"
nxpfan 0:075157567b0c 42 #include "lwip/api.h"
nxpfan 0:075157567b0c 43 #include "lwip/sys.h"
nxpfan 0:075157567b0c 44 #include "lwip/timers.h"
nxpfan 0:075157567b0c 45 #include "lwip/netif.h"
nxpfan 0:075157567b0c 46
nxpfan 0:075157567b0c 47 #ifdef __cplusplus
nxpfan 0:075157567b0c 48 extern "C" {
nxpfan 0:075157567b0c 49 #endif
nxpfan 0:075157567b0c 50
nxpfan 0:075157567b0c 51 /** Define this to something that triggers a watchdog. This is called from
nxpfan 0:075157567b0c 52 * tcpip_thread after processing a message. */
nxpfan 0:075157567b0c 53 #ifndef LWIP_TCPIP_THREAD_ALIVE
nxpfan 0:075157567b0c 54 #define LWIP_TCPIP_THREAD_ALIVE()
nxpfan 0:075157567b0c 55 #endif
nxpfan 0:075157567b0c 56
nxpfan 0:075157567b0c 57 #if LWIP_TCPIP_CORE_LOCKING
nxpfan 0:075157567b0c 58 /** The global semaphore to lock the stack. */
nxpfan 0:075157567b0c 59 extern sys_mutex_t lock_tcpip_core;
nxpfan 0:075157567b0c 60 #define LOCK_TCPIP_CORE() sys_mutex_lock(&lock_tcpip_core)
nxpfan 0:075157567b0c 61 #define UNLOCK_TCPIP_CORE() sys_mutex_unlock(&lock_tcpip_core)
nxpfan 0:075157567b0c 62 #define TCPIP_APIMSG(m) tcpip_apimsg_lock(m)
nxpfan 0:075157567b0c 63 #define TCPIP_APIMSG_ACK(m)
nxpfan 0:075157567b0c 64 #define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m)
nxpfan 0:075157567b0c 65 #define TCPIP_NETIFAPI_ACK(m)
nxpfan 0:075157567b0c 66 #else /* LWIP_TCPIP_CORE_LOCKING */
nxpfan 0:075157567b0c 67 #define LOCK_TCPIP_CORE()
nxpfan 0:075157567b0c 68 #define UNLOCK_TCPIP_CORE()
nxpfan 0:075157567b0c 69 #define TCPIP_APIMSG(m) tcpip_apimsg(m)
nxpfan 0:075157567b0c 70 #define TCPIP_APIMSG_ACK(m) sys_sem_signal(&m->conn->op_completed)
nxpfan 0:075157567b0c 71 #define TCPIP_NETIFAPI(m) tcpip_netifapi(m)
nxpfan 0:075157567b0c 72 #define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(&m->sem)
nxpfan 0:075157567b0c 73 #endif /* LWIP_TCPIP_CORE_LOCKING */
nxpfan 0:075157567b0c 74
nxpfan 0:075157567b0c 75 /** Function prototype for the init_done function passed to tcpip_init */
nxpfan 0:075157567b0c 76 typedef void (*tcpip_init_done_fn)(void *arg);
nxpfan 0:075157567b0c 77 /** Function prototype for functions passed to tcpip_callback() */
nxpfan 0:075157567b0c 78 typedef void (*tcpip_callback_fn)(void *ctx);
nxpfan 0:075157567b0c 79
nxpfan 0:075157567b0c 80 void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg);
nxpfan 0:075157567b0c 81
nxpfan 0:075157567b0c 82 #if LWIP_NETCONN
nxpfan 0:075157567b0c 83 err_t tcpip_apimsg(struct api_msg *apimsg);
nxpfan 0:075157567b0c 84 #if LWIP_TCPIP_CORE_LOCKING
nxpfan 0:075157567b0c 85 err_t tcpip_apimsg_lock(struct api_msg *apimsg);
nxpfan 0:075157567b0c 86 #endif /* LWIP_TCPIP_CORE_LOCKING */
nxpfan 0:075157567b0c 87 #endif /* LWIP_NETCONN */
nxpfan 0:075157567b0c 88
nxpfan 0:075157567b0c 89 err_t tcpip_input(struct pbuf *p, struct netif *inp);
nxpfan 0:075157567b0c 90
nxpfan 0:075157567b0c 91 #if LWIP_NETIF_API
nxpfan 0:075157567b0c 92 err_t tcpip_netifapi(struct netifapi_msg *netifapimsg);
nxpfan 0:075157567b0c 93 #if LWIP_TCPIP_CORE_LOCKING
nxpfan 0:075157567b0c 94 err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg);
nxpfan 0:075157567b0c 95 #endif /* LWIP_TCPIP_CORE_LOCKING */
nxpfan 0:075157567b0c 96 #endif /* LWIP_NETIF_API */
nxpfan 0:075157567b0c 97
nxpfan 0:075157567b0c 98 err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block);
nxpfan 0:075157567b0c 99 #define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1)
nxpfan 0:075157567b0c 100
nxpfan 0:075157567b0c 101 /* free pbufs or heap memory from another context without blocking */
nxpfan 0:075157567b0c 102 err_t pbuf_free_callback(struct pbuf *p);
nxpfan 0:075157567b0c 103 err_t mem_free_callback(void *m);
nxpfan 0:075157567b0c 104
nxpfan 0:075157567b0c 105 #if LWIP_TCPIP_TIMEOUT
nxpfan 0:075157567b0c 106 err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
nxpfan 0:075157567b0c 107 err_t tcpip_untimeout(sys_timeout_handler h, void *arg);
nxpfan 0:075157567b0c 108 #endif /* LWIP_TCPIP_TIMEOUT */
nxpfan 0:075157567b0c 109
nxpfan 0:075157567b0c 110 enum tcpip_msg_type {
nxpfan 0:075157567b0c 111 #if LWIP_NETCONN
nxpfan 0:075157567b0c 112 TCPIP_MSG_API,
nxpfan 0:075157567b0c 113 #endif /* LWIP_NETCONN */
nxpfan 0:075157567b0c 114 TCPIP_MSG_INPKT,
nxpfan 0:075157567b0c 115 #if LWIP_NETIF_API
nxpfan 0:075157567b0c 116 TCPIP_MSG_NETIFAPI,
nxpfan 0:075157567b0c 117 #endif /* LWIP_NETIF_API */
nxpfan 0:075157567b0c 118 #if LWIP_TCPIP_TIMEOUT
nxpfan 0:075157567b0c 119 TCPIP_MSG_TIMEOUT,
nxpfan 0:075157567b0c 120 TCPIP_MSG_UNTIMEOUT,
nxpfan 0:075157567b0c 121 #endif /* LWIP_TCPIP_TIMEOUT */
nxpfan 0:075157567b0c 122 TCPIP_MSG_CALLBACK
nxpfan 0:075157567b0c 123 };
nxpfan 0:075157567b0c 124
nxpfan 0:075157567b0c 125 struct tcpip_msg {
nxpfan 0:075157567b0c 126 enum tcpip_msg_type type;
nxpfan 0:075157567b0c 127 sys_sem_t *sem;
nxpfan 0:075157567b0c 128 union {
nxpfan 0:075157567b0c 129 #if LWIP_NETCONN
nxpfan 0:075157567b0c 130 struct api_msg *apimsg;
nxpfan 0:075157567b0c 131 #endif /* LWIP_NETCONN */
nxpfan 0:075157567b0c 132 #if LWIP_NETIF_API
nxpfan 0:075157567b0c 133 struct netifapi_msg *netifapimsg;
nxpfan 0:075157567b0c 134 #endif /* LWIP_NETIF_API */
nxpfan 0:075157567b0c 135 struct {
nxpfan 0:075157567b0c 136 struct pbuf *p;
nxpfan 0:075157567b0c 137 struct netif *netif;
nxpfan 0:075157567b0c 138 } inp;
nxpfan 0:075157567b0c 139 struct {
nxpfan 0:075157567b0c 140 tcpip_callback_fn function;
nxpfan 0:075157567b0c 141 void *ctx;
nxpfan 0:075157567b0c 142 } cb;
nxpfan 0:075157567b0c 143 #if LWIP_TCPIP_TIMEOUT
nxpfan 0:075157567b0c 144 struct {
nxpfan 0:075157567b0c 145 u32_t msecs;
nxpfan 0:075157567b0c 146 sys_timeout_handler h;
nxpfan 0:075157567b0c 147 void *arg;
nxpfan 0:075157567b0c 148 } tmo;
nxpfan 0:075157567b0c 149 #endif /* LWIP_TCPIP_TIMEOUT */
nxpfan 0:075157567b0c 150 } msg;
nxpfan 0:075157567b0c 151 };
nxpfan 0:075157567b0c 152
nxpfan 0:075157567b0c 153 #ifdef __cplusplus
nxpfan 0:075157567b0c 154 }
nxpfan 0:075157567b0c 155 #endif
nxpfan 0:075157567b0c 156
nxpfan 0:075157567b0c 157 #endif /* !NO_SYS */
nxpfan 0:075157567b0c 158
nxpfan 0:075157567b0c 159 #endif /* __LWIP_TCPIP_H__ */