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