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

Developer

API Reference

ISENSORUTIL_GETVALUEBYDATATYPE()

Brew Release
Brew MP 1.0.2
See Also
ISensorUtil_IterCreate ISensorUtil_IterDelete ISensorUtil_IterNumKeys ISensorUtil_IterNumValues ISensorUtil_IterNextKey
Description
Given a response and the data type interested, returns the value corresponding to input. This API also returns the error code in the repsonse, and indicates if the value returned is valid.
This API is intended as a lightweight alternative to the iterator based API's. As a result there are some limitations listed below. This API shall not be used for cases where the response is presented as a buffered stream. Reponses that result in more than 1 response field ( like GPSInfo) also is not supported by this API. Finally, attributes (like maxfreq) cannot be requested through this API. This API only supports querying the data type values. For the cases described abouve, use the iterator based approach to iterate through the response fields.
Params
_me
[in]:
Pointer to ISensorUtil interface
pResponseStr
[in]:
buffer that has the response message from which to parse the value. the buffer is unaltered by this API.
pResponseStrLen
[in]:
size of pResultLen buffer
pDataTypeLookup
[in]:
Data type for which the value is desired. Cannot be NULL. This argument can be a regular data type (accelx) or a timestamp (ts).
pDataTypeLookupLen
[in]:
size of pDataType
nErrorVal
[out]:
Indicates the error code in pResponseStr.
nValue
[out]:
value corresponding to the provided pDataTypeLookup. if a timestamp is requested in pDataTypeLookup, then nValue returns 0 and the nTimeStamp argument has the required value.
nTimeStamp
[out]:
Valid only if the timestamp(ts) was requested in pDataTypeLookup argument. Else 0.
bIsValid
[out]:
If nValue is a valid value. 1(TRUE) = Valid 0(FALSE) = Invalid
Interface
Prototype
  • AEEResult ISensorUtil_GetValueByDataType( ISensorUtil* _me, const char* pResponseStr, int pResponseStrLen,
                                              const char* pDataTypeLookup, int pDataTypeLookupLen, int32* nErrorVal
                                              int64* nValue, uint64* nTimeStamp, boolean* bIsValid )
    
Return

  • AEE_SUCCESS: if the nvalue can be returned. AEE_EINVALIDFORMAT : if the response message in the iterator is invalid. AEE_EFAILED: Otherwise
Side Effect
  • None
Comments
Example code1: Request a data type { // Assume pResponseStr has the message //"error=0#accelx=140,accely=1008,accelz=176#get,accelx,accely,accelz" int64 nValue; int32 nError; boolean bIsValid; char pDataType[32]; char pSys[32]; uint64 ts; { ISensorUtil_GetValueByDatatype( _me, pResponseStr, STRLEN(pDataType)+1, ISensorUtil_DATA_TYPE_ACCELX, STRLEN(ISensorUtil_DATA_TYPE_ACCELX)+1, &nValue, &ts, &nError, &bIsValid ); // nValue returns 140 // ts returns 0 // nError returns 0 // bIsValid return TRUE ISensorUtil_GetValueByDatatype( _me, pResponseStr, STRLEN(pDataType)+1, ISensorUtil_DATA_TYPE_ACCELY, STRLEN(ISensorUtil_DATA_TYPE_ACCELY)+1, &nValue, &ts, &nError, &bIsValid ); // nValue returns 1008 // ts returns 0 // nError returns 0 // bIsValid return TRUE ISensorUtil_GetValueByDatatype( _me, pResponseStr, STRLEN(pDataType)+1, ISensorUtil_DATA_TYPE_ACCELZ, STRLEN(ISensorUtil_DATA_TYPE_ACCELZ)+1, &nValue, &ts, &nError, &bIsValid ); // nValue returns 176 // ts returns 0 // nError returns 0 // bIsValid return TRUE } } Example code 2: Request a timestamp { // Assume pResponseStr has the message //"error=0#ts=1234223,accelx=140#get,ts,accelx" int64 nValue; int32 nError; boolean bIsValid; char pDataType[32]; char pSys[32]; uint64 ts; { ISensorUtil_GetValueByDatatype( _me, pResponseStr, STRLEN(pDataType)+1, ISensorUtil_SYSTEM_ATTRIBUTE_TIMESTAMP, STRLEN(ISensorUtil_SYSTEM_ATTRIBUTE_TIMESTAMP)+1, &nValue, &ts, &nError, &bIsValid ); // ts returns 140 // nValue returns 0 // nError returns 0 // bIsValid return TRUE } }