Jim Patterson / Mbed 2 deprecated MultiSensor_00

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers comms.h Source File

comms.h

Go to the documentation of this file.
00001 /**
00002     * @file comms.h
00003     * Header file for comms.cpp
00004     * A simplistic communication profile for streaming data sampled
00005     * from sensors over UART->radio->UART->dislpay
00006     *
00007     * @brief Header file for comms.cpp
00008     *
00009     * @author James A C Patterson
00010  */
00011 #ifndef COMMS_H
00012 #define COMMS_H
00013 
00014 #define MAX_PACKET_SIZE 64
00015 
00016 #define PORT_BASE (1<<13)
00017 #define PROTOCOL 17
00018 
00019 typedef struct header {
00020     uint16_t src_port;
00021     uint16_t dst_port;
00022     uint16_t length;
00023     uint16_t checksum;
00024 } header_t;
00025 
00026 
00027 typedef uint8_t packet_t[MAX_PACKET_SIZE];
00028 
00029 typedef struct pseudo_header {
00030     uint32_t src_addr;
00031     uint32_t dst_addr;
00032     uint16_t protocol;
00033     uint16_t length;
00034     uint16_t checksum;
00035 } pseudo_header_t;
00036 
00037 /**
00038  * A class to implement a basic transport layer that is based very
00039  * loosely on UDP/UDP-lite
00040  */
00041 class Transport {
00042 public:
00043     Transport (uint32_t, uint32_t, uint32_t);
00044     void get_packet (uint8_t**,uint16_t*);
00045     void load_data (uint16_t*,uint16_t);
00046     void set_dst_port (uint16_t);
00047 private:
00048     pseudo_header_t pseudo_header_;
00049     header_t header_;
00050     packet_t packet_;
00051 };
00052 
00053 #endif