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