Leest de waarde van een sensor binnen een maakt deze beschikbaar via internet

Dependencies:   NTPClient_NetServices mbed

Committer:
hendrikvincent
Date:
Mon Dec 02 09:01:23 2013 +0000
Revision:
0:05ccbd4f84f1
eerste programma;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hendrikvincent 0:05ccbd4f84f1 1 /**
hendrikvincent 0:05ccbd4f84f1 2 * @file
hendrikvincent 0:05ccbd4f84f1 3 * Common functions used throughout the stack.
hendrikvincent 0:05ccbd4f84f1 4 *
hendrikvincent 0:05ccbd4f84f1 5 */
hendrikvincent 0:05ccbd4f84f1 6
hendrikvincent 0:05ccbd4f84f1 7 /*
hendrikvincent 0:05ccbd4f84f1 8 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
hendrikvincent 0:05ccbd4f84f1 9 * All rights reserved.
hendrikvincent 0:05ccbd4f84f1 10 *
hendrikvincent 0:05ccbd4f84f1 11 * Redistribution and use in source and binary forms, with or without modification,
hendrikvincent 0:05ccbd4f84f1 12 * are permitted provided that the following conditions are met:
hendrikvincent 0:05ccbd4f84f1 13 *
hendrikvincent 0:05ccbd4f84f1 14 * 1. Redistributions of source code must retain the above copyright notice,
hendrikvincent 0:05ccbd4f84f1 15 * this list of conditions and the following disclaimer.
hendrikvincent 0:05ccbd4f84f1 16 * 2. Redistributions in binary form must reproduce the above copyright notice,
hendrikvincent 0:05ccbd4f84f1 17 * this list of conditions and the following disclaimer in the documentation
hendrikvincent 0:05ccbd4f84f1 18 * and/or other materials provided with the distribution.
hendrikvincent 0:05ccbd4f84f1 19 * 3. The name of the author may not be used to endorse or promote products
hendrikvincent 0:05ccbd4f84f1 20 * derived from this software without specific prior written permission.
hendrikvincent 0:05ccbd4f84f1 21 *
hendrikvincent 0:05ccbd4f84f1 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
hendrikvincent 0:05ccbd4f84f1 23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
hendrikvincent 0:05ccbd4f84f1 24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
hendrikvincent 0:05ccbd4f84f1 25 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
hendrikvincent 0:05ccbd4f84f1 26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
hendrikvincent 0:05ccbd4f84f1 27 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
hendrikvincent 0:05ccbd4f84f1 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
hendrikvincent 0:05ccbd4f84f1 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
hendrikvincent 0:05ccbd4f84f1 30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
hendrikvincent 0:05ccbd4f84f1 31 * OF SUCH DAMAGE.
hendrikvincent 0:05ccbd4f84f1 32 *
hendrikvincent 0:05ccbd4f84f1 33 * This file is part of the lwIP TCP/IP stack.
hendrikvincent 0:05ccbd4f84f1 34 *
hendrikvincent 0:05ccbd4f84f1 35 * Author: Simon Goldschmidt
hendrikvincent 0:05ccbd4f84f1 36 *
hendrikvincent 0:05ccbd4f84f1 37 */
hendrikvincent 0:05ccbd4f84f1 38
hendrikvincent 0:05ccbd4f84f1 39 #include "lwip/opt.h"
hendrikvincent 0:05ccbd4f84f1 40 #include "lwip/def.h"
hendrikvincent 0:05ccbd4f84f1 41
hendrikvincent 0:05ccbd4f84f1 42 /**
hendrikvincent 0:05ccbd4f84f1 43 * These are reference implementations of the byte swapping functions.
hendrikvincent 0:05ccbd4f84f1 44 * Again with the aim of being simple, correct and fully portable.
hendrikvincent 0:05ccbd4f84f1 45 * Byte swapping is the second thing you would want to optimize. You will
hendrikvincent 0:05ccbd4f84f1 46 * need to port it to your architecture and in your cc.h:
hendrikvincent 0:05ccbd4f84f1 47 *
hendrikvincent 0:05ccbd4f84f1 48 * #define LWIP_PLATFORM_BYTESWAP 1
hendrikvincent 0:05ccbd4f84f1 49 * #define LWIP_PLATFORM_HTONS(x) <your_htons>
hendrikvincent 0:05ccbd4f84f1 50 * #define LWIP_PLATFORM_HTONL(x) <your_htonl>
hendrikvincent 0:05ccbd4f84f1 51 *
hendrikvincent 0:05ccbd4f84f1 52 * Note ntohs() and ntohl() are merely references to the htonx counterparts.
hendrikvincent 0:05ccbd4f84f1 53 */
hendrikvincent 0:05ccbd4f84f1 54
hendrikvincent 0:05ccbd4f84f1 55 #if (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN)
hendrikvincent 0:05ccbd4f84f1 56
hendrikvincent 0:05ccbd4f84f1 57 /**
hendrikvincent 0:05ccbd4f84f1 58 * Convert an u16_t from host- to network byte order.
hendrikvincent 0:05ccbd4f84f1 59 *
hendrikvincent 0:05ccbd4f84f1 60 * @param n u16_t in host byte order
hendrikvincent 0:05ccbd4f84f1 61 * @return n in network byte order
hendrikvincent 0:05ccbd4f84f1 62 */
hendrikvincent 0:05ccbd4f84f1 63 u16_t
hendrikvincent 0:05ccbd4f84f1 64 lwip_htons(u16_t n)
hendrikvincent 0:05ccbd4f84f1 65 {
hendrikvincent 0:05ccbd4f84f1 66 return ((n & 0xff) << 8) | ((n & 0xff00) >> 8);
hendrikvincent 0:05ccbd4f84f1 67 }
hendrikvincent 0:05ccbd4f84f1 68
hendrikvincent 0:05ccbd4f84f1 69 /**
hendrikvincent 0:05ccbd4f84f1 70 * Convert an u16_t from network- to host byte order.
hendrikvincent 0:05ccbd4f84f1 71 *
hendrikvincent 0:05ccbd4f84f1 72 * @param n u16_t in network byte order
hendrikvincent 0:05ccbd4f84f1 73 * @return n in host byte order
hendrikvincent 0:05ccbd4f84f1 74 */
hendrikvincent 0:05ccbd4f84f1 75 u16_t
hendrikvincent 0:05ccbd4f84f1 76 lwip_ntohs(u16_t n)
hendrikvincent 0:05ccbd4f84f1 77 {
hendrikvincent 0:05ccbd4f84f1 78 return lwip_htons(n);
hendrikvincent 0:05ccbd4f84f1 79 }
hendrikvincent 0:05ccbd4f84f1 80
hendrikvincent 0:05ccbd4f84f1 81 /**
hendrikvincent 0:05ccbd4f84f1 82 * Convert an u32_t from host- to network byte order.
hendrikvincent 0:05ccbd4f84f1 83 *
hendrikvincent 0:05ccbd4f84f1 84 * @param n u32_t in host byte order
hendrikvincent 0:05ccbd4f84f1 85 * @return n in network byte order
hendrikvincent 0:05ccbd4f84f1 86 */
hendrikvincent 0:05ccbd4f84f1 87 u32_t
hendrikvincent 0:05ccbd4f84f1 88 lwip_htonl(u32_t n)
hendrikvincent 0:05ccbd4f84f1 89 {
hendrikvincent 0:05ccbd4f84f1 90 return ((n & 0xff) << 24) |
hendrikvincent 0:05ccbd4f84f1 91 ((n & 0xff00) << 8) |
hendrikvincent 0:05ccbd4f84f1 92 ((n & 0xff0000UL) >> 8) |
hendrikvincent 0:05ccbd4f84f1 93 ((n & 0xff000000UL) >> 24);
hendrikvincent 0:05ccbd4f84f1 94 }
hendrikvincent 0:05ccbd4f84f1 95
hendrikvincent 0:05ccbd4f84f1 96 /**
hendrikvincent 0:05ccbd4f84f1 97 * Convert an u32_t from network- to host byte order.
hendrikvincent 0:05ccbd4f84f1 98 *
hendrikvincent 0:05ccbd4f84f1 99 * @param n u32_t in network byte order
hendrikvincent 0:05ccbd4f84f1 100 * @return n in host byte order
hendrikvincent 0:05ccbd4f84f1 101 */
hendrikvincent 0:05ccbd4f84f1 102 u32_t
hendrikvincent 0:05ccbd4f84f1 103 lwip_ntohl(u32_t n)
hendrikvincent 0:05ccbd4f84f1 104 {
hendrikvincent 0:05ccbd4f84f1 105 return lwip_htonl(n);
hendrikvincent 0:05ccbd4f84f1 106 }
hendrikvincent 0:05ccbd4f84f1 107
hendrikvincent 0:05ccbd4f84f1 108 #endif /* (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) */