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