Apps     Components     Interfaces     All Files     Source Tree     source: tos.interfaces.AttrUse.nc

Interface: AttrUse

Interface for using Attributes. Attributes provided a generic mechanism for registering named attribute-value pairs and retrieving their values.

See lib/Attributes/... for examples of components that register attributes

See interfaces/Attr.h for the data structures used in this interface

Implemented by lib/Attr.td

Author: Wei Hong (wei.hong@intel-research.net)

Components providing this interface:
tos.lib.Attr
tos.lib.TinyDB.TinyDBAttr

Components requiring this interface:
tos.lib.TinyDB.ParsedQuery
tos.lib.TinyDB.Tuple
tos.lib.TinyDB.TupleRouterM

Commands

Events

Commands - Details

getAttr

AttrDescPtr getAttr(char *name)

Get a descriptor for the specified attribute

Parameters:

name - The (8 byte or shorted, null-terminated) name for the attribute of interest.

Returns: A pointer to the attribute descriptior, or NULL if no such attribute exists.

getAttrById

AttrDescPtr getAttrById(uint8_t attrIdx)

Get a descriptor for the specified attribute

Parameters:

attrIdx - THe (0-based) index of the attribute of interest

Returns: A pointer to the attribute descriptior, or NULL if no such attribute exists.

numAttrs

uint8_t numAttrs(void)

Get the number of attributes currently registered with the system
Returns: The number of attributes currently registered with the system.

getAttrs

AttrDescsPtr getAttrs(void)

Returns a list of all attributes in the system.
Returns: A list of all the attributes in the system

getAttrValue

result_t getAttrValue(char *name, char *resultBuf, SchemaErrorNo *errorNo)

Get the value of a specified attribute.

Parameters:

name - The name of the attribute to fetch

resultBuf - The buffer to write the value into (must be at least sizeOf(AttrDescPtr.type) long)

errorNo - (on return) The error code, if any (see SchemaType.h for a list of error codes.) Note that the error code may be SCHEMA_RESULT_PENDING, in which case a getAttrDone event will be fired at some point to indicate that the data has been written into resultBuf.


setAttrValue

result_t setAttrValue(char *name, char *attrVal)

Set the value of the specified attribute.

Parameters:

name - The attribute to set

attrVal - The value to set it to

Events - Details

getAttrDone

result_t getAttrDone(char *name, char *resultBuf, SchemaErrorNo errorNo)

Signal that a specific getAttrValue command is complete.

Parameters:

name - The name of the command that finished

resultBuf - The buffer that the value was written into

errorNo - The result code from the get command