1 // *********************************************************************
    2 //   IQRF standards header file                                        *
    3 // *********************************************************************
    4 // Copyright (c) MICRORISC s.r.o.
    5 //
    6 // File:    $RCSfile: IQRFstandard.h,v $
    7 // Version: $Revision: 1.86 $
    8 // Date:    $Date: 2021/08/20 12:56:25 $
    9 //
   10 // Revision history:
   11 //   2021/08/20  Release for DPA 4.16
   12 //   2020/09/03  Release for DPA 4.15
   13 //   2020/04/03  Release for DPA 4.14
   14 //   2020/02/27  Release for DPA 4.13
   15 //   2020/01/09  Release for DPA 4.12
   16 //   2019/12/11  Release for DPA 4.11
   17 //   2019/10/09  Release for DPA 4.10
   18 //   2019/06/12  Release for DPA 4.03
   19 //   2019/06/03  Release for DPA 4.02
   20 //   2019/03/07  Release for DPA 4.01
   21 //   2019/01/20  Release for DPA 4.00
   22 //   2018/10/25  Release for DPA 3.03
   23 //   2017/11/16  Release for DPA 3.02
   24 //   2017/08/14  Release for DPA 3.01
   25 //
   26 // *********************************************************************
   27 
   28 // Online DPA documentation https://doc.iqrf.org/DpaTechGuide/
   29 // IQRF Standards documentation https://doc.iqrf.org/
   30 
   31 #ifndef _IQRFSTD_HEADER_
   32 #define _IQRFSTD_HEADER_
   33 
   34 //############################################################################################
   35 
   36 // Enumerate command valid for standards, when applicable
   37 #define PCMD_STD_ENUMERATE                      0x3E
   38 
   39 #define FRC_STD_FRC_NO_VALUE                    0
   40 #define FRC_STD_FRC_NOT_IMPLEMENTED_VALUE       1
   41 #define FRC_STD_FRC_ERROR_VALUE                 2
   42 
   43 // -------------------------------------------------------------------------------------------
   44 // IQRF Sensors standard
   45 // -------------------------------------------------------------------------------------------
   46 // IQRF Sensors standard peripheral
   47 #define PNUM_STD_SENSORS                        0x5E
   48 // IQRF Sensors standard peripheral type
   49 #define PERIPHERAL_TYPE_STD_SENSORS             0x5E
   50 // Current version
   51 #define STD_SENSORS_VERSION                     15
   52 
   53 // IQRF Sensors standard peripheral - read sensor values command
   54 #define PCMD_STD_SENSORS_READ_VALUES            0x00
   55 // IQRF Sensors standard peripheral - read sensor types and values command
   56 #define PCMD_STD_SENSORS_READ_TYPES_AND_VALUES  0x01
   57 
   58 // Beaming sensor command
   59 #define PCMD_STD_SENSORS_READ_TYPES_AND_FRC_VALUES  0x7B
   60 
   61 // IQRF Sensors standard peripheral - sensor types
   62 //  2 bytes
   63 #define STD_SENSOR_TYPE_TEMPERATURE             0x01
   64 #define STD_SENSOR_TYPE_CO2                     0x02
   65 #define STD_SENSOR_TYPE_VOC                     0x03
   66 #define STD_SENSOR_TYPE_EXTRA_LOW_VOLTAGE       0x04
   67 #define STD_SENSOR_TYPE_EARTHS_MAGNETIC_FIELD   0x05
   68 #define STD_SENSOR_TYPE_LOW_VOLTAGE             0x06
   69 #define STD_SENSOR_TYPE_CURRENT                 0x07
   70 #define STD_SENSOR_TYPE_POWER                   0x08
   71 #define STD_SENSOR_TYPE_MAINS_FREQUENCY         0x09
   72 #define STD_SENSOR_TYPE_TIMESPAN                0x0A
   73 #define STD_SENSOR_TYPE_ILLUMINANCE             0x0B
   74 #define STD_SENSOR_TYPE_NO2                     0x0C
   75 #define STD_SENSOR_TYPE_SO2                     0x0D
   76 #define STD_SENSOR_TYPE_CO                      0x0E
   77 #define STD_SENSOR_TYPE_O3                      0x0F
   78 #define STD_SENSOR_TYPE_ATMOSPHERIC_PRESSURE    0x10
   79 #define STD_SENSOR_TYPE_COLOR_TEMPERATURE       0x11
   80 #define STD_SENSOR_TYPE_PARTICULATES_PM25       0x12
   81 #define STD_SENSOR_TYPE_SOUND_PRESSURE_LEVEL    0x13
   82 #define STD_SENSOR_TYPE_ALTITUDE                0x14
   83 #define STD_SENSOR_TYPE_ACCELERATION            0x15
   84 #define STD_SENSOR_TYPE_NH3                     0x16
   85 #define STD_SENSOR_TYPE_METHANE                 0x17
   86 #define STD_SENSOR_TYPE_SHORT_LENGTH            0x18
   87 #define STD_SENSOR_TYPE_PARTICULATES_PM1        0x19
   88 #define STD_SENSOR_TYPE_PARTICULATES_PM4        0x1A
   89 #define STD_SENSOR_TYPE_PARTICULATES_PM10       0x1B
   90 #define STD_SENSOR_TYPE_TVOC                    0x1C
   91 #define STD_SENSOR_TYPE_NOX                     0x1D
   92 
   93 //  1 byte
   94 #define STD_SENSOR_TYPE_HUMIDITY                0x80
   95 #define STD_SENSOR_TYPE_BINARYDATA7             0x81
   96 #define STD_SENSOR_TYPE_POWER_FACTOR            0x82
   97 #define STD_SENSOR_TYPE_UV_INDEX                0x83
   98 #define STD_SENSOR_TYPE_PH                      0x84
   99 #define STD_SENSOR_TYPE_RSSI                    0x85
  100 
  101 //  4 bytes
  102 #define STD_SENSOR_TYPE_BINARYDATA30            0xA0
  103 #define STD_SENSOR_TYPE_CONSUMPTION             0xA1
  104 #define STD_SENSOR_TYPE_DATETIME                0xA2
  105 #define STD_SENSOR_TYPE_TIMESPAN_LONG           0xA3
  106 #define STD_SENSOR_TYPE_LATITUDE                0xA4
  107 #define STD_SENSOR_TYPE_LONGITUDE               0xA5
  108 
  109 // Computes constant (otherwise not optimal) quantity size
  110 #define STD_SENSOR_TYPE_SIZE(q) ( ( ( (q) & 0x80 ) == 0x00 ) * 2 + ( ( (q) & 0xE0 ) == 0x80 ) * 1 + ( ( (q) & 0xE0 ) == 0xA0 ) * 4  + ( ( q & 0xC0 ) == 0xC0 || (q) == 0x00 ) * 0xFfFfFfFf /* hopefully causes overflow to signal error */ )
  111 
  112 //  Multiple bytes
  113 #define STD_SENSOR_TYPE_DATA_BLOCK              0xC0
  114 
  115 // IQRF Sensors standard peripheral - FRC commands
  116 #define FRC_STD_SENSORS_BIT                     0x10
  117 #define FRC_STD_SENSORS_1B                      0x90
  118 #define FRC_STD_SENSORS_2B                      0xE0
  119 #define FRC_STD_SENSORS_4B                      0xF9
  120 
  121 // Used at Local FRC by Controller to send quantities' values
  122 #define FRC_STD_SENSORS_CTRL_CMD                0x11
  123 
  124 typedef struct
  125 {
  126   // Equals to PNUM_STD_SENSORS
  127   uns8  Header;
  128   // Sensor type STD_SENSOR_TYPE_???
  129   uns8  SensorType;
  130   // Sensor index (bits 0-4) + optional extended data (bits 5-7)
  131   uns8  SensorIndex;
  132   // Options
  133   // bit  0  : sleep
  134   // bits 1-7: reserved
  135   uns8  Options;
  136   // Optional sleep parameters
  137   TPerOSSleep_Request SleepParameters;
  138 } STRUCTATTR TPerStdSensorFrc;
  139 
  140 
  141 #if defined( __CC5X__ ) && !defined( CC5XnotDPA )
  142 // The above structure located at memory
  143 TPerStdSensorFrc PerStdSensorFrc @ DataOutBeforeResponseFRC;
  144 #endif  // #ifdef __CC5X__
  145 
  146 // Structure for PCMD_STD_SENSORS_READ[_TYPES_AND]_VALUES
  147 typedef struct
  148 {
  149   uns8  Bitmap[4];
  150   uns8  WrittenData[DPA_MAX_DATA_LENGTH - 4];
  151 } STRUCTATTR TPerStdSensorRead_Request;
  152 
  153 // IQRF Sensors standard peripheral - error values
  154 //  2 bytes
  155 #define STD_SENSOR_TYPE_TEMPERATURE_SET_ERROR(v)            do { v = 0x8000; } while( 0 )
  156 #define STD_SENSOR_TYPE_TEMPERATURE_IS_ERROR(v)             ( (v) == 0x8000 )
  157 
  158 #define STD_SENSOR_TYPE_CO2_SET_ERROR(v)                    do { v = 0x8000; } while( 0 )
  159 #define STD_SENSOR_TYPE_CO2_IS_ERROR(v)                     ( (v) == 0x8000 )
  160 
  161 #define STD_SENSOR_TYPE_VOC_SET_ERROR(v)                    do { v = 0x8000; } while( 0 )
  162 #define STD_SENSOR_TYPE_VOC_IS_ERROR(v)                     ( (v) == 0x8000 )
  163 
  164 #define STD_SENSOR_TYPE_EXTRA_LOW_VOLTAGE_SET_ERROR(v)      do { v = 0x8000; } while( 0 )
  165 #define STD_SENSOR_TYPE_EXTRA_LOW_VOLTAGE_IS_ERROR(v)       ( (v) == 0x8000 )
  166 
  167 #define STD_SENSOR_TYPE_EARTHS_MAGNETIC_FIELD_SET_ERROR(v)  do { v = 0x8000; } while( 0 )
  168 #define STD_SENSOR_TYPE_EARTHS_MAGNETIC_FIELD_IS_ERROR(v)   ( (v) == 0x8000 )
  169 
  170 #define STD_SENSOR_TYPE_LOW_VOLTAGE_SET_ERROR(v)            do { v = 0x8000; } while( 0 )
  171 #define STD_SENSOR_TYPE_LOW_VOLTAGE_IS_ERROR(v)             ( (v) == 0x8000 )
  172 
  173 #define STD_SENSOR_TYPE_CURRENT_SET_ERROR(v)                do { v = 0x8000; } while( 0 )
  174 #define STD_SENSOR_TYPE_CURRENT_IS_ERROR(v)                 ( (v) == 0x8000 )
  175 
  176 #define STD_SENSOR_TYPE_POWER_SET_ERROR(v)                  do { v = 0xFfFf; } while( 0 )
  177 #define STD_SENSOR_TYPE_POWER_IS_ERROR(v)                   ( (v) == 0xFfFf )
  178 
  179 #define STD_SENSOR_TYPE_MAINS_FREQUENCY_SET_ERROR(v)        do { v = 0xFfFf; } while( 0 )
  180 #define STD_SENSOR_TYPE_MAINS_FREQUENCY_IS_ERROR(v)         ( (v) == 0xFfFf )
  181 
  182 #define STD_SENSOR_TYPE_TIMESPAN_SET_ERROR(v)               do { v = 0xFfFf; } while( 0 )
  183 #define STD_SENSOR_TYPE_TIMESPAN_IS_ERROR(v)                ( (v) == 0xFfFf )
  184 
  185 #define STD_SENSOR_TYPE_ILLUMINANCE_SET_ERROR(v)            do { v = 0xFfFf; } while( 0 )
  186 #define STD_SENSOR_TYPE_ILLUMINANCE_IS_ERROR(v)             ( (v) == 0xFfFf )
  187 
  188 #define STD_SENSOR_TYPE_NO2_SET_ERROR(v)                    do { v = 0xFfFf; } while( 0 )
  189 #define STD_SENSOR_TYPE_NO2_IS_ERROR(v)                     ( (v) == 0xFfFf )
  190 
  191 #define STD_SENSOR_TYPE_SO2_SET_ERROR(v)                    do { v = 0xFfFf; } while( 0 )
  192 #define STD_SENSOR_TYPE_SO2_IS_ERROR(v)                     ( (v) == 0xFfFf )
  193 
  194 #define STD_SENSOR_TYPE_CO_SET_ERROR(v)                     do { v = 0xFfFf; } while( 0 )
  195 #define STD_SENSOR_TYPE_CO_IS_ERROR(v)                      ( (v) == 0xFfFf )
  196 
  197 #define STD_SENSOR_TYPE_O3_SET_ERROR(v)                     do { v = 0xFfFf; } while( 0 )
  198 #define STD_SENSOR_TYPE_O3_IS_ERROR(v)                      ( (v) == 0xFfFf )
  199 
  200 #define STD_SENSOR_TYPE_ATMOSPHERIC_PRESSURE_SET_ERROR(v)   do { v = 0xFfFf; } while( 0 )
  201 #define STD_SENSOR_TYPE_ATMOSPHERIC_PRESSURE_IS_ERROR(v)    ( (v) == 0xFfFf )
  202 
  203 #define STD_SENSOR_TYPE_COLOR_TEMPERATURE_SET_ERROR(v)      do { v = 0x8000; } while( 0 )
  204 #define STD_SENSOR_TYPE_COLOR_TEMPERATURE_IS_ERROR(v)       ( (v) == 0x8000 )
  205 
  206 #define STD_SENSOR_TYPE_PARTICULATES_PM25_SET_ERROR(v)      do { v = 0x8000; } while( 0 )
  207 #define STD_SENSOR_TYPE_PARTICULATES_PM25_IS_ERROR(v)       ( (v) == 0x8000 )
  208 
  209 #define STD_SENSOR_TYPE_SOUND_PRESSURE_LEVEL_SET_ERROR(v)   do { v = 0x8000; } while( 0 )
  210 #define STD_SENSOR_TYPE_SOUND_PRESSURE_LEVEL_IS_ERROR(v)    ( (v) == 0x8000 )
  211 
  212 #define STD_SENSOR_TYPE_ALTITUDE_SET_ERROR(v)               do { v = 0xFfFf; } while( 0 )
  213 #define STD_SENSOR_TYPE_ALTITUDE_IS_ERROR(v)                ( (v) == 0xFfFf )
  214 
  215 #define STD_SENSOR_TYPE_ACCELERATION_SET_ERROR(v)           do { v = 0x8000; } while( 0 )
  216 #define STD_SENSOR_TYPE_ACCELERATION_IS_ERROR(v)            ( (v) == 0x8000 )
  217 
  218 #define STD_SENSOR_TYPE_NH3_SET_ERROR(v)                    do { v = 0xFfFf; } while( 0 )
  219 #define STD_SENSOR_TYPE_NH3_IS_ERROR(v)                     ( (v) == 0xFfFf )
  220 
  221 #define STD_SENSOR_TYPE_METHANE_SET_ERROR(v)                do { v = 0xFfFf; } while( 0 )
  222 #define STD_SENSOR_TYPE_METHANE_IS_ERROR(v)                 ( (v) == 0xFfFf )
  223 
  224 #define STD_SENSOR_TYPE_SHORT_LENGTH_SET_ERROR(v)           do { v = 0xFfFf; } while( 0 )
  225 #define STD_SENSOR_TYPE_SHORT_LENGTH_IS_ERROR(v)            ( (v) == 0xFfFf )
  226 
  227 #define STD_SENSOR_TYPE_PARTICULATES_PM1_SET_ERROR(v)       do { v = 0x8000; } while( 0 )
  228 #define STD_SENSOR_TYPE_PARTICULATES_PM1_IS_ERROR(v)        ( (v) == 0x8000 )
  229 
  230 #define STD_SENSOR_TYPE_PARTICULATES_PM4_SET_ERROR(v)       do { v = 0x8000; } while( 0 )
  231 #define STD_SENSOR_TYPE_PARTICULATES_PM4_IS_ERROR(v)        ( (v) == 0x8000 )
  232 
  233 #define STD_SENSOR_TYPE_PARTICULATES_PM10_SET_ERROR(v)      do { v = 0x8000; } while( 0 )
  234 #define STD_SENSOR_TYPE_PARTICULATES_PM10_IS_ERROR(v)       ( (v) == 0x8000 )
  235 
  236 #define STD_SENSOR_TYPE_TVOC_SET_ERROR(v)                   do { v = 0xFfFf; } while( 0 )
  237 #define STD_SENSOR_TYPE_TVOC_IS_ERROR(v)                    ( (v) == 0xFfFf )
  238 
  239 #define STD_SENSOR_TYPE_NOX_SET_ERROR(v)                    do { v = 0xFfFf; } while( 0 )
  240 #define STD_SENSOR_TYPE_NOX_IS_ERROR(v)                     ( (v) == 0xFfFf )
  241 
  242 //  1 byte
  243 #define STD_SENSOR_TYPE_HUMIDITY_SET_ERROR(v)               do { v = 0xEE; } while( 0 )
  244 #define STD_SENSOR_TYPE_HUMIDITY_IS_ERROR(v)                ( (v) == 0xEE )
  245 
  246 #define STD_SENSOR_TYPE_BINARYDATA7_SET_ERROR(v)            do { v = 0x80; } while( 0 )
  247 #define STD_SENSOR_TYPE_BINARYDATA7_IS_ERROR(v)             ( ( (v) & 0x80 ) != 0x00 )
  248 
  249 #define STD_SENSOR_TYPE_POWER_FACTOR_SET_ERROR(v)           do { v = 0xEE; } while( 0 )
  250 #define STD_SENSOR_TYPE_POWER_FACTOR_IS_ERROR(v)            ( (v) == 0xEE )
  251 
  252 #define STD_SENSOR_TYPE_UV_INDEX_SET_ERROR(v)               do { v = 0xFF; } while( 0 )
  253 #define STD_SENSOR_TYPE_UV_INDEX_IS_ERROR(v)                ( (v) == 0xFF )
  254 
  255 #define STD_SENSOR_TYPE_PH_INDEX_SET_ERROR(v)               do { v = 0xFF; } while( 0 )
  256 #define STD_SENSOR_TYPE_PH_INDEX_IS_ERROR(v)                ( (v) == 0xFF )
  257 
  258 #define STD_SENSOR_TYPE_RSSI_INDEX_SET_ERROR(v)             do { v = 0xFF; } while( 0 )
  259 #define STD_SENSOR_TYPE_RSSI_INDEX_IS_ERROR(v)              ( (v) == 0xFF )
  260 
  261 //  4 bytes
  262 #define STD_SENSOR_TYPE_BINARYDATA30_SET_ERROR(v)           do { v = 0x80000000; } while( 0 )
  263 #define STD_SENSOR_TYPE_BINARYDATA30_IS_ERROR(v)            ( ( (v) & 0x80000000 ) != 0x00000000 )
  264 
  265 #define STD_SENSOR_TYPE_CONSUMPTION_SET_ERROR(v)            do { v = 0xFfFfFfFf; } while( 0 )
  266 #define STD_SENSOR_TYPE_CONSUMPTION_IS_ERROR(v)             ( (v) == 0xFfFfFfFf )
  267 
  268 #define STD_SENSOR_TYPE_DATETIME_SET_ERROR(v)               do { v = 0xFfFfFfFf; } while( 0 )
  269 #define STD_SENSOR_TYPE_DATETIME_IS_ERROR(v)                ( (v) == 0xFfFfFfFf )
  270 
  271 #define STD_SENSOR_TYPE_TIMESPAN_LONG_SET_ERROR(v)          do { v = 0xFfFfFfFf; } while( 0 )
  272 #define STD_SENSOR_TYPE_TIMESPAN_LONG_IS_ERROR(v)           ( (v) == 0xFfFfFfFf )
  273 
  274 #define STD_SENSOR_TYPE_LATITUDE_SET_ERROR(v)               do { v = 0xFF000000; } while( 0 )
  275 #define STD_SENSOR_TYPE_LATITUDE_IS_ERROR(v)                ( ( (v) & 0xFF000000 ) == 0xFF000000 )
  276 
  277 #define STD_SENSOR_TYPE_LONGITUDE_SET_ERROR(v)              do { v = 0xFF000000; } while( 0 )
  278 #define STD_SENSOR_TYPE_LONGITUDE_IS_ERROR(v)               ( ( (v) & 0xFF000000 ) == 0xFF000000 )
  279 
  280 //  Written data constants
  281 #define STD_SENSOR_TYPE_TEMPERATURE_DATA_GET_1_POINT_CALIBRATION  1
  282 #define STD_SENSOR_TYPE_TEMPERATURE_DATA_SET_1_POINT_CALIBRATION  2
  283 
  284 #define STD_SENSOR_TYPE_HUMIDITY_DATA_GET_1_POINT_CALIBRATION  1
  285 #define STD_SENSOR_TYPE_HUMIDITY_DATA_SET_1_POINT_CALIBRATION  2
  286 
  287 // -------------------------------------------------------------------------------------------
  288 // IQRF Binary Outputs standard
  289 // -------------------------------------------------------------------------------------------
  290 // IQRF Binary Outputs standard peripheral
  291 #define PNUM_STD_BINARY_OUTPUTS                 0x4B
  292 // IQRF Binary Outputs peripheral type
  293 #define PERIPHERAL_TYPE_STD_BINARY_OUTPUTS      0x4B
  294 // Current version
  295 #define STD_BINARY_OUTPUTS_VERSION              4
  296 
  297 // IQRF Binary Outputs standard peripheral - set outputs
  298 #define PCMD_STD_BINARY_OUTPUTS_SET             0x00
  299 
  300 // Structure returned by PCMD_STD_ENUMERATE
  301 typedef struct
  302 {
  303   uns8  Count;
  304 } STRUCTATTR TPerStdBinaryOutputEnumerate_Response;
  305 
  306 // Structure for PCMD_STD_BINARY_OUTPUTS_SET
  307 typedef struct
  308 {
  309   uns8  Bitmap[4];
  310   uns8  NewState[DPA_MAX_DATA_LENGTH - 4];
  311 } STRUCTATTR TPerStdBinaryOutputSet_Request;
  312 
  313 #define STD_BINARY_OUTPUT_STATE_OFF                    0x00
  314 #define STD_BINARY_OUTPUT_STATE_ON                     0x01
  315 
  316 #define STD_BINARY_OUTPUT_IS_STATE_OK(state)           ( (state) != 0x80 )
  317 #define STD_BINARY_OUTPUT_IS_STATE_OFF(state)          ( (state) == STD_BINARY_OUTPUT_STATE_OFF )
  318 #define STD_BINARY_OUTPUT_IS_STATE_ON(state)           ( (state) >= STD_BINARY_OUTPUT_STATE_ON )
  319 #define STD_BINARY_OUTPUT_STATE_HAS_TIME(state)        ( (state) > STD_BINARY_OUTPUT_STATE_ON )
  320 #define STD_BINARY_OUTPUT_STATE_TIME_IN_SECONDS(state) ( ( (state) & 0x80 ) != 0x00 )
  321 #define STD_BINARY_OUTPUT_STATE_GET_SECONDS(state)     ( (state) & 0x7F )
  322 #define STD_BINARY_OUTPUT_STATE_TIME_IN_MINUTES(state) ( (state) > STD_BINARY_OUTPUT_STATE_ON && (state) <= 0x7F )
  323 #define STD_BINARY_OUTPUT_STATE_GET_MINUTES(state)     (state)
  324 
  325 // Structure returned by PCMD_STD_BINARY_OUTPUTS_SET
  326 typedef struct
  327 {
  328   uns8  PreviousStates[4];
  329 } STRUCTATTR TPerStdBinaryOutputSet_Response;
  330 
  331 
  332 // -------------------------------------------------------------------------------------------
  333 // IQRF Light standard
  334 // -------------------------------------------------------------------------------------------
  335 // IQRF Light standard peripheral
  336 #define PNUM_STD_LIGHT                          0x71
  337 // IQRF Light standard peripheral type
  338 #define PERIPHERAL_TYPE_STD_LIGHT               0x71
  339 // Current version
  340 #define STD_LIGHT_VERSION                       5
  341 
  342 // IQRF Light standard peripheral - Set Power
  343 #define PCMD_STD_LIGHT_SET                      0x00
  344 // IQRF Light standard peripheral - Increment Power
  345 #define PCMD_STD_LIGHT_INC                      0x01
  346 // IQRF Light standard peripheral - Decrement Power
  347 #define PCMD_STD_LIGHT_DEC                      0x02
  348 
  349 // IQRF Light standard peripheral - FRC commands
  350 #define FRC_STD_LIGHT_ONOFF                     0x10
  351 #define FRC_STD_LIGHT_ALARM                     0x11
  352 
  353 // Structure returned by PCMD_STD_ENUMERATE
  354 typedef struct
  355 {
  356   uns8  Count;
  357 } STRUCTATTR TPerStdLightEnumerate_Response;
  358 
  359 // Structure for PCMD_STD_LIGHT_???
  360 typedef struct
  361 {
  362   uns8  Bitmap[4];
  363   uns8  Power[DPA_MAX_DATA_LENGTH - 4];
  364 } STRUCTATTR TPerStdLightSetIncDec_Request;
  365 
  366 #define STD_LIGHT_POWER_MIN                 0
  367 #define STD_LIGHT_POWER_MAX                 100
  368 #define STD_LIGHT_KEEP_POWER                127
  369 #define STD_LIGHT_IS_POWER_OK(power)        ( ( ( (power) & 0x7F ) <= STD_LIGHT_POWER_MAX ) || ( (power) & 0x7F ) == STD_LIGHT_KEEP_POWER )
  370 #define STD_LIGHT_TIME_FOLLOWS_POWER(power) ( ( (power) & 0x80 ) != 0x00 )
  371 
  372 #define STD_LIGHT_IS_TIME_OK(time)          ( ( (time) & 0x7F ) != 0x00 )
  373 #define STD_LIGHT_TIME_IN_SECONDS(time)     ( ( (time) & 0x80 ) != 0x00 )
  374 #define STD_LIGHT_TIME_GET_SECONDS(time)    ( (time) & 0x7F )
  375 #define STD_LIGHT_TIME_IN_MINUTES(time)     ( !STD_LIGHT_TIME_IN_SECONDS( time ) )
  376 #define STD_LIGHT_TIME_GET_MINUTES(time)    (time)
  377 
  378 // -------------------------------------------------------------------------------------------
  379 // IQRF DALI standard
  380 // -------------------------------------------------------------------------------------------
  381 // IQRF DALI standard peripheral
  382 #define PNUM_STD_DALI                           0x4A
  383 // IQRF DALI standard peripheral type
  384 #define PERIPHERAL_TYPE_STD_DALI                0x4A
  385 // Current version
  386 #define STD_DALI_VERSION                        0
  387 
  388 // IQRF DALI standard peripheral - Send DALI commands
  389 #define PCMD_STD_DALI_SEND_COMMANDS             0x00
  390 // IQRF DALI standard peripheral - Send DALI commands asynchronously
  391 #define PCMD_STD_DALI_SEND_COMMANDS_ASYNC       0x01
  392 
  393 // IQRF DALI standard peripheral - FRC commands
  394 #define FRC_STD_DALI_SEND                       0xE0
  395 
  396 #if defined( __CC5X__ )
  397 // DALI answer byte #0
  398 typedef struct
  399 {
  400   bit Answer;
  401   bit AnswerError;
  402   bit _bit2_reserved;
  403   bit _bit3_reserved;
  404   bit _bit4_reserved;
  405   bit _bit5_reserved;
  406   bit _bit6_reserved;
  407   bit Always1;
  408 } TSTD_DALI_Answer0;
  409 #endif
  410 
  411 // -------------------------------------------------------------------------------------------
  412 
  413 // DPA Message data structure (packet w/o NADR, PNUM, PCMD, HWPID) for IQRF standards
  414 typedef union
  415 {
  416   // Structure for PCMD_STD_SENSORS_READ[_TYPES_AND]_VALUES
  417   TPerStdSensorRead_Request PerStdSensorRead_Request;
  418 
  419   // Structure returned by PCMD_STD_ENUMERATE for binary output
  420   TPerStdBinaryOutputEnumerate_Response PerStdBinaryOutputEnumerate_Response;
  421 
  422   // Structure for PCMD_STD_BINARY_OUTPUTS_SET
  423   TPerStdBinaryOutputSet_Request PerStdBinaryOutputSet_Request;
  424 
  425   // Structure returned by PCMD_STD_BINARY_OUTPUTS_SET
  426   TPerStdBinaryOutputSet_Response PerStdBinaryOutputSet_Response;
  427 
  428   // Structure returned by PCMD_STD_ENUMERATE for light
  429   TPerStdLightEnumerate_Response PerStdLightEnumerate_Response;
  430 } TDpaMessageIqrfStd;
  431 
  432 #if defined( __CC5X__ ) && !defined( CC5XnotDPA )
  433 // The structure above mapped at the DpaMessage
  434 TDpaMessageIqrfStd  _DpaMessageIqrfStd @ DpaRfMessage;
  435 #endif  // #ifdef __CC5X__
  436 
  437 // -------------------------------------------------------------------------------------------
  438 
  439 #endif  // _IQRFSTD_HEADER_
  440 
  441 //############################################################################################