CHENGQI YANG / SmartLab_MuRata
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Payload.h Source File

Payload.h

00001 #ifndef SmartLab_MuRata_Payload
00002 #define SmartLab_MuRata_Payload
00003 
00004 #include "mbed.h"
00005 
00006 #include "ResponseFlag.h"
00007 #include "SubCommandID.h"
00008 
00009 
00010 namespace SmartLabMuRata
00011 {
00012 class Payload
00013 {
00014 private :
00015 
00016     static const int EXPANDSIZE = 1024;
00017 
00018     char * data;
00019 
00020     int position;
00021     
00022     int max;
00023 
00024 public:
00025     Payload();
00026 
00027     Payload(Payload * payload);
00028     
00029     void SetPayload(Payload * payload);
00030 
00031     char * GetData();
00032 
00033     /// <summary>
00034     /// The first byte of the Payload of the command describes the specific operation to perform for the Command ID, and it contains the Response Flag and Sub-Command ID (RFSCID). The Payload may be a request (REQ) from the host to the module, a response (RSP) from the module to that request, an indication (IND) from the module to the host, and the optional confirmation (CFM) from the host for that indication.
00035     /// </summary>
00036     /// <returns></returns>
00037     ResponseFlag GetResponseFlag();
00038 
00039     void SetResponseFlag(const ResponseFlag flag);
00040 
00041     // sub command id
00042     SubCommandID GetSubCommandID();
00043 
00044     /// <summary>
00045     /// must call SetSubCommandID first then SetFrameID, and any other data afterwards
00046     /// </summary>
00047     void SetSubCommandID(const SubCommandID id) ;
00048 
00049     /// <summary>
00050     /// must call SetSubCommandID first then SetFrameID, and any other data afterwards
00051     /// </summary>
00052     void SetSubCommandID(const int value);
00053 
00054     // frame id
00055     char GetFrameID();
00056 
00057     /// <summary>
00058     /// must call SetSubCommandID first then SetFrameID, and any other data afterwards
00059     /// </summary>
00060     void SetFrameID(const char frameID);
00061 
00062     // content
00063     int GetPosition();
00064 
00065     void SetPosition(const int position);
00066 
00067     void Allocate(const int length);
00068 
00069     void Rewind();
00070 
00071     void SetContent(const char value);
00072 
00073     void SetContent(const char * value, const int offset, const int length);
00074 };
00075 }
00076 
00077 #endif