summaryrefslogtreecommitdiff
path: root/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMessagingCluster.h
blob: 4e0e11cbac1c5a08f4b10f0940e75998e98f6096 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/************************************************************************//**
  \file zclMessageingCluster.h

  \brief
    The header file describes the ZCL Message Cluster

    The header file describes the ZCL Message Cluster

  \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:
    27.11.08 A. Potashov - Created.
******************************************************************************/

#ifndef _MESSAGINGCLUSTER_H
#define _MESSAGINGCLUSTER_H

#include <zcl.h>
#include <clusters.h>
/*******************************************************************************
                             Defines section
 ******************************************************************************/
/***************************************************************************//**
\brief Macros defines duration value of Display Message command,
 * which means 'until change'.
 * According to ZB AMI Spec r15, D.5.2.3.1.1.1, page 203.
*******************************************************************************/
#define DISPLAY_MESSAGE_DURATION_UNTIL_CHANGED 0xFFFF

/*************************************************************************//**
  \brief Message Cluster attributes amount
*****************************************************************************/
#define MESSAGE_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT      0
#define MESSAGE_CLUSTER_SERVER_ATTRIBUTES_AMOUNT      0

/*************************************************************************//**
  \brief Message Cluster commands amount
*****************************************************************************/
#define MESSAGE_CLUSTER_COMMANDS_AMOUNT               4

#define DISPLAY_MESSAGE_COMMAND_ID  0x00
#define CANCEL_MESSAGE_COMMAND_ID   0x01
#define GET_LAST_MESSAGE_COMMAND_ID 0x00
#define CONFIRM_MESSAGE_COMMAND_ID  0x01

#define DEFINE_MESSAGING_CLUSTER_COMMANDS(clDisplayMessageInd, clCancelMessageInd, clGetLastMessageInd, clMessageConfirmationInd) \
  DEFINE_COMMAND(displayMessageCommand, 0x00, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), clDisplayMessageInd), \
  DEFINE_COMMAND(cancelMessageCommand,  0x01, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), clCancelMessageInd), \
  DEFINE_COMMAND(getLastMessageCommand,      0x00, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), clGetLastMessageInd), \
  DEFINE_COMMAND(messageConfirmationCommand, 0x01, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), clMessageConfirmationInd)

#define MESSAGING_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
  { \
    .id = MESSAGE_CLUSTER_ID, \
    .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
    .attributesAmount = MESSAGE_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
    .attributes = (uint8_t *)clattributes, \
    .commandsAmount = MESSAGE_CLUSTER_COMMANDS_AMOUNT, \
    .commands = (uint8_t *)clcommands \
  }

#define MESSAGING_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
  { \
    .id = MESSAGE_CLUSTER_ID, \
    .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
    .attributesAmount = MESSAGE_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
    .attributes = (uint8_t *)clattributes, \
    .commandsAmount = MESSAGE_CLUSTER_COMMANDS_AMOUNT, \
    .commands = (uint8_t *)clcommands \
  }
#define DEFINE_MESSAGING_CLUSTER(cltype, clattributes, clcommands) MESSAGING_CLUSTER_##cltype(clattributes, clcommands)

BEGIN_PACK

typedef struct PACK
{
  LITTLE_ENDIAN_OCTET(4,(
    uint8_t transmissionType : 2,
    uint8_t importanceLevel : 2,
    uint8_t reserved : 3,
    uint8_t messageConfirmation : 1
  ))
} MessageControl_t;

/***************************************************************************//**
  \brief
    ZCL Messaging Cluster Display Message Command payload format
*******************************************************************************/
typedef struct PACK
{
  uint32_t            messageId;        //!<Message Id (Unsignet 32 bit Integer)
  MessageControl_t    messageControl;   //!<Message Control (8-bit Bitmap)
  uint32_t            startTime;        //!<Start Time (UTCTime)
  uint16_t            duration;         //!<Duration In Minutes (Unsigned 16-bit Integer)
  uint8_t             message[1];       //!<Message (Character string)
} DisplayMessage_t;

/***************************************************************************//**
  \brief
    ZCL Messaging Cluster Cancel Message Command payload format
*******************************************************************************/
typedef struct PACK
{
  uint32_t            messageId;        //!<Message Id (Unsignet 32 bit Integer)
  MessageControl_t    messageControl;   //!<Message Control (8-bit Bitmap)
} CancelMessage_t;

typedef struct PACK
{
  uint32_t      messageId;
  ZCL_UTCTime_t confirmationTime;
}MessageConfirmation_t;
END_PACK


/***************************************************************************//**
  \brief
    ZCL Messaging Cluster Commands
*******************************************************************************/
typedef struct
{
  //!Display Message Command descriptor
  struct
  {
    ZCL_CommandId_t       id;       //!<Command Id (0x00)
    ZclCommandOptions_t   options;  //!<Command options
    /**
      \brief Command indication handler
      \param payloadLength - length of payload in cotets
      \param payload - payload
      \return none
    */
    ZCL_Status_t (*displayMessage)(ZCL_Addressing_t *addressing, uint8_t payloadLength, DisplayMessage_t *payload);
  } displayMessageCommand;

  //!Cancel Message Command descriptor
  struct
  {
    ZCL_CommandId_t       id;       //!<Command Id (0x01)
    ZclCommandOptions_t   options;  //!<Command options
    /**
      \brief Command indication handler
      \param payloadLength - length of payload in cotets
      \param payload - payload
      \return none
    */
    ZCL_Status_t (*cancelMessage)(ZCL_Addressing_t *addressing, uint8_t payloadLength, CancelMessage_t *payload);
  } cancelMessageCommand;
  //!Get Last Message Command descriptor
  struct
  {
    ZCL_CommandId_t       id;       //!<Command Id (0x01)
    ZclCommandOptions_t   options;  //!<Command options
    /**
      \brief Command indication handler
      \param payloadLength - length of payload in cotets
      \param payload - payload
      \return none
    */
    ZCL_Status_t (*getLastMessage)(ZCL_Addressing_t *addressing, uint8_t payloadLength, void *payload);
  } getLastMessageCommand;
  //!Message Confirmation Command descriptor
  struct
  {
    ZCL_CommandId_t       id;       //!<Command Id (0x01)
    ZclCommandOptions_t   options;  //!<Command options
    /**
      \brief Command indication handler
      \param payloadLength - length of payload in cotets
      \param payload - payload
      \return none
    */
    ZCL_Status_t (*messageConfirmation)(ZCL_Addressing_t *addressing, uint8_t payloadLength, MessageConfirmation_t *payload);
  } messageConfirmationCommand;
} MessagingClusterCommands_t;



#endif // _MESSAGINGCLUSTER_H