From b24866225a6301d3a663f874725e83c012dc25d3 Mon Sep 17 00:00:00 2001 From: Florent Duchon Date: Wed, 26 Dec 2012 17:36:00 +0100 Subject: digital/beacon: add bitcloud stack into common directory digital/zigbit --- .../bitcloud/stack/Components/ZCL/include/zcl.h | 1120 ++++++++++++++++++++ 1 file changed, 1120 insertions(+) create mode 100644 digital/zigbit/bitcloud/stack/Components/ZCL/include/zcl.h (limited to 'digital/zigbit/bitcloud/stack/Components/ZCL/include/zcl.h') diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zcl.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zcl.h new file mode 100644 index 00000000..0731a417 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zcl.h @@ -0,0 +1,1120 @@ +/************************************************************************//** + \file zcl.h + + \brief + The header file describes the public ZCL interface + + The file describes the public interface and types of ZCL + + \author + Atmel Corporation: http://www.atmel.com \n + Support email: avr@atmel.com + + Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. + Licensed under Atmel's Limited License Agreement (BitCloudTM). + + \internal + History: + 01.12.08 I. Fedina & A. Potashov - Created. +******************************************************************************/ + +#ifndef _ZCL_H +#define _ZCL_H + +/****************************************************************************** + Includes section +******************************************************************************/ +#include +#include +#include + +/****************************************************************************** + Definitions section +******************************************************************************/ +#define PROFILE_ID_SMART_ENERGY CCPU_TO_LE16(0x0109) +#define PROFILE_ID_CBA CCPU_TO_LE16(0x0105) +#define PROFILE_ID_HOME_AUTOMATION CCPU_TO_LE16(0x0104) +#define PROFILE_ID_SMART_LIGHTING CCPU_TO_LE16(0xc05e) + +#define ZCL_MAX_ASDU_SIZE 75 //it is temporary hack to prevent fragmentation for ZCL packets. It should be fixed with correct calculation of payload size. + +// Macros defines the maximum size allocated for a value of type OCTET_STRING +#define OCTET_STRING_MAX_SIZE 255 +/****************************************************************************** + Types section +******************************************************************************/ +typedef uint8_t ZCL_ClusterType_t; +typedef uint16_t ZCL_AttributeId_t; //ZCL_Response field is called. + + Common uses of the function include sending the following commands (the command's + ID listed below should be assigned to the \c req->id field): + \li ::ZCL_READ_ATTRIBUTES_COMMAND_ID - reading remote attributes (obtaining values) + \li ::ZCL_WRITE_ATTRIBUTES_COMMAND_ID - writing remote attributes (assigning new values) + \li ::ZCL_REPORT_ATTRIBUTES_COMMAND_ID - reporting local attributes to remote devices + (sending current attributes' values) + \li ::ZCL_DISCOVER_ATTRIBUTES_COMMAND_ID - discovering attributes of a remote device (obtaining + data types and IDs of attributes supported by a particular cluster) + + \param[in] req - command parameters +*****************************************************************************/ +void ZCL_AttributeReq(ZCL_Request_t *req); + +/*********************************************************************************//** + \brief Sends a cluster command + + The function sends a general cluster specific command. The command's type is + recognized according to the \c req->id field. Commands' IDs are defined in clusters' + definition files, which also contain all definition related to a particular cluster. + + In addition to addressing information and command's ID, eesential fields of + the request parameters include the payload and the payload length. The payload + for each command is defined as a structure in the cluster's definition file. + The pointer to a properly configured instance of the command's payload shall be \ + assigned to the \c req->requestPayload field. + + The callback function specified in the \c req->ZCL_Response field is called to + indicate the status of the command's delivery (not a specific response for the + command). If acknowledgment of the command's delivery is received the success + status is reported in the callback. + + A specific response to the command is processed by a special indication function + registered for the command. If a command does not imply a specific response + the default response may be requested (to indicate that the command has been + executed). To request the default response set the \c req->defaultResponse field + to ::ZCL_FRAME_CONTROL_ENABLE_DEFAULT_RESPONSE and assign the callback function + that should be called upon default response reception to the \c req->ZCL_DefaultResponse + field. To disable default response set \c req->defaultResponse to + ::ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE and \c req->ZCL_DefaultResponse to \c NULL. + + \param[in] req - contains request descriptor +************************************************************************************/ +void ZCL_CommandReq(ZCL_Request_t *req); + +/*********************************************************************************//** +\brief Specific command indication handler + +\param[in] ind - contains indication descriptor +************************************************************************************/ +//void ZCL_CommandInd(ZCL_CommandInd_t *ind); + +/*************************************************************************//** + \brief ZCL event notification handler + + \param[in] event - contains event descriptor +*****************************************************************************/ +void ZCL_EventNtfy(ZCL_EventNtfy_t *event); + +/*************************************************************************//** + \brief This function returns bytes amount of a type by type id. + + \param[in] typeId - type id + \param[in] value - pointer to variable of typeId, NULL means maximum possible + size. +*****************************************************************************/ +uint16_t ZCL_GetAttributeLength(uint8_t typeId, const uint8_t *value); + +/*************************************************************************//** + \brief Adds an element to the outgoing command payload + + This function is used to simplify forming a correst payload for general + commands (read/write attributes etc.). A single command may involve actions on + several attributes, and so the overall payload should contain pieces + corresponding to each attribute. + + The general idea is to provide a buffer for the payload and some content. The + function writes the content in a correct way to the buffer and calculate the + overall payload length. The buffer and the payload length are then passed as + parameters to the ZCL_AttributeReq() function. + + See the following example: + +\code +ZCL_NextElement_t element; +ZCL_ReadAttributeReq_t readAttrReqElement; +ZCL_Request_t readAttrReq; +uint8_t buffer[BUFFER_SIZE]; + +element.payloadLength = 0; +element.payload = buffer; +element.id = ZCL_READ_ATTRIBUTES_COMMAND_ID; +element.content = &readAttrReqElement; + +readAttrReqElement = ATTRIBUTE_ID1; //Set to the ID of the first attribute +ZCL_PutNextElement(&element); + +readAttrReqElement = ATTRIBUTE_ID2; //Set to the ID of the second attribute +ZCL_PutNextElement(&element); + +readAttrReq.requestLength = element.payloadLength; +readAttrReq.requestPayload = element.payload; +... +\endcode + + Note, however, that the usage may differ depending on a command's type. + + \param[in] element - information about payload and element + \param[out] status of the operation +*****************************************************************************/ +ZCL_Status_t ZCL_PutNextElement(ZCL_NextElement_t *element); + +/*************************************************************************//** + \brief Gets an element from the incoming command's payload + + The function is used to simplify processing of responses fo general + attributes related commands. Such command may return information concerning + several attributes in a single frame. This function reads the next portion + of information from the response payload. + + To use the function configure an instance of ZCL_NextElement type. + The \c element->payload field should be set to the response payload, + the \c element->payloadLength to the reponse payload's length, and + the \c element->id field to the ID of the response. After calling this + function, the \c element->content field may be casted to the appropriate + response type (depending on the command's type); for example, for + read attributes response it is ZCL_ReadAttributeResp_t. + + \param[in] element - information about payload and element + \param[out] status of the operation +*****************************************************************************/ +ZCL_Status_t ZCL_GetNextElement(ZCL_NextElement_t *element); + +/***************************************************************************//** +\brief Checks whether ZCL is busy or not. + +\return true - if ZCL is busy, false - otherwise. +******************************************************************************/ +bool ZCL_IsBusy(void); + +/*************************************************************************//** + \brief ZCL Data Type Descriptor get by Type Id function. + Fills the ZCL Data Type Descriptor dased on ZCL Data Type Id + \param Id - ZCL Data Type Id (unsigned 8-bit integer) + \param value - pointer to variable of typeId, NULL means maximum possible + size. + \param descriptor - ZCL Data Type Descriptor being filled. + \return None. + \sa ZCL_DataTypeDescriptor_t + \sa ZCL_GetAttributeLength() +*****************************************************************************/ +void ZCL_GetDataTypeDescriptor(uint8_t typeId, const uint8_t *value, ZCL_DataTypeDescriptor_t *descriptor); + +#endif //_ZCL_H + -- cgit v1.2.3