Hi. This is the feed program for Cosm. (The previous name of the services is Pachube.)

Dependencies:   mbed ThermistorPack Pachube ConfigFile EthernetNetIf TextLCD HTTPClient_ToBeRemoved FatFileSystem SDFileSystem

Committer:
shintamainjp
Date:
Mon Aug 06 12:37:59 2012 +0000
Revision:
0:521ba375aa0f
Pachube renamed to Cosm.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shintamainjp 0:521ba375aa0f 1
shintamainjp 0:521ba375aa0f 2 /*
shintamainjp 0:521ba375aa0f 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
shintamainjp 0:521ba375aa0f 4
shintamainjp 0:521ba375aa0f 5 Permission is hereby granted, free of charge, to any person obtaining a copy
shintamainjp 0:521ba375aa0f 6 of this software and associated documentation files (the "Software"), to deal
shintamainjp 0:521ba375aa0f 7 in the Software without restriction, including without limitation the rights
shintamainjp 0:521ba375aa0f 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
shintamainjp 0:521ba375aa0f 9 copies of the Software, and to permit persons to whom the Software is
shintamainjp 0:521ba375aa0f 10 furnished to do so, subject to the following conditions:
shintamainjp 0:521ba375aa0f 11
shintamainjp 0:521ba375aa0f 12 The above copyright notice and this permission notice shall be included in
shintamainjp 0:521ba375aa0f 13 all copies or substantial portions of the Software.
shintamainjp 0:521ba375aa0f 14
shintamainjp 0:521ba375aa0f 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
shintamainjp 0:521ba375aa0f 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
shintamainjp 0:521ba375aa0f 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
shintamainjp 0:521ba375aa0f 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
shintamainjp 0:521ba375aa0f 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
shintamainjp 0:521ba375aa0f 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
shintamainjp 0:521ba375aa0f 21 THE SOFTWARE.
shintamainjp 0:521ba375aa0f 22 */
shintamainjp 0:521ba375aa0f 23
shintamainjp 0:521ba375aa0f 24 #ifndef LWIPNETTCPSOCKET_H
shintamainjp 0:521ba375aa0f 25 #define LWIPNETTCPSOCKET_H
shintamainjp 0:521ba375aa0f 26
shintamainjp 0:521ba375aa0f 27 #define NET_LWIP_STACK 1
shintamainjp 0:521ba375aa0f 28 #include "if/net/nettcpsocket.h"
shintamainjp 0:521ba375aa0f 29 #include "LwipNetIf.h"
shintamainjp 0:521ba375aa0f 30
shintamainjp 0:521ba375aa0f 31 #include "stdint.h"
shintamainjp 0:521ba375aa0f 32
shintamainjp 0:521ba375aa0f 33 //Implements NetTcpSockets over lwIP raw API
shintamainjp 0:521ba375aa0f 34
shintamainjp 0:521ba375aa0f 35 struct tcp_pcb; //Represents a Tcp Connection, "Protocol Control Block", see rawapi.txt & tcp.h
shintamainjp 0:521ba375aa0f 36 struct pbuf; //Lwip Buffer Container
shintamainjp 0:521ba375aa0f 37
shintamainjp 0:521ba375aa0f 38 typedef signed char err_t;
shintamainjp 0:521ba375aa0f 39 typedef uint16_t u16_t;
shintamainjp 0:521ba375aa0f 40
shintamainjp 0:521ba375aa0f 41 class LwipNetTcpSocket: public NetTcpSocket
shintamainjp 0:521ba375aa0f 42 {
shintamainjp 0:521ba375aa0f 43 public:
shintamainjp 0:521ba375aa0f 44 LwipNetTcpSocket(tcp_pcb* pPcb = NULL); //Passes a pcb if already created (by an accept req for instance), in that case transfers ownership
shintamainjp 0:521ba375aa0f 45 virtual ~LwipNetTcpSocket();
shintamainjp 0:521ba375aa0f 46
shintamainjp 0:521ba375aa0f 47 virtual NetTcpSocketErr bind(const Host& me);
shintamainjp 0:521ba375aa0f 48 virtual NetTcpSocketErr listen();
shintamainjp 0:521ba375aa0f 49 virtual NetTcpSocketErr connect(const Host& host);
shintamainjp 0:521ba375aa0f 50 virtual NetTcpSocketErr accept(Host* pClient, NetTcpSocket** ppNewNetTcpSocket);
shintamainjp 0:521ba375aa0f 51
shintamainjp 0:521ba375aa0f 52 virtual int /*if < 0 : NetTcpSocketErr*/ send(const char* buf, int len);
shintamainjp 0:521ba375aa0f 53 virtual int /*if < 0 : NetTcpSocketErr*/ recv(char* buf, int len);
shintamainjp 0:521ba375aa0f 54
shintamainjp 0:521ba375aa0f 55 virtual NetTcpSocketErr close();
shintamainjp 0:521ba375aa0f 56
shintamainjp 0:521ba375aa0f 57 virtual NetTcpSocketErr poll();
shintamainjp 0:521ba375aa0f 58
shintamainjp 0:521ba375aa0f 59 protected:
shintamainjp 0:521ba375aa0f 60 volatile tcp_pcb* m_pPcb;
shintamainjp 0:521ba375aa0f 61
shintamainjp 0:521ba375aa0f 62 //Events callbacks from lwIp
shintamainjp 0:521ba375aa0f 63 err_t acceptCb(tcp_pcb* newpcb, err_t err);
shintamainjp 0:521ba375aa0f 64 err_t connectedCb(tcp_pcb* tpcb, err_t err);
shintamainjp 0:521ba375aa0f 65
shintamainjp 0:521ba375aa0f 66 void errCb(err_t err);
shintamainjp 0:521ba375aa0f 67
shintamainjp 0:521ba375aa0f 68 err_t sentCb(tcp_pcb* tpcb, u16_t len);
shintamainjp 0:521ba375aa0f 69 err_t recvCb(tcp_pcb* tpcb, pbuf *p, err_t err);
shintamainjp 0:521ba375aa0f 70
shintamainjp 0:521ba375aa0f 71 private:
shintamainjp 0:521ba375aa0f 72 void cleanUp(); //Flush input buffer
shintamainjp 0:521ba375aa0f 73
shintamainjp 0:521ba375aa0f 74 // queue<tcp_pcb*> m_lpInPcb; //Incoming connections that have not been accepted yet
shintamainjp 0:521ba375aa0f 75 queue<LwipNetTcpSocket*> m_lpInNetTcpSocket; //Incoming connections that have not been accepted yet
shintamainjp 0:521ba375aa0f 76
shintamainjp 0:521ba375aa0f 77 volatile pbuf* m_pReadPbuf; //Ptr to read buffer
shintamainjp 0:521ba375aa0f 78
shintamainjp 0:521ba375aa0f 79 //Static callbacks : Transforms into a C++ callback
shintamainjp 0:521ba375aa0f 80 static err_t sAcceptCb(void *arg, struct tcp_pcb *newpcb, err_t err);
shintamainjp 0:521ba375aa0f 81 static err_t sConnectedCb(void *arg, struct tcp_pcb *tpcb, err_t err);
shintamainjp 0:521ba375aa0f 82
shintamainjp 0:521ba375aa0f 83 static void sErrCb(void *arg, err_t err);
shintamainjp 0:521ba375aa0f 84
shintamainjp 0:521ba375aa0f 85 static err_t sSentCb(void *arg, struct tcp_pcb *tpcb, u16_t len);
shintamainjp 0:521ba375aa0f 86 static err_t sRecvCb(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err);
shintamainjp 0:521ba375aa0f 87
shintamainjp 0:521ba375aa0f 88 };
shintamainjp 0:521ba375aa0f 89
shintamainjp 0:521ba375aa0f 90 #endif