![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
UDPversion
Dependencies: XBee mbed NetServicesMin
common/data_models.h@0:84a3b029656e, 2012-04-14 (annotated)
- Committer:
- recotana
- Date:
- Sat Apr 14 03:53:45 2012 +0000
- Revision:
- 0:84a3b029656e
- Child:
- 1:3a46d2725374
UDPversion
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
recotana | 0:84a3b029656e | 1 | #ifndef _DATA_MODELS_ |
recotana | 0:84a3b029656e | 2 | #define _DATA_MODELS_ |
recotana | 0:84a3b029656e | 3 | |
recotana | 0:84a3b029656e | 4 | #include "types.h" |
recotana | 0:84a3b029656e | 5 | |
recotana | 0:84a3b029656e | 6 | //frame type |
recotana | 0:84a3b029656e | 7 | typedef enum{ |
recotana | 0:84a3b029656e | 8 | Ftype_NoID =0, |
recotana | 0:84a3b029656e | 9 | Ftype_Type_A=1, |
recotana | 0:84a3b029656e | 10 | Ftype_Type_B=4 |
recotana | 0:84a3b029656e | 11 | } Ftype; |
recotana | 0:84a3b029656e | 12 | |
recotana | 0:84a3b029656e | 13 | typedef enum{ |
recotana | 0:84a3b029656e | 14 | SERVER, |
recotana | 0:84a3b029656e | 15 | LED_SENDER, |
recotana | 0:84a3b029656e | 16 | LED_RECIEVER |
recotana | 0:84a3b029656e | 17 | } Device; |
recotana | 0:84a3b029656e | 18 | |
recotana | 0:84a3b029656e | 19 | typedef enum{ |
recotana | 0:84a3b029656e | 20 | PING, |
recotana | 0:84a3b029656e | 21 | ACK, |
recotana | 0:84a3b029656e | 22 | RECIEVE, |
recotana | 0:84a3b029656e | 23 | SEND_SINGLE, |
recotana | 0:84a3b029656e | 24 | SEND_CONTINUEOUS, |
recotana | 0:84a3b029656e | 25 | SEND_CONT_STOP, |
recotana | 0:84a3b029656e | 26 | SET_TX_GAIN, |
recotana | 0:84a3b029656e | 27 | SET_LIGHT_CONTROL |
recotana | 0:84a3b029656e | 28 | } Command; |
recotana | 0:84a3b029656e | 29 | // |
recotana | 0:84a3b029656e | 30 | //for TCP/IP data structure |
recotana | 0:84a3b029656e | 31 | // |
recotana | 0:84a3b029656e | 32 | |
recotana | 0:84a3b029656e | 33 | //message data 48byte(size fix) |
recotana | 0:84a3b029656e | 34 | typedef struct{ |
recotana | 0:84a3b029656e | 35 | uint16_t totalSize; //2(total size) + 2(frame number) + 1(device) + 1(command) + 40(data:max 40) <--- max 46 |
recotana | 0:84a3b029656e | 36 | uint16_t frameNumber; |
recotana | 0:84a3b029656e | 37 | Device device; |
recotana | 0:84a3b029656e | 38 | Command command; |
recotana | 0:84a3b029656e | 39 | uint8_t data[40]; //0 fill,size fix |
recotana | 0:84a3b029656e | 40 | uint16_t sum; |
recotana | 0:84a3b029656e | 41 | } Message; |
recotana | 0:84a3b029656e | 42 | |
recotana | 0:84a3b029656e | 43 | //payload id 16byte |
recotana | 0:84a3b029656e | 44 | typedef struct{ |
recotana | 0:84a3b029656e | 45 | // uint16_t head; //reserve 0x0000 |
recotana | 0:84a3b029656e | 46 | uint8_t personalId[16]; |
recotana | 0:84a3b029656e | 47 | } ID; |
recotana | 0:84a3b029656e | 48 | |
recotana | 0:84a3b029656e | 49 | typedef struct{ |
recotana | 0:84a3b029656e | 50 | ID id; // 16 byte |
recotana | 0:84a3b029656e | 51 | Message message; // 48 byte |
recotana | 0:84a3b029656e | 52 | } Frame; |
recotana | 0:84a3b029656e | 53 | |
recotana | 0:84a3b029656e | 54 | //66byte Payload |
recotana | 0:84a3b029656e | 55 | typedef struct{ |
recotana | 0:84a3b029656e | 56 | uint16_t size; // 2(size) + 1(dummy) + 1(Ftype) + 64(frame) = 68 byte |
recotana | 0:84a3b029656e | 57 | uint8_t dummy; //adjust Alignment |
recotana | 0:84a3b029656e | 58 | Ftype ftype; |
recotana | 0:84a3b029656e | 59 | Frame frame; //64byte |
recotana | 0:84a3b029656e | 60 | } Payload; |
recotana | 0:84a3b029656e | 61 | |
recotana | 0:84a3b029656e | 62 | |
recotana | 0:84a3b029656e | 63 | |
recotana | 0:84a3b029656e | 64 | |
recotana | 0:84a3b029656e | 65 | /* --------------------------------------------------- |
recotana | 0:84a3b029656e | 66 | message data structure |
recotana | 0:84a3b029656e | 67 | ---------------------------------------------------*/ |
recotana | 0:84a3b029656e | 68 | |
recotana | 0:84a3b029656e | 69 | /* light�@illuminate level */ |
recotana | 0:84a3b029656e | 70 | typedef struct{ |
recotana | 0:84a3b029656e | 71 | uint8_t gain; //1~10 |
recotana | 0:84a3b029656e | 72 | uint8_t middleLevel; //1~10 |
recotana | 0:84a3b029656e | 73 | } TxGainData; |
recotana | 0:84a3b029656e | 74 | |
recotana | 0:84a3b029656e | 75 | typedef struct{ |
recotana | 0:84a3b029656e | 76 | uint16_t currentFrameNumber; |
recotana | 0:84a3b029656e | 77 | TxGainData gainData; |
recotana | 0:84a3b029656e | 78 | uint8_t lightsw; //0:light off 1:light on |
recotana | 0:84a3b029656e | 79 | uint8_t continueusMode; //0:single 1:continueus |
recotana | 0:84a3b029656e | 80 | uint8_t isSend; |
recotana | 0:84a3b029656e | 81 | uint8_t dummy; |
recotana | 0:84a3b029656e | 82 | uint32_t xbeeAdress; |
recotana | 0:84a3b029656e | 83 | } PrefSender; |
recotana | 0:84a3b029656e | 84 | |
recotana | 0:84a3b029656e | 85 | typedef struct{ |
recotana | 0:84a3b029656e | 86 | uint32_t xbeeAdress; |
recotana | 0:84a3b029656e | 87 | } PrefReciever; |
recotana | 0:84a3b029656e | 88 | |
recotana | 0:84a3b029656e | 89 | typedef struct{ |
recotana | 0:84a3b029656e | 90 | uint32_t xbeeAdress; |
recotana | 0:84a3b029656e | 91 | |
recotana | 0:84a3b029656e | 92 | uint8_t serverAddress[4]; |
recotana | 0:84a3b029656e | 93 | uint8_t subnetMask[4]; |
recotana | 0:84a3b029656e | 94 | uint8_t routerAddress[4]; |
recotana | 0:84a3b029656e | 95 | uint16_t serverPort; |
recotana | 0:84a3b029656e | 96 | |
recotana | 0:84a3b029656e | 97 | uint8_t destinationAddress[4]; |
recotana | 0:84a3b029656e | 98 | uint16_t destinationPort; |
recotana | 0:84a3b029656e | 99 | } PrefServer; |
recotana | 0:84a3b029656e | 100 | |
recotana | 0:84a3b029656e | 101 | |
recotana | 0:84a3b029656e | 102 | |
recotana | 0:84a3b029656e | 103 | void initPayload(Payload *_payload); |
recotana | 0:84a3b029656e | 104 | |
recotana | 0:84a3b029656e | 105 | void payloadToNetwork(Payload *_payload); |
recotana | 0:84a3b029656e | 106 | void networkToPayload(Payload *_payload); |
recotana | 0:84a3b029656e | 107 | |
recotana | 0:84a3b029656e | 108 | void initTestPayloadData(Payload *_payload); |
recotana | 0:84a3b029656e | 109 | uint16_t culcSum(Payload *_payload); |
recotana | 0:84a3b029656e | 110 | |
recotana | 0:84a3b029656e | 111 | void dumpPayload(Payload *_payload); |
recotana | 0:84a3b029656e | 112 | |
recotana | 0:84a3b029656e | 113 | #endif |