API Reference | developer.brewmp.com API Reference | developer.brewmp.com


API Reference


Brew Release
Brew MP 1.0.2
See Also
RequestFields structure CommandType enum
Takes an input array of RequestFields structures and creates the request message.
Pointer to ISensorUtil interface
Type of command that needs to be created, representd by the CommandType enumeration.
RequestFields structures representing the type of data that the application is interested in requesting. Can be an array of structs to represent multiple data types in the same request command.
Number of elements in RequestFields array.
where to put the request command. Memory needs to be allocated by the user.
size (in bytes) of pRequestStr.
a)number of bytes succesfully copied into pRequestStr, if pRequestStrLenReq is less than or equal to pRequestStrLen. [if pRequestStrLenReq <= pRequestStrLen, the response string is complete] or b) number of bytes required to succesfully copy the entire string to pRequestStr, if pRequestStrLenReq is greater than pRequestStrLen [if pRequestStrLenReq > pRequestStrLen, the pRequestStr is incomplete.]
  • AEEResult ISensorUtil_CreateRequest(ISensorUtil* _me, 
                                        ISensorUtil_CommandType eCmdtype, 
                                        const ISensorUtil_RequestFields* pRequestStruct, int pRequestStructLen, 
                                        char* pRequestStr, int pRequestStrLen, int* pRequestStrLenReq)
  • AEE_SUCCESS: if the request string can be created. AEE_EBADPARM : pRequestStr is NULL or pRequestStrLen is 0. AEE_ENOMEMORY: if memory provided is not sufficient to copy ' the request string to pRequestStr; AEE_EFAILED: Otherwise
Side Effect
  • None
a) if pRequestStr is non-null and the result would not fit, pRequestStr will contain an incomplete string euqal to the size specified in pRequestStrLen argument. Check pRequestStrLenReq to determine if the pRequestStr is complete or not. b) pRequestStr is always null-terminated c) Example code: { int pRequestLen = 3; RequestFields pRequest[pRequestLen]; STRLCPY(pRequest[0].sns_DataType, ISensorUtil_DATA_TYPE_ACCELX, sizeof(pRequest[0].sns_DataType)); STRLCPY(pRequest[0].sns_Attribute, ISensorUtil_ATTRIBUTE_NONE, sizeof(pRequest[0].sns_Attribute)); STRLCPY(ReqField[0].sns_Operator, ISensorUtil_CONDITION_NONE, sizeof(ReqField[0].sns_Operator)); pRequest[0].sns_value = 40; STRLCPY(pRequest[1].sns_DataType, ISensorUtil_DATA_TYPE_ACCELY, sizeof(pRequest[1].sns_DataType)); STRLCPY(pRequest[1].sns_Attribute, ISensorUtil_ATTRIBUTE_NONE, sizeof(pRequest[1].sns_Attribute)); STRLCPY(pRequest[1].sns_Operator, ISensorUtil_CONDITION_NONE, sizeof(pRequest[1].sns_Operator)); pRequest[1].sns_value = 40; STRLCPY(pRequest[2].sns_DataType, ISensorUtil_DATA_TYPE_ACCELZ, sizeof(pRequest[2].sns_DataType)); STRLCPY(pRequest[2].sns_Attribute, ISensorUtil_ATTRIBUTE_NONE, sizeof(pRequest[2].sns_Attribute)); STRLCPY(pRequest[2].sns_Operator, ISensorUtil_CONDITION_NONE, sizeof(pRequest[2].sns_Operator)); pRequest[2].sns_value = 40; char *pRequestStr = (char *)MALLOC(100); int pRequestStrLen = 100; int pRequestStrLenReq; ISensorUtil_CreateRequest(me, SNS_CMD_SET, pRequest, pRequestLen, pRequestStr, 100, &pRequestStrLenReq); // If ISensorUtil_CreateRequest returns SUCCESS, pRequestStr holds the request string. // pRequestStrLenReq holds the number of bytes succesfully copied into pRequestStr (including // null termination). // If pRequestStrLenReq is less than or equal to pRequestStrLen, pRequeststr is completely formed. // If pRequestStrLenReq is greater than pRequestStrLen, pRequeststr is incomplete. // pRequestStrLenReq is the number of bytes needed to completer create pRequeststr } d) the sns_SystemAttribute field of the pRequestStruct struct should be filled in if the application is requesting a system attribute (like "sys", "sysres", "ts" etc). e) If a virtual data type (like "step" or "proximity" is requested, the command to turn on the condition is "get,step=on" or "get,proximity=on". Since the sns_value field of pRequestStruct is an int32 parameter, the macros ISensorUtil_VALUE_ON or ISensorUtil_VALUE_OFF can be used instead.