summaryrefslogtreecommitdiff
path: root/digital/zigbit/bitcloud
diff options
context:
space:
mode:
Diffstat (limited to 'digital/zigbit/bitcloud')
-rw-r--r--digital/zigbit/bitcloud/makefiles/Makefile_All_Sec_ZigBit_Atmega1281_Rf230_8Mhz_Gcc134
-rw-r--r--digital/zigbit/bitcloud/makefiles/Makefile_All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc144
-rw-r--r--digital/zigbit/bitcloud/makefiles/Makefile_All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc~145
-rw-r--r--digital/zigbit/bitcloud/makefiles/Makefile_Coordinator_Sec_ZigBit_Atmega1281_Rf230_8Mhz_Gcc134
-rw-r--r--digital/zigbit/bitcloud/makefiles/Makefile_Coordinator_ZigBit_Atmega1281_Rf230_8Mhz_Gcc134
-rw-r--r--digital/zigbit/bitcloud/makefiles/Makefile_Router_Sec_ZigBit_Atmega1281_Rf230_8Mhz_Gcc134
-rw-r--r--digital/zigbit/bitcloud/makefiles/Makefile_Router_ZigBit_Atmega1281_Rf230_8Mhz_Gcc134
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/aps.h196
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/apsAIB.h177
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/apsCommon.h412
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/apsConfigServer.h37
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/apsCryptoKeys.h426
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/apsTcSwapOut.h59
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/apsdeData.h319
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/apsdeEndpoint.h203
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/apsmeAuthenticate.h195
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/apsmeBind.h189
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/apsmeEstablishKey.h317
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/apsmeGroup.h173
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/apsmeRemoveDevice.h145
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/apsmeRequestKey.h175
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/apsmeSwitchKey.h155
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/apsmeTransportKey.h292
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/apsmeUpdateDevice.h165
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/intrpData.h194
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsAuthenticate.h162
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsBinding.h186
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsCommand.h185
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsConfig.h44
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsDataManager.h164
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsDbg.h277
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsEndpoint.h47
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsFrames.h188
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsGroup.h66
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsKeyPairSet.h116
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsMemoryManager.h340
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsRejectDuplicate.h47
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsRemoveDevice.h61
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsRequestKey.h80
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSkke.h225
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSkkeInitiator.h61
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSkkeResponder.h60
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSmSsp.h80
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsState.h152
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSwitchKey.h61
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTaskManager.h68
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTransportAppKey.h84
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTransportKey.h118
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTransportNwkKey.h130
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTransportTrustKey.h83
-rw-r--r--digital/zigbit/bitcloud/stack/Components/APS/include/private/apsUpdateDevice.h64
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/BoardConfig106
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/BoardConfig.h89
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/battery.h63
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/bspDbg.h40
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/bspLeds.h70
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/bspTaskManager.h60
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/lm73.h66
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/pwrCtrl.h47
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/tsl2550.h64
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/battery.c168
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/bspTaskManager.c121
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/buttons.c239
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/fakeBSP.c359
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/leds.c139
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/lm73.c184
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/pwrCtrl.c91
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/sensors.c196
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/sliders.c59
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/tsl2550.c457
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/Makefile221
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/RCB/include/bspLeds.h68
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/RCB/include/bspTaskManager.h60
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/RCB/src/bspTaskManager.c86
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/RCB/src/buttons.c187
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/RCB/src/fakeBSP.c356
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/RCB/src/leds.c124
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/include/buttons.h96
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/include/hexSwitch.h45
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/include/joystick.h74
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/include/lcd.h140
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/include/leds.h83
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/include/rs232Controller.h89
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/include/rs485Controller.h33
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/include/sensors.h137
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/include/sliders.h43
-rw-r--r--digital/zigbit/bitcloud/stack/Components/BSP/include/usbController.h42
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ConfigServer/Makefile76
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ConfigServer/include/configServer.h158
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ConfigServer/include/csDefaults.h1381
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ConfigServer/include/csPersistentMem.h42
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ConfigServer/include/private/csBuffers.h151
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ConfigServer/include/private/csDbg.h32
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ConfigServer/include/private/csParamTable.h304
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ConfigServer/include/private/csSIB.h207
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ConfigServer/include/stackVersion.h3
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ConfigServer/src/configServer.c244
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ConfigServer/src/csMem.c289
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ConfigServer/src/csPersistentMem.c221
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/Configuration103
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/Makefile103
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/Makerules807
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/Makefile274
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/gpio.h147
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halAdc.h68
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halAppClock.h101
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halAssert.h108
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halAtomic.h57
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halClkCtrl.h70
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halDbg.h95
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halDiagnostic.h51
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halEeprom.h87
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halFCPU.h36
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halInit.h31
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halInterrupt.h36
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halIrq.h99
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halPwm.h199
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halSleep.h73
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halSleepTimerClock.h146
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halSpi.h180
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halUsart.h327
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halW1.h93
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halWdt.h53
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/i2c.h185
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/macros.m90152
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/calibration.c141
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/cstartup.s90250
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halAdc.c163
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halAppClock.c124
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halCalibration.s79
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halCalibration.s9080
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halClkCtrl.c122
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halEeprom.c66
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halInit.c71
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halIrq.c119
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halPwm.c161
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halSleep.c297
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halSleepTimerClock.c304
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halSpi.c142
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halUsart.c190
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halW1.s210
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halW1.s90211
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halWdtInit.c175
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/i2c.c90
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/wdt.c79
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/include/halMacIsr.h77
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/include/halRfCtrl.h127
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/include/halRfPio.h43
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/include/halRfSpi.h80
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/src/halMacIsr.c152
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/src/halRfCtrl.c214
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/src/halRfSpi.c90
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/src/halUid.c87
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/include/halMacIsr.h77
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/include/halRfCtrl.h142
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/include/halRfPio.h41
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/include/halRfSpi.h79
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/src/halMacIsr.c152
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/src/halRfCtrl.c257
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/src/halRfSpi.c90
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/src/halUid.c87
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halAtmelUid.h68
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halMacIsr.h77
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfCtrl.h142
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfPio.h41
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfSpi.h79
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halAtmelUid.c248
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halMacIsr.c152
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halRfCtrl.c281
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halRfSpi.c87
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halUid.c72
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/adc.c133
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/appTimer.c169
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/eeprom.c156
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/halTaskManager.c305
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/i2cPacket.c371
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/irq.c143
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/pwm.c165
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/resetReason.c59
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/sleep.c79
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/sleepTimer.c126
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/spi.c602
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/timer.c114
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/usart.c1061
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/usb.c435
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/w1.c382
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/ISD/src/isdImageStorage.c626
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/Makefile107
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/include/ofdMemoryDriver.h310
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdAt25Driver.c742
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdAt45dbDriver.c758
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdCommand.c243
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdCrcService.c66
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdFakeDriver.c218
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdIntFlashRead.s40
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdIntFlashRead.s9040
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdSpiSerializer.c91
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/DFU/include/dfuProtocol.h81
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/DFU/src/dfuProtocol.c135
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/include/abstractMemory.h83
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/include/mem.h106
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/include/mscProtocol.h79
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/include/scsiProtocol.h114
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/abstractMemory.c225
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/massStorageDevice.c327
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/mmc.c618
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/mscProtocol.c53
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/scsiProtocol.c398
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/VCP/Makefile71
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/VCP/include/vcpCdcProtocol.h119
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/VCP/src/vcpCdcProtocol.c226
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/VCP/src/vcpVirtualUsart.c498
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbDescriptors.h184
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbEnumeration.h53
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbSetupProcess.h51
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbDescriptors.c424
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbEnumeration.c231
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbSetupProcess.c90
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBFIFO/include/usbFifoVirtualUsart.h69
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBFIFO/src/usbFifoFT245RL.c290
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBFIFO/src/usbFifoVirtualUsart.c250
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/isdImageStorage.h89
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/massStorageDevice.h71
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/ofdExtMemory.h175
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/usbFifoUsart.h109
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/vcpVirtualUsart.h111
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/adc.h229
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/appTimer.h81
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/atomic.h72
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/bcTimer.h98
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/calibration.h31
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/dbgu.h41
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/eeprom.h113
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/halInit.h31
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/halTaskManager.h335
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/hsmci.h142
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/i2cPacket.h165
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/irq.h203
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/pwm.h193
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/reducePower.h33
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/resetReason.h153
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/sleep.h71
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/sleepTimer.h69
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/spi.h173
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/uart.h118
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/uid.h48
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/usart.h289
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/usb.h245
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/w1.h109
-rw-r--r--digital/zigbit/bitcloud/stack/Components/HAL/include/wdtCtrl.h122
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_ENV/include/macenvMem.h114
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_ENV/include/macenvPib.h444
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwd.h34
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdBatMon.h50
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdCalibration.h52
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdData.h92
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdEd.h61
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdEncrypt.h51
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdMem.h41
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdReset.h32
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdRnd.h58
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdService.h57
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdSet.h94
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdSetTrx.h65
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiAssociateHandler.h101
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiBeaconHandler.h50
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiDataHandler.h65
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiDisassociateHandler.h98
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiHwdReqMemPool.h48
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiManager.h234
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiMem.h82
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiMemAccess.h88
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiOrphanHandler.h61
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiPanIdConflictHandler.h41
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiPanServer.h67
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiPollHandler.h82
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiPurgeHandler.h58
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiResetHandler.h41
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiRxEnableHandler.h50
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiScanHandler.h97
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiSetGetHandler.h50
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiStartHandler.h69
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiSwitchRxCtrl.h113
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiTransactionHandler.h85
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiTransactionQueue.h123
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/mac.h51
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macAddr.h85
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macAffix.h48
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macAssociate.h154
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macBanNode.h121
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macBeacon.h108
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macBuffers.h54
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macCommStatus.h64
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macCommon.h90
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macData.h143
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macDbg.h210
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macDisassociate.h129
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macEnvironment.h59
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macFrame.h205
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macMem.h52
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macOrphan.h81
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macPoll.h105
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macPurge.h75
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macReset.h73
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macRxEnable.h78
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macScan.h116
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macSetGet.h113
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macStart.h89
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macSuperframe.h104
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macSync.h70
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macphyPib.h381
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/phy.h163
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfBattery.h126
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfCalibration.h78
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfEncrypt.h72
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfInit.h45
-rw-r--r--digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfRandom.h73
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nldeData.h402
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeDirectJoin.h76
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeEdScan.h88
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeJoin.h148
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeLeave.h105
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNetworkDiscovery.h122
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNetworkFormation.h95
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNwkStatus.h122
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmePermitJoining.h99
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeReset.h124
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeRouteDiscovery.h88
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSetGet.h299
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeStartRouter.h81
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSync.h79
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSyncLoss.h34
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwk.h87
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwkAddressResolv.h67
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwkAttributes.h196
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwkCommon.h353
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwkConfigServer.h47
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwkGroup.h144
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwkNeighbor.h241
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwkProfiler.h68
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwkRouteInfo.h124
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/nwkSecurity.h270
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddress.h82
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddressConflict.h105
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddressMap.h117
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkBTT.h86
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkCommands.h86
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkConcentrator.h83
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkConfig.h137
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDataReq.h92
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDbg.h473
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDirectJoin.h59
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDiscovery.h73
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkEDScan.h75
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkFormation.h92
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkFrame.h363
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkIB.h178
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkJoinInd.h209
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkJoinReq.h172
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLeave.h200
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLinkStatus.h194
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLoopback.h87
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkManager.h127
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkManyToOne.h69
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkMem.h421
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkNeighborTable.h261
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkOrphan.h109
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPacket.h154
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPassiveAck.h174
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPermitJoining.h86
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkReportCommand.h167
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkReset.h100
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteCache.h116
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteDiscovery.h91
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteDiscoveryTable.h240
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteRecord.h172
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteReply.h125
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteRequest.h149
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouting.h71
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRoutingTable.h162
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRx.h85
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRxSecurity.h54
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSilentJoin.h94
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSourceRouting.h119
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStartRouter.h89
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStateMachine.h154
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStatusInd.h86
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStatusReq.h230
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSync.h92
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSyncLoss.h61
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSystem.h100
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTaskManager.h98
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTx.h209
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTxDelay.h101
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTxSecurity.h70
-rw-r--r--digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkUpdateCommand.h146
-rw-r--r--digital/zigbit/bitcloud/stack/Components/PersistDataServer/Makefile73
-rw-r--r--digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/pdsDataServer.h99
-rw-r--r--digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsAuxService.h80
-rw-r--r--digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsCrcService.h73
-rw-r--r--digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsDbg.h37
-rw-r--r--digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsMemAbstract.h70
-rw-r--r--digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsWriteData.h84
-rw-r--r--digital/zigbit/bitcloud/stack/Components/PersistDataServer/src/pdsCrcService.c217
-rw-r--r--digital/zigbit/bitcloud/stack/Components/PersistDataServer/src/pdsDataServer.c206
-rw-r--r--digital/zigbit/bitcloud/stack/Components/PersistDataServer/src/pdsWriteData.c286
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspAuthenticHandler.h75
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspCcmHandler.h171
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspChallengeGenHandler.h42
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspHashHandler.h118
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspManager.h174
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspMem.h238
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspSfpHandler.h134
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspSkkeHandler.h96
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspAuthentic.h101
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspChallengeGen.h50
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspCommon.h74
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspDbg.h38
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspHash.h69
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspReset.h34
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspSfp.h203
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspSkke.h92
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcAuthenticHandler.h67
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcDeviceTableCtrlHandler.h46
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcKeyEstablishHandler.h82
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcKeyUpdateHandler.h60
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcMem.h116
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcRemoveHandler.h77
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcTaskManager.h81
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tc.h37
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcAuthentic.h63
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcCommon.h31
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcDbg.h49
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcDeviceTableCtrl.h109
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcKeyEstablish.h53
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcKeyUpdate.h66
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcPromiscuousMode.h59
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcRemove.h56
-rw-r--r--digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcReset.h33
-rw-r--r--digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/bcEndian.h144
-rw-r--r--digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/bcSysSleep.h37
-rw-r--r--digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/dbg.h244
-rw-r--r--digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/mnUtils.h127
-rw-r--r--digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/queue.h92
-rw-r--r--digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysDbg.h31
-rw-r--r--digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysDuplicateTable.h82
-rw-r--r--digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysStat.h53
-rw-r--r--digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysTimer.h79
-rw-r--r--digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/taskManager.h118
-rw-r--r--digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/types.h242
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/caps.h90
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/clusters.h186
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/eccAux.h11
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/genericEcc.h90
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/private/zclDbg.h137
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zcl.h1120
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclBACnetProtocolTunnelCluster.h105
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclBasicCluster.h259
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclDemandResponseCluster.h351
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclGenericTunnelCluster.h176
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclGroupsCluster.h361
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclHumidityMeasurementCluster.h122
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclIdentifyCluster.h178
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclInt.h46
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclKeyEstablishmentCluster.h529
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclLevelControlCluster.h286
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMem.h62
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMemoryManager.h90
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMessagingCluster.h185
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOTAUCluster.h564
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOccupancySensingCluster.h155
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOnOffCluster.h200
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOnOffSwitchConfigurationCluster.h150
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOtauDiscovery.h100
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOtauManager.h180
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclParser.h445
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPowerConfigurationCluster.h107
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPriceCluster.h267
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclScenesCluster.h487
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclSecurityManager.h190
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclSimpleMeteringCluster.h175
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTaskManager.h71
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTemperatureMeasurementCluster.h121
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclThermostatCluster.h214
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTimeCluster.h220
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZll.h155
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllBasicCluster.h308
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllColorControlCluster.h1004
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllCommissioningCluster.h228
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllFrameFormat.h265
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllGroupsCluster.h363
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllIB.h171
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllIdentifyCluster.h215
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllInterPan.h71
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllLevelControlCluster.h297
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllMisc.h95
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllNetwork.h114
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllOnOffCluster.h281
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllScan.h109
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllScenesCluster.h648
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllSecurity.h63
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/appFramework.h310
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoBinding.h46
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoDbg.h129
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoDiscoveryManager.h24
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoEndDeviceBinding.h134
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoInit.h39
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoLeaveNetwork.h111
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoManager.h116
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoMem.h177
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoNodeManager.h68
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoNwkManager.h87
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoPowerManager.h66
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoReset.h75
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoResetNetwork.h61
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoStartNetwork.h127
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTaskManager.h66
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTcKeepAlive.h72
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTcSwapOut.h92
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZdpFrameProcessor.h121
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZdpManager.h65
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZib.h99
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/zdo.h1676
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/zdoNotify.h108
-rw-r--r--digital/zigbit/bitcloud/stack/Components/ZDO/include/zdoSecurityManager.h85
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf212_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf212_Gcc.h91
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf230B_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf230B_Gcc.h91
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf230_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf230_Gcc.h91
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf231_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf231_Gcc.h91
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf212_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf212_Gcc.h112
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf230B_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf230B_Gcc.h112
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf230_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf230_Gcc.h112
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf231_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf231_Gcc.h112
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf212_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf212_Gcc.h85
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf230B_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf230B_Gcc.h85
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf230_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf230_Gcc.h85
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf231_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf231_Gcc.h85
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf212_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf212_Gcc.h106
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf230B_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf230B_Gcc.h106
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf230_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf230_Gcc.h106
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf231_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf231_Gcc.h106
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf212_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf212_Gcc.h112
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf230B_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf230B_Gcc.h112
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf230_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf230_Gcc.h112
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf231_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf231_Gcc.h112
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf212_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf212_Gcc.h82
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf230B_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf230B_Gcc.h82
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf230_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf230_Gcc.h82
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf231_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf231_Gcc.h82
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf212_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf212_Gcc.h103
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf230B_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf230B_Gcc.h103
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf230_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf230_Gcc.h103
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf231_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf231_Gcc.h103
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf212_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf212_Gcc.h109
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf230B_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf230B_Gcc.h109
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf230_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf230_Gcc.h109
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf231_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf231_Gcc.h109
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf212_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf212_Gcc.h85
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf230B_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf230B_Gcc.h85
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf230_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf230_Gcc.h85
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf231_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf231_Gcc.h85
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf212_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf212_Gcc.h106
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf230B_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf230B_Gcc.h106
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf230_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf230_Gcc.h106
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf231_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf231_Gcc.h106
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf212_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf212_Gcc.h112
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf230B_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf230B_Gcc.h112
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf230_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf230_Gcc.h112
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf231_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf231_Gcc.h112
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesHalSe_x86_Gcc32
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesSelector380
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesSelector.h15813
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Atmega1281_Rf212_Gcc34
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Atmega1281_Rf212_Gcc.h85
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Atmega1281_Rf230_Gcc34
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Atmega1281_Rf230_Gcc.h85
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Sec_Atmega1281_Rf212_Gcc34
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Sec_Atmega1281_Rf212_Gcc.h106
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Sec_Atmega1281_Rf230_Gcc34
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Sec_Atmega1281_Rf230_Gcc.h106
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Atmega1281_Rf212_Gcc34
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Atmega1281_Rf212_Gcc.h79
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Atmega1281_Rf230_Gcc34
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Atmega1281_Rf230_Gcc.h79
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Sec_Atmega1281_Rf212_Gcc34
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Sec_Atmega1281_Rf212_Gcc.h100
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Sec_Atmega1281_Rf230_Gcc34
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Sec_Atmega1281_Rf230_Gcc.h100
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Atmega1281_Rf212_Gcc34
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Atmega1281_Rf212_Gcc.h76
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Atmega1281_Rf230_Gcc34
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Atmega1281_Rf230_Gcc.h76
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Sec_Atmega1281_Rf212_Gcc34
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Sec_Atmega1281_Rf212_Gcc.h97
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Sec_Atmega1281_Rf230_Gcc34
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Sec_Atmega1281_Rf230_Gcc.h97
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Atmega1281_Rf212_Gcc34
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Atmega1281_Rf212_Gcc.h79
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Atmega1281_Rf230_Gcc34
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Atmega1281_Rf230_Gcc.h79
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Sec_Atmega1281_Rf212_Gcc34
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Sec_Atmega1281_Rf212_Gcc.h100
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Sec_Atmega1281_Rf230_Gcc34
-rw-r--r--digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Sec_Atmega1281_Rf230_Gcc.h100
-rw-r--r--digital/zigbit/bitcloud/stack/lib/Makerules_Atmega1281_Gcc28
-rw-r--r--digital/zigbit/bitcloud/stack/lib/Makerules_x86_Gcc35
-rw-r--r--digital/zigbit/bitcloud/stack/lib/WdtInitatmega1281_Gcc.obin0 -> 976 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_All_Atmega1281_Rf212_Gcc.abin0 -> 410990 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_All_Atmega1281_Rf230B_Gcc.abin0 -> 401536 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_All_Atmega1281_Rf230_Gcc.abin0 -> 405008 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_All_Atmega1281_Rf231_Gcc.abin0 -> 409570 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_All_Sec_Atmega1281_Rf212_Gcc.abin0 -> 489828 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_All_Sec_Atmega1281_Rf230B_Gcc.abin0 -> 476360 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_All_Sec_Atmega1281_Rf230_Gcc.abin0 -> 479832 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_All_Sec_Atmega1281_Rf231_Gcc.abin0 -> 488408 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Atmega1281_Rf212_Gcc.abin0 -> 385294 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Atmega1281_Rf230B_Gcc.abin0 -> 375840 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Atmega1281_Rf230_Gcc.abin0 -> 379312 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Atmega1281_Rf231_Gcc.abin0 -> 383874 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Sec_Atmega1281_Rf212_Gcc.abin0 -> 463156 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Sec_Atmega1281_Rf230B_Gcc.abin0 -> 449688 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Sec_Atmega1281_Rf230_Gcc.abin0 -> 453160 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Sec_Atmega1281_Rf231_Gcc.abin0 -> 461736 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_StdlinkSec_Atmega1281_Rf212_Gcc.abin0 -> 501370 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_StdlinkSec_Atmega1281_Rf230B_Gcc.abin0 -> 491916 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_StdlinkSec_Atmega1281_Rf230_Gcc.abin0 -> 495388 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_StdlinkSec_Atmega1281_Rf231_Gcc.abin0 -> 504212 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Atmega1281_Rf212_Gcc.abin0 -> 327256 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Atmega1281_Rf230B_Gcc.abin0 -> 317802 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Atmega1281_Rf230_Gcc.abin0 -> 321272 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Atmega1281_Rf231_Gcc.abin0 -> 325836 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Sec_Atmega1281_Rf212_Gcc.abin0 -> 403692 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Sec_Atmega1281_Rf230B_Gcc.abin0 -> 390226 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Sec_Atmega1281_Rf230_Gcc.abin0 -> 393696 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Sec_Atmega1281_Rf231_Gcc.abin0 -> 402272 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_StdlinkSec_Atmega1281_Rf212_Gcc.abin0 -> 441868 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_StdlinkSec_Atmega1281_Rf230B_Gcc.abin0 -> 432414 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_StdlinkSec_Atmega1281_Rf230_Gcc.abin0 -> 435884 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_StdlinkSec_Atmega1281_Rf231_Gcc.abin0 -> 444708 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Router_Atmega1281_Rf212_Gcc.abin0 -> 396374 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Router_Atmega1281_Rf230B_Gcc.abin0 -> 386920 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Router_Atmega1281_Rf230_Gcc.abin0 -> 390392 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Router_Atmega1281_Rf231_Gcc.abin0 -> 394954 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Router_Sec_Atmega1281_Rf212_Gcc.abin0 -> 474700 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Router_Sec_Atmega1281_Rf230B_Gcc.abin0 -> 461232 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Router_Sec_Atmega1281_Rf230_Gcc.abin0 -> 464704 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Router_Sec_Atmega1281_Rf231_Gcc.abin0 -> 473280 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Router_StdlinkSec_Atmega1281_Rf212_Gcc.abin0 -> 512914 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Router_StdlinkSec_Atmega1281_Rf230B_Gcc.abin0 -> 503460 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Router_StdlinkSec_Atmega1281_Rf230_Gcc.abin0 -> 506932 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libBc_Router_StdlinkSec_Atmega1281_Rf231_Gcc.abin0 -> 515756 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libHAL_Rcb230_Atmega1281_8Mhz_Gcc.abin0 -> 91866 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libHAL_Rcb231_212_Atmega1281_8Mhz_Gcc.abin0 -> 92328 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc.abin0 -> 84176 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc_Amp.abin0 -> 92054 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libZcl_All_Atmega1281_Rf212_Gcc.abin0 -> 464778 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libZcl_All_Atmega1281_Rf230_Gcc.abin0 -> 458796 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libZcl_All_Sec_Atmega1281_Rf212_Gcc.abin0 -> 543608 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libZcl_All_Sec_Atmega1281_Rf230_Gcc.abin0 -> 533612 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libZcl_Coordinator_Atmega1281_Rf212_Gcc.abin0 -> 438898 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libZcl_Coordinator_Atmega1281_Rf230_Gcc.abin0 -> 432916 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libZcl_Coordinator_Sec_Atmega1281_Rf212_Gcc.abin0 -> 516748 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libZcl_Coordinator_Sec_Atmega1281_Rf230_Gcc.abin0 -> 506752 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libZcl_EndDevice_Atmega1281_Rf212_Gcc.abin0 -> 381872 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libZcl_EndDevice_Atmega1281_Rf230_Gcc.abin0 -> 375888 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libZcl_EndDevice_Sec_Atmega1281_Rf212_Gcc.abin0 -> 458300 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libZcl_EndDevice_Sec_Atmega1281_Rf230_Gcc.abin0 -> 448304 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libZcl_Router_Atmega1281_Rf212_Gcc.abin0 -> 450162 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libZcl_Router_Atmega1281_Rf230_Gcc.abin0 -> 444180 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libZcl_Router_Sec_Atmega1281_Rf212_Gcc.abin0 -> 528476 bytes
-rw-r--r--digital/zigbit/bitcloud/stack/lib/libZcl_Router_Sec_Atmega1281_Rf230_Gcc.abin0 -> 518480 bytes
715 files changed, 104581 insertions, 0 deletions
diff --git a/digital/zigbit/bitcloud/makefiles/Makefile_All_Sec_ZigBit_Atmega1281_Rf230_8Mhz_Gcc b/digital/zigbit/bitcloud/makefiles/Makefile_All_Sec_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
new file mode 100644
index 00000000..d1573b08
--- /dev/null
+++ b/digital/zigbit/bitcloud/makefiles/Makefile_All_Sec_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
@@ -0,0 +1,134 @@
+COMPONENTS_PATH = ./../../../../BitCloud/Components
+APP_NAME = Peer2Peer
+CONFIG_NAME = All_Sec_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
+LIST_PATH = $(CONFIG_NAME)/List
+EXE_PATH = $(CONFIG_NAME)/Exe
+OBJ_PATH = $(CONFIG_NAME)/Obj
+
+include ./../../../../BitCloud/lib/Makerules_Atmega1281_Gcc
+
+DEFINES = \
+ -DBOARD_MESHBEAN \
+ -DATMEGA1281 \
+ -DHAL_8MHz \
+ -DAT86RF230 \
+ -DSTANDARD_SECURITY_MODE \
+ -DSTACK_TYPE_ALL
+
+INCLUDES = \
+ -I./../.. \
+ -I./../../include \
+ -I./../../../../BitCloud/Components/BSP/MESHBEAN/include \
+ -I./../../../../BitCloud/lib \
+ -I./../../../../BitCloud/Components/HAL/include \
+ -I./../../../../BitCloud/Components/BSP \
+ -I./../../../../BitCloud/Components/BSP/include \
+ -I./../../../../BitCloud/Components/NWK/include \
+ -I./../../../../BitCloud/Components/NWK/include/private \
+ -I./../../../../BitCloud/Components/ZDO/include \
+ -I./../../../../BitCloud/Components/ZDO/include/private \
+ -I./../../../../BitCloud/Components/APS/include \
+ -I./../../../../BitCloud/Components/APS/include/private \
+ -I./../../../../BitCloud/Components/SystemEnvironment/include \
+ -I./../../../../BitCloud/Components/ConfigServer/include \
+ -I./../../../../BitCloud/Components/ConfigServer/include/private \
+ -I./../../../../BitCloud/Components/PersistDataServer/include \
+ -I./../../../../BitCloud/Components/PersistDataServer/include/private \
+ -I./../../../../BitCloud/Components/Security/TrustCentre/include \
+ -I./../../../../BitCloud/Components/Security/ServiceProvider/include \
+ -I./../../../../BitCloud/Components/HAL/avr/atmega1281/common/include \
+ -I./../../../../BitCloud/Components/HAL/avr/atmega1281/zigBit/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_ENV/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWI/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWD_PHY/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWD_PHY/RF230/PHY/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWD_PHY/RF230/MAC_HWD/include
+
+LIBS = \
+ ./../../../../BitCloud/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc.a \
+ ./../../../../BitCloud/lib/libBc_All_Sec_Atmega1281_Rf230_Gcc.a \
+ ./../../../../BitCloud/lib/WdtInitatmega1281_Gcc.o
+
+SRCS = \
+ ./../../../../BitCloud/Components/PersistDataServer/src/pdsWriteData.c \
+ ./../../../../BitCloud/Components/PersistDataServer/src/pdsDataServer.c \
+ ./../../../../BitCloud/Components/PersistDataServer/src/pdsCrcService.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/sensors.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/buttons.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/pwrCtrl.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/leds.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/battery.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/lm73.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/tsl2550.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/sliders.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/fakeBSP.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/bspTaskManager.c \
+ ./../../../../BitCloud/Components/ConfigServer/src/csPersistentMem.c \
+ ./../../../../BitCloud/Components/ConfigServer/src/csMem.c \
+ ./../../../../BitCloud/Components/ConfigServer/src/configServer.c
+
+PREINCLUDE = MakerulesBc_All_Sec_Atmega1281_Rf230_Gcc.h
+
+SRCS += $(wildcard ./../../src/*.c)
+SRCS += $(wildcard ./../../../common/src/*.c)
+
+CSRCS = $(filter %.c, $(SRCS))
+OBJS = $(addprefix $(OBJ_PATH)/, $(notdir %/$(subst .c,.o,$(CSRCS))))
+
+ASM_FILE_EXT = s
+
+ifneq (, $(findstring .$(ASM_FILE_EXT), $(SRCS)))
+ ASRCS = $(filter %.$(ASM_FILE_EXT), $(SRCS))
+ OBJS += $(addprefix $(OBJ_PATH)/, $(notdir %$(subst .$(ASM_FILE_EXT),.o,$(ASRCS))))
+endif
+
+CFLAGS += $(DEFINES)
+CFLAGS += $(INCLUDES)
+CFLAGS += -include $(PREINCLUDE)
+CFLAGS += -g
+
+ASFLAGS = $(INCLUDES)
+ASFLAGS += $(filter -mmcu%,$(CFLAGS))
+
+LD = $(CC)
+LINKER_FLAGS = -Wl,-Map=$(LIST_PATH)/$(APP_NAME).map -Wl,--gc-sections
+LINKER_FLAGS += -Wl,--script=./../../linkerScr/atmega1281.ld
+LINKER_FLAGS += $(filter -mmcu%,$(CFLAGS))
+
+.PHONY: all directories clean size root_files
+
+all: directories $(EXE_PATH)/$(APP_NAME).elf $(EXE_PATH)/$(APP_NAME).hex $(EXE_PATH)/$(APP_NAME).srec $(EXE_PATH)/$(APP_NAME).bin root_files size
+
+$(OBJ_PATH)/%.o: $(SRCS)
+ $(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -o $@
+
+
+$(EXE_PATH)/$(APP_NAME).elf: $(OBJS)
+ $(LD) $(LINKER_FLAGS) $(OBJS) -Wl,-\( $(LIBS) -Wl,-\) -o $@
+
+$(EXE_PATH)/$(APP_NAME).srec: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O srec --srec-len 128 $^ $@
+
+$(EXE_PATH)/$(APP_NAME).hex: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O ihex -R .eeprom $^ $@
+
+$(EXE_PATH)/$(APP_NAME).bin: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O binary --strip-debug --strip-unneeded -R .eeprom $^ $@
+
+root_files:
+ cp -f $(EXE_PATH)/*.* ./../../
+
+clean:
+ rm -rf $(CONFIG_NAME) ./../../$(APP_NAME).elf ./../../$(APP_NAME).hex ./../../$(APP_NAME).srec ./../../$(APP_NAME).bin
+
+directories:
+ @mkdir -p $(LIST_PATH)
+ @mkdir -p $(EXE_PATH)
+ @mkdir -p $(OBJ_PATH)
+
+size: $(EXE_PATH)/$(APP_NAME).elf
+ @echo
+ @$(SIZE) -td $(EXE_PATH)/$(APP_NAME).elf
+
+# eof Makefile
diff --git a/digital/zigbit/bitcloud/makefiles/Makefile_All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc b/digital/zigbit/bitcloud/makefiles/Makefile_All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
new file mode 100644
index 00000000..a6d216b4
--- /dev/null
+++ b/digital/zigbit/bitcloud/makefiles/Makefile_All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
@@ -0,0 +1,144 @@
+COMPONENTS_PATH = $(BITCLOUD_PATH)/Components
+CONFIG_NAME = All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
+LIST_PATH = $(CONFIG_NAME)/List
+EXE_PATH = $(CONFIG_NAME)/Exe
+OBJ_PATH = $(CONFIG_NAME)/Obj
+
+include $(BITCLOUD_PATH)/lib/Makerules_Atmega1281_Gcc
+
+DEFINES = \
+ -DBOARD_MESHBEAN \
+ -DATMEGA1281 \
+ -DHAL_8MHz \
+ -DAT86RF230 \
+ -DNO_SECURITY_MODE \
+ -DSTACK_TYPE_ALL
+
+ifeq ($(LOL_NUMBER),0)
+ DEFINES += -DLOL_NUMBER_0
+else ifeq ($(LOL_NUMBER),1)
+ DEFINES += -DLOL_NUMBER_1
+else ifeq ($(LOL_NUMBER),2)
+ DEFINES += -DLOL_NUMBER_2
+else ifeq ($(LOL_NUMBER),3)
+ DEFINES += -DLOL_NUMBER_3
+endif
+
+INCLUDES = \
+ -I$(PROJECT_BASE) \
+ -I$(BITCLOUD_PATH)/Components/BSP/MESHBEAN/include \
+ -I$(BITCLOUD_PATH)/lib \
+ -I$(BITCLOUD_PATH)/Components/HAL/include \
+ -I$(BITCLOUD_PATH)/Components/BSP \
+ -I$(BITCLOUD_PATH)/Components/BSP/include \
+ -I$(BITCLOUD_PATH)/Components/NWK/include \
+ -I$(BITCLOUD_PATH)/Components/NWK/include/private \
+ -I$(BITCLOUD_PATH)/Components/ZDO/include \
+ -I$(BITCLOUD_PATH)/Components/ZDO/include/private \
+ -I$(BITCLOUD_PATH)/Components/APS/include \
+ -I$(BITCLOUD_PATH)/Components/APS/include/private \
+ -I$(BITCLOUD_PATH)/Components/SystemEnvironment/include \
+ -I$(BITCLOUD_PATH)/Components/ConfigServer/include \
+ -I$(BITCLOUD_PATH)/Components/ConfigServer/include/private \
+ -I$(BITCLOUD_PATH)/Components/PersistDataServer/include \
+ -I$(BITCLOUD_PATH)/Components/PersistDataServer/include/private \
+ -I$(BITCLOUD_PATH)/Components/Security/TrustCentre/include \
+ -I$(BITCLOUD_PATH)/Components/Security/ServiceProvider/include \
+ -I$(BITCLOUD_PATH)/Components/HAL/avr/atmega1281/common/include \
+ -I$(BITCLOUD_PATH)/Components/HAL/avr/atmega1281/zigBit/include \
+ -I$(BITCLOUD_PATH)/Components/MAC_PHY/include \
+ -I$(BITCLOUD_PATH)/Components/MAC_PHY/MAC_ENV/include \
+ -I$(BITCLOUD_PATH)/Components/MAC_PHY/MAC_HWI/include \
+ -I$(BITCLOUD_PATH)/Components/MAC_PHY/MAC_HWD_PHY/include \
+ -I$(BITCLOUD_PATH)/Components/MAC_PHY/MAC_HWD_PHY/RF230/PHY/include \
+ -I$(BITCLOUD_PATH)/Components/MAC_PHY/MAC_HWD_PHY/RF230/MAC_HWD/include \
+ -I$(APB_AVR_PATH) \
+ -I$(APB_AVR_PATH)/common \
+ -I$(APB_AVR_PATH)/modules/twi
+
+LIBS = \
+ $(BITCLOUD_PATH)/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc_Amp.a \
+ $(BITCLOUD_PATH)/lib/libBc_All_Atmega1281_Rf230_Gcc.a \
+ $(BITCLOUD_PATH)/lib/WdtInitatmega1281_Gcc.o
+
+SRCS = \
+ $(BITCLOUD_PATH)/Components/PersistDataServer/src/pdsWriteData.c \
+ $(BITCLOUD_PATH)/Components/PersistDataServer/src/pdsDataServer.c \
+ $(BITCLOUD_PATH)/Components/PersistDataServer/src/pdsCrcService.c \
+ $(BITCLOUD_PATH)/Components/BSP/MESHBEAN/src/fakeBSP.c \
+ $(BITCLOUD_PATH)/Components/BSP/MESHBEAN/src/bspTaskManager.c \
+ $(BITCLOUD_PATH)/Components/ConfigServer/src/csPersistentMem.c \
+ $(BITCLOUD_PATH)/Components/ConfigServer/src/csMem.c \
+ $(BITCLOUD_PATH)/Components/ConfigServer/src/configServer.c \
+ $(APB_AVR_PATH)/modules/twi/twi_hard.avr.c \
+ $(APB_AVR_PATH)/modules/twi/twi.c
+
+PREINCLUDE = MakerulesBc_All_Atmega1281_Rf230_Gcc.h
+
+SRCS += $(wildcard $(PROJECT_BASE)/*.c)
+SRCS += $(wildcard ./../../common/src/*.c)
+
+CSRCS = $(filter %.c, $(SRCS))
+OBJS = $(addprefix $(OBJ_PATH)/, $(notdir %/$(subst .c,.o,$(CSRCS))))
+
+ASM_FILE_EXT = s
+
+ifneq (, $(findstring .$(ASM_FILE_EXT), $(SRCS)))
+ ASRCS = $(filter %.$(ASM_FILE_EXT), $(SRCS))
+ OBJS += $(addprefix $(OBJ_PATH)/, $(notdir %$(subst .$(ASM_FILE_EXT),.o,$(ASRCS))))
+endif
+
+CFLAGS += $(DEFINES)
+CFLAGS += $(INCLUDES)
+CFLAGS += -include $(PREINCLUDE)
+CFLAGS += -g
+
+# APB sources need to be compiled without this option in order to manage correctly APB inline functions
+APB_CFLAGS := $(filter-out -std=gnu99,$(CFLAGS))
+
+ASFLAGS = $(INCLUDES)
+ASFLAGS += $(filter -mmcu%,$(CFLAGS))
+
+LD = $(CC)
+LINKER_FLAGS = -Wl,-Map=$(LIST_PATH)/$(APP_NAME).map -Wl,--gc-sections
+LINKER_FLAGS += -Wl,--script=$(PROJECT_BASE)/atmega1281.ld
+LINKER_FLAGS += $(filter -mmcu%,$(CFLAGS))
+LINKER_FLAGS += -Wl,-u,vfprintf -lprintf_flt -lm
+
+.PHONY: all directories clean size root_files
+
+all: directories $(EXE_PATH)/$(APP_NAME).elf $(EXE_PATH)/$(APP_NAME).hex $(EXE_PATH)/$(APP_NAME).srec $(EXE_PATH)/$(APP_NAME).bin root_files size
+
+$(OBJ_PATH)/%.o: $(SRCS)
+ $(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -o $@
+All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc/Obj/twi_hard.avr.o: CFLAGS=$(APB_CFLAGS)
+
+
+$(EXE_PATH)/$(APP_NAME).elf: $(OBJS)
+ $(LD) $(LINKER_FLAGS) $(OBJS) -lm -Wl,-\( $(LIBS) -Wl,-\) -o $@
+
+$(EXE_PATH)/$(APP_NAME).srec: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O srec --srec-len 128 $^ $@
+
+$(EXE_PATH)/$(APP_NAME).hex: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O ihex -R .eeprom $^ $@
+
+$(EXE_PATH)/$(APP_NAME).bin: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O binary --strip-debug --strip-unneeded -R .eeprom $^ $@
+
+root_files:
+ cp -f $(EXE_PATH)/*.* $(PROJECT_BASE)/obj
+
+clean:
+ rm -rf $(CONFIG_NAME) $(PROJECT_BASE)/obj/$(APP_NAME).elf $(PROJECT_BASE)/obj/$(APP_NAME).hex $(PROJECT_BASE)/obj/$(APP_NAME).srec $(PROJECT_BASE)/obj/$(APP_NAME).bin
+
+directories:
+ @mkdir -p $(LIST_PATH)
+ @mkdir -p $(EXE_PATH)
+ @mkdir -p $(OBJ_PATH)
+
+size: $(EXE_PATH)/$(APP_NAME).elf
+ @echo
+ @$(SIZE) -td $(EXE_PATH)/$(APP_NAME).elf
+
+# eof Makefile
diff --git a/digital/zigbit/bitcloud/makefiles/Makefile_All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc~ b/digital/zigbit/bitcloud/makefiles/Makefile_All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc~
new file mode 100644
index 00000000..895ba2b9
--- /dev/null
+++ b/digital/zigbit/bitcloud/makefiles/Makefile_All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc~
@@ -0,0 +1,145 @@
+COMPONENTS_PATH = $(BITCLOUD_PATH)/Components
+CONFIG_NAME = All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
+LIST_PATH = $(CONFIG_NAME)/List
+EXE_PATH = $(CONFIG_NAME)/Exe
+OBJ_PATH = $(CONFIG_NAME)/Obj
+
+include $(BITCLOUD_PATH)/lib/Makerules_Atmega1281_Gcc
+
+DEFINES = \
+ -DBOARD_MESHBEAN \
+ -DATMEGA1281 \
+ -DHAL_8MHz \
+ -DAT86RF230 \
+ -DNO_SECURITY_MODE \
+ -DSTACK_TYPE_ALL
+
+ifeq ($(LOL_NUMBER),0)
+ DEFINES += -DLOL_NUMBER_0
+else ifeq ($(LOL_NUMBER),1)
+ DEFINES += -DLOL_NUMBER_1
+else ifeq ($(LOL_NUMBER),2)
+ DEFINES += -DLOL_NUMBER_2
+else ifeq ($(LOL_NUMBER),3)
+ DEFINES += -DLOL_NUMBER_3
+endif
+
+INCLUDES = \
+ -I$(PROJECT_BASE) \
+ -I$(BITCLOUD_PATH)/Components/BSP/MESHBEAN/include \
+ -I$(BITCLOUD_PATH)/lib \
+ -I$(BITCLOUD_PATH)/Components/HAL/include \
+ -I$(BITCLOUD_PATH)/Components/BSP \
+ -I$(BITCLOUD_PATH)/Components/BSP/include \
+ -I$(BITCLOUD_PATH)/Components/NWK/include \
+ -I$(BITCLOUD_PATH)/Components/NWK/include/private \
+ -I$(BITCLOUD_PATH)/Components/ZDO/include \
+ -I$(BITCLOUD_PATH)/Components/ZDO/include/private \
+ -I$(BITCLOUD_PATH)/Components/APS/include \
+ -I$(BITCLOUD_PATH)/Components/APS/include/private \
+ -I$(BITCLOUD_PATH)/Components/SystemEnvironment/include \
+ -I$(BITCLOUD_PATH)/Components/ConfigServer/include \
+ -I$(BITCLOUD_PATH)/Components/ConfigServer/include/private \
+ -I$(BITCLOUD_PATH)/Components/PersistDataServer/include \
+ -I$(BITCLOUD_PATH)/Components/PersistDataServer/include/private \
+ -I$(BITCLOUD_PATH)/Components/Security/TrustCentre/include \
+ -I$(BITCLOUD_PATH)/Components/Security/ServiceProvider/include \
+ -I$(BITCLOUD_PATH)/Components/HAL/avr/atmega1281/common/include \
+ -I$(BITCLOUD_PATH)/Components/HAL/avr/atmega1281/zigBit/include \
+ -I$(BITCLOUD_PATH)/Components/MAC_PHY/include \
+ -I$(BITCLOUD_PATH)/Components/MAC_PHY/MAC_ENV/include \
+ -I$(BITCLOUD_PATH)/Components/MAC_PHY/MAC_HWI/include \
+ -I$(BITCLOUD_PATH)/Components/MAC_PHY/MAC_HWD_PHY/include \
+ -I$(BITCLOUD_PATH)/Components/MAC_PHY/MAC_HWD_PHY/RF230/PHY/include \
+ -I$(BITCLOUD_PATH)/Components/MAC_PHY/MAC_HWD_PHY/RF230/MAC_HWD/include \
+ -I$(APB_AVR_PATH) \
+ -I$(APB_AVR_PATH)/common \
+ -I$(APB_AVR_PATH)/modules/twi
+
+LIBS = \
+ $(BITCLOUD_PATH)/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc_Amp.a \
+ $(BITCLOUD_PATH)/lib/libBc_All_Atmega1281_Rf230_Gcc.a \
+ $(BITCLOUD_PATH)/lib/WdtInitatmega1281_Gcc.o
+
+SRCS = \
+ $(BITCLOUD_PATH)/Components/PersistDataServer/src/pdsWriteData.c \
+ $(BITCLOUD_PATH)/Components/PersistDataServer/src/pdsDataServer.c \
+ $(BITCLOUD_PATH)/Components/PersistDataServer/src/pdsCrcService.c \
+ $(BITCLOUD_PATH)/Components/BSP/MESHBEAN/src/fakeBSP.c \
+ $(BITCLOUD_PATH)/Components/BSP/MESHBEAN/src/bspTaskManager.c \
+ $(BITCLOUD_PATH)/Components/ConfigServer/src/csPersistentMem.c \
+ $(BITCLOUD_PATH)/Components/ConfigServer/src/csMem.c \
+ $(BITCLOUD_PATH)/Components/ConfigServer/src/configServer.c \
+ $(APB_AVR_PATH)/modules/twi/twi_hard.avr.c \
+ $(APB_AVR_PATH)/modules/twi/twi.c
+
+PREINCLUDE = MakerulesBc_All_Atmega1281_Rf230_Gcc.h
+
+SRCS += $(wildcard $(PROJECT_BASE)/*.c)
+SRCS += $(wildcard ./../../common/src/*.c)
+
+CSRCS = $(filter %.c, $(SRCS))
+OBJS = $(addprefix $(OBJ_PATH)/, $(notdir %/$(subst .c,.o,$(CSRCS))))
+
+ASM_FILE_EXT = s
+
+ifneq (, $(findstring .$(ASM_FILE_EXT), $(SRCS)))
+ ASRCS = $(filter %.$(ASM_FILE_EXT), $(SRCS))
+ OBJS += $(addprefix $(OBJ_PATH)/, $(notdir %$(subst .$(ASM_FILE_EXT),.o,$(ASRCS))))
+endif
+
+CFLAGS += $(DEFINES)
+CFLAGS += $(INCLUDES)
+CFLAGS += -include $(PREINCLUDE)
+CFLAGS += -g
+
+# APB sources need to be compiled without this option in order to manage correctly APB inline functions
+APB_CFLAGS := $(filter-out -std=gnu99,$(CFLAGS))
+
+ASFLAGS = $(INCLUDES)
+ASFLAGS += $(filter -mmcu%,$(CFLAGS))
+
+LD = $(CC)
+LINKER_FLAGS = -Wl,-Map=$(LIST_PATH)/$(APP_NAME).map -Wl,--gc-sections
+LINKER_FLAGS += -Wl,--script=$(PROJECT_BASE)/atmega1281.ld
+LINKER_FLAGS += $(filter -mmcu%,$(CFLAGS))
+LINKER_FLAGS += -Wl,-u,vfprintf -lprintf_flt -lm
+
+.PHONY: all directories clean size root_files
+
+all: directories $(EXE_PATH)/$(APP_NAME).elf $(EXE_PATH)/$(APP_NAME).hex $(EXE_PATH)/$(APP_NAME).srec $(EXE_PATH)/$(APP_NAME).bin root_files size
+
+$(OBJ_PATH)/%.o: $(SRCS)
+ $(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -o $@
+All_ZigBit_Atmega1281_Rf230_8Mhz_Gcc/Obj/twi_hard.avr.o: CFLAGS=$(APB_CFLAGS)
+
+
+$(EXE_PATH)/$(APP_NAME).elf: $(OBJS)
+ $(LD) $(LINKER_FLAGS) $(OBJS) -lm -Wl,-\( $(LIBS) -Wl,-\) -o $@
+
+$(EXE_PATH)/$(APP_NAME).srec: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O srec --srec-len 128 $^ $@
+
+$(EXE_PATH)/$(APP_NAME).hex: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O ihex -R .eeprom $^ $@
+
+$(EXE_PATH)/$(APP_NAME).bin: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O binary --strip-debug --strip-unneeded -R .eeprom $^ $@
+
+root_files:
+ cp -f $(EXE_PATH)/*.* $(PROJECT_BASE)/obj
+
+clean:
+ echo $(PROJECT_BASE)
+ rm -rf $(CONFIG_NAME) $(PROJECT_BASE)/obj/$(APP_NAME).elf $(PROJECT_BASE)/obj/$(APP_NAME).hex $(PROJECT_BASE)/obj/$(APP_NAME).srec $(PROJECT_BASE)/obj/$(APP_NAME).bin
+
+directories:
+ @mkdir -p $(LIST_PATH)
+ @mkdir -p $(EXE_PATH)
+ @mkdir -p $(OBJ_PATH)
+
+size: $(EXE_PATH)/$(APP_NAME).elf
+ @echo
+ @$(SIZE) -td $(EXE_PATH)/$(APP_NAME).elf
+
+# eof Makefile
diff --git a/digital/zigbit/bitcloud/makefiles/Makefile_Coordinator_Sec_ZigBit_Atmega1281_Rf230_8Mhz_Gcc b/digital/zigbit/bitcloud/makefiles/Makefile_Coordinator_Sec_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
new file mode 100644
index 00000000..b9583c1f
--- /dev/null
+++ b/digital/zigbit/bitcloud/makefiles/Makefile_Coordinator_Sec_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
@@ -0,0 +1,134 @@
+COMPONENTS_PATH = ./../../../../BitCloud/Components
+APP_NAME = Peer2Peer
+CONFIG_NAME = Coordinator_Sec_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
+LIST_PATH = $(CONFIG_NAME)/List
+EXE_PATH = $(CONFIG_NAME)/Exe
+OBJ_PATH = $(CONFIG_NAME)/Obj
+
+include ./../../../../BitCloud/lib/Makerules_Atmega1281_Gcc
+
+DEFINES = \
+ -DBOARD_MESHBEAN \
+ -DATMEGA1281 \
+ -DHAL_8MHz \
+ -DAT86RF230 \
+ -DSTANDARD_SECURITY_MODE \
+ -DSTACK_TYPE_COORDINATOR
+
+INCLUDES = \
+ -I./../.. \
+ -I./../../include \
+ -I./../../../../BitCloud/Components/BSP/MESHBEAN/include \
+ -I./../../../../BitCloud/lib \
+ -I./../../../../BitCloud/Components/HAL/include \
+ -I./../../../../BitCloud/Components/BSP \
+ -I./../../../../BitCloud/Components/BSP/include \
+ -I./../../../../BitCloud/Components/NWK/include \
+ -I./../../../../BitCloud/Components/NWK/include/private \
+ -I./../../../../BitCloud/Components/ZDO/include \
+ -I./../../../../BitCloud/Components/ZDO/include/private \
+ -I./../../../../BitCloud/Components/APS/include \
+ -I./../../../../BitCloud/Components/APS/include/private \
+ -I./../../../../BitCloud/Components/SystemEnvironment/include \
+ -I./../../../../BitCloud/Components/ConfigServer/include \
+ -I./../../../../BitCloud/Components/ConfigServer/include/private \
+ -I./../../../../BitCloud/Components/PersistDataServer/include \
+ -I./../../../../BitCloud/Components/PersistDataServer/include/private \
+ -I./../../../../BitCloud/Components/Security/TrustCentre/include \
+ -I./../../../../BitCloud/Components/Security/ServiceProvider/include \
+ -I./../../../../BitCloud/Components/HAL/avr/atmega1281/common/include \
+ -I./../../../../BitCloud/Components/HAL/avr/atmega1281/zigBit/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_ENV/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWI/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWD_PHY/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWD_PHY/RF230/PHY/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWD_PHY/RF230/MAC_HWD/include
+
+LIBS = \
+ ./../../../../BitCloud/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc.a \
+ ./../../../../BitCloud/lib/libBc_Coordinator_Sec_Atmega1281_Rf230_Gcc.a \
+ ./../../../../BitCloud/lib/WdtInitatmega1281_Gcc.o
+
+SRCS = \
+ ./../../../../BitCloud/Components/PersistDataServer/src/pdsWriteData.c \
+ ./../../../../BitCloud/Components/PersistDataServer/src/pdsDataServer.c \
+ ./../../../../BitCloud/Components/PersistDataServer/src/pdsCrcService.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/sensors.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/buttons.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/pwrCtrl.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/leds.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/battery.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/lm73.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/tsl2550.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/sliders.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/fakeBSP.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/bspTaskManager.c \
+ ./../../../../BitCloud/Components/ConfigServer/src/csPersistentMem.c \
+ ./../../../../BitCloud/Components/ConfigServer/src/csMem.c \
+ ./../../../../BitCloud/Components/ConfigServer/src/configServer.c
+
+PREINCLUDE = MakerulesBc_Coordinator_Sec_Atmega1281_Rf230_Gcc.h
+
+SRCS += $(wildcard ./../../src/*.c)
+SRCS += $(wildcard ./../../../common/src/*.c)
+
+CSRCS = $(filter %.c, $(SRCS))
+OBJS = $(addprefix $(OBJ_PATH)/, $(notdir %/$(subst .c,.o,$(CSRCS))))
+
+ASM_FILE_EXT = s
+
+ifneq (, $(findstring .$(ASM_FILE_EXT), $(SRCS)))
+ ASRCS = $(filter %.$(ASM_FILE_EXT), $(SRCS))
+ OBJS += $(addprefix $(OBJ_PATH)/, $(notdir %$(subst .$(ASM_FILE_EXT),.o,$(ASRCS))))
+endif
+
+CFLAGS += $(DEFINES)
+CFLAGS += $(INCLUDES)
+CFLAGS += -include $(PREINCLUDE)
+CFLAGS += -g
+
+ASFLAGS = $(INCLUDES)
+ASFLAGS += $(filter -mmcu%,$(CFLAGS))
+
+LD = $(CC)
+LINKER_FLAGS = -Wl,-Map=$(LIST_PATH)/$(APP_NAME).map -Wl,--gc-sections
+LINKER_FLAGS += -Wl,--script=./../../linkerScr/atmega1281.ld
+LINKER_FLAGS += $(filter -mmcu%,$(CFLAGS))
+
+.PHONY: all directories clean size root_files
+
+all: directories $(EXE_PATH)/$(APP_NAME).elf $(EXE_PATH)/$(APP_NAME).hex $(EXE_PATH)/$(APP_NAME).srec $(EXE_PATH)/$(APP_NAME).bin root_files size
+
+$(OBJ_PATH)/%.o: $(SRCS)
+ $(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -o $@
+
+
+$(EXE_PATH)/$(APP_NAME).elf: $(OBJS)
+ $(LD) $(LINKER_FLAGS) $(OBJS) -Wl,-\( $(LIBS) -Wl,-\) -o $@
+
+$(EXE_PATH)/$(APP_NAME).srec: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O srec --srec-len 128 $^ $@
+
+$(EXE_PATH)/$(APP_NAME).hex: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O ihex -R .eeprom $^ $@
+
+$(EXE_PATH)/$(APP_NAME).bin: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O binary --strip-debug --strip-unneeded -R .eeprom $^ $@
+
+root_files:
+ cp -f $(EXE_PATH)/*.* ./../../
+
+clean:
+ rm -rf $(CONFIG_NAME) ./../../$(APP_NAME).elf ./../../$(APP_NAME).hex ./../../$(APP_NAME).srec ./../../$(APP_NAME).bin
+
+directories:
+ @mkdir -p $(LIST_PATH)
+ @mkdir -p $(EXE_PATH)
+ @mkdir -p $(OBJ_PATH)
+
+size: $(EXE_PATH)/$(APP_NAME).elf
+ @echo
+ @$(SIZE) -td $(EXE_PATH)/$(APP_NAME).elf
+
+# eof Makefile
diff --git a/digital/zigbit/bitcloud/makefiles/Makefile_Coordinator_ZigBit_Atmega1281_Rf230_8Mhz_Gcc b/digital/zigbit/bitcloud/makefiles/Makefile_Coordinator_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
new file mode 100644
index 00000000..27fab6d3
--- /dev/null
+++ b/digital/zigbit/bitcloud/makefiles/Makefile_Coordinator_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
@@ -0,0 +1,134 @@
+COMPONENTS_PATH = ./../../../../BitCloud/Components
+APP_NAME = Peer2Peer
+CONFIG_NAME = Coordinator_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
+LIST_PATH = $(CONFIG_NAME)/List
+EXE_PATH = $(CONFIG_NAME)/Exe
+OBJ_PATH = $(CONFIG_NAME)/Obj
+
+include ./../../../../BitCloud/lib/Makerules_Atmega1281_Gcc
+
+DEFINES = \
+ -DBOARD_MESHBEAN \
+ -DATMEGA1281 \
+ -DHAL_8MHz \
+ -DAT86RF230 \
+ -DNO_SECURITY_MODE \
+ -DSTACK_TYPE_COORDINATOR
+
+INCLUDES = \
+ -I./../.. \
+ -I./../../include \
+ -I./../../../../BitCloud/Components/BSP/MESHBEAN/include \
+ -I./../../../../BitCloud/lib \
+ -I./../../../../BitCloud/Components/HAL/include \
+ -I./../../../../BitCloud/Components/BSP \
+ -I./../../../../BitCloud/Components/BSP/include \
+ -I./../../../../BitCloud/Components/NWK/include \
+ -I./../../../../BitCloud/Components/NWK/include/private \
+ -I./../../../../BitCloud/Components/ZDO/include \
+ -I./../../../../BitCloud/Components/ZDO/include/private \
+ -I./../../../../BitCloud/Components/APS/include \
+ -I./../../../../BitCloud/Components/APS/include/private \
+ -I./../../../../BitCloud/Components/SystemEnvironment/include \
+ -I./../../../../BitCloud/Components/ConfigServer/include \
+ -I./../../../../BitCloud/Components/ConfigServer/include/private \
+ -I./../../../../BitCloud/Components/PersistDataServer/include \
+ -I./../../../../BitCloud/Components/PersistDataServer/include/private \
+ -I./../../../../BitCloud/Components/Security/TrustCentre/include \
+ -I./../../../../BitCloud/Components/Security/ServiceProvider/include \
+ -I./../../../../BitCloud/Components/HAL/avr/atmega1281/common/include \
+ -I./../../../../BitCloud/Components/HAL/avr/atmega1281/zigBit/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_ENV/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWI/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWD_PHY/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWD_PHY/RF230/PHY/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWD_PHY/RF230/MAC_HWD/include
+
+LIBS = \
+ ./../../../../BitCloud/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc.a \
+ ./../../../../BitCloud/lib/libBc_Coordinator_Atmega1281_Rf230_Gcc.a \
+ ./../../../../BitCloud/lib/WdtInitatmega1281_Gcc.o
+
+SRCS = \
+ ./../../../../BitCloud/Components/PersistDataServer/src/pdsWriteData.c \
+ ./../../../../BitCloud/Components/PersistDataServer/src/pdsDataServer.c \
+ ./../../../../BitCloud/Components/PersistDataServer/src/pdsCrcService.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/sensors.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/buttons.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/pwrCtrl.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/leds.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/battery.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/lm73.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/tsl2550.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/sliders.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/fakeBSP.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/bspTaskManager.c \
+ ./../../../../BitCloud/Components/ConfigServer/src/csPersistentMem.c \
+ ./../../../../BitCloud/Components/ConfigServer/src/csMem.c \
+ ./../../../../BitCloud/Components/ConfigServer/src/configServer.c
+
+PREINCLUDE = MakerulesBc_Coordinator_Atmega1281_Rf230_Gcc.h
+
+SRCS += $(wildcard ./../../src/*.c)
+SRCS += $(wildcard ./../../../common/src/*.c)
+
+CSRCS = $(filter %.c, $(SRCS))
+OBJS = $(addprefix $(OBJ_PATH)/, $(notdir %/$(subst .c,.o,$(CSRCS))))
+
+ASM_FILE_EXT = s
+
+ifneq (, $(findstring .$(ASM_FILE_EXT), $(SRCS)))
+ ASRCS = $(filter %.$(ASM_FILE_EXT), $(SRCS))
+ OBJS += $(addprefix $(OBJ_PATH)/, $(notdir %$(subst .$(ASM_FILE_EXT),.o,$(ASRCS))))
+endif
+
+CFLAGS += $(DEFINES)
+CFLAGS += $(INCLUDES)
+CFLAGS += -include $(PREINCLUDE)
+CFLAGS += -g
+
+ASFLAGS = $(INCLUDES)
+ASFLAGS += $(filter -mmcu%,$(CFLAGS))
+
+LD = $(CC)
+LINKER_FLAGS = -Wl,-Map=$(LIST_PATH)/$(APP_NAME).map -Wl,--gc-sections
+LINKER_FLAGS += -Wl,--script=./../../linkerScr/atmega1281.ld
+LINKER_FLAGS += $(filter -mmcu%,$(CFLAGS))
+
+.PHONY: all directories clean size root_files
+
+all: directories $(EXE_PATH)/$(APP_NAME).elf $(EXE_PATH)/$(APP_NAME).hex $(EXE_PATH)/$(APP_NAME).srec $(EXE_PATH)/$(APP_NAME).bin root_files size
+
+$(OBJ_PATH)/%.o: $(SRCS)
+ $(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -o $@
+
+
+$(EXE_PATH)/$(APP_NAME).elf: $(OBJS)
+ $(LD) $(LINKER_FLAGS) $(OBJS) -Wl,-\( $(LIBS) -Wl,-\) -o $@
+
+$(EXE_PATH)/$(APP_NAME).srec: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O srec --srec-len 128 $^ $@
+
+$(EXE_PATH)/$(APP_NAME).hex: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O ihex -R .eeprom $^ $@
+
+$(EXE_PATH)/$(APP_NAME).bin: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O binary --strip-debug --strip-unneeded -R .eeprom $^ $@
+
+root_files:
+ cp -f $(EXE_PATH)/*.* ./../../
+
+clean:
+ rm -rf $(CONFIG_NAME) ./../../$(APP_NAME).elf ./../../$(APP_NAME).hex ./../../$(APP_NAME).srec ./../../$(APP_NAME).bin
+
+directories:
+ @mkdir -p $(LIST_PATH)
+ @mkdir -p $(EXE_PATH)
+ @mkdir -p $(OBJ_PATH)
+
+size: $(EXE_PATH)/$(APP_NAME).elf
+ @echo
+ @$(SIZE) -td $(EXE_PATH)/$(APP_NAME).elf
+
+# eof Makefile
diff --git a/digital/zigbit/bitcloud/makefiles/Makefile_Router_Sec_ZigBit_Atmega1281_Rf230_8Mhz_Gcc b/digital/zigbit/bitcloud/makefiles/Makefile_Router_Sec_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
new file mode 100644
index 00000000..4329e82d
--- /dev/null
+++ b/digital/zigbit/bitcloud/makefiles/Makefile_Router_Sec_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
@@ -0,0 +1,134 @@
+COMPONENTS_PATH = ./../../../../BitCloud/Components
+APP_NAME = Peer2Peer
+CONFIG_NAME = Router_Sec_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
+LIST_PATH = $(CONFIG_NAME)/List
+EXE_PATH = $(CONFIG_NAME)/Exe
+OBJ_PATH = $(CONFIG_NAME)/Obj
+
+include ./../../../../BitCloud/lib/Makerules_Atmega1281_Gcc
+
+DEFINES = \
+ -DBOARD_MESHBEAN \
+ -DATMEGA1281 \
+ -DHAL_8MHz \
+ -DAT86RF230 \
+ -DSTANDARD_SECURITY_MODE \
+ -DSTACK_TYPE_ROUTER
+
+INCLUDES = \
+ -I./../.. \
+ -I./../../include \
+ -I./../../../../BitCloud/Components/BSP/MESHBEAN/include \
+ -I./../../../../BitCloud/lib \
+ -I./../../../../BitCloud/Components/HAL/include \
+ -I./../../../../BitCloud/Components/BSP \
+ -I./../../../../BitCloud/Components/BSP/include \
+ -I./../../../../BitCloud/Components/NWK/include \
+ -I./../../../../BitCloud/Components/NWK/include/private \
+ -I./../../../../BitCloud/Components/ZDO/include \
+ -I./../../../../BitCloud/Components/ZDO/include/private \
+ -I./../../../../BitCloud/Components/APS/include \
+ -I./../../../../BitCloud/Components/APS/include/private \
+ -I./../../../../BitCloud/Components/SystemEnvironment/include \
+ -I./../../../../BitCloud/Components/ConfigServer/include \
+ -I./../../../../BitCloud/Components/ConfigServer/include/private \
+ -I./../../../../BitCloud/Components/PersistDataServer/include \
+ -I./../../../../BitCloud/Components/PersistDataServer/include/private \
+ -I./../../../../BitCloud/Components/Security/TrustCentre/include \
+ -I./../../../../BitCloud/Components/Security/ServiceProvider/include \
+ -I./../../../../BitCloud/Components/HAL/avr/atmega1281/common/include \
+ -I./../../../../BitCloud/Components/HAL/avr/atmega1281/zigBit/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_ENV/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWI/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWD_PHY/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWD_PHY/RF230/PHY/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWD_PHY/RF230/MAC_HWD/include
+
+LIBS = \
+ ./../../../../BitCloud/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc.a \
+ ./../../../../BitCloud/lib/libBc_Router_Sec_Atmega1281_Rf230_Gcc.a \
+ ./../../../../BitCloud/lib/WdtInitatmega1281_Gcc.o
+
+SRCS = \
+ ./../../../../BitCloud/Components/PersistDataServer/src/pdsWriteData.c \
+ ./../../../../BitCloud/Components/PersistDataServer/src/pdsDataServer.c \
+ ./../../../../BitCloud/Components/PersistDataServer/src/pdsCrcService.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/sensors.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/buttons.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/pwrCtrl.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/leds.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/battery.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/lm73.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/tsl2550.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/sliders.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/fakeBSP.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/bspTaskManager.c \
+ ./../../../../BitCloud/Components/ConfigServer/src/csPersistentMem.c \
+ ./../../../../BitCloud/Components/ConfigServer/src/csMem.c \
+ ./../../../../BitCloud/Components/ConfigServer/src/configServer.c
+
+PREINCLUDE = MakerulesBc_Router_Sec_Atmega1281_Rf230_Gcc.h
+
+SRCS += $(wildcard ./../../src/*.c)
+SRCS += $(wildcard ./../../../common/src/*.c)
+
+CSRCS = $(filter %.c, $(SRCS))
+OBJS = $(addprefix $(OBJ_PATH)/, $(notdir %/$(subst .c,.o,$(CSRCS))))
+
+ASM_FILE_EXT = s
+
+ifneq (, $(findstring .$(ASM_FILE_EXT), $(SRCS)))
+ ASRCS = $(filter %.$(ASM_FILE_EXT), $(SRCS))
+ OBJS += $(addprefix $(OBJ_PATH)/, $(notdir %$(subst .$(ASM_FILE_EXT),.o,$(ASRCS))))
+endif
+
+CFLAGS += $(DEFINES)
+CFLAGS += $(INCLUDES)
+CFLAGS += -include $(PREINCLUDE)
+CFLAGS += -g
+
+ASFLAGS = $(INCLUDES)
+ASFLAGS += $(filter -mmcu%,$(CFLAGS))
+
+LD = $(CC)
+LINKER_FLAGS = -Wl,-Map=$(LIST_PATH)/$(APP_NAME).map -Wl,--gc-sections
+LINKER_FLAGS += -Wl,--script=./../../linkerScr/atmega1281.ld
+LINKER_FLAGS += $(filter -mmcu%,$(CFLAGS))
+
+.PHONY: all directories clean size root_files
+
+all: directories $(EXE_PATH)/$(APP_NAME).elf $(EXE_PATH)/$(APP_NAME).hex $(EXE_PATH)/$(APP_NAME).srec $(EXE_PATH)/$(APP_NAME).bin root_files size
+
+$(OBJ_PATH)/%.o: $(SRCS)
+ $(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -o $@
+
+
+$(EXE_PATH)/$(APP_NAME).elf: $(OBJS)
+ $(LD) $(LINKER_FLAGS) $(OBJS) -Wl,-\( $(LIBS) -Wl,-\) -o $@
+
+$(EXE_PATH)/$(APP_NAME).srec: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O srec --srec-len 128 $^ $@
+
+$(EXE_PATH)/$(APP_NAME).hex: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O ihex -R .eeprom $^ $@
+
+$(EXE_PATH)/$(APP_NAME).bin: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O binary --strip-debug --strip-unneeded -R .eeprom $^ $@
+
+root_files:
+ cp -f $(EXE_PATH)/*.* ./../../
+
+clean:
+ rm -rf $(CONFIG_NAME) ./../../$(APP_NAME).elf ./../../$(APP_NAME).hex ./../../$(APP_NAME).srec ./../../$(APP_NAME).bin
+
+directories:
+ @mkdir -p $(LIST_PATH)
+ @mkdir -p $(EXE_PATH)
+ @mkdir -p $(OBJ_PATH)
+
+size: $(EXE_PATH)/$(APP_NAME).elf
+ @echo
+ @$(SIZE) -td $(EXE_PATH)/$(APP_NAME).elf
+
+# eof Makefile
diff --git a/digital/zigbit/bitcloud/makefiles/Makefile_Router_ZigBit_Atmega1281_Rf230_8Mhz_Gcc b/digital/zigbit/bitcloud/makefiles/Makefile_Router_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
new file mode 100644
index 00000000..69df3d37
--- /dev/null
+++ b/digital/zigbit/bitcloud/makefiles/Makefile_Router_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
@@ -0,0 +1,134 @@
+COMPONENTS_PATH = ./../../../../BitCloud/Components
+APP_NAME = Peer2Peer
+CONFIG_NAME = Router_ZigBit_Atmega1281_Rf230_8Mhz_Gcc
+LIST_PATH = $(CONFIG_NAME)/List
+EXE_PATH = $(CONFIG_NAME)/Exe
+OBJ_PATH = $(CONFIG_NAME)/Obj
+
+include ./../../../../BitCloud/lib/Makerules_Atmega1281_Gcc
+
+DEFINES = \
+ -DBOARD_MESHBEAN \
+ -DATMEGA1281 \
+ -DHAL_8MHz \
+ -DAT86RF230 \
+ -DNO_SECURITY_MODE \
+ -DSTACK_TYPE_ROUTER
+
+INCLUDES = \
+ -I./../.. \
+ -I./../../include \
+ -I./../../../../BitCloud/Components/BSP/MESHBEAN/include \
+ -I./../../../../BitCloud/lib \
+ -I./../../../../BitCloud/Components/HAL/include \
+ -I./../../../../BitCloud/Components/BSP \
+ -I./../../../../BitCloud/Components/BSP/include \
+ -I./../../../../BitCloud/Components/NWK/include \
+ -I./../../../../BitCloud/Components/NWK/include/private \
+ -I./../../../../BitCloud/Components/ZDO/include \
+ -I./../../../../BitCloud/Components/ZDO/include/private \
+ -I./../../../../BitCloud/Components/APS/include \
+ -I./../../../../BitCloud/Components/APS/include/private \
+ -I./../../../../BitCloud/Components/SystemEnvironment/include \
+ -I./../../../../BitCloud/Components/ConfigServer/include \
+ -I./../../../../BitCloud/Components/ConfigServer/include/private \
+ -I./../../../../BitCloud/Components/PersistDataServer/include \
+ -I./../../../../BitCloud/Components/PersistDataServer/include/private \
+ -I./../../../../BitCloud/Components/Security/TrustCentre/include \
+ -I./../../../../BitCloud/Components/Security/ServiceProvider/include \
+ -I./../../../../BitCloud/Components/HAL/avr/atmega1281/common/include \
+ -I./../../../../BitCloud/Components/HAL/avr/atmega1281/zigBit/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_ENV/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWI/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWD_PHY/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWD_PHY/RF230/PHY/include \
+ -I./../../../../BitCloud/Components/MAC_PHY/MAC_HWD_PHY/RF230/MAC_HWD/include
+
+LIBS = \
+ ./../../../../BitCloud/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc.a \
+ ./../../../../BitCloud/lib/libBc_Router_Atmega1281_Rf230_Gcc.a \
+ ./../../../../BitCloud/lib/WdtInitatmega1281_Gcc.o
+
+SRCS = \
+ ./../../../../BitCloud/Components/PersistDataServer/src/pdsWriteData.c \
+ ./../../../../BitCloud/Components/PersistDataServer/src/pdsDataServer.c \
+ ./../../../../BitCloud/Components/PersistDataServer/src/pdsCrcService.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/sensors.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/buttons.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/pwrCtrl.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/leds.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/battery.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/lm73.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/tsl2550.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/sliders.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/fakeBSP.c \
+ ./../../../../BitCloud/Components/BSP/MESHBEAN/src/bspTaskManager.c \
+ ./../../../../BitCloud/Components/ConfigServer/src/csPersistentMem.c \
+ ./../../../../BitCloud/Components/ConfigServer/src/csMem.c \
+ ./../../../../BitCloud/Components/ConfigServer/src/configServer.c
+
+PREINCLUDE = MakerulesBc_Router_Atmega1281_Rf230_Gcc.h
+
+SRCS += $(wildcard ./../../src/*.c)
+SRCS += $(wildcard ./../../../common/src/*.c)
+
+CSRCS = $(filter %.c, $(SRCS))
+OBJS = $(addprefix $(OBJ_PATH)/, $(notdir %/$(subst .c,.o,$(CSRCS))))
+
+ASM_FILE_EXT = s
+
+ifneq (, $(findstring .$(ASM_FILE_EXT), $(SRCS)))
+ ASRCS = $(filter %.$(ASM_FILE_EXT), $(SRCS))
+ OBJS += $(addprefix $(OBJ_PATH)/, $(notdir %$(subst .$(ASM_FILE_EXT),.o,$(ASRCS))))
+endif
+
+CFLAGS += $(DEFINES)
+CFLAGS += $(INCLUDES)
+CFLAGS += -include $(PREINCLUDE)
+CFLAGS += -g
+
+ASFLAGS = $(INCLUDES)
+ASFLAGS += $(filter -mmcu%,$(CFLAGS))
+
+LD = $(CC)
+LINKER_FLAGS = -Wl,-Map=$(LIST_PATH)/$(APP_NAME).map -Wl,--gc-sections
+LINKER_FLAGS += -Wl,--script=./../../linkerScr/atmega1281.ld
+LINKER_FLAGS += $(filter -mmcu%,$(CFLAGS))
+
+.PHONY: all directories clean size root_files
+
+all: directories $(EXE_PATH)/$(APP_NAME).elf $(EXE_PATH)/$(APP_NAME).hex $(EXE_PATH)/$(APP_NAME).srec $(EXE_PATH)/$(APP_NAME).bin root_files size
+
+$(OBJ_PATH)/%.o: $(SRCS)
+ $(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -o $@
+
+
+$(EXE_PATH)/$(APP_NAME).elf: $(OBJS)
+ $(LD) $(LINKER_FLAGS) $(OBJS) -Wl,-\( $(LIBS) -Wl,-\) -o $@
+
+$(EXE_PATH)/$(APP_NAME).srec: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O srec --srec-len 128 $^ $@
+
+$(EXE_PATH)/$(APP_NAME).hex: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O ihex -R .eeprom $^ $@
+
+$(EXE_PATH)/$(APP_NAME).bin: $(EXE_PATH)/$(APP_NAME).elf
+ $(OBJCOPY) -O binary --strip-debug --strip-unneeded -R .eeprom $^ $@
+
+root_files:
+ cp -f $(EXE_PATH)/*.* ./../../
+
+clean:
+ rm -rf $(CONFIG_NAME) ./../../$(APP_NAME).elf ./../../$(APP_NAME).hex ./../../$(APP_NAME).srec ./../../$(APP_NAME).bin
+
+directories:
+ @mkdir -p $(LIST_PATH)
+ @mkdir -p $(EXE_PATH)
+ @mkdir -p $(OBJ_PATH)
+
+size: $(EXE_PATH)/$(APP_NAME).elf
+ @echo
+ @$(SIZE) -td $(EXE_PATH)/$(APP_NAME).elf
+
+# eof Makefile
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/aps.h b/digital/zigbit/bitcloud/stack/Components/APS/include/aps.h
new file mode 100644
index 00000000..a9933759
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/aps.h
@@ -0,0 +1,196 @@
+/**************************************************************************//**
+ \file aps.h
+
+ \brief Interface of APS layer.
+
+ \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:
+ 2010-10-20 Max Gekk - Created.
+ Last change:
+ $Id: aps.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _APS_H
+#define _APS_H
+/**//**
+ * \page Endian
+ * \note \b |LE| - parameter in little endian format.
+ *
+ * Use macroes CPU_TO_LE* and CCPU_TO_LE* from bcEndian.h to convert from
+ * CPU-endian to little-endian format.
+ **/
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsCommon.h>
+#include <apsdeEndpoint.h>
+#include <apsdeData.h>
+#include <apsmeGroup.h>
+#include <apsmeBind.h>
+#include <apsAIB.h>
+#include <apsCryptoKeys.h>
+#include <apsmeAuthenticate.h>
+#include <apsmeEstablishKey.h>
+#include <apsmeRemoveDevice.h>
+#include <apsmeRequestKey.h>
+#include <apsmeSwitchKey.h>
+#include <apsmeTransportKey.h>
+#include <apsmeUpdateDevice.h>
+#include <apsTcSwapOut.h>
+#include <intrpData.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** External events identifiers. */
+typedef enum
+{
+ APS_EVENT_RESET_ID = 0x19,
+ APS_EVENT_START_ID = 0x8a,
+ APS_EVENT_STOP_ID = 0xc5
+} APS_EventId_t;
+
+/** Type of external APS event. */
+typedef struct
+{
+ void *next; /*!< Used for queue support. */
+ APS_EventId_t id; /*!< Identifier of APS event. */
+} APS_Event_t;
+
+/** Confirmation parameters of APS Reset. */
+typedef struct
+{
+ APS_Status_t status;
+} APS_ResetConf_t;
+
+/** Type of APS Reset parameters structure. */
+typedef struct
+{
+ /** \cond SERVICE_FIELDS **/
+ struct
+ {
+ APS_Event_t event;
+ /** NLME-RESET request primitive's parameters structure. */
+ NWK_ResetReq_t nwkResetReq;
+ } service;
+ /** \endcond **/
+
+ NWK_PowerFailureControl_t powerFailureControl; /*!< To restore or not the saved parameters? */
+ /** This field shall contain the device capability information.
+ * See ZigBee spec r18, Table 3.44, page 345. */
+ MAC_CapabilityInf_t capabilityInformation;
+ /** APS reset confirm callback function's pointer. */
+ void (*APS_ResetConf)(APS_ResetConf_t *conf);
+ APS_ResetConf_t confirm; /*!< Parameters are passed to callback function. */
+} APS_ResetReq_t;
+
+/** Type of startup confirmation parameters. */
+typedef struct
+{
+ APS_Status_t status; /*!< Status code of APS startup. */
+} APS_StartConf_t;
+
+/** Parameters of APS start procedure. */
+typedef struct
+{
+ /** \cond SERVICE_FIELDS **/
+ struct
+ {
+ APS_Event_t event;
+ } service;
+ /** \endcond **/
+
+ /** APS startup callback function. */
+ void (*APS_StartConf)(APS_StartConf_t *conf);
+ APS_StartConf_t confirm; /*!< APS startup confirmation parameters. */
+} APS_StartReq_t;
+
+/** Type of APS stoping confirmation parameters. */
+typedef struct
+{
+ APS_Status_t status; /*!< Status code of APS stoping. */
+} APS_StopConf_t;
+
+/** Parameters of APS stoping primitive. */
+typedef struct
+{
+ /** \cond SERVICE_FIELDS **/
+ struct
+ {
+ APS_Event_t event;
+ uint16_t waitMask; /*! Bit map of stopping components. */
+ } service;
+ /** \endcond **/
+
+ /** Callback and APS stoping confirmation function. */
+ void (*APS_StopConf)(APS_StopConf_t *conf);
+ APS_StopConf_t confirm;
+} APS_StopReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Initialization internal state and main variables of APS-layer.
+
+ The function can be called only by ZDO.
+ It must be called before any operation with APS.
+
+ \return None.
+ ******************************************************************************/
+void APS_Init(void);
+
+/**************************************************************************//**
+ \brief Resets APS to default state.
+
+ The function can be called only by ZDO and only after APS_Init().
+
+ \param[in] req - pointer to reset parameters.
+ \return None.
+ *****************************************************************************/
+void APS_ResetReq(APS_ResetReq_t *const req);
+
+/**************************************************************************//**
+ \brief Makes APS allow processing of incoming packets.
+
+ After this function is called, APS is ready to process incoming packets.
+
+ \param[in] req - pointer to startup parameters.
+ \return None.
+ ******************************************************************************/
+void APS_StartReq(APS_StartReq_t *const req);
+
+/**************************************************************************//**
+ \brief Makes APS disallow processing of incoming packets.
+
+ After this function is called, APS does not process incoming packets.
+
+ \param[in] req - pointer to stopping parameters.
+ \return None.
+ ******************************************************************************/
+void APS_StopReq(APS_StopReq_t *const req);
+
+/**************************************************************************//**
+ \brief Check if APS is started.
+
+ \return 'true' if APS is started otherwise return 'false'
+ ******************************************************************************/
+bool APS_IsStarted(void);
+
+/**************************************************************************//**
+ \brief Check if there are any active requests in progress.
+
+ \return 'true' if there are any active requests in progress otherwise - 'false'
+ ******************************************************************************/
+bool APS_IsActiveTransaction(void);
+
+#endif /* _APS_H */
+/** eof aps.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/apsAIB.h b/digital/zigbit/bitcloud/stack/Components/APS/include/apsAIB.h
new file mode 100644
index 00000000..428c254d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/apsAIB.h
@@ -0,0 +1,177 @@
+/**************************************************************************//**
+ \file apsAIB.h
+
+ \brief Interface of APS information base.
+
+ \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:
+ 2010-10-19 Max Gekk - Created.
+ Last change:
+ $Id: apsAIB.h 18613 2011-09-20 13:15:05Z mgekk $
+ ******************************************************************************/
+/**//**
+ *
+ * The APS information base comprises the attributes required to manage the APS
+ * layer of a device. The attributes of the AIB are listed in ZigBee spec r19,
+ * Table 2.24, page 61. The securityrelated AIB attributes are described in
+ * sub-clause 4.4.10, page 489.
+ **/
+#if !defined _APS_AIB_H
+#define _APS_AIB_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwk.h>
+#include <configServer.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+#define APS_AIB_NONMEMBER_RADIUS_DEFAULT_VALUE 2
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \struct AIB_t apsAIB.h "aps.h"
+ *
+ * \brief Attributes in APS Information Base.
+ **/
+typedef struct
+{
+ /** The value to be used for the NonmemberRadius parameter when using
+ * NWK layer multicast. Valid range: 0 - 7, default value - 2. */
+ NwkRadius_t nonMemberRadius;
+#if defined _SECURITY_
+ /** \ref Endian "[LE]" Identifies the address of the device's Trust Center. */
+ ExtAddr_t trustCenterAddress;
+#endif /* _SECURITY_ */
+#ifdef _APS_FRAGMENTATION_
+ uint8_t fragWindowSize;
+#ifdef _CERTIFICATION_
+ uint8_t fragDropMask;
+#endif /* _CERTIFICATION_ */
+#endif /* _APS_FRAGMENTATION_ */
+} AIB_t;
+
+/**//**
+ * \struct APS_TcMode_t apsAIB.h "aps.h"
+ *
+ * \brief Mode indicate role of this device in the network as trust center.
+ **/
+typedef enum _APS_TcMode_t
+{
+ APS_NOT_TRUST_CENTER,
+ APS_CENTRALIZED_TRUST_CENTER,
+ /** Mode whereby routers in a ZigBee Pro network can each act like a trust
+ * center so that there is no need for a single centralized device. */
+ APS_DISTRIBUTED_TRUST_CENTER
+} APS_TcMode_t;
+
+/******************************************************************************
+ Global variables section
+ ******************************************************************************/
+extern AIB_t csAIB; /*!< APS Information Base */
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _SECURITY_
+/**************************************************************************//**
+ \brief Check whether supplied address is a Trust Center address
+
+ \param[in] addr - pointer to required address
+
+ \return true, if required address is TC address, false - otherwise
+******************************************************************************/
+INLINE bool APS_IsTcAddress(const ExtAddr_t *addr)
+{
+ return IS_EQ_EXT_ADDR(*addr, csAIB.trustCenterAddress);
+}
+
+/**************************************************************************//**
+ \brief Get pointer to Trust Center address
+
+ \return pointer to Trust Center extended address
+******************************************************************************/
+INLINE ExtAddr_t* APS_GetTrustCenterAddress(void)
+{
+ return &csAIB.trustCenterAddress;
+}
+
+/**************************************************************************//**
+ \brief Set Trust Center address
+
+ \param[in] addr - pointer to address to set
+
+ \return none
+******************************************************************************/
+INLINE void APS_SetTrustCenterAddress(const ExtAddr_t *addr)
+{
+ memcpy(&csAIB.trustCenterAddress, addr, sizeof(ExtAddr_t));
+}
+
+/**************************************************************************//**
+ \brief Gets the trust center mode of the current device.
+
+ \return Status of the device as Trust Center:
+ \li APS_NOT_TRUST_CENTER - this deive is not trust center,
+ \li APS_CENTRALIZED_TRUST_CENTER - single trust center in the network,
+ \li APS_DISTRIBUTED_TRUST_CENTER - each routers can be trust center.
+******************************************************************************/
+INLINE APS_TcMode_t APS_GetOwnTcMode(void)
+{
+#if defined _DISTRIBUTED_TRUST_CENTER_
+ if (APS_DISTRIBUTED_TC_ADDRESS == csAIB.trustCenterAddress)
+ return APS_DISTRIBUTED_TRUST_CENTER;
+#endif /* _DISTRIBUTED_TRUST_CENTER_ */
+
+ if (IS_EQ_EXT_ADDR(*MAC_GetExtAddr(), csAIB.trustCenterAddress))
+ return APS_CENTRALIZED_TRUST_CENTER;
+ else
+ return APS_NOT_TRUST_CENTER;
+}
+
+/**************************************************************************//**
+ \brief Check whether this node is the Trust Center or not.
+
+ \return true, if this node is the Distributed or Centralized Trust Center,
+ otherwise return false.
+******************************************************************************/
+INLINE bool APS_IsTrustCenter(void)
+{
+ return APS_NOT_TRUST_CENTER != APS_GetOwnTcMode();
+}
+
+/**************************************************************************//**
+ \brief Check whether given address is trusted address.
+
+ \param[in] addr - pointer to required address
+
+ \return true, if argument is the address of the centralized Trust Center
+ or we are in distributed TC mode,
+ otherwise return false.
+******************************************************************************/
+INLINE bool APS_IsTrustedAddress(const ExtAddr_t *addr)
+{
+#if defined _DISTRIBUTED_TRUST_CENTER_
+ if (APS_DISTRIBUTED_TC_ADDRESS == csAIB.trustCenterAddress)
+ return true;
+#endif /* _DISTRIBUTED_TRUST_CENTER_ */
+
+ return IS_EQ_EXT_ADDR(*addr, csAIB.trustCenterAddress);
+}
+
+#endif /* _SECURITY_ */
+
+#endif /* _APS_AIB_H */
+/** eof apsAIB.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/apsCommon.h b/digital/zigbit/bitcloud/stack/Components/APS/include/apsCommon.h
new file mode 100644
index 00000000..49164477
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/apsCommon.h
@@ -0,0 +1,412 @@
+/**************************************************************************//**
+ \file apsCommon.h
+
+ \brief Declarations of common APS layer's constants and types.
+
+ \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:
+ 2010-07-21 Max Gekk - Created.
+ 2010-10-18 Max Gekk - MAC and NWK status values are added.
+ Last change:
+ $Id: apsCommon.h 18682 2011-09-28 12:59:47Z mgekk $
+ ******************************************************************************/
+#if !defined _APS_COMMON_H
+#define _APS_COMMON_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+#include <nwk.h>
+#include <macAddr.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+
+#ifndef _LINK_SECURITY_
+/** Max APS header size. */
+#define APS_MAX_DATA_FRAME_HEADER_LENGTH 12U
+
+/** Max APS footer size. */
+#define APS_MAX_DATA_FRAME_FOOTER_LENGTH 0U
+#else /* _LINK_SECURITY_ */
+
+
+/**//**
+ * \brief APS auxiliary header size.
+ *
+ * See ZigBee spec. r18, 4.5.1.1, Security Control Field.
+ **/
+#define APS_AUXILIARY_HEADER_LENGTH (6U + 8U)
+
+/** Max APS header size. */
+#define APS_MAX_DATA_FRAME_HEADER_LENGTH (12U + APS_AUXILIARY_HEADER_LENGTH)
+
+/** Max APS footer size: 4 bytes - Message Integrity Code (MIC) */
+#define APS_MAX_DATA_FRAME_FOOTER_LENGTH 4U
+
+/** Universal extended address. */
+#ifdef _UNIVERSAL_EXTENDED_ADDRESS_
+ #define APS_UNIVERSAL_EXTENDED_ADDRESS 0xFFFFFFFFFFFFFFFBULL
+#endif /* _UNIVERSAL_EXTENDED_ADDRESS_ */
+
+#endif /* _LINK_SECURITY_ */
+
+
+/** Max size of APS payload. */
+#define APS_MAX_ASDU_SIZE \
+ (NWK_MAX_NSDU_SIZE - APS_MAX_DATA_FRAME_HEADER_LENGTH - APS_MAX_DATA_FRAME_FOOTER_LENGTH)
+
+/** Size of the reserved header in the data frame */
+#define APS_ASDU_OFFSET \
+ (NWK_NSDU_OFFSET + APS_MAX_DATA_FRAME_HEADER_LENGTH)
+
+/** Size of the reserved part in the data frame. */
+#define APS_AFFIX_LENGTH \
+ (NWK_AFFIX_LENGTH + APS_MAX_DATA_FRAME_HEADER_LENGTH + APS_MAX_DATA_FRAME_FOOTER_LENGTH)
+
+/** APS Broadcast Endpoint. */
+#define APS_BROADCAST_ENDPOINT 0xff
+
+/** Minimum value of user endpoint number. */
+#define APS_MIN_USER_ENDPOINT 0x01
+
+/** Maximum value of user endpoint number */
+#define APS_MAX_USER_ENDPOINT 0xf0
+
+/** ZDO Endpoint */
+#define APS_ZDO_ENDPOINT 0x00
+
+/** Reserved endpoints */
+#define APS_MIN_RESERVED_ENDPOINT 0xf1
+#define APS_MAX_RESERVED_ENDPOINT 0xfe
+
+/** APS short address defines */
+#define APS_MAX_UNICAST_SHORT_ADDRESS 0xfff7
+
+#define APS_SM_INVALID_FRAME_COUNTER_VALUE (0xffffffffUL)
+
+#define APS_SM_BROADCAST_EXT_ADDRESS 0xffffffffffffffffULL
+#define APS_SM_BROADCAST_ALL_EXT_ADDRESS 0xffffffffffffffffULL
+#define APS_SM_BROADCAST_RX_ON_WHEN_IDLE_EXT_ADDRESS 0xfffffffffffffffdULL
+#define APS_SM_BROADCAST_ALL_ROUTERS_EXT_ADDRESS 0xfffffffffffffffcULL
+#define APS_SM_BROADCAST_LOW_POWER_ROUTERS_EXT_ADDRESS 0xfffffffffffffffbULL
+#define APS_SM_UNIVERSAL_TRUST_CENTER_EXT_ADDRESS 0xfffffffffffffffaULL /*!< Universal trust center address*/
+#define APS_LAST_UNICAST_ADDRESS 0xfffffffffffffff9ULL
+#define APS_SM_INVALID_EXT_ADDRESS 0x0000000000000000ULL
+
+/* Special value of apsTrustCenterAddress indicates distrubuted trust center mode. */
+#define APS_DISTRIBUTED_TC_ADDRESS APS_SM_BROADCAST_EXT_ADDRESS
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \struct APS_Address_t apsCommon.h "aps.h"
+ *
+ * \brief Common APS Address type.
+ *
+ * Used as the part of standard APS primitives
+ **/
+typedef struct
+{
+ union
+ {
+ ShortAddr_t shortAddress; /*!< 16-bit network address */
+#ifdef _APS_MULTICAST_
+ GroupAddr_t groupAddress; /*!< 16-bit group (multicast) address */
+#endif
+ };
+ ExtAddr_t extAddress; /*!< 64-bit extended IEEE address */
+} APS_Address_t;
+
+/**//**
+ * \brief APS addressing modes.
+ *
+ * Defines APS addressing modes used in some standard primitives.
+ **/
+typedef enum
+{
+ /** Indirect addressing mode via binding future. */
+ APS_NO_ADDRESS = 0x00,
+ /** Group addressing mode via multicast. */
+ APS_GROUP_ADDRESS = 0x01,
+ /** Unicast addressing mode by 16-bit network address. */
+ APS_SHORT_ADDRESS = 0x02,
+ /** Unicast addressing mode by 64-bit IEEE address. */
+ APS_EXT_ADDRESS = 0x03
+} APS_AddrMode_t;
+
+/***//**
+ * \brief APS status values.
+ *
+ * APS status values used in the most part of standard primives except for
+ * the security service primitives where APS_SecurityStatus_t is used instead.
+ **/
+typedef enum
+{
+ /** A request has been executed successfully. */
+ APS_SUCCESS_STATUS = 0x00,
+ /** IEEE 802.15.4-2006, Table 83. */
+ /** Valid values of the Association Status field. */
+ APS_MAC_PAN_AT_CAPACITY_STATUS = 0x01,
+ APS_MAC_PAN_ACCESS_DENIED_STATUS = 0x02,
+ /** A transmit request failed since the ASDU is too large and fragmentation
+ * is not supported. */
+ APS_ASDU_TOO_LONG_STATUS = 0xa0,
+ /** A received fragmented frame could not be defragmented
+ * at the current time. */
+ APS_DEFRAG_DEFERRED_STATUS = 0xa1,
+ /** A received fragmented frame could not be defragmented since the device
+ * does not support fragmentation. */
+ APS_DEFRAG_UNSUPPORTED_STATUS = 0xa2,
+ /** A parameter value was out of range. */
+ APS_ILLEGAL_REQUEST_STATUS = 0xa3,
+ /** An APSME-UNBIND.request failed due to the requested binding link not
+ * existing in the binding table. */
+ APS_INVALID_BINDING_STATUS = 0xa4,
+ /** An APSME-REMOVE-GROUP.request has been issued with a group identifier
+ * that does not appear in the group table. */
+ APS_INVALID_GROUP_STATUS = 0xa5,
+ /** A parameter value was invalid or out of range. */
+ APS_INVALID_PARAMETER_STATUS = 0xa6,
+ /** An APSDE-DATA.request requesting acknowledged transmission failed due
+ * to no acknowledgement being received. */
+ APS_NO_ACK_STATUS = 0xa7,
+ /** An APSDE-DATA.request with a destination addressing mode set to 0x00
+ * failed due to there being no devices bound to this device. */
+ APS_NO_BOUND_DEVICE_STATUS = 0xa8,
+ /** An APSDE-DATA.request with a destination addressing mode
+ * set to 0x03 failed due to no corresponding short address found
+ * in the address map table. */
+ APS_NO_SHORT_ADDRESS_STATUS = 0xa9,
+ /** An APSDE-DATA.request with a destination addressing mode set to 0x00
+ * failed due to a binding table not being supported on the device. */
+ APS_NOT_SUPPORTED_STATUS = 0xaa,
+ /** An ASDU was received that was secured using a link key. */
+ APS_SECURED_LINK_KEY_STATUS = 0xab,
+ /** An ASDU was received that was secured using a network key. */
+ APS_SECURED_NWK_KEY_STATUS = 0xac,
+ /** An APSDE-DATA.request requesting security has resulted in an error
+ * during the corresponding security processing. */
+ APS_SECURITY_FAIL_STATUS = 0xad,
+ /** An APSME-BIND.request or APSME.ADDGROUP.request issued when the binding
+ * or group tables, respectively, were full. */
+ APS_TABLE_FULL_STATUS = 0xae,
+ /** An ASDU was received without any security. */
+ APS_UNSECURED_STATUS = 0xaf,
+ /** An APSME-GET.request or APSMESET.request has been issued with an
+ * unknown attribute identifier. */
+ APS_UNSUPPORTED_ATTRIBUTE_STATUS = 0xb0,
+ /** An ASDU was received that was secured using the trust center link key. */
+ APS_SECURED_TRUST_CENTER_LINK_KEY_STATUS = 0xb1,
+ /** An ASDU was received that was secured using
+ * hash ofthe trust center link key. */
+ APS_SECURED_HASH_OF_TRUST_CENTER_LINK_KEY_STATUS = 0xb2,
+ /** An invalid or out-of-range parameter has been passed to a primitive from
+ * the next higher layer. */
+ APS_NWK_INVALID_PARAMETERS_STATUS = 0xC1,
+ /** The next higher layer has issued a request that is invalid or cannot be
+ * executed given the current state of the NWK layer. */
+ APS_NWK_INVALID_REQUEST_STATUS = 0xC2,
+ /** An NLME-JOIN.request has been disallowed. */
+ APS_NWK_NOT_PERMITTED_STATUS = 0xC3,
+ /** An NLME-NETWORK-FORMATION.request has failed to start a network. */
+ APS_NWK_STARTUP_FAILURE_STATUS = 0xC4,
+ /** A device with the address supplied to the NLMEDIRECT-JOIN.request is
+ * already present in the neighbor table of the device on which
+ * the NLME-DIRECT-JOIN.request was issued. */
+ APS_NWK_ALREADY_PRESENT_STATUS = 0xC5,
+ /** Used to indicate that an NLME-SYNC.request has failed at the MAC layer. */
+ APS_NWK_SYNC_FAILURE_STATUS = 0xC6,
+ /** An NLME-JOIN-DIRECTLY.request has failed because there is no more room in
+ * the neighbor table. */
+ APS_NWK_NEIGHBOR_TABLE_FULL_STATUS = 0xC7,
+ /** An NLME-LEAVE.request has failed because the device addressed in
+ * the parameter list is not in the neighbor table of the issuing device. */
+ APS_NWK_UNKNOWN_DEVICE_STATUS = 0xC8,
+ /** An NLME-GET.request or NLME-SET.request has been issued with
+ * an unknown attribute identifier. */
+ APS_NWK_UNSUPPORTED_ATTRIBUTE_STATUS = 0xC9,
+ /** An NLME-JOIN.request has been issued in an environment
+ * where no networks are detectable. */
+ APS_NWK_NO_NETWORKS_STATUS = 0xCA,
+ /** Security processing has been attempted on an outgoing frame,
+ * and has failed because the frame counter has reached its maximum value. */
+ APS_NWK_MAX_FRM_COUNTER_STATUS = 0xCC,
+ /** Security processing has been attempted on an outgoing frame,
+ * and has failed because no key was available with which to process it. */
+ APS_NWK_NO_KEY_STATUS = 0xCD,
+ /** Security processing has been attempted on an outgoing frame,
+ * and has failed because the security engine produced erroneous output. */
+ APS_NWK_BAD_CCM_OUTPUT_STATUS = 0xCE,
+ /** An attempt to discover a route has failed due to a lack of routing table
+ * or discovery table capacity. */
+ APS_NWK_NO_ROUTING_CAPACITY_STATUS = 0xCF,
+ /** An attempt to discover a route has failed due to a reason other
+ * than a lack of routing capacity. */
+ APS_NWK_ROUTE_DISCOVERY_FAILED_STATUS = 0xD0,
+ /** An NLDE-DATA.request has failed due to a routing
+ * failure on the sending device. */
+ APS_NWK_ROUTE_ERROR_STATUS = 0xD1,
+ /** An attempt to send a broadcast frame or member mode multicast has failed
+ * due to the fact that there is no room in the BTT. */
+ APS_NWK_BT_TABLE_FULL_STATUS = 0xD2,
+ /** An NLDE-DATA.request has failed due to insufficient buffering available.
+ **/
+ APS_NWK_FRAME_NOT_BUFFERED_STATUS = 0xD3,
+ /** IEEE 802.15.4-2006, Table 78 MAC enumerations description. */
+ /** The frame counter purportedly applied by the originator of the
+ * received frame is invalid. */
+ APS_MAC_COUNTER_ERROR_STATUS = 0xDB,
+ /** The key purportedly applied by the originator of the received frame is
+ * not allowed to be used with that frame type according to the key usage
+ * policy of the recipient. */
+ APS_MAC_IMPROPER_KEY_TYPE_STATUS = 0xDC,
+ /** The security level purportedly applied by the originator of the received
+ * frame does not meet the minimum security level required/expected by
+ * the recipient for that frame type. */
+ APS_MAC_IMPROPER_SECURITY_LEVEL_STATUS = 0xDD,
+ /** The received frame was purportedly secured using security based on
+ * IEEE Std 802.15.4-2003, and such security is not supported by this standard.
+ **/
+ APS_MAC_UNSUPPORTED_LEGACY_STATUS = 0xDE,
+ /** The security purportedly applied by the originator of the received frame
+ * is not supported. */
+ APS_MAC_UNSUPPORTED_SECURITY_STATUS = 0xDF,
+ /** The beacon was lost following a synchronization request. */
+ APS_MAC_BEACON_LOSS_STATUS = 0xE0,
+ /** A transmission could not take place due to activity on the channel,
+ * i.e., the CSMA-CA mechanism has failed. */
+ APS_MAC_CHANNEL_ACCESS_FAILURE_STATUS = 0xE1,
+ /** The GTS request has been denied by the PAN coordinator. */
+ APS_MAC_DENIED_STATUS = 0xE2,
+ /** The attempt to disable the transceiver has failed. */
+ APS_MAC_DISABLE_TRX_FAILURE_STATUS = 0xE3,
+ /** Either a frame resulting from processing has a length that is
+ * greater than aMaxPHYPacketSize or a requested transaction is
+ * too large to fit in the CAP or GTS. */
+ APS_MAC_FRAME_TOO_LONG_STATUS = 0xE5,
+ /** The requested GTS transmission failed because the specified
+ * GTS either did not have a transmit GTS direction or was not defined. */
+ APS_MAC_INVALID_GTS_STATUS = 0xE6,
+ /** A request to purge an MSDU from the transaction queue was made using
+ * an MSDU handle that was not found in the transaction table. */
+ APS_MAC_INVALID_HANDLE_STATUS = 0xE7,
+ /** A parameter in the primitive is either not supported or is out of
+ * the valid range. */
+ APS_MAC_INVALID_PARAMETER_STATUS = 0xE8,
+ /** No acknowledgment was received after macMaxFrameRetries. */
+ APS_MAC_NO_ACK_STATUS = 0xE9,
+ /** A scan operation failed to find any network beacons. */
+ APS_MAC_NO_BEACON_STATUS = 0xEA,
+ /** No response data were available following a request. */
+ APS_MAC_NO_DATA_STATUS = 0xEB,
+ /** The operation failed because a 16-bit short address was not allocated. */
+ APS_MAC_NO_SHORT_ADDRESS_STATUS = 0xEC,
+ /** A receiver enable request was unsuccessful because it could not be
+ * completed within the CAP. */
+ APS_MAC_OUT_OF_CAP_STATUS = 0xED,
+ /** A PAN identifier conflict has been detected and communicated
+ * to the PAN coordinator. */
+ APS_MAC_PAN_ID_CONFLICT_STATUS = 0xEE,
+ /** A coordinator realignment command has been received. */
+ APS_MAC_REALIGNMENT_STATUS = 0xEF,
+ /** The transaction has expired and its information was discarded. */
+ APS_MAC_TRANSACTION_EXPIRED_STATUS = 0xF0,
+ /** There is no capacity to store the transaction. */
+ APS_MAC_TRANSACTION_OVERFLOW_STATUS = 0xF1,
+ /** The transceiver was in the transmitter enabled state when the receiver
+ * was requested to be enabled. */
+ APS_MAC_TX_ACTIVE_STATUS = 0xF2,
+ /** The key purportedly used by the originator of the received frame is
+ * not available or, if available, the originating device is not known
+ * or is blacklisted with that particular key. */
+ APS_MAC_UNAVAILABLE_KEY_STATUS = 0xF3,
+ /** A SET/GET request was issued with the identifier of a PIB
+ * attribute that is not supported. */
+ APS_MAC_UNSUPPORTED_ATTRIBUTE_STATUS = 0xF4,
+ /** A request to send data was unsuccessful because neither the source address
+ * parameters nor the destination address parameters were present. */
+ APS_MAC_INVALID_ADDRESS_STATUS = 0xF5,
+ /** A receiver enable request was unsuccessful because it specified a number
+ * of symbols that was longer than the beacon interval. */
+ APS_MAC_ON_TIME_TOO_LONG_STATUS = 0xF6,
+ /** A receiver enable request was unsuccessful because it could not be
+ * completed within the current superframe and was not permitted to be
+ * deferred until the next superframe. */
+ APS_MAC_PAST_TIME_STATUS = 0xF7,
+ /** The device was instructed to start sending beacons based on the
+ * timing of the beacon transmissions of its coordinator, but the device
+ * is not currently tracking the beacon of its coordinator. */
+ APS_MAC_TRACKING_OFF_STATUS = 0xF8,
+ /** An attempt to write to a MAC PIB attribute that is in a table failed
+ * because the specified table index was out of range. */
+ APS_MAC_INVALID_INDEX_STATUS = 0xF9,
+ /** There are some unscanned channels yet, but there is no memory */
+ APS_MAC_LIMIT_REACHED_STATUS = 0xFA,
+ /** A SET/GET request was issued with the identifier of an attribute
+ * that is read only. */
+ APS_MAC_READ_ONLY_STATUS = 0xFB,
+ /** A request to perform a scan operation failed because the MLME was
+ * in the process of performing a previously initiated scan operation. */
+ APS_MAC_SCAN_IN_PROGRESS_STATUS = 0xFC,
+ /** The device was instructed to start sending beacons based on the timing of
+ * the beacon transmissions of its coordinator, but the instructed start time
+ * overlapped the transmission time of the beacon of its coordinator. */
+ APS_MAC_SUPERFRAME_OVERLAP_STATUS = 0xFD
+} APS_Status_t;
+
+#if defined _SECURITY_
+/** Type of request to transmit APS command. */
+typedef struct _ApsCommandReq_t
+{
+ /** \cond SERVICE_FIELDS **/
+ struct
+ {
+ /** Service field, used for queue support */
+ QueueElement_t next;
+ /** Partner device short address. */
+ ShortAddr_t partnerShortAddr;
+ /** Service structure for memory allocation on NWK-layer */
+ NWK_AllocDataReq_t allocateReq;
+ /** Callback function for preparing an NWK-DATA.request. */
+ void (*prepareNwkDataReq)(struct _ApsCommandReq_t *const commandReq);
+#if defined _LINK_SECURITY_
+ /** Service structure for payload encryption */
+ SSP_EncryptFrameReq_t encryptReq;
+#endif /* _LINK_SECURITY_ */
+
+ } service;
+ /** Flag indicates the command frame encryption on NWK-layer. */
+ bool nwkSecurity;
+ /** Flag indicates the command frame encryption on APS-layer. */
+ bool apsSecurity;
+ /** Identifies the type of the key which is used to protect the frame. */
+ uint8_t keyIdentifier;
+ /** If the extendedNonce field is equal to 1 then source address shall
+ * be present in Auxilary header. */
+ bool extendedNonce;
+ /** Actual command frame lenght, APS header with payload */
+ uint8_t frameLength;
+ /** Pointer to extended address of partner device. */
+ ExtAddr_t *partnerExtAddr;
+ /** Callback function for preparing an APS command. */
+ void (*prepareCommand)(struct _ApsCommandReq_t *const commandReq);
+ /** Callback function for confirmation of APS command transmission. */
+ void (*confirmCommand)(struct _ApsCommandReq_t *const commandReq,
+ const APS_Status_t status);
+} ApsCommandReq_t;
+#endif /* _SECURITY_ */
+
+#endif /* _APS_COMMON_H */
+/** eof apsCommon.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/apsConfigServer.h b/digital/zigbit/bitcloud/stack/Components/APS/include/apsConfigServer.h
new file mode 100644
index 00000000..0c673157
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/apsConfigServer.h
@@ -0,0 +1,37 @@
+/**************************************************************************//**
+ \file apsConfigServer.h
+
+ \brief The data types necessary for building of the ConfigServer.
+
+ \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:
+ 2010-10-16 Max Gekk - Created.
+ Last change:
+ $Id: apsConfigServer.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _APS_CONFIG_SERVER_H
+#define _APS_CONFIG_SERVER_H
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+#ifndef APS_PRIVATE
+ #define APS_PRIVATE
+#endif /* APS_PRIVATE */
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsMemoryManager.h>
+#include <apsKeyPairSet.h>
+
+#endif /* _APS_CONFIG_SERVER_H */
+/** eof apsConfigServer.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/apsCryptoKeys.h b/digital/zigbit/bitcloud/stack/Components/APS/include/apsCryptoKeys.h
new file mode 100644
index 00000000..216cc70e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/apsCryptoKeys.h
@@ -0,0 +1,426 @@
+/**************************************************************************//**
+ \file apsCryptoKeys.h
+
+ \brief Access interface to cryptographic keys.
+
+ \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:
+ 2010-10-31 Max Gekk - Created.
+ Last change:
+ $Id: apsCryptoKeys.h 18914 2011-10-18 09:13:36Z mgekk $
+ ******************************************************************************/
+#if !defined _APS_CRYPTO_KEYS_H
+#define _APS_CRYPTO_KEYS_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwk.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+/** Macro returns true if crypto key handle is valid. */
+#define APS_KEY_HANDLE_IS_VALID(handle) (0 <= (handle))
+/** Macro returns true if key-pair handle is successfully found. */
+#define APS_KEYS_FOUND(handle) APS_KEY_HANDLE_IS_VALID(handle)
+/** Macro returns true if security status is related to any security with
+ * link key.*/
+#define APS_SECURED_WITH_ANY_LINK_KEY_STATUS(securityStatus) \
+ ((APS_SECURED_LINK_KEY_STATUS == securityStatus) || \
+ (APS_SECURED_TRUST_CENTER_LINK_KEY_STATUS == securityStatus) || \
+ (APS_SECURED_HASH_OF_TRUST_CENTER_LINK_KEY_STATUS == securityStatus))
+
+
+/** List of invalid and service key handle values. */
+/** Initial and finish value of key-pair iterator. */
+#define APS_KEY_PAIR_INITIAL -1
+#define APS_KEY_PAIR_FINISH -2
+/** Memory for key-pair descriptor is out. */
+#define APS_KEY_PAIR_ALLOC_FAIL -3
+/** Key-pair is not found by device address. */
+#define APS_KEY_PAIR_NOT_FOUND -4
+/** Parameter is out of range. */
+#define APS_KEY_PAIR_INVALID_PARAMETER -5
+/** APS Key-Pair Set is not initialized. */
+#define APS_KEY_PAIR_NO_INIT -6
+
+/** Values of reset flag. These request reset master, link keys or counters.
+ * Zero or more flags can be bitwise-or'd in argument of APS_ResetKeys. */
+#define APS_RESET_MASTER_KEY 0x01 /*!< Set default master key (zero key). */
+#define APS_RESET_LINK_KEY 0x02 /*!< Set default link key (zero key). */
+#define APS_RESET_COUNTERS 0x04 /*!< Set 0 to incoming and outgoing counters.*/
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/* Type of outgoing frame counter. See ZigBee spec r19, Table 4.37. */
+typedef uint32_t ApsOutFrameCounter_t;
+
+/* Type of incoming frame counter. See ZigBee spec r19, Table 4.37. */
+typedef uint32_t ApsInFrameCounter_t;
+
+/** Type of cryptographic key handle. */
+typedef int16_t APS_KeyHandle_t;
+
+/** Bit map of reset flags. */
+typedef uint8_t APS_KeyResetFlags_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Sets a link key for the device with a given extended address
+
+ This function inserts a new entry into the APS key-pair set containing provided
+ link key value and extended address.
+
+ The function shall be called to specify the trust center link key before performing
+ network start if high security is used with ::CS_ZDO_SECURITY_STATUS set to 1 or
+ standard security with link keys is used.
+
+ In high security, if the trust center link key is unavailable
+ ::CS_ZDO_SECURITY_STATUS can be set to 2 or 3; in this case a master key is used to authenticate
+ the joining device to launch link key establishment procedure with the trust center.
+
+ For communication with a node different from the trust center a separate link key is also
+ needed (an application link key). If it is known to the application it shall be set with
+ the use of this function. Otherwise, the application shall either apply a master key to
+ launch link key establishment procedure (SKKE) with the partner node or request for a link
+ key from the trust center.
+
+ A typical example of the function's usage is given below:
+\code
+APS_KeyHandle_t apsKeyHandle; //A variable to hold a key handle
+//Set a link key variable to a 16-byte value
+uint8_t linkKey[SECURITY_KEY_SIZE] = {0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa};
+//A variable for the trust center address predefined in ::CS_APS_TRUST_CENTER_ADDRESS.
+ExtAddr_t trustCenterAddr;
+
+//Read the trust center address
+CS_ReadParameter(CS_APS_TRUST_CENTER_ADDRESS_ID, &trustCenterAddr);
+//Set the trust center link key
+apsKeyHandle = APS_SetLinkKey(&trustCenterAddr, linkKey);
+
+//Check for errors
+if (APS_KEY_HANDLE_IS_VALID(apsKeyHandle))
+{
+ ...
+}
+\endcode
+
+ \param[in] deviceAddress \ref Endian "[LE]" - pointer to
+ extended (IEEE) device address
+ \param[in] linkKey - pointer to a new link key
+
+ \return A valid key handle if operation is successfully completed otherwise
+ invalid key handle (Use APS_KEY_HANDLE_IS_VALID to check it out).
+ ******************************************************************************/
+APS_KeyHandle_t APS_SetLinkKey(const ExtAddr_t *const deviceAddress,
+ const uint8_t *const linkKey);
+
+/**************************************************************************//**
+ \brief Sets a master key for the device with a given extended address
+
+ This function inserts a new entry into the APS key-pair set containing provided
+ master key value and extended address. Thus it specifies a master key used to launch
+ link key establishment (SKKE) with the remote device with the corresponding extended address.
+
+ The function is used in high security with ::CS_ZDO_SECURITY_STATUS set to 2 or 3.
+ If ::CS_ZDO_SECURITY_STATUS is set to 2, then before joining the network the device
+ shall specify a master key value corresponding to the trust center using this function. The
+ master key in pair with the joining device's extended address must be set on the trust
+ center via this function as well. If ::CS_ZDO_SECURITY_STATUS is set to 3, then the
+ master key must be set only on the trust center. In this case the trust center
+ trasfers the master key to the device at the beginning of the authentication procedure.
+
+ The function can also be used to specify application master keys corresponding to devices
+ different from the trust center. The need for this occurs when a link key for a remote device
+ is unknown. The device shall set a master key value for a remote device with which it wishes to
+ communicate and initiate the SKKE procedure to establish the link key by calling the
+ APS_EstablishKeyReq() function before sending any data requests to the device.
+
+ See the example of usage below:
+\code
+APS_KeyHandle_t apsKeyHandle; //A variable to hold a key handle
+//Set a master key variable to a 16-byte value
+uint8_t masterKey[16] = {0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa};
+//Assume the remote node extended address is held by APP_EXT_ADDR constant
+ExtAddr_t partnerExtAddr = APP_EXT_ADDR;
+
+apsKeyHandle = APS_SetMasterKey(&partnerExtAddr, masterKey); //Set the master key
+
+//Check for errors
+if (APS_KEY_HANDLE_IS_VALID(apsKeyHandle))
+{
+ ...
+}
+\endcode
+Note that the APP_EXT_ADDR constant shall contain a 64-bit value in the little endian
+format. For this purpose in the definition of the constant convert a common value
+to the little endian format using the CCPU_TO_LE64 format as follows:
+\code
+#define APP_EXT_ADDR CCPU_TO_LE64(0xAAAAAAAAAAAAAAAALL)
+\endcode
+
+An extended address corresponding to a given short address can be obtained
+through Device Discovery, while short addresses of devices supporting certain services can be
+discovered using Service Discovery.
+
+ \param[in] deviceAddress \ref Endian "[LE]" - pointer to extended
+ IEEE device address.
+ \param[in] masterKey - pointer to new cryptographic master key.
+
+ \return Valid key handle if operation is successfully completed otherwise
+ invalid key handle (Use APS_KEY_HANDLE_IS_VALID to check it out).
+ ******************************************************************************/
+APS_KeyHandle_t APS_SetMasterKey(const ExtAddr_t *const deviceAddress,
+ const uint8_t *const masterKey);
+
+/**************************************************************************//**
+ \brief Find the master key or the link key corresponding to a given extended address
+
+ The function is used to check whether the link key or the master key has been set for a given
+ device identified by its extended address and to retrieve a handle to it if one exists. To
+ check whether the key has been found use the APS_KEYS_FOUND macro. If the handle is
+ valid an access to a key value is got via APS_GetMasterKey() or APS_GetLinkKey().
+
+ See the example:
+\code
+//Assume that the extended address of interest is held by APP_EXT_ADDR constant
+ExtAddr_t partnerExtAddr = APP_EXT_ADDR;
+
+if (!APS_KEYS_FOUND(APS_FindKeys(&partnerExtAddr)))
+{
+ ... //Perform required action, e.g. request for a link key, using APS_RequestKeyReq()
+}
+\endcode
+
+ \param[in] deviceAddress \ref Endian "[LE]" - pointer to extended IEEE
+ device address.
+
+ \return Valid key handle if any key is found otherwise
+ invalid key handle (Use APS_KEYS_FOUND to check it out).
+ ******************************************************************************/
+APS_KeyHandle_t APS_FindKeys(const ExtAddr_t *const deviceAddress);
+
+/**************************************************************************//**
+ \brief Get a pointer to the master key value by a given key handle
+
+ The function returns a pointer to the section of memory containing the master key value
+ for a given key handle. A key handle points to a certain entry in the APS key-pair set
+ corresponding to a specific extended address. To obtain a key handle for a given
+ extended address use the APS_FindKeys() function.
+
+ Note that the received pointer must be only used to read the value and not to
+ modify it.
+
+ Consider the example:
+\code
+//Search for keys associated with the provided extended address
+const APS_KeyHandle_t keyHandle = APS_FindKeys(&extAddr);
+
+uint8_t *masterKey;
+
+if (APS_KEYS_FOUND(keyHandle) && NULL != (masterKey = APS_GetMasterKey(keyHandle)))
+{
+ ... //A pointer to the master key value has been successfully captured
+}
+\endcode
+
+
+ \param[in] handle - valid key handle.
+
+ \return A pointer to the master key or NULL if the key handle is invalid
+ ******************************************************************************/
+uint8_t* APS_GetMasterKey(const APS_KeyHandle_t handle);
+
+/**************************************************************************//**
+ \brief Get a pointer to the link key value by a given key handle
+
+ The function returns a pointer to the section of memory containing the link key value
+ for a given key handle. A key handle points to a certain entry in the APS key-pair set
+ corresponding to a specific extended address. To obtain a key handle for a given
+ extended address use the APS_FindKeys() function.
+
+ Note that the received pointer must be only used to read the value and not to
+ modify it.
+
+ Consider the example:
+\code
+//Search for keys associated with the provided extended address
+const APS_KeyHandle_t keyHandle = APS_FindKeys(&extAddr);
+
+uint8_t *linkKey;
+
+if (APS_KEYS_FOUND(keyHandle) && (linkKey = APS_GetLinkKey(keyHandle)))
+{
+ ... //A pointer to the link key value has been successfully captured
+}
+\endcode
+
+ \param[in] handle - valid key handle.
+
+ \return A pointer to the link key or NULL if the key handle is invalid
+ ******************************************************************************/
+uint8_t* APS_GetLinkKey(const APS_KeyHandle_t handle);
+
+/**************************************************************************//**
+ \brief Delete key-pair - master and link keys.
+
+ \param[in] deviceAddress \ref Endian "[LE]" - pointer to extended
+ IEEE device address.
+ \param[in] notify - notify to upper layer or not.
+
+ \return 'true' if the key-pair is removed otherwise false.
+ ******************************************************************************/
+bool APS_DeleteKeyPair(ExtAddr_t *const deviceAddress, const bool notify);
+
+/**************************************************************************//**
+ \brief Get next key handle.
+
+ \code Example:
+ APS_KeyHandle_t handle = APS_KEY_PAIR_INITIAL;
+
+ while (APS_KEYS_FOUND(handle = APS_NextKeys(handle)))
+ {
+ linkKey = APS_GetLinkKey(handle);
+ if (NULL != linkKey)
+ ...
+ ...
+ }
+ \endcode
+
+ \param[in] handle - handle of previous key-pair or APS_KEY_PAIR_INITIAL
+ if it's initial call.
+
+ \return if next key-pair is found then return valid key handle
+ otherwise return APS_KEY_PAIR_FINISH.
+ ******************************************************************************/
+APS_KeyHandle_t APS_NextKeys(const APS_KeyHandle_t handle);
+
+/**************************************************************************//**
+ \brief (Un)authorize cryptographic key-pair of given device.
+
+ \param[in] deviceAddress \ref Endian "[LE]" - pointer to extended IEEE
+ device address.
+ \param[in] status - 'true' for authorized keys otherwise 'false'.
+
+ \return None.
+ ******************************************************************************/
+void APS_SetAuthorizedStatus(const ExtAddr_t *const deviceAddress,
+ const bool status);
+
+/**************************************************************************//**
+ \brief Check authorization of crypthographic key-pair.
+
+ \param[in] deviceAddress \ref Endian "[LE]" - pointer to extended
+ IEEE device address.
+
+ \return 'true' if key-pair is authorized otherwise 'false'.
+ ******************************************************************************/
+bool APS_AreKeysAuthorized(const ExtAddr_t *const deviceAddress);
+
+/**************************************************************************//**
+ \brief Reset device's keys and counters to default values.
+
+ \param[in] deviceAddress \ref Endian "[LE]" - pointer to extended IEEE
+ device address.
+ \param[in] flags - bit map of APS Key-Pair reset flags. Current implementation
+ supported only APS_RESET_LINK_KEY and APS_RESET_COUNTERS.
+
+ \return APS Key Handle of reseting key-pair or invalid key handle if
+ key-pair is not found.
+ ******************************************************************************/
+APS_KeyHandle_t APS_ResetKeys(const ExtAddr_t *const deviceAddress,
+ const APS_KeyResetFlags_t flags);
+
+/**************************************************************************//**
+ \brief Init APS key-pair set.
+
+ \param[in] powerFailureControl - stack restoring after power failure control bitfield;
+ affects on initialization procedure.
+
+ \return None.
+ ******************************************************************************/
+void APS_InitKeyPairSet(const NWK_PowerFailureControl_t powerFailureControl);
+
+/**************************************************************************//**
+ \brief Get extended device address of key-pair.
+
+ \param[in] handle - valid key handle.
+
+ \return Pointer to device address or NULL if key-pair is not found..
+ ******************************************************************************/
+ExtAddr_t* APS_GetKeyPairDeviceAddress(const APS_KeyHandle_t handle);
+
+/**************************************************************************//**
+ \brief Find key-pair with old address and set new address.
+
+ \param[in] oldAddress \ref Endian "[LE]" - extended IEEE device
+ address of key-pair.
+ \param[in] newAddress \ref Endian "[LE]" - new device address of key-pair.
+ \return None.
+ ******************************************************************************/
+void APS_ChangeKeyPairDeviceAddress(const ExtAddr_t oldAddress,
+ const ExtAddr_t newAddress);
+
+#ifdef _TC_PROMISCUOUS_MODE_
+/**************************************************************************//**
+ \brief Get preinstalled link key.
+
+ \param[in] handle - valid key handle.
+
+ \return Pointer to preinstalled link key or NULL if handle is invalid.
+ ******************************************************************************/
+uint8_t* APS_GetPreinstalledLinkKey(const APS_KeyHandle_t handle);
+
+/**************************************************************************//**
+ \brief Set new preinstalled link key for given device.
+
+ This function copies value of preinstalled link key to APS Key-Pair Set.
+
+ \param[in] deviceAddress - pointer to extended IEEE device address.
+ \param[in] preinstalledLinkKey - pointer to new cryptographic preinstalled
+ link key.
+
+ \return Valid key handle if operation is successfully completed otherwise
+ invalid key handle (Use APS_KEY_HANDLE_IS_VALID to check it out).
+ ******************************************************************************/
+APS_KeyHandle_t APS_SetPreinstalledLinkKey(const ExtAddr_t *const deviceAddress,
+ const uint8_t *const preinstalledLinkKey);
+
+/**************************************************************************//**
+ \brief Restores link key from preinstalled one.
+ Uses to accept TC reestablishing keys with previously joined device.
+
+ \param[in] deviceAddress - pointer to extended IEEE device address.
+
+ \return None.
+ ******************************************************************************/
+void APS_RestorePreinstalledLinkKey(const ExtAddr_t *const deviceAddress);
+
+#endif /* _TC_PROMISCUOUS_MODE_ */
+
+#ifdef _LINK_SECURITY_
+/**************************************************************************//**
+ \brief Get current value of outgoing security frames counter.
+
+ \param[in] keyHandle - valid key handle.
+
+ \return Current value of outgoing frame counter.
+ ******************************************************************************/
+ApsOutFrameCounter_t APS_GetOutSecFrameCounter(const APS_KeyHandle_t keyHandle);
+#endif /* _LINK_SECURITY_ */
+
+
+#endif /* _APS_CRYPTO_KEYS_H */
+/** eof apsCryptoKeys.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/apsTcSwapOut.h b/digital/zigbit/bitcloud/stack/Components/APS/include/apsTcSwapOut.h
new file mode 100644
index 00000000..a005ee69
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/apsTcSwapOut.h
@@ -0,0 +1,59 @@
+/*************************************************************************//**
+ \file apsTcSwapOut.h
+
+ \brief Interface of APS Trust Centre Swap Out.
+
+ \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:
+ 2010-11-28 Max Gekk - Created.
+ Last change:
+ $Id: apsTcSwapOut.h 17813 2011-07-04 14:11:12Z dloskutnikov $
+ *****************************************************************************/
+#if !defined _APS_TC_SWAP_OUT_H
+#define _APS_TC_SWAP_OUT_H
+/**//**
+ *
+ * In order to protect the data that is being backed up, a hash on the TC
+ * link key will be performed and that will be the key stored externally.
+ * The actual link key used for operational networks never be transported
+ * out of the ESI. See ZigBee-095310r23ZB, page 82.
+ *
+ **/
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsCommon.h>
+
+#if defined _SECURITY_ && defined _LINK_SECURITY_ && defined _TC_SWAPOUT_
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Creates link key hash for the Trust Centre and store it inside.
+ ******************************************************************************/
+void APS_EnableLinkKeyHashChecking(void);
+
+/**************************************************************************//**
+ \brief Writes invalid value to link key hash for the Trust Centre.
+ ******************************************************************************/
+void APS_DisableLinkKeyHashChecking(void);
+
+/**************************************************************************//**
+ \brief Gets pointer to stored link key hash for the Trust Centre.
+ ******************************************************************************/
+uint8_t *APS_GetLinkKeyHash(void);
+
+#endif /* _SECURITY_ and _LINK_SECURITY_ and _TC_SWAPOUT_ */
+
+#endif /* _APS_TC_SWAP_OUT_H */
+/** eof apsTcSwapOut.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/apsdeData.h b/digital/zigbit/bitcloud/stack/Components/APS/include/apsdeData.h
new file mode 100644
index 00000000..50f202ba
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/apsdeData.h
@@ -0,0 +1,319 @@
+/**************************************************************************//**
+ \file apsdeData.h
+
+ \brief The interface for sending data through the APS component
+
+ \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:
+ 2010-10-18 Max Gekk - Created.
+ Last change:
+ $Id: apsdeData.h 18132 2011-08-02 15:58:18Z ataradov $
+ ******************************************************************************/
+#if !defined _APSDE_DATA_H
+#define _APSDE_DATA_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsCommon.h>
+#include <bcEndian.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \struct APS_DataConf_t apsdeData.h "aps.h"
+ *
+ * \brief The structure for reporting the result of APS_DataReq() function
+ *
+ * A pointer to an instance of this type is received as an argument in a confirmation callback for APS_DataReq()
+ * request reporting the result of data transmission.
+ * The structure definition follows APSDE-DATA confirm primitive described in
+ * ZigBee Specification r18, 2.2.4.1.2 APSDE-DATA.confirm, page 27.
+ **/
+typedef struct
+{
+ /** The status of the corresponding request. */
+ APS_Status_t status;
+ /** Timestamp for the transmitted packet based on the local clock,
+ * as provided by the NWK layer. */
+ uint32_t txTime;
+} APS_DataConf_t;
+
+/**//**
+ * \struct APS_TxOptions_t apsdeData.h "aps.h"
+ *
+ * \brief Describes additional options of data transmission.
+ *
+ * The structure is used to set additional parameters for a data request such as
+ * \li to request for acknowledgement assign acknowledgedTransmission to 1
+ * \li to enable fragmentation assign fragmentationPermitted to 1
+ * \li to enable security assign securityEnabledTransmission to 1
+ * \li to use network key in the request assign useNwkKey to 1
+ * \li to include extended nonce to the auxiliary header assign includeExtendedNonce to 1
+ *
+ * This fields conform to the primitive defined in ZigBee Specification r20, Table 2.2, page 25.
+ *
+ * Few extensions to the specification are defined:
+ * \li to disable decryption of sent data (clobbers data pointed by the asdu field) assign doNotDecrypt to 1
+ * \li to enable indications from broadcast transmissions assign indicateBroadcasts to 1
+ *
+ */
+BEGIN_PACK
+typedef struct PACK
+{
+ uint8_t securityEnabledTransmission :1;
+ uint8_t useNwkKey :1;
+ uint8_t acknowledgedTransmission :1;
+ uint8_t fragmentationPermitted :1;
+ uint8_t includeExtendedNonce :1;
+ uint8_t doNotDecrypt :1;
+ uint8_t indicateBroadcasts :1;
+ /** Reserved. Should always be zero. */
+ uint8_t reserved :1;
+} APS_TxOptions_t;
+END_PACK
+
+/**//**
+ * \struct APS_DataReq_t apsdeData.h "aps.h"
+ *
+ * \brief The structure for request parameters of APS_DataReq() function
+ *
+ * The structure represents parameters of data request, i.e. the request for sending data across the network. A pointer
+ * to an instance of the structure should to be passed as an argument to APS_DataReq() function.
+ * The structure definition follows APSDE-DATA request primitive described in
+ * Zigbee Specification r18, 2.2.4.1.1 APSDE-DATA.request, page 23.
+ */
+typedef struct
+{
+ /** \cond SERVICE_FIELDS **/
+ struct
+ {
+ void *next; /*!< Used for queue support */
+ } service;
+ /** \endcond **/
+
+ /** The addressing mode for identifying the destination of a data request.
+ * May take any non-reserved value from the following list:
+ * \li APS_NO_ADDRESS (0x00) - used for binding; set dstAddress and dstEndpoint
+ * \li APS_GROUP_ADDRESS (0x01) - used for group transmission; 16-bit group address should be specified in dstAddress; dstEndpoint is not set
+ * \li APS_SHORT_ADDRESS (0x02) - identifying the destination (unicast or broadcast) with a 16-bit short address specified
+ * in dstAddress and the endpoint set in dstEndpoint
+ * \li APS_EXT_ADDRESS (0x03) - identifying the destination with a 64-bit extended address specified in dstAddress and the endpoint set in dstEndpoint
+ * \li 0x04..0xff - reserved values, must not be used by the application*/
+ APS_AddrMode_t dstAddrMode;
+ /**
+ * \ref Endian "[LE]" The address of the individual device or group address
+ * of the entity to which the ASDU is being transferred.
+ **/
+ APS_Address_t dstAddress;
+ /** This parameter shall be present if and only if the DstAddrMode parameter
+ * value is 0x02 or 0x03 and, if present, shall contain either the number of
+ * individual endpoints of the entity to which the ASDU is being transferred,
+ * or the broadcast endpoint (0xff). */
+ Endpoint_t dstEndpoint;
+ /** \ref Endian "[LE]" The identifier of the profile for which
+ * this frame is intended. */
+ ProfileId_t profileId;
+ /** \ref Endian "[LE]" The identifier of the cluster for which
+ * this frame is intended. */
+ ClusterId_t clusterId;
+ /** The endpoint on the request originator node from
+ * which the data frame is being transferred. */
+ Endpoint_t srcEndpoint;
+ /** The number of octets comprising the ASDU to be transferred.
+ * The maximum length of an individual APS frame payload is given
+ * as NsduLength-apscMinHeaderOverhead. Assuming the possibility
+ * of fragmentation, a maximum-sized single ASDU consists of 256 such blocks.
+ **/
+ uint16_t asduLength;
+ /** The set of octets comprising the ASDU to be transferred. */
+ uint8_t *asdu;
+ /** The transmission options for the ASDU to be transferred.
+ * See structure definition for details.
+ */
+ APS_TxOptions_t txOptions;
+ /** The distance, in hops, that a transmitted frame will be allowed to
+ * travel via the network*/
+ uint8_t radius;
+ /** A pointer to a callback function called upon request
+ * completion.*/
+ void (*APS_DataConf)(APS_DataConf_t *conf);
+ /** Confirm primitive passed to the callback and containing the results of request execution*/
+ APS_DataConf_t confirm;
+} APS_DataReq_t;
+
+/**//**
+ * \struct APS_DataInd_t apsdeData.h "aps.h"
+ *
+ * \brief The structure for indication of data reception
+ *
+ * A pointer to an instance of this type is passed to a data indication callback registered for a given
+ * endpoint when the data is received destined to the endpoint.
+ * The structure definition follows APSDE-DATA indication primitive described in
+ * Zigbee Specification r18, 2.2.4.1.3 APSDE-DATA.indication, page 29.
+ */
+typedef struct
+{
+ /** \cond SERVICE_FIELDS **/
+ struct
+ {
+ void *next; /*!< Service field for queue support */
+ } service;
+ /** \endcond **/
+
+ /** The addressing mode used to identify the destination
+ * in the data frame that has been received.
+ * May take any non-reserved value from the following list:
+ * \li APS_NO_ADDRESS (0x00) - used for binding; set dstAddress and dstEndpoint
+ * \li APS_GROUP_ADDRESS (0x01) - used for group transmission; 16-bit group address should be specified in dstAddress; dstEndpoint is not set
+ * \li APS_SHORT_ADDRESS (0x02) - identifying the destination (unicast or broadcast) with a 16-bit short address specified
+ * in dstAddress and the endpoint set in dstEndpoint
+ * \li APS_EXT_ADDRESS (0x03) - identifying the destination with a 64-bit extended address specified in dstAddress and the endpoint set in dstEndpoint
+ * \li 0x04..0xff - reserved values, must not be used by the application*/
+ APS_AddrMode_t dstAddrMode;
+ /** \ref Endian "[LE]" The individual device address or group addressto which
+ * the ASDU is directed. Value size depends on the dstAddrMode parameter. */
+ APS_Address_t dstAddress;
+ /** The target endpoint on the local entity to which the ASDU is directed. */
+ Endpoint_t dstEndpoint;
+ /** The addressing mode for the source address used in this primitive
+ * and of the APDU that has been received. May possess any non-reserved value
+ * from the following list:
+ * \li APS_SHORT_ADDRESS (0x02) - short address is used in srcAddress and srcEndpoint is specified
+ * \li APS_EXT_ADDRESS (0x03) - extended address is used in srcAddress and srcEndpoint is specified
+ * */
+ APS_AddrMode_t srcAddrMode;
+ /** \ref Endian "[LE]" The individual device address of the entity from which
+ * the ASDU has been received.
+ * Value type and size is depend of the srcAddrMode parameter. */
+ APS_Address_t srcAddress;
+ /** \ref Endian "[LE]" Network address of previous hop from which the packet
+ * received. */
+ ShortAddr_t prevHopAddr;
+ /** The number of the individual endpoint of the entity from
+ * which the ASDU has been received. */
+ Endpoint_t srcEndpoint;
+ /** \ref Endian "[LE]" The identifier of the profile from
+ * which this frame originates. */
+ ProfileId_t profileId;
+ /** \ref Endian "[LE]" The identifier of the received object. */
+ ClusterId_t clusterId;
+ /** The number of octets comprising the ASDU being indicated by the APSDE. */
+ uint16_t asduLength;
+ /** The set of octets comprising the ASDU being indicated by the APSDE. */
+ uint8_t *asdu;
+ /** The status of the incoming frame processing. */
+ APS_Status_t status;
+ /**
+ * \li APS_UNSECURED_STATUS=0xaf if the ASDU was received without any security.
+ * \li APS_SECURED_NWK_KEY_STATUS=0xac if the received ASDU was secured
+ * with the NWK key,
+ * \li APS_SECURED_LINK_KEY_STATUS=0xab if the ASDU was secured with a link key,
+ * \li APS_SECURED_TRUST_CENTER_LINK_KEY_STATUS=0xb1 if the ASDU was secured
+ * with the trust center link key,
+ * \li APS_SECURED_HASH_OF_TRUST_CENTER_LINK_KEY_STATUS=0xb2 if secured
+ * with hash of the trust center link key.
+ **/
+ APS_Status_t securityStatus;
+ /** The status of whether the NSDU is using security: TRUE = use,
+ * FALSE = doesn't use. */
+ bool nwkSecurityStatus;
+ /** The link quality indication delivered by the NLDE. */
+ uint8_t linkQuality;
+ /** Timestamp for the received packet based on the local clock,
+ * as provided by the NWK layer. */
+ uint32_t rxTime;
+ int8_t rssi;
+} APS_DataInd_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Sends data to a node in the network.
+
+The function is used to transmit data across the network. The function is able to send a data frame to a single
+node (unicast), an arbitrary group of nodes (multicast), or to all nodes in the network (broadcast). Sending data to devices
+that support a specific cluster and to which the node has already bound is also possible. Specific actions performed by the
+request depend on parameters configuration. A destination type is identified according the value
+of APS_DataReq_t::dstAddrMode.
+
+To send a unicast message to a node with a known short address set ::APS_SHORT_ADDRESS as addressing mode, specify
+the destination address, destination and source endpoints, profile and cluster IDs.Specified cluster should be supported
+by both the destination and the originator enpoints. Both endpoints should also have the same profile ID. If the short address
+is unknown ::APS_EXT_ADDRESS mode can be used to identify the destination with a help of extended address
+(\c dstAddress.extAddress field). For broadcasting
+exactly the same parameters should be set, but the destination address (\c dstAddress.shortAddress) should be assigned to
+::BROADCAST_ADDRESS_ALL to send a message to all nodes in the network, ::BROADCAST_ADDR_RX_ON_WHEN_IDLE
+to send a message to all nodes with \c rxOnWhenIdle parameter equal to 1, or ::BROADCAST_ADDR_ROUTERS to send data to
+all routers.
+
+To send data to all members of a group set ::APS_GROUP_ADDRESS as addressing mode, and specify 16bit group address
+(via \c dstAddress.groupAddress). Destination endpoint should be assigned to 0xFF value. The data will be delivered to all endpoints
+associated to a given group address on each group member. To apply binding use ::APS_NO_ADDRESS mode and specify
+source endpoint and cluster ID. Other parameters such as profile, destination address and endpoint are ignored.
+
+Actual data to be sent with a request is provided through APS_DataReq_t::asdu. The parameter takes as an argument a pointer
+to a segment of memory within a specially defined structure. Consider the example:
+
+\code
+// Application message buffer
+BEGIN_PACK
+typedef struct
+{
+ uint8_t header[APS_ASDU_OFFSET]; // Header
+ uint8_t data[APP_ASDU_SIZE]; // Application data
+ uint8_t footer[APS_AFFIX_LENGTH - APS_ASDU_OFFSET]; //Footer
+} PACK AppMessageBuffer_t; END_PACK
+static AppMessageBuffer_t appMessageBuffer; // A global variable for the message buffer
+static APS_DataReq_t dataReq; // A global variable for the data request
+...
+dataReq.asdu = appMessageBuffer.data;
+dataReq.asduLength = sizeof(appMessageBuffer.data);
+\endcode
+
+Additional options are switched on and off with a help of APS_DataReq_t::txOptions parameter. For unicast messages the application can request
+for acknowledgement and apply fragmentation if it needs to sends greater amounts of data within a single request. Security is also
+may be turned and off.
+
+The result of the operation is reported via callback call with confirm (APS_DataConf_t) primitive pointer as an argument. In case
+of acknowledged transmission the callback is called after the response from the destination node is received. When one of
+destination nodes receives data, it fires data indication callback on the destination endpoint.
+
+
+ \param[in] req - The APSDE-DATA.request primitive pointer.
+ \sa APS_DataReq_t
+
+ \return None.
+ ******************************************************************************/
+void APS_DataReq(APS_DataReq_t *const req);
+
+/**************************************************************************//**
+ \brief ZDO APSDE-DATA.indication handler.
+
+ \param[in] ind - pointer to APSDE_DATA.indication parameters.
+ \return None.
+ ******************************************************************************/
+extern void APS_ZdoDataInd(APS_DataInd_t *ind);
+
+/**************************************************************************//**
+ \brief Recalculates transmission timeouts and duplicate rejection time.
+ Reads maximum frame transmission time,
+ indirect poll rate and other parameters from the config server and
+ updates ack time.
+ \param none
+ \return none
+ ******************************************************************************/
+void APS_CalculateTimes(void);
+
+#endif /* _APSDE_DATA_H */
+/** eof apsdeData.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/apsdeEndpoint.h b/digital/zigbit/bitcloud/stack/Components/APS/include/apsdeEndpoint.h
new file mode 100644
index 00000000..02bd43b2
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/apsdeEndpoint.h
@@ -0,0 +1,203 @@
+/**************************************************************************//**
+ \file apsdeEndpoint.h
+
+ \brief Interface of APS Endpoint SAP.
+
+ \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:
+ 2010-10-20 Max Gekk - Created.
+ Last change:
+ $Id: apsdeEndpoint.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+/**//**
+ *
+ * The application framework in ZigBee is the environment in which application
+ * objects are hosted on ZigBee devices. Up to 254 distinct application objects
+ * can be defined, each identified by an endpoint address from 1 to 254.
+ *
+ * Two additional endpoints are defined for APSDE-SAP usage: endpoint 0 is
+ * reserved for the data interface to the ZDO, and endpoint 255 is reserved for
+ * the data interface function to broadcast data to all application objects.
+ * See ZigBee Specification r19, 2.1.2, page 18.
+ *
+ **/
+#if !defined _APSDE_ENDPOINT_H
+#define _APSDE_ENDPOINT_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+#include <apsdeData.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \struct APS_RegisterEndpointReq_t apsdeEndpoint.h "aps.h"
+ *
+ * \brief Parameters of the APS_RegisterEndpointReq() function
+ *
+ * A pointer to an instance of this type shall be passed to APS_RegisterEndpointReq() function
+ * as an argument to register a new endpoint. The structure contains simple descriptor
+ * configuration, data indication callback pointer, and the status field.
+ **/
+typedef struct
+{
+ /** \cond SERVICE_FIELDS **/
+ struct
+ {
+ void *next; /*!< Used for queue support. */
+ bool noIndication; /*!< Disable indication to upper-layer. */
+ } service;
+ /** \endcond **/
+
+ /** A pointer to a simple descriptor */
+ SimpleDescriptor_t *simpleDescriptor;
+ /** A pointer to an indication callback function, which is called when data is received addressed to
+ * the endpoint; conforms to APSDE-DATA.indication handler defined in ZigBee spec r19, 2.2.4.1.3.1, page 30. */
+ void (*APS_DataInd)(APS_DataInd_t *ind);
+ /** The status of endpoint registration; is written by the stack to report the result of the operation */
+ APS_Status_t status;
+} APS_RegisterEndpointReq_t;
+
+typedef APS_RegisterEndpointReq_t APS_EndpointReg_t;
+
+/**//**
+ * \struct APS_UnregisterEndpointReq_t apsdeEndpoint.h "aps.h"
+ *
+ * \brief Parameters of the APS_UnregisterEndpointReq() function
+ **/
+typedef struct
+{
+ /*! The endpoint which is to be unregistered. */
+ Endpoint_t endpoint;
+ /*! The status of endpoint unregistration; is written by the stack to report the result
+ * of the operation execution. */
+ APS_Status_t status;
+} APS_UnregisterEndpointReq_t;
+
+typedef APS_UnregisterEndpointReq_t APS_EndpointUnreg_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Registers a new endpoint in the APS layer
+
+ The function is used to register an application endpoint. In order to take part in network
+ communication the application on the device must register at least one endpoint, since
+ data exchange on the application level occurs between two endpoints registered on
+ two nodes, which in fact can be a single node as well.
+
+ The function call is done synchronously. The function simply writes an entry containing
+ endpoint information to a dedicated internal structure. The request parameters for
+ the funciton include simple descriptor configuration, a pointer to the indication callback
+ function, which is to be called upon data reception addressed to the endpoint, and a status
+ field, which is written by the stack.
+
+ See the example of request parameters configuration and function usage:
+\code
+//Global definitions
+static ClusterId_t clustersTable[] = {0}; //The list of clusters that the endpoint will support
+
+//Configure the simple descriptor of the endpoint
+static SimpleDescriptor_t simpleDescriptor =
+{
+ .endpoint = APP_ENDPOINT, //Endpoint ID, an arbitrary number between 1 and 240
+ .AppDeviceVersion = 1,
+ .AppInClustersCount = 1, //The number of suppoted input clusters
+ .AppInClustersList = clustersTable, //The list of supported input clusters
+ .AppOutClustersCount = 0,
+ .AppOutClustersList = NULL, //Suppose out clusters are not supported
+};
+
+//Configure parameters for endpoint registration request
+static APS_RegisterEndpointReq_t endpointDesc =
+{
+ .simpleDescriptor = &simpleDescriptor,
+ .APS_DataInd = APS_DataInd,
+};
+
+//Data indication callback definition
+static void APS_DataInd(APS_DataInd_t *ind)
+{
+ //Perform appropriate actions, for example, switch on the value of
+ //cluster specified in the received frame
+ switch (ind->clusterId)
+ {
+ case CPU_TO_LE16(APP_CLUSTER_ONE):
+ ...
+ case CPU_TO_LE16(APP_CLUSTER_TWO):
+ ...
+ }
+}
+...
+simpleDescriptor.AppProfileId = CPU_TO_LE16(APP_PROFILE_ID);
+simpleDescriptor.AppDeviceId = CPU_TO_LE16(1);
+
+APS_RegisterEndpointReq(&endpointDesc);
+\endcode
+Although it is not required that a variable for the simple descriptor is static or simply defined
+in the global scope, it may be convenient to do so to keep track of the endpoint. Note the use
+of the CPU_TO_LE16 macro which converts a 16-bit value to a 16-bit little-endian value. Backward
+convertion is performed with the LE16_TO_CPU macro.
+
+ \param[in] req - pointer to the endpoint registration request parameters
+
+ \return APS_SUCCESS_STATUS in req->status if registration is a success,
+ otherwise, APS_INVALID_PARAMETER_STATUS. \sa APS_Status_t
+ ******************************************************************************/
+void APS_RegisterEndpointReq(APS_RegisterEndpointReq_t *const req);
+
+/**************************************************************************//**
+ \brief Unregisters an endpoint from the APS layer
+
+ \param[in] req - pointer to the endpoint unregistering request parameters
+
+ \return APS_SUCCESS_STATUS in req->status if unregistration is a success,
+ otherwise, APS_INVALID_PARAMETER_STATUS. \sa APS_Status_t
+ ******************************************************************************/
+void APS_UnregisterEndpointReq(APS_UnregisterEndpointReq_t *const req);
+
+/**************************************************************************//**
+ \brief Get next registered endpoint descriptor by previous.
+
+ \param[in] prev - previous endpoint descriptor pointer.It is must be non NULL
+ sequential access required if. And it is must be NULL the
+ first descriptor as registered endpoints queue head element
+ access required if.
+
+ \return Valid endpoint descriptor pointer descriptor found if,
+ NULL - other case.
+ ******************************************************************************/
+APS_RegisterEndpointReq_t* APS_NextEndpoint(const APS_RegisterEndpointReq_t *const prev);
+
+/**************************************************************************//**
+ \brief Stops APS Data indications of specific endpoint number.
+
+ \param[in] endpoint - the registered endpoint number. The 0xff special value
+ means all registered endpoints.
+ \return None.
+ ******************************************************************************/
+void APS_StopEndpointIndication(const Endpoint_t endpoint);
+
+/**************************************************************************//**
+ \brief Resumes APS Data indications of specific endpoint number.
+
+ \param[in] endpoint - the registered endpoint number. The 0xff special value
+ means all registered endpoints.
+ \return None.
+ ******************************************************************************/
+void APS_ResumeEndpointIndication(const Endpoint_t endpoint);
+
+#endif /* _APSDE_ENDPOINT_H */
+/** eof apsdeEndpoint.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeAuthenticate.h b/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeAuthenticate.h
new file mode 100644
index 00000000..0812491a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeAuthenticate.h
@@ -0,0 +1,195 @@
+/**************************************************************************//**
+ \file apsmeAuthenticate.h
+
+ \brief Interface of APS Entity Authentication Services.
+
+ \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:
+ 2010-11-24 Max Gekk - Created.
+ Last change:
+ $Id: apsmeAuthenticate.h 17813 2011-07-04 14:11:12Z dloskutnikov $
+ ******************************************************************************/
+#if !defined _APSME_AUTHENTICATE_H
+#define _APSME_AUTHENTICATE_H
+/**//**
+ *
+ * The APS-layer provides services that allow two devices to mutually
+ * authenticate each other. The process authenticates the originator of the
+ * data by using a random challenge with a response based on a pre-shared
+ * secret, in this case, a key. It also allows optional authenticated data
+ * transfer. See ZigBee Specification r19, 4.4.8, page 470.
+ *
+ **/
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsCommon.h>
+#if defined _SECURITY_ && defined _LINK_SECURITY_
+#include <sspChallengeGen.h>
+#include <sspAuthentic.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Type of entity authentication status code. */
+typedef enum
+{
+ /** No errors occur. */
+ APS_AUTH_SUCCESS_STATUS = 0x00,
+ /*! An invalid parameter was input to one of the key establishment primitives.
+ **/
+ APS_AUTH_INVALID_PARAMETER_STATUS = 0x01,
+ /** No authentication key exists. */
+ APS_AUTH_NO_KEY_STATUS = 0x02,
+ /** No authentication data exists. */
+ APS_AUTH_NO_DATA_STATUS = 0x03,
+ /** Challenge is invalid:
+ * \li Initiator during action step 2 (sub-clause B.8.1 of ZigBee Spec r19),
+ * \li Responder during action step 1 (sub-clause B.8.2). */
+ APS_AUTH_INVALID_CHALLENGE_STATUS = 0x04,
+ /** MAC transformation outputs invalid:
+ * \li Initiator during action step 4 (sub-clause B.8.1),
+ * \li Responder during action steps 4 and 7 (sub-clause B.8.2). */
+ APS_AUTH_INVALID_MAC_STATUS = 0x05,
+ /** Tag checking transformation outputs invalid:
+ * \li Initiator during action step 3 (sub-clause B.8.1),
+ * \li Responder during action step 6 (sub-clause B.8.2). */
+ APS_AUTH_INVALID_KEY_STATUS = 0x06,
+ /** The initiator or responder waits for an expected incoming
+ * message for time greater than apsSecurityTimeoutPeriod. */
+ APS_AUTH_TIMEOUT_STATUS = 0x07,
+ /** Short address of authentic partner is not found. */
+ APS_AUTH_NO_SHORT_ADDR_STATUS = 0x08
+} APS_AuthenticateStatus_t;
+
+/**//**
+ * \struct APS_AuthenticateConf_t apsmeAuthenticate.h "aps.h"
+ *
+ * \brief Parameters of APSME-AUTHENTICATE.confirm primitive.
+ * See ZigBee Specification r19, Table 4.30, page 472.
+ **/
+typedef struct
+{
+ /** \ref Endian "[LE]" The extended, 64-bit IEEE address of the device
+ * with which the entity authentication took place. */
+ ExtAddr_t address;
+ /** The final status of the entity authentication. */
+ APS_AuthenticateStatus_t status;
+} APS_AuthenticateConf_t;
+
+/** Type of action. See ZigBee Specification r19, Table 4.29. */
+typedef enum
+{
+ /** Initiate the entity authentication. */
+ APS_INITIATE_ACTION = 0x00,
+ /** Respond to the entity authentication request, accepting it. */
+ APS_RESPOND_ACCEPT_ACTION = 0x01,
+ /** Respond to the entity authentication request, rejecting it. */
+ APS_RESPOND_REJECT_ACTION = 0x02
+} APS_AuthenticateAction_t;
+
+/**//**
+ * \struct APS_AuthenticateReq_t apsmeAuthenticate.h "aps.h"
+ *
+ * \brief Parameters of APSME-AUTHENTICATE.request primitive.
+ * See ZigBee Specification r19, Table 4.28, page 471.
+ **/
+typedef struct
+{
+ /** \cond SERVICE_FIELDS **/
+ struct
+ {
+ void *next; /*!< Service field, used for queue support. */
+ uint8_t ttl;
+ /** Allocation request of memory for NWK_DataReq_t and APDU. */
+ NWK_AllocDataReq_t allocNwkDataReq;
+ /** Request's parameters of authentic calculation - MacTag2 and MacTag1. */
+ SSP_CalculateAuthenticParamsReq_t macTagReq;
+ /** Pointer to NWK_DataReq_t structure for challenge and macdata frames. */
+ NWK_DataReq_t *challengeNwkDataReq;
+ NWK_DataReq_t *macdataNwkDataReq;
+ struct /** Information about authentic partner. */
+ {/** Network address of the ounterpart device in the authentication request.*/
+ ShortAddr_t shortAddr;
+ /** Received MacTag hash from authentic partner. */
+ uint8_t macTag[HASH_SIZE];
+ /** Frame counter received from partner in the Data field. */
+ uint32_t frameCounter;
+ } partner;
+ /** The 16-octet random challenge generated by the responder. */
+ uint8_t responderChallenge[CHALLENGE_SEQUENCE_SIZE];
+ } service;
+ /** \endcond **/
+
+ /** \ref Endian "[LE]" The extended, 64-bit IEEE address of the counterpart
+ * device in the entity authentication request. */
+ ExtAddr_t partnerAddress;
+ /** Indicates the action required. See APS_AuthenticateAction_t enumeration.
+ * \sa APS_AuthenticateAction_t */
+ APS_AuthenticateAction_t action;
+ /** The 16-octet random challenge generated by the initiator. */
+ uint8_t initiatorChallenge[CHALLENGE_SEQUENCE_SIZE];
+ /** Callback confirmation function of entity authentication. */
+ void (*APS_AuthenticateConf)(APS_AuthenticateConf_t *conf);
+ /** Confirm primitive as a parameter of the callback function */
+ APS_AuthenticateConf_t confirm;
+} APS_AuthenticateReq_t;
+
+/**//**
+ * \struct APS_AuthenticateInd_t apsmeAuthenticate.h "aps.h"
+ *
+ * \brief Parameters of APSME-AUTHENTICATE.indication primitive.
+ * See ZigBee Specification r19, Table 4.31, page 473.
+ **/
+typedef struct
+{
+ /** \ref Endian "[LE]"
+ * The extended, 64-bit IEEE address of the initiator device. */
+ ExtAddr_t initiatorAddress;
+ /** The 16-octet random challenge received from the initiator. */
+ uint8_t randomChallenge[CHALLENGE_SEQUENCE_SIZE];
+} APS_AuthenticateInd_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Initiate or respond an entity authentication.
+
+ This primitive can be used when there is a need to authenticate another
+ device without using frame security. The protocol confirms authenticity
+ based on the two devices sharing a pre-shared key. See ZigBee spec r19,
+ 4.4.8.1, page 470.
+
+ \param[in] req - pointer to APSME-AUTHENTICATE.request's parameters.
+ \sa APS_AuthenticateReq_t
+
+ \return None.
+ ******************************************************************************/
+void APS_AuthenticateReq(APS_AuthenticateReq_t *const req);
+
+/**************************************************************************//**
+ \brief A request to start an entity authentication is received.
+
+ See ZigBee Specification r19, 4.4.8.3, page 473.
+
+ \param[in] ind - pointer to APSME-AUTHENTICATE.indication's parameters.
+ \sa APS_AuthenticateInd_t
+
+ \return None.
+ ******************************************************************************/
+void APS_AuthenticateInd(APS_AuthenticateInd_t *ind);
+
+#endif /* _SECURITY_ and _LINK_SECURITY_ */
+
+#endif /* _APSME_AUTHENTICATE_H */
+/** eof apsmeAuthenticate.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeBind.h b/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeBind.h
new file mode 100644
index 00000000..a55f3193
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeBind.h
@@ -0,0 +1,189 @@
+/**************************************************************************//**
+ \file apsmeBind.h
+
+ \brief Interface of APS binding.
+
+ \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:
+ 2010-10-07 Max Gekk - Created.
+ Last change:
+ $Id: apsmeBind.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+/**//**
+ *
+ * The APS binding table allows ZigBee devices to establish designated
+ * destination for frames from a given source endpoint and with a given
+ * cluster ID. See ZigBee spec. r18, 2.2.8.2, page 65.
+ *
+ **/
+#if !defined _APSME_BIND_H
+#define _APSME_BIND_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+#include <apsCommon.h>
+
+#if defined _BINDING_
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \union APS_DstBindAddr_t apsmeBind.h "aps.h"
+ *
+ * \brief Information about the destination address of a binding entry.
+ *
+ * \note A value of APS_DstBindAddr_t type should be in little-endian format.
+ **/
+typedef union
+{
+ GroupAddr_t group;
+ struct
+ {
+ ExtAddr_t extAddr;
+ Endpoint_t endpoint;
+ } unicast;
+} APS_DstBindAddr_t;
+
+/**//**
+ * \struct APS_BindConf_t apsmeBind.h "aps.h"
+ *
+ * \brief The structure is used to report the result of a binding request. Conforms to APSME-BIND.confirm primitive.
+ **/
+typedef struct
+{
+ /** This parameter can take a value from the following list:
+ * \li APS_SUCCESS_STATUS - the binding link has been successfully created,
+ * \li APS_TABLE_FULL_STATUS - the binding table capacity has been exceeded,
+ * \li APS_NOT_SUPPORTED_STATUS - the device does not support the binding table,
+ * \li APS_ILLEGAL_REQUEST_STATUS - the device is not joined to
+ * a network, or one of the parameters has a value that is out of range.
+ **/
+ APS_Status_t status;
+} APS_BindConf_t;
+
+/**//**
+ * \struct APS_BindReq_t apsmeBind.h "aps.h"
+ *
+ * \brief The structure used to hold parameters for APS_BindReq()
+ *
+ * A pointer to an instance of this type should be passed to APS_BindReq() function. The structure conforms to the APSME-BIND.request
+ * primitive defined in ZigBee specification.
+ **/
+typedef struct
+{
+ /** \ref Endian "[LE]" The source IEEE address for the binding entry. */
+ ExtAddr_t srcAddr;
+ /** The source endpoint for the binding entry. Valid range: 0x01-0xFE. */
+ Endpoint_t srcEndpoint;
+ /** \ref Endian "[LE]" The identifier of the cluster on the source device
+ * that is to be bound to the destination device. */
+ ClusterId_t clusterId;
+ /** The addressing mode for the destination address. This parameter can take
+ * a value from the following list:
+ * \li APS_GROUP_ADDRES - 16-bit dst.group is used to identify the destination group
+ * \li APS_EXT_ADDRESS - the destination node is identified with extended address;
+ * dst.unicast.extAddr holds the extended address, dst.unicast.endpoint holds the endpoint
+ **/
+ APS_AddrMode_t dstAddrMode;
+ /** \ref Endian "[LE]" The destination address for the binding entry. */
+ APS_DstBindAddr_t dst;
+ /** The field to keep the result of the request*/
+ APS_BindConf_t confirm;
+} APS_BindReq_t;
+
+/**//**
+ * \struct APS_UnbindReq_t apsmeBind.h "aps.h"
+ *
+ * \brief A type to hold parameters for APS_UnbindReq(); conforms to APSME-UNBIND.confirm primitive.
+ **/
+typedef APS_BindReq_t APS_UnbindReq_t;
+
+/**//**
+ * \struct ApsBindingEntry_t apsmeBind.h "aps.h"
+ *
+ * \brief A type for a binding table entry
+ **/
+typedef APS_BindReq_t ApsBindingEntry_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Bind to a remote device or a group
+
+ This function establishes binding of two devices, or binding of a device to a group,
+ by creating an entry in the lcoal binding table, if supported. The function follows the primitive defined in
+ ZigBee specification r18, 2.2.4.3.1, page 34.
+
+ \param[in] req - pointer to request's parameters: source and destination
+ addresses, cluster identifier and etc. \sa APS_DataReq_t.
+ \return None.
+ ******************************************************************************/
+void APS_BindReq(APS_BindReq_t *const req);
+
+/**************************************************************************//**
+ \brief Unbind device from a group or from other device.
+
+ This function performs unbinding of two devices, or unbinding of a device from a group, by removing an entry in
+ the local binding table, if supported. The function follows the primitive defined in ZigBee specification r18, 2.2.4.3.3, page 38.
+
+ \param[in] req - pointer to request's parameters.
+
+ \return None.
+ ******************************************************************************/
+void APS_UnbindReq(APS_UnbindReq_t *const req);
+
+/**************************************************************************//**
+ \brief Deactivates all records in the binding table that contain dstAddr as
+ the destination address in a binding entry
+
+ \param[in] dstAddr - pointer to the target extended address
+
+ \return None
+ ******************************************************************************/
+void APS_DeactivateBindRecords(const ExtAddr_t *const dstAddr);
+
+/**************************************************************************//**
+ \brief Activates all records in the binding table that contain dstAddr as
+ the destination address in a binding entry
+
+ \param[in] dstAddr - pointer to the target extended address
+
+ \return None
+ ******************************************************************************/
+void APS_ActivateBindRecords(const ExtAddr_t *const dstAddr);
+
+/**************************************************************************//**
+ \brief Get a next binding entry.
+
+ \code Example:
+ ApsBindingEntry_t bindingEntry = NULL;
+
+ while (NULL != (bindingEntry = APS_NextBindingEntry(bindingEntry)))
+ {
+ if (0x1234 == bindingEntry->clusterId)
+ ...
+ ...
+ }
+ \endcode
+
+ \param[in] entry - pointer to binding entry or NULL if it's initial call.
+
+ \return if next binding entry is found then return valid pointer
+ otherwise return NULL.
+ ******************************************************************************/
+ApsBindingEntry_t* APS_NextBindingEntry(ApsBindingEntry_t *entry);
+
+#endif /* _BINDING_ */
+#endif /* _APSME_BIND_H */
+/** eof apsmeBind.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeEstablishKey.h b/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeEstablishKey.h
new file mode 100644
index 00000000..2065dc72
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeEstablishKey.h
@@ -0,0 +1,317 @@
+/**************************************************************************//**
+ \file apsmeEstablishKey.h
+
+ \brief Interface of APS Key-Establishment Services.
+
+ \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:
+ 2010-11-24 Max Gekk - Created.
+ Last change:
+ $Id: apsmeEstablishKey.h 18914 2011-10-18 09:13:36Z mgekk $
+ ******************************************************************************/
+#if !defined _APSME_ESTABLISH_KEY_H
+#define _APSME_ESTABLISH_KEY_H
+/**//**
+ *
+ * The APS layer provides services that allow two devices to establish
+ * a mutual link key. Initial trust information (for example, a master key) must be
+ * installed on each device prior to running the key establishment procedure.
+ * See ZigBee Specification r19, 4.4.2, page 441.
+ *
+ **/
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsCommon.h>
+#if defined _SECURITY_ && defined _LINK_SECURITY_
+#include <sspSkke.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief Status values as a result of the SKKE protocol.
+ * See ZigBee Specification r19, Table 4.10, page 448.
+ **/
+typedef enum
+{
+ /** No errors occured .*/
+ APS_SKKE_SUCCESS_STATUS = 0x00,
+ /** An invalid parameter was input to one of the key establishment
+ * primitives. */
+ APS_SKKE_INVALID_PARAMETER_STATUS = 0x01,
+ /** No master key is available. */
+ APS_SKKE_NO_MASTER_KEY_STATUS = 0x02,
+ /** Challenge is invalid:
+ * \li Initiator during action step 3 (sub-clause B.7.1),
+ * \li Responder during action step 3 (sub-clause B.7.2).
+ **/
+ APS_SKKE_INVALID_CHALLENGE_STATUS = 0x03,
+ /** SKG outputs invalid:
+ * \li Initiator during action step 4 (sub-clause B.7.1),
+ * \li Responder during action step 3 (sub-clause B.7.2).
+ **/
+ APS_SKKE_INVALID_SKG_STATUS = 0x04,
+ /** MAC transformation outputs invalid:
+ * \li Initiator during action step 8 (sub-clause B.7.1),
+ * \li Responder during action step 10 (sub-clause B.7.2).
+ **/
+ APS_SKKE_INVALID_MAC_STATUS = 0x05,
+ /** Tag checking transformation outputs invalid:
+ * \li Initiator during action step 12 (sub-clause B.7.1),
+ * \li Responder during action step 8 (sub-clause B.7.2).
+ **/
+ APS_SKKE_INVALID_KEY_STATUS = 0x06,
+ /** Either the initiator or responder waits for the next expected incoming
+ * message for time greater than the apsSecurityTimeOutPeriod attribute
+ * of the AIB. */
+ APS_SKKE_TIMEOUT_STATUS = 0x07,
+ /** Either the initiator or responder receives an SKKE frame out of order. */
+ APS_SKKE_BAD_FRAME_STATUS = 0x08,
+ /** Invalid global state of APS layer. */
+ APS_SKKE_NOT_PERMITTED_STATUS = 0x09,
+ /** Transmission of SKKE-1 command frame is failure. */
+ APS_SKKE_1_TX_ERROR_STATUS = 0x0A,
+ /** Transmission of SKKE-2 command frame is failure. */
+ APS_SKKE_2_TX_ERROR_STATUS = 0x0B,
+ /** Transmission of SKKE-3 command frame is failure. */
+ APS_SKKE_3_TX_ERROR_STATUS = 0x0C,
+ /** Transmission of SKKE-4 command frame is failure. */
+ APS_SKKE_4_TX_ERROR_STATUS = 0x0D,
+ /** Error saving new link key. */
+ APS_SKKE_SET_LINK_KEY_ERROR_STATUS = 0x0E,
+ /** Short address of key establish partner is not found. */
+ APS_SKKE_NO_SHORT_ADDR_STATUS = 0x0F
+} APS_SkkeStatus_t;
+
+/**//**
+ * \brief The requested key-establishment method.
+ **/
+typedef enum
+{
+ APS_SKKE_KEY_ESTABLISHMENT_METHOD = 0x00
+} APS_KeyEstablishmentMethod_t;
+
+/**//**
+ * \struct APS_EstablishKeyConf_t apsmeEstablishKey.h "aps.h"
+ *
+ * \brief Parameters of a callback for the APS_EstablishKeyReq() function.
+ *
+ * The structure conforms to APSME-KEY-ESTABLISH.confirm primitive defined in
+ * ZigBee Specification r19, Table 4.6, page 443.
+ **/
+typedef struct
+{
+ /** \ref Endian "[LE]" The extended 64-bit address of the device with
+ * which the key-establishment protocol was executed. */
+ ExtAddr_t address;
+ /** This parameter indicates the final status of the key-establishment
+ * protocol. */
+ APS_SkkeStatus_t status;
+} APS_EstablishKeyConf_t;
+
+/** Type of time-to-live of Establish Key request or response. */
+typedef uint16_t ApsSkkeTTL_t;
+
+typedef struct _ApsSkkeElem_t
+{
+ QueueElement_t qelem; /*!< Used for queue support. */
+ uint8_t state; /*!< Internal state of Establish Key request (response). */
+ ApsSkkeTTL_t ttl; /*!< Time to live of appropriate SKKE request. */
+ /** Pointer to confirmation function of SKKE operations. */
+ void (* apsSkkeConf)(struct _ApsSkkeElem_t *elem, APS_SkkeStatus_t skkeStatus);
+} ApsSkkeElem_t;
+
+/**//**
+ * \struct APS_EstablishKeyReq_t apsmeEstablishKey.h "aps.h"
+ *
+ * \brief Parameters of the APS_EstablishKeyReq() function
+ *
+ * The structure conforms to APSME-KEY-ESTABLISH.request primitive
+ * defined in ZigBee Specification r19, Table 4.5, page 441.
+ **/
+typedef struct
+{
+ /** \cond SERVICE_FIELDS */
+ struct
+ {
+ ApsSkkeElem_t elem; /*!< Common substructure of SKKE request. */
+ ShortAddr_t dstShortAddr; /*!< Short address of SKKE responder. */
+ /** Saved pointer to NWK_DataReq_t structure for SKKE-1 command frame. */
+ NWK_DataReq_t *skke1NwkDataReq;
+ /** Saved pointer to NWK_DataReq_t structure for SKKE-3 command frame. */
+ NWK_DataReq_t *skke3NwkDataReq;
+ /** Request to allocate memory for SKKE command in NWK layer. */
+ NWK_AllocDataReq_t allocNwkDataReq;
+ /** Parameters of request for calculation of link key by master key. */
+ SSP_CalculateSkkeParamsReq_t sspReq;
+ } service;
+ /** \endcond */
+
+ /** \ref Endian "[LE]" The extended 64-bit address of the responder device. */
+ ExtAddr_t responderAddress;
+ /** This parameter indicates if the responder's parent shall be used to
+ * forward messages between the initiator and responder devices:
+ * \li TRUE - Use parent,
+ * \li FALSE - Do not use parent.
+ **/
+ bool useParent;
+ /** \ref Endian "[LE]"
+ * If \c useParent is TRUE, then the \c responderParentAddress parameter shall
+ * contain the extended 64-bit address of the responder’s parent device.
+ * Otherwise, this parameter is not used and need not to be set. */
+ ExtAddr_t responderParentAddress;
+ /** Requested key-establishment method. The valid value is SKKE. */
+ APS_KeyEstablishmentMethod_t keyEstablishmentMethod;
+ /** Parameters that will be passed to the confirmation callback in the argument */
+ APS_EstablishKeyConf_t confirm;
+ /** Confirmation callback function */
+ void (*APS_EstablishKeyConf)(APS_EstablishKeyConf_t *conf);
+} APS_EstablishKeyReq_t;
+
+/**//**
+ * \struct APS_EstablishKeyInd_t apsmeEstablishKey.h "aps.h"
+ *
+ * \brief Parameters of APSME-KEY-ESTABLISH.indication.
+ * See ZigBee Specification r19, Table 4.7, page 444.
+ **/
+typedef struct
+{
+ /** \ref Endian "[LE]" The extended 64-bit address of the initiator device. */
+ ExtAddr_t initiatorAddress;
+ /** The requested key-establishment method shall be SKKE. */
+ APS_KeyEstablishmentMethod_t keyEstablishmentMethod;
+ /** Data field from received SKKE-1 command frame. */
+ uint8_t qeu[CHALLENGE_SEQUENCE_SIZE];
+ /** An initial Establish Key command is received from parent or not. */
+ bool fromParent;
+} APS_EstablishKeyInd_t;
+
+/**//**
+ * \struct APS_EstablishKeyResp_t apsmeEstablishKey.h "aps.h"
+ *
+ * \brief Parameters of APSME-KEY-ESTABLISH.response.
+ * See ZigBee Specification r19, Table 4.8, page 445.
+ **/
+typedef struct
+{
+ /** \cond SERVICE_FIELDS */
+ struct
+ {
+ ApsSkkeElem_t elem; /*!< Common substructure of SKKE request. */
+ ShortAddr_t dstShortAddr; /*!< Short address of SKKE initiator. */
+ /** Parameters of request for calculation of link key by master key. */
+ SSP_CalculateSkkeParamsReq_t sspReq;
+ /** Request to allocate memory for SKKE command in NWK layer. */
+ NWK_AllocDataReq_t allocNwkDataReq;
+ /** Saved pointer to NWK_DataReq_t structure for SKKE-2 command frame. */
+ NWK_DataReq_t *skke2NwkDataReq;
+ /** Saved pointer to NWK_DataReq_t structure for SKKE-4 command frame. */
+ NWK_DataReq_t *skke4NwkDataReq;
+ } service;
+ /** \endcond */
+
+ /** \ref Endian "[LE]" The extended 64-bit address of the device
+ * that initiated key establishment. */
+ ExtAddr_t initiatorAddress;
+ /** This parameter indicates the response to an initiator's request to
+ * execute a keyestablishment protocol. The response shall be either:
+ * \li TRUE = Accept,
+ * \li FALSE = Reject.
+ **/
+ bool accept;
+ /** This parameter indicates if the responder's parent shall be used to
+ * forward messages between the initiator and responder devices:
+ * \li TRUE - Use parent,
+ * \li FALSE - Do not use parent.
+ **/
+ bool useParent;
+ /** Data field from received SKKE-1 command frame. */
+ uint8_t qeu[CHALLENGE_SEQUENCE_SIZE];
+ /** Confirm primitive as a parameter of the callback function. */
+ APS_EstablishKeyConf_t confirm;
+ /** Callback function pointer as a handler of corresponding
+ * confirm primitive. */
+ void (*APS_EstablishKeyConf)(APS_EstablishKeyConf_t *conf);
+} APS_EstablishKeyResp_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _HI_SECURITY_
+/**************************************************************************//**
+ \brief Initiates the key establishment procedure
+
+ The function is used in high security to initiate a link key
+ establishment procedure (currently, SKKE) between two device. The procedure requires
+ the master key, which must be known on both devices (set via the APS_SetMasterKey()
+ function). The stack uses this procedure during device authentication on the
+ trust center, while the application may use it to establish application link
+ keys between two common devices.
+
+ If the function is used to establish an application link key, set the
+ \c useParent field to \c false and do not specify \c responderParentAddress.
+
+ Currently only SKKE protocol is supported, and so set \c keyEstablishmentMethod
+ to ::APS_SKKE_KEY_ESTABLISHMENT_METHOD.
+
+ The function conforms to APSME-ESTABLISH-KEY.request primitive.
+ See ZigBee Specification r19, 4.4.2.1, page 441.
+
+ \param[in] req - pointer to request parameters of the APS_EstablishKeyReq_t type
+
+ \return None
+ ******************************************************************************/
+void APS_EstablishKeyReq(APS_EstablishKeyReq_t *const req);
+
+/**************************************************************************//**
+ \brief Informs the upper layer when APS receives an initial
+ key-establishment message
+
+ The APS layer on the responder device calls this function informing the ZDO layer
+ when a request to start the key-establishment procedure (for example, an SKKE-1
+ frame) is received from the initiator device and the master key associated with
+ the initiator is present in the APS Key-pair set.
+
+ The function conforms to APSME-ESTABLISH-KEY.indication primitive.
+ See ZigBee Specification r19, 4.4.2.3, page 444.
+
+ \param[in] ind - pointer to parameters of the APS_EstablishKeyInd_t type
+
+ \return None
+ ******************************************************************************/
+void APS_EstablishKeyInd(APS_EstablishKeyInd_t *ind);
+
+/**************************************************************************//**
+ \brief The responder device calls this function to respond
+ to an APSME-ESTABLISH-KEY.indication primitive.
+
+ The ZDO layer calls this function to inform APS following a request from the
+ initiator device to start the key-establishment procedure. The function provides
+ the responder's ZDO with an opportunity to determine whether to accept or reject
+ the request to establish the key with a given initiator.
+
+ The function conforms to APSME-ESTABLISH-KEY.response primitive.
+ See ZigBee Specification r19, 4.4.2.4, page 444.
+
+ \param[in] resp - pointer to parameters of the APS_EstablishKeyResp_t type
+
+ \return None
+ ******************************************************************************/
+void APS_EstablishKeyResp(APS_EstablishKeyResp_t *const resp);
+
+#endif /* _HI_SECURITY_ */
+
+#endif /* _SECURITY_ and _LINK_SECURITY_ */
+
+#endif /* _APSME_ESTABLISH_KEY_H */
+/** eof apsmeEstablishKey.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeGroup.h b/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeGroup.h
new file mode 100644
index 00000000..c206f988
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeGroup.h
@@ -0,0 +1,173 @@
+/**************************************************************************//**
+ \file apsmeGroup.h
+
+ \brief Interface of APS Group table.
+
+ \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:
+ 24/07/07 A. Potashov - Created.
+ 21/07/10 M. Gekk - Refactoring.
+ Last change:
+ $Id: apsmeGroup.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _APSME_GROUP_H
+#define _APSME_GROUP_H
+/**//**
+ *
+ * This interface allows the next higher layer to manage group membership
+ * for endpoints on the current device by adding and removing entries in
+ * the group table. See ZigBee spec. r18, 2.2.4.5, page 45.
+ *
+ **/
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \struct APS_AddGroupConf_t apsmeGroup.h "aps.h"
+ *
+ * \brief Parameters of the APSME-ADD-GROUP.confirm primitive.
+ **/
+typedef struct
+{
+ /** The status of the request to add a group. */
+ APS_Status_t status;
+} APS_AddGroupConf_t;
+
+/**//**
+ * \struct APS_AddGroupReq_t apsmeGroup.h "aps.h"
+ *
+ * \brief Parameters of the APS_AddGroupReq() function.
+ **/
+typedef struct
+{
+ /** \ref Endian "[LE]" The 16-bit address of the group being added. */
+ GroupAddr_t groupAddress;
+ /** The endpoint to which the given group is being added. */
+ Endpoint_t endpoint;
+
+ /** The confirm primitive as transaction result. */
+ APS_AddGroupConf_t confirm;
+} APS_AddGroupReq_t;
+
+/**//**
+ * \struct APS_RemoveGroupConf_t apsmeGroup.h "aps.h"
+ *
+ * \brief The primitive presenting the result of APS_RemoveAllGroupReq() function.
+ **/
+typedef struct
+{
+ /** The status of the request to remove a group. */
+ APS_Status_t status;
+} APS_RemoveGroupConf_t;
+
+/**//**
+ * \struct APS_RemoveGroupReq_t apsmeGroup.h "aps.h"
+ *
+ * \brief Parameters of the APS_RemoveGroupReq() function.
+ **/
+typedef struct
+{
+ /** \ref Endian "[LE]" The 16-bit address of the group being removed. */
+ GroupAddr_t groupAddress;
+ /** The endpoint at which the given group is being removed. */
+ Endpoint_t endpoint;
+
+ /** The confirm primitive containing the result of the function call. */
+ APS_RemoveGroupConf_t confirm;
+} APS_RemoveGroupReq_t;
+
+/**//**
+ * \struct APS_RemoveAllGroupsConf_t apsmeGroup.h "aps.h"
+ *
+ * \brief The structure presenting the result of APS_RemoveAllGroupReq() function.
+ **/
+typedef struct
+{
+ /** The status of the request to remove all groups. */
+ APS_Status_t status;
+} APS_RemoveAllGroupsConf_t;
+
+/**//**
+ * \struct APS_RemoveAllGroupsReq_t apsmeGroup.h "aps.h"
+ *
+ * \brief Parameters of the APS_RemoveAllGroupsReq() function.
+ **/
+typedef struct
+{
+ /** The endpoint from which the group is being removed. */
+ Endpoint_t endpoint;
+
+ /** The confirm primitive as transaction result. */
+ APS_RemoveAllGroupsConf_t confirm;
+} APS_RemoveAllGroupsReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Adds the current device to the members of a certain group.
+
+ The function makes the current device a member of the specified group. A call to the function is done
+ synchronously since no requests are sent to the network. Instead, the function simply adds a new entry
+ to the group table associating the group address and the endpoint ID specified within the parameters.
+ The function can be called several times with the same group address and different endpoints which will
+ cause inserting an entry for each distinct pair of the group address and an endpoint. When a data frame is
+ sent to a group each group member upon reception of the frame fires indication callbacks for all endpoints
+ associated with the group address specified in the request.
+
+ The result of task execution is indicated by APS_AddGroupReq_t::confirm property inside the request
+ parameters. The status field reports
+ \li APS_SUCCESS_STATUS if the device has been added to the group
+ \li APS_TABLE_FULL_STATUS if the group table is full and a new entry can not be added.
+
+ \param[in] req - pointer to parameters of the APSME-ADD-GROUP.request.
+ *****************************************************************************/
+void APS_AddGroupReq(APS_AddGroupReq_t *const req);
+
+/**************************************************************************//**
+ \brief Removes the current device from the members of a certain group.
+
+ The function removes the node from a group. A call to the function is done synchronously. The function drops
+ all entries with the specified group and endpoint inside from the group table.
+
+ The result of task execution is indicated by APS_AddGroupReq_t::confirm property inside the request
+ parameters. The status field reports
+ \li APS_SUCCESS_STATUS if the device has been removed from the group
+ \li APS_INVALID_PARAMETER_STATUS if requested entry has not been found in the group table
+
+ \param[in] req - pointer to parameters of the APSME-REMOVE-GROUP.request.
+ ******************************************************************************/
+void APS_RemoveGroupReq(APS_RemoveGroupReq_t *const req);
+
+/**************************************************************************//**
+ \brief Removes the current device from the members of all groups for which a given
+ endpoint if registered
+
+ The function unscribe the current device from the members of all groups for which
+ a given endpoint is registered. To fullfill the task the function deletes all entries with a given
+ endpoint inside from the group table. If 0xFF is specified for endpoint the node is removed
+ from all groups.
+
+ The result of task execution is indicated by APS_AddGroupReq_t::confirm property inside the request
+ parameters.
+
+ \param[in] req - pointer to parameters of the APSME-REMOVE-ALL-GROUPS.request.
+ ******************************************************************************/
+void APS_RemoveAllGroupsReq(APS_RemoveAllGroupsReq_t *const req);
+
+#endif /* _APSME_GROUP_H */
+/** eof apsmeGroup.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeRemoveDevice.h b/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeRemoveDevice.h
new file mode 100644
index 00000000..209bbb27
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeRemoveDevice.h
@@ -0,0 +1,145 @@
+/**************************************************************************//**
+ \file apsmeRemoveDevice.h
+
+ \brief Interface of APS Remove Device Service.
+
+ \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:
+ 2010-11-24 Max Gekk - Created.
+ Last change:
+ $Id: apsmeRemoveDevice.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _APSME_REMOVE_DEVICE_H
+#define _APSME_REMOVE_DEVICE_H
+/**//**
+ *
+ * The APS-layer provides services that allow a device (for example,
+ * a Trust Center) to inform another device (for example, a router)
+ * that one of its children should be removed from the network.
+ * See ZigBee Specification r19, 4.4.5, page 463.
+ *
+ **/
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsCommon.h>
+
+#if defined _SECURITY_
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Status of creating and sending a remove device command frame. */
+typedef enum
+{
+ APS_REMOVE_SUCCESS_STATUS = 0x00,
+ APS_REMOVE_NO_SHORT_ADDRESS_STATUS = 0x01,
+ APS_REMOVE_SECURITY_FAIL_STATUS = 0x02,
+ APS_REMOVE_NOT_SENT_STATUS = 0x03,
+ /* These names are deprecated and will be removed. */
+ APS_RDR_SUCCESS_STATUS = APS_REMOVE_SUCCESS_STATUS,
+ APS_RDR_NO_SHORT_ADDRESS_STATUS = APS_REMOVE_NO_SHORT_ADDRESS_STATUS,
+ APS_RDR_SECURITY_FAIL_STATUS = APS_REMOVE_SECURITY_FAIL_STATUS,
+ APS_RDR_NOT_SENT_STATUS = APS_REMOVE_NOT_SENT_STATUS
+} APS_RemoveStatus_t;
+
+/** This type is deprecated and will be removed. */
+typedef APS_RemoveStatus_t APS_RdrStatus_t;
+
+/**//**
+ * \struct APS_RemoveDeviceConf_t apsmeRemoveDevice.h "aps.h"
+ *
+ * \brief Confirmation parameters of APSME-REMOVE-DEVICE.request primitive.
+ **/
+typedef struct
+{
+ /** Status of device removing. */
+ APS_RemoveStatus_t status;
+} APS_RemoveDeviceConf_t;
+
+/**//**
+ * \struct APS_RemoveDeviceReq_t apsmeRemoveDevice.h "aps.h"
+ *
+ * \brief Parameters of APSME-REMOVE-DEVICE.request primitive.
+ *
+ * See ZigBee Specification r19, Table 4.22, page 463.
+ **/
+typedef struct
+{
+ /** \cond SERVICE_FIELDS **/
+ struct
+ {
+ /** Request to send APS Remove Device command. */
+ ApsCommandReq_t commandReq;
+ } service;
+ /** \endcond **/
+
+ /** \ref Endian "[LE]" The extended 64-bit address of the device that is
+ * the parent of the child device that is requested to be removed. */
+ ExtAddr_t parentAddress;
+ /** \ref Endian "[LE]" The extended 64-bit address of the child device
+ * that is requested to be removed. */
+ ExtAddr_t childAddress;
+ /** Confirm primitive as a parameter of the callback function */
+ APS_RemoveDeviceConf_t confirm;
+ /** Callback function pointer as a handler of corresponding
+ * confirm primitive. */
+ void (*APS_RemoveDeviceConf)(APS_RemoveDeviceConf_t *conf);
+} APS_RemoveDeviceReq_t;
+
+/**//**
+ * \struct APS_RemoveDeviceInd_t apsmeRemoveDevice.h "aps.h"
+ *
+ * \brief Parameters of APSME-REMOVE-DEVICE.indication primitive.
+ *
+ * See ZigBee Specification r19, Table 4.23, page 464.
+ **/
+typedef struct
+{
+ /** \ref Endian "[LE]" The extended 64-bit address of the device requesting
+ * that a child device be removed. */
+ ExtAddr_t srcAddress;
+ /** \ref Endian "[LE]" The extended 64-bit address of the child device
+ * that is requested to be removed. */
+ ExtAddr_t childAddress;
+} APS_RemoveDeviceInd_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Request to remove one of children from the network.
+
+ For example, a Trust Center can use this primitive to remove a child
+ device that fails to authenticate properly. See ZigBee Specification r19,
+ 4.4.5.1, page 463.
+
+ \param[in] req - pointer to APSME-REMOVE-DEVICE.request's parameters.
+
+ \return None.
+ ******************************************************************************/
+void APS_RemoveDeviceReq(APS_RemoveDeviceReq_t *req);
+
+/**************************************************************************//**
+ \brief Indication about device removing from the network.
+
+ The APSME shall generate this primitive when it receives a remove-device
+ command frame that is successfully decrypted and authenticated, as specified
+ in sub-clause 4.4.1.2 of ZigBee Specification r19.
+
+ \param[in] ind - pointer to APSME-REMOVE-DEVICE.indication's parameters.
+
+ \return None.
+ ******************************************************************************/
+void APS_RemoveDeviceInd(APS_RemoveDeviceInd_t *ind);
+
+#endif /* _SECURITY_ */
+#endif /* _APSME_REMOVE_DEVICE_H */
+/** eof apsmeRemoveDevice.h } */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeRequestKey.h b/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeRequestKey.h
new file mode 100644
index 00000000..fbb55e1c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeRequestKey.h
@@ -0,0 +1,175 @@
+/**************************************************************************//**
+ \file apsmeRequestKey.h
+
+ \brief Interface of APS Request Key Service.
+
+ \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:
+ 2010-11-24 Max Gekk - Created.
+ Last change:
+ $Id: apsmeRequestKey.h 18914 2011-10-18 09:13:36Z mgekk $
+ ******************************************************************************/
+#if !defined _APSME_REQUEST_KEY_H
+#define _APSME_REQUEST_KEY_H
+/**//**
+ *
+ * The APSME provides services that allow a device to request the active
+ * network key or a master key from another device (for example, its Trust
+ * Center). See ZigBee Specification r19, 4.4.6, page 465.
+ *
+ **/
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsCommon.h>
+
+#if defined _SECURITY_ && defined _LINK_SECURITY_
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * The type of key being requested:
+ * \li Network (0x01) and Application (0x02) key,
+ * \li Trust Center Link Key (0x04 - it's not supported),
+ * \li 0x00 and 0x03-0xFF = Reserved.
+ **/
+typedef enum
+{
+ APS_NETWORK_KEY_TYPE = 0x01,
+ APS_APP_KEY_TYPE = 0x02,
+ APS_TC_LINK_KEY_TYPE = 0x04
+} APS_RequestKeyType_t;
+
+/** Status of creating and sending a request key command frame. */
+typedef enum
+{
+ APS_REQUEST_KEY_SUCCESS_STATUS = 0x00,
+ APS_REQUEST_KEY_NO_SHORT_ADDRESS_STATUS = 0x01,
+ APS_REQUEST_KEY_SECURITY_FAIL_STATUS = 0x02,
+ APS_REQUEST_KEY_NOT_SENT_STATUS = 0x03,
+ APS_REQUEST_KEY_TIMEOUT_STATUS = 0x04,
+ /* These names are deprecated and will be removed. */
+ APS_RKR_SUCCESS_STATUS = APS_REQUEST_KEY_SUCCESS_STATUS,
+ APS_RKR_NO_SHORT_ADDRESS_STATUS = APS_REQUEST_KEY_NO_SHORT_ADDRESS_STATUS,
+ APS_RKR_SECURITY_FAIL_STATUS = APS_REQUEST_KEY_SECURITY_FAIL_STATUS,
+ APS_RKR_NOT_SENT_STATUS = APS_REQUEST_KEY_NOT_SENT_STATUS,
+ APS_RKR_TIMEOUT = APS_REQUEST_KEY_TIMEOUT_STATUS
+} APS_RequestKeyStatus_t;
+
+/** This type is deprecated and will be removed. */
+typedef APS_RequestKeyStatus_t APS_RkrStatus_t;
+
+/**//**
+ * \struct APS_RequestKeyConf_t apsmeRequestKey.h "aps.h"
+ *
+ * \brief Parameters of APSME-REQUEST-KEY.confirm primitive.
+ **/
+typedef struct
+{
+ APS_RequestKeyStatus_t status; /*!< \sa APS_RequestKeyStatus_t */
+} APS_RequestKeyConf_t;
+
+/**//**
+ * \struct APS_RequestKeyReq_t apsmeRequestKey.h "aps.h"
+ *
+ * \brief Parameters of APSME-REQUEST-KEY.request primitive.
+ *
+ * See ZigBee Specification r19, Table 4.24, page 465.
+ **/
+typedef struct
+{
+ /** \cond SERVICE_FIELDS **/
+ struct
+ {
+ /** Service field, used for queue support */
+ QueueElement_t qelem;
+ /** Request to send APS Update Device command. */
+ ApsCommandReq_t commandReq;
+ uint32_t ttl;
+ bool transportKeyReceived;
+ bool requestKeySent;
+ } service;
+ /** \endcond **/
+
+ /** \ref Endian "[LE]" The extended 64-bit address of the device to which
+ * the request-key command should be sent. */
+ ExtAddr_t destAddress;
+ /** The type of key being requested:
+ * \li 0x01 = Network key,
+ * \li 0x02 = Application key,
+ * \li 0x04 = Trust Center Link Key. */
+ APS_RequestKeyType_t keyType;
+ /** \ref Endian "[LE]" If the KeyType parameter indicates an application key,
+ * this parameter shall indicate an extended 64-bit address of a device that
+ * shall receive the same key as the device requesting the key. */
+ ExtAddr_t partnerAddress;
+ /** Canfirmation parameters. \sa APS_RequestKeyConf_t */
+ APS_RequestKeyConf_t confirm;
+ /** Callback function pointer as a handler of corresponding
+ * confirm primitive. */
+ void (*APS_RequestKeyConf)(APS_RequestKeyConf_t *conf);
+} APS_RequestKeyReq_t;
+
+/**//**
+ * \struct APS_RequestKeyInd_t apsmeRequestKey.h "aps.h"
+ *
+ * \brief Parameters of APSME-REQUEST-KEY.indication primitive.
+ *
+ * See ZigBee Specification r19, Table 4.25, page 466.
+ **/
+typedef struct
+{
+ /** \ref Endian "[LE]" The extended 64-bit address of the device that sent
+ * the request-key command. */
+ ExtAddr_t srcAddress;
+ /** The type of key being requested. Valid values:
+ * \li APS_NETWORK_KEY_TYPE
+ * \li APS_APP_KEY_TYPE
+ **/
+ APS_RequestKeyType_t keyType;
+ /** \ref Endian "[LE]" If the KeyType parameter indicates an application key,
+ * this parameter shall indicate an extended 64-bit address of a device that
+ * shall receive the same key as the device requesting the key. */
+ ExtAddr_t partnerAddress;
+} APS_RequestKeyInd_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Request either the active network key or a new application link key
+
+ See ZigBee Specification r19, 4.4.6.1, page 465.
+
+ \param[in] req - pointer to APSME-REQUEST-KEY.request's parameters.
+ \sa APS_RequestKeyReq_t
+ \return None.
+ ******************************************************************************/
+void APS_RequestKeyReq(APS_RequestKeyReq_t *req);
+
+/**************************************************************************//**
+ \brief Generate this primitive when APS receives a request-key command frame
+
+ Upon receipt of the APSME-REQUEST-KEY.indication primitive, the ZDO shall
+ be informed that the device referenced by the SrcAddress parameter is
+ requesting a key. See ZigBee Specification r19, 4.4.6.2, page 466.
+
+ \param[in] indParams - pointer to APSME-REQUEST-KEY.indication's parameters.
+ \sa APS_RequestKeyInd_t
+ \return None.
+ ******************************************************************************/
+void APS_RequestKeyInd(APS_RequestKeyInd_t *indParams);
+
+#endif /* _SECURITY_ and _LINK_SECURITY_ */
+
+#endif /* _APSME_REQUEST_KEY_H */
+/** eof apsmeRequestKey.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeSwitchKey.h b/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeSwitchKey.h
new file mode 100644
index 00000000..6833adc6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeSwitchKey.h
@@ -0,0 +1,155 @@
+/**************************************************************************//**
+ \file apsmeSwitchKey.h
+
+ \brief Interface of APS Switch Key Service.
+
+ \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:
+ 2010-11-24 Max Gekk - Created.
+ Last change:
+ $Id: apsmeSwitchKey.h 18914 2011-10-18 09:13:36Z mgekk $
+ ******************************************************************************/
+#if !defined _APSME_SWITCH_KEY_H
+#define _APSME_SWITCH_KEY_H
+/**//**
+ *
+ * The APS layer provides services that allow a device (typically,
+ * the trust center) to inform another device that it should be switched to a new
+ * active network key. See ZigBee Specification r19, 4.4.7, page 467.
+ *
+ **/
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsCommon.h>
+
+#if defined _SECURITY_
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Status of creating and sending a switch key command frame. */
+typedef enum
+{
+ APS_SWITCH_SUCCESS_STATUS = 0x00,
+ APS_SWITCH_NO_SHORT_ADDRESS_STATUS = 0x01,
+ APS_SWITCH_SECURITY_FAIL_STATUS = 0x02,
+ APS_SWITCH_NOT_SENT_STATUS = 0x03,
+ /* These names are deprecated and will be removed. */
+ APS_SKR_SUCCESS_STATUS = APS_SWITCH_SUCCESS_STATUS,
+ APS_SKR_NO_SHORT_ADDRESS_STATUS = APS_SWITCH_NO_SHORT_ADDRESS_STATUS,
+ APS_SKR_SECURITY_FAIL_STATUS = APS_SWITCH_SECURITY_FAIL_STATUS,
+ APS_SKR_NOT_SENT_STATUS = APS_SWITCH_NOT_SENT_STATUS
+} APS_SwitchStatus_t;
+
+/** This type is deprecated and will be removed. */
+typedef APS_SwitchStatus_t APS_SkrStatus_t;
+
+/**//**
+ * \struct APS_SwitchKeyConf_t apsmeSwitchKey.h "aps.h"
+ *
+ * \brief Confirmation parameters of APSME-SWITCH-KEY.request primitive.
+ **/
+typedef struct
+{
+ /* Status of key switching. */
+ APS_SwitchStatus_t status;
+} APS_SwitchKeyConf_t;
+
+/**//**
+ * \struct APS_SwitchKeyReq_t apsmeSwitchKey.h "aps.h"
+ *
+ * \brief Parameters of APSME-SWITCH-KEY.request primitive.
+ *
+ * See ZigBee Specification r19, Table 4.26, page 468.
+ **/
+typedef struct
+{
+ /** \cond SERVICE_FIELDS **/
+ struct
+ {
+ /** Request to send APS Remove Device command. */
+ ApsCommandReq_t commandReq;
+ } service;
+ /** \endcond **/
+
+ /** \ref Endian "[LE]" The extended 64-bit address of the device to
+ * which the switch-key command is sent. */
+ ExtAddr_t destAddress;
+ /** A sequence number assigned to a network key by the Trust Center
+ * and used to distinguish network keys. */
+ uint8_t keySeqNumber;
+ /** Confirm primitive as a parameter of the callback function */
+ APS_SwitchKeyConf_t confirm;
+ /** Callback function pointer as a handler of corresponding
+ * confirm primitive. */
+ void (*APS_SwitchKeyConf)(APS_SwitchKeyConf_t *conf);
+} APS_SwitchKeyReq_t;
+
+/**//**
+ * \struct APS_SwitchKeyInd_t apsmeSwitchKey.h "aps.h"
+ *
+ * \brief Parameters of APSME-SWITCH-KEY.indication primitive.
+ *
+ * See ZigBee Specification r19, Table 4.27, page 469.
+ **/
+typedef struct
+{
+ /** \ref Endian "[LE]" The extended 64-bit address of the device
+ * that sent the switch-key command. */
+ ExtAddr_t srcAddress;
+ /** A sequence number assigned to a network key by the Trust Center
+ * and used to distinguish network keys. */
+ NWK_KeySeqNum_t keySeqNumber;
+} APS_SwitchKeyInd_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Sends a command to a remote device to switch to another network key
+
+ The command can be send by the trust center to force a specific device or all
+ devices in the network to make another network key active. If a single node is to be
+ affected the extended address of the node shall be specified in the \c destAddress field.
+ To send a switch key command to all devices in the network assign \c destAddress to
+ ::APS_SM_BROADCAST_RX_ON_WHEN_IDLE_EXT_ADDRESS.
+
+ A single network key must be active on all devices in the network. Two network keys
+ may be active on different device, while the network is switching to the new network
+ key. In high security the command to switch the network key must be sent by the trust
+ center separately to each device in the network (unicast). In other security modes the
+ trust center should send a broadcast request.
+
+ The function conforms to a primitive defined in ZigBee Specification r19, 4.4.7.1, page 467.
+
+ \param[in] req - pointer to APSME-SWITCH-KEY.request's parameters.
+ \sa APS_SwitchKeyReq_t
+ \return None
+ ******************************************************************************/
+void APS_SwitchKeyReq(APS_SwitchKeyReq_t *req);
+
+/**************************************************************************//**
+ \brief Informs the upper layer that it received a switch key command frame.
+
+ The APS layer shall generate this primitive when it receives a switch-key
+ command frame that is successfully decrypted and authenticated.
+ See ZigBee Specification r19, 4.4.7.2, page 468.
+
+ \param[in] ind - pointer to APSME-SWITCH-KEY.indication's parameters.
+ \sa APS_SwitchKeyInd_t
+ \return None.
+ ******************************************************************************/
+void APS_SwitchKeyInd(APS_SwitchKeyInd_t *ind);
+
+#endif /* _SECURITY_ */
+#endif /* _APSME_SWITCH_KEY_H */
+/** eof apsmeSwitchKey.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeTransportKey.h b/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeTransportKey.h
new file mode 100644
index 00000000..2c50ab5f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeTransportKey.h
@@ -0,0 +1,292 @@
+/**************************************************************************//**
+ \file apsmeTransportKey.h
+
+ \brief Interface of APS Transport-Key Services.
+
+ \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:
+ 2010-11-24 Max Gekk - Created.
+ Last change:
+ $Id: apsmeTransportKey.h 17946 2011-07-13 09:26:59Z mgekk $
+ ******************************************************************************/
+#if !defined _APSME_TRANSPORT_KEY_H
+#define _APSME_TRANSPORT_KEY_H
+/**//**
+ *
+ * The APS-layer provides this services that allow an initiator to transport
+ * keying material to a responder. The different types of keying material that
+ * can be transported are shown in Tables 4.12 to 4.15 of ZigBee Spec. r19.
+ *
+ **/
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsCommon.h>
+#if defined _SECURITY_
+#include <sspCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief KeyType Parameter of the Transport-Key Primitive.
+ * See ZigBee Specification r19, Table 4.12, page 452.
+ **/
+typedef enum
+{
+ /** Indicates the key is a master key used to set up link keys between
+ * the Trust Center and another device. */
+ APS_TRUST_CENTER_MASTER_KEY_TYPE = 0x00,
+ /** Indicates that the key is a network key to be used in standard security
+ * mode and may be distributed using key-transport or a standard network key.
+ **/
+ APS_STANDARD_NETWORK_KEY_TYPE = 0x01,
+ /** Indicates the key is a master key used to set up link keys between
+ * two devices. */
+ APS_APP_MASTER_KEY_TYPE = 0x02,
+ /** Indicates the key is a link key used as a basis of security between
+ * two devices. */
+ APS_APP_LINK_KEY_TYPE = 0x03,
+ /** Indicates that the key is a link key used as a basis for security
+ * between the Trust Center and another device. */
+ APS_TRUST_CENTER_LINK_KEY_TYPE = 0x04,
+ /** Indicates that the key is a network key to be used in high security
+ * mode and may be distributed using key-transport only. */
+ APS_HIGH_SECURITY_NETWORK_KEY_TYPE = 0x05
+} APS_TransportKeyType_t;
+
+/**//**
+ * \brief TransportKeyData Parameter for a Trust Center Master Key or Link Key
+ * See ZigBee Specification r19, Table 4.13, page 453.
+ **/
+typedef struct
+{
+ /** \ref Endian "[LE]" The extended 64-bit address of the parent of
+ * the destination device given by the DestAddress parameter. */
+ ExtAddr_t parentAddress;
+ /** The Trust Center master or link key. */
+ uint8_t key[SECURITY_KEY_SIZE];
+} APS_ReqTrustCenterMasterOrLinkKeyTransportData_t;
+
+/**//**
+ * \brief TransportKeyData Parameter for a Network Key.
+ * See ZigBee Specification r19, Table 4.14, page 453.
+ **/
+typedef struct
+{
+ /** A sequence number assigned to a network key by the Trust Center and used
+ * to distinguish network keys for purposes of key updates and incoming
+ * frame security operations. */
+ uint8_t keySeqNumber;
+ uint8_t networkKey[SECURITY_KEY_SIZE];
+ /** This parameter indicates if the destination device's parent shall be
+ * used to forward the key to the destination device:
+ * \li TRUE = Use parent,
+ * \li FALSE = Do not use parent. */
+ bool useParent;
+ /** \ref Endian "[LE]" If the UseParent is TRUE, then ParentAddress parameter
+ * shall contain the extended 64-bit address of the destination device’s
+ * parent device; otherwise, this parameter is not used and need not be set.*/
+ ExtAddr_t parentAddress;
+ /** Use tunneling for transport NWK key. */
+ bool tunneling;
+} APS_ReqNetworkKeyTransportData_t;
+
+/**//**
+ * \brief TransportKeyData Parameter for an Application Master or Link Key.
+ * See ZigBee Specification r19, Table 4.15, page 454.
+ **/
+typedef struct
+{
+ /** \ref Endian "[LE]" The extended 64-bit address of the device that was also
+ * sent this master key. */
+ ExtAddr_t partnerAddress;
+ /** This parameter indicates if the destination device of this master
+ * key requested it:
+ * \li TRUE = If the destination requested the key,
+ * \li FALSE = Otherwise. */
+ bool initiator;
+ /** The master or link key (as indicated by the KeyType parameter). */
+ uint8_t key[SECURITY_KEY_SIZE];
+} APS_ReqApplicationMasterOrLinkKeyTransportData_t;
+
+typedef union
+{
+ APS_ReqTrustCenterMasterOrLinkKeyTransportData_t trustCenterKey;
+ APS_ReqNetworkKeyTransportData_t networkKey;
+ APS_ReqApplicationMasterOrLinkKeyTransportData_t applicationKey;
+} APS_ReqTransportKeyData_t;
+
+/** Status of creating and sending a transport key command frame. */
+typedef enum
+{
+ APS_TRANSPORT_KEY_SUCCESS_STATUS = 0x00,
+ APS_TRANSPORT_KEY_NO_SHORT_ADDRESS_STATUS = 0x01,
+ APS_TRANSPORT_KEY_SECURITY_FAIL_STATUS = 0x02,
+ APS_TRANSPORT_KEY_NOT_SENT_STATUS = 0x03,
+ APS_TRANSPORT_KEY_INVALID_PARAMETER_STATUS = 0x04,
+ /* These names are deprecated and will be removed. */
+ APS_TKR_SUCCESS_STATUS = APS_TRANSPORT_KEY_SUCCESS_STATUS,
+ APS_TKR_NO_SHORT_ADDRESS_STATUS = APS_TRANSPORT_KEY_NO_SHORT_ADDRESS_STATUS,
+ APS_TKR_SECURITY_FAIL_STATUS = APS_TRANSPORT_KEY_SECURITY_FAIL_STATUS,
+ APS_TKR_NOT_SENT_STATUS = APS_TRANSPORT_KEY_NOT_SENT_STATUS
+} APS_TkrStatus_t;
+
+/**//**
+ * \struct APS_TransportKeyConf_t apsmeTransportKey.h "aps.h"
+ *
+ * \brief Confirmation parameters of APSME-TRANSPORT-KEY.request.
+ **/
+typedef struct
+{
+ APS_TkrStatus_t status;
+} APS_TransportKeyConf_t;
+
+/**//**
+ * \struct APS_TransportKeyReq_t apsmeTransportKey.h "aps.h"
+ *
+ * \brief Parameters of APSME-TRANSPORT-KEY.request primitive.
+ * See ZigBee Specification r19, 4.4.3.1, page 451.
+ **/
+typedef struct
+{
+ /** \cond SERVICE_FIELDS **/
+ struct
+ {
+ ApsCommandReq_t commandReq;
+ /** Global internal state of APS Transport Key component. */
+ enum
+ {
+ APS_TRANSPORT_KEY_BEGIN_STATE,
+ APS_TRANSPORT_KEY_CONFIRM_STATE,
+ APS_TRANSPORT_KEY_PROCESS_STATE
+ } state;
+ } service;
+ /** \endcond **/
+
+ /** \ref Endian "[LE]"
+ * The extended 64-bit address of the destination device.*/
+ ExtAddr_t destAddress;
+ /** Identifies the type of key material that should be transported;
+ * See ZigBee Specification r19, Table 4.12, page 452. */
+ APS_TransportKeyType_t keyType;
+ /** The key being transported along with identification
+ * and usage parameters. */
+ APS_ReqTransportKeyData_t transportKeyData;
+ /** Confirm primitive as a parameter of the callback function. */
+ APS_TransportKeyConf_t confirm;
+ /** Callback function pointer as a handler of corresponding
+ * confirm primitive. */
+ void (*APS_TransportKeyConf)(APS_TransportKeyConf_t *conf);
+} APS_TransportKeyReq_t;
+
+/**//**
+ * \brief TransportKeyData Parameter for a Trust Center Master or Link Key.
+ * See ZigBee Specification r19, Table 4.17, page 457.
+ **/
+typedef struct
+{
+ uint8_t trustCenterMasterKey[SECURITY_KEY_SIZE];
+} APS_IndTrustCenterMasterOrLinkKeyTransportData_t;
+
+/**//**
+ * \brief TransportKeyData Parameter for a Network Key.
+ * See ZigBee Specification r19, Table 4.18, page 457.
+ **/
+typedef struct
+{
+ /** A sequence number assigned to a network key by the Trust Center and
+ * used to distinguish. */
+ uint8_t keySeqNumber;
+ uint8_t networkKey[SECURITY_KEY_SIZE];
+} APS_IndNetworkKeyTransportData_t;
+
+/**//**
+ * \brief TransportKeyData Parameter for an Application Master or Link Key.
+ * See ZigBee Specification r19, Table 4.19, page 457.
+ **/
+typedef struct
+{
+ /** This parameter indicates this device was initiator or not. */
+ bool initiatorFlag;
+ /** \ref Endian "[LE]" The extended 64-bit address of the device that was also
+ * sent this master key. */
+ ExtAddr_t partnerAddress;
+ /** The master or link key (as indicated by the KeyType
+ * parameter). \sa APS_TransportKeyInd_t */
+ uint8_t key[SECURITY_KEY_SIZE];
+} APS_IndApplicationMasterOrLinkKeyTransportData_t;
+
+typedef union
+{
+ APS_IndTrustCenterMasterOrLinkKeyTransportData_t trustCenterKey;
+ APS_IndNetworkKeyTransportData_t networkKey;
+ APS_IndApplicationMasterOrLinkKeyTransportData_t applicationKey;
+} APS_IndTransportKeyData_t;
+
+//\cond internal
+/**//**
+ * \struct APS_TransportKeyInd_t apsmeTransportKey.h "aps.h"
+ *
+ * \brief Parameters of APSME-TRANSPORT-KEY.indication primitive.
+ * See ZigBee Specification r19, 4.4.3.2, page 455.
+ **/
+typedef struct
+{
+ /** \ref Endian "[LE]" The extended 64-bit address of the device
+ * that is the original source of the transported key. */
+ ExtAddr_t srcAddress;
+ /** Identifies the type of key material that was be transported;
+ * See Table 4.12 of ZigBee Specification r19. */
+ APS_TransportKeyType_t keyType;
+ /** The key that was transported along with identification and usage
+ * parameters. The type of this parameter depends on the KeyType
+ * parameter. */
+ APS_IndTransportKeyData_t transportKeyData;
+ /* Type of key with the transport key command was secured. */
+ APS_Status_t securedWith;
+} APS_TransportKeyInd_t;
+//\endcond
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Transfers a security key to a specified node
+
+ The function is used by the stack on the trust center to transfer security
+ keys during authentication procedures and upon receiving requests for a link
+ key. The application can also use it, for example, to distribute a new network
+ key. The function conforms to ZigBee Specification r19, 4.4.3.1, page 451.
+
+ \param[in] req - a pointer to request parameters of type APS_TransportKeyReq_t
+
+ \return None.
+ ******************************************************************************/
+void APS_TransportKeyReq(APS_TransportKeyReq_t *const req);
+
+/**************************************************************************//**
+ \cond internal
+ \brief Informs ZDO of security key reception
+
+ See ZigBee Specification r19, 4.4.3.2, page 455.
+
+ \param[in] ind - pointer to APSME-TRANSPORT-KEY.indication's parameters.
+
+ \return None
+ \endcond
+ ******************************************************************************/
+void APS_TransportKeyInd(APS_TransportKeyInd_t *ind);
+
+#endif /* _SECURITY_ */
+#endif /* _APSME_TRANSPORT_KEY_H */
+/** eof apsmeTransportKey.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeUpdateDevice.h b/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeUpdateDevice.h
new file mode 100644
index 00000000..748fc80f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/apsmeUpdateDevice.h
@@ -0,0 +1,165 @@
+/**************************************************************************//**
+ \file apsmeUpdateDevice.h
+
+ \brief Interface of APS Update Device Service.
+
+ \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:
+ 2010-11-24 Max Gekk - Created.
+ Last change:
+ $Id: apsmeUpdateDevice.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _APSME_UPDATE_DEVICE_H
+#define _APSME_UPDATE_DEVICE_H
+/**//**
+ *
+ * The APS-layer provides services that allow a device (for example, a router)
+ * to inform another device (for example, a Trust Center) that a third device
+ * has changed its status (for example, joined or left the network). See ZigBee
+ * Specification r19, 4.4.4, page 459.
+ *
+ **/
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsCommon.h>
+
+#if defined _SECURITY_
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Status of creating and sending a update device command frame. */
+typedef enum
+{
+ APS_UPDATE_SUCCESS_STATUS = 0x00,
+ APS_UPDATE_NO_SHORT_ADDRESS_STATUS = 0x01,
+ APS_UPDATE_SECURITY_FAIL_STATUS = 0x02,
+ APS_UPDATE_NOT_SENT_STATUS = 0x03,
+ /* These names are deprecated and will be removed. */
+ APS_UDR_SUCCESS_STATUS = APS_UPDATE_SUCCESS_STATUS,
+ APS_UDR_NO_SHORT_ADDRESS_STATUS = APS_UPDATE_NO_SHORT_ADDRESS_STATUS,
+ APS_UDR_SECURITY_FAIL_STATUS = APS_UPDATE_SECURITY_FAIL_STATUS,
+ APS_UDR_NOT_SENT_STATUS = APS_UPDATE_NOT_SENT_STATUS
+} APS_UpdateStatus_t;
+
+/** This type is deprecated and will be removed. */
+typedef APS_UpdateStatus_t APS_UdrStatus_t;
+
+/**//**
+ * \struct APS_UpdateDeviceConf_t apsmeUpdateDevice.h "aps.h"
+ *
+ * \brief Type of confirmation parameters of APSME-UPDATE-DEVICE.confirm.
+ **/
+typedef struct
+{
+ APS_UpdateStatus_t status;
+} APS_UpdateDeviceConf_t;
+
+/** Type is used to indicate the updated status of the device
+ * given by the DeviceAddress parameter. See ZigBee Spec. r19, Table 4.20. */
+typedef enum
+{
+ APS_UPDATE_DEVICE_STATUS_STANDARD_SECURED_REJOIN = 0x00,
+ APS_UPDATE_DEVICE_STATUS_STANDARD_UNSECURED_JOIN = 0x01,
+ APS_UPDATE_DEVICE_STATUS_LEFT = 0x02,
+ APS_UPDATE_DEVICE_STATUS_STANDARD_UNSECURED_REJOIN = 0x03,
+ APS_UPDATE_DEVICE_STATUS_HIGH_SECURITY_SECURED_REJOIN = 0x04,
+ APS_UPDATE_DEVICE_STATUS_HIGH_SECURITY_UNSECURED_JOIN = 0x05,
+ APS_UPDATE_DEVICE_STATUS_RESERVED = 0x06,
+ APS_UPDATE_DEVICE_STATUS_HIGH_SECURITY_UNSECURED_REJOIN = 0x07
+} APS_UpdateDeviceStatus_t;
+
+/**//**
+ * \struct APS_UpdateDeviceReq_t apsmeUpdateDevice.h "aps.h"
+ *
+ * \brief Parameters of APSME-UPDATE-DEVICE.request primitive.
+ * See ZigBee Specification r19, 4.4.4.1, page 459.
+ **/
+typedef struct
+{
+ /** \cond SERVICE_FIELDS **/
+ struct
+ {
+ /** Request to send APS Update Device command. */
+ ApsCommandReq_t commandReq;
+ } service;
+ /** \endcond **/
+
+ /** \ref Endian "[LE]" The extended 64-bit address of the device that shall
+ * be sent the update information. */
+ ExtAddr_t destAddress;
+ /** \ref Endian "[LE]"
+ * The extended 64-bit address of the device whose status is being updated. */
+ ExtAddr_t deviceAddress;
+ /** This parameter Indicates the updated status of the device given
+ * by the deviceAddress parameter. */
+ APS_UpdateDeviceStatus_t status;
+ /** \ref Endian "[LE]"
+ * The 16-bit network address of the device whose status is being updated. */
+ ShortAddr_t deviceShortAddress;
+ /** Confirm primitive as a parameter of the callback function. */
+ APS_UpdateDeviceConf_t confirm;
+ /** Callback function pointer as a handler of corresponding
+ * confirm primitive. */
+ void (*APS_UpdateDeviceConf)(APS_UpdateDeviceConf_t *conf);
+} APS_UpdateDeviceReq_t;
+
+/**//**
+ * \struct APS_UpdateDeviceInd_t apsmeUpdateDevice.h "aps.h"
+ *
+ * \brief Parameters of APSME-UPDATE-DEVICE.indication primitive.
+ * See ZigBee Specification r19, 4.4.4.2, page 461.
+ **/
+typedef struct
+{
+ /** \ref Endian "[LE]" The extended 64-bit address of the device originating
+ * the update-device command. */
+ ExtAddr_t srcAddress;
+ /** \ref Endian "[LE]"
+ * The extended 64-bit address of the device whose status is being updated. */
+ ExtAddr_t deviceAddress;
+ /** This parameter Indicates the updated status of the device given
+ * by the deviceAddress parameter. */
+ APS_UpdateDeviceStatus_t status;
+ /** \ref Endian "[LE]"
+ * The 16-bit network address of the device whose status is being updated. */
+ ShortAddr_t deviceShortAddress;
+} APS_UpdateDeviceInd_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Request to inform a device that another device has new status.
+
+ The ZDO (for example, on a router or ZigBee coordinator) shall initiate
+ the APSME-UPDATE-DEVICE.request primitive when it wants to send updated
+ device information to another device (for example, the Trust Center).
+ See ZigBee Specification r15, 4.4.1, page 459.
+
+ \param[in] req - pointer to APSME-UPDATE-DEVICE.request's parameters.
+
+ \return None.
+ ******************************************************************************/
+void APS_UpdateDeviceReq(APS_UpdateDeviceReq_t *req);
+
+/**************************************************************************//**
+ \brief Inform the upper-layer that it received an update-device command frame.
+
+ \param[in] ind - pointer to APSME-UPDATE-DEVICE.indication's parameters.
+
+ \return None.
+ ******************************************************************************/
+void APS_UpdateDeviceInd(APS_UpdateDeviceInd_t *ind);
+
+#endif /* _SECURITY_ */
+#endif /* _APSME_UPDATE_DEVICE_H */
+/** eof apsmeUpdateDevice.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/intrpData.h b/digital/zigbit/bitcloud/stack/Components/APS/include/intrpData.h
new file mode 100644
index 00000000..4f46d490
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/intrpData.h
@@ -0,0 +1,194 @@
+/**************************************************************************//**
+ \file intrpData.h
+
+ \brief Interface of inter-PAN transmission.
+
+ \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:
+ 2010-02-18 A. Kostyukov - Created.
+ 2010-11-20 Max Gekk - Refactoring.
+ Last change:
+ $Id: intrpData.h 18271 2011-08-18 12:07:56Z nfomin $
+ ******************************************************************************/
+#if !defined _INTRP_DATA_H
+#define _INTRP_DATA_H
+/**//**
+ *
+ * Inter-PAN is a transmission mechanism whereby ZigBee devices can perform
+ * limited, insecure, and possibly anonymous exchanges of information with
+ * devices in their local neighborhood without having to form or join the same
+ * ZigBee network. See ZigBee SE Profile Spec r15, page 81.
+ *
+ **/
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsCommon.h>
+
+#if defined _INTERPAN_
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+#define INTRP_NO_PANID_COMPRESSION_TXOPTION 1u
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Type of handle associated with the inter-PAN ASDU to be transmitted. */
+typedef uint8_t IntrpAsduHandle_t;
+/** Type of inter-PAN frame length. */
+typedef uint8_t IntrpLength_t;
+
+/**//**
+ * \struct INTRP_DataConf_t intrpData.h "aps.h"
+ *
+ * \brief INTRP-DATA confirm primitive's parameters structure declaration.
+ *
+ * ZigBee Smart Energy profile specification r15, B.3.2.
+ * The INTRP-DATA.confirm Primitive, page 85.
+ **/
+typedef struct
+{
+ /** An integer handle associated with the transmitted frame. */
+ IntrpAsduHandle_t asduHandle;
+ /** The status of the ASDU transmission corresponding to ASDUHandle as
+ * returned by the MAC.*/
+ MAC_Status_t status;
+} INTRP_DataConf_t;
+
+typedef uint8_t INTRP_TxOptions_t;
+
+/**//**
+ * \struct INTRP_DataReq_t intrpData.h "aps.h"
+ *
+ * \brief INTRP-DATA.request primitive's parameters structure declaration.
+ *
+ * ZigBee Smart Energy profile specification r15, B.3.1
+ * The INTRP-DATA.request Primitive, page 83.
+ **/
+typedef struct
+{
+ /** \cond SERVICE_FIELDS **/
+ struct
+ {
+ /** MCPS-DATA request primitive's parameters structure. */
+ MAC_DataReq_t macDataReq;
+ } service;
+ /** \endcond **/
+
+ /** The addressing mode for the destination address used in this primitive.
+ * This parameter can take one of the values from the following list:
+ * \li 0x01 = 16-bit group address
+ * \li 0x02 = 16-bit NWK address, normally the broadcast address 0xffff
+ * \li 0x03 = 64-bit extended address
+ **/
+ APS_AddrMode_t dstAddrMode;
+ /** \ref Endian "[LE]" The 16-bit PAN identifier of the entity or entities
+ * to which the ASDU is being transferred or the broadcast PANId 0xffff. */
+ PanId_t dstPANID;
+ /** \ref Endian "[LE]" The address of the entity or entities to which
+ * the ASDU is being transferred. */
+ MAC_Addr_t dstAddress;
+ /** \ref Endian "[LE]" The identifier of the profile for which this frame is
+ * intended. */
+ ProfileId_t profileId;
+ /** \ref Endian "[LE]" The identifier of the cluster, within the profile
+ * specified by the ProfileId parameter, which defines the application
+ * semantics of the ASDU. **/
+ ClusterId_t clusterId;
+ /** The number of octets in the ASDU to be transmitted. */
+ IntrpLength_t asduLength;
+ /** The set of octets comprising the ASDU to be transferred. */
+ uint8_t *asdu;
+ /** An integer handle associated with the ASDU to be transmitted. */
+ IntrpAsduHandle_t asduHandle;
+ /** Callback function pointer as a handler of corresponding
+ * confirm primitive.
+ **/
+ void (*INTRP_DataConf)(INTRP_DataConf_t *conf);
+ /** Confirm primitive as a parameter of the callback function. */
+ INTRP_DataConf_t confirm;
+ /** Transmission options for this request **/
+ INTRP_TxOptions_t txOptions;
+} INTRP_DataReq_t;
+
+/**//**
+ * \struct INTRP_DataInd_t intrpData.h "aps.h"
+ *
+ * \brief INTRP-DATA indication primitive's parameters structure declaration.
+ *
+ * ZigBee Smart Energy profile specification r15, B.3.3.
+ * The INTRP-DATA.indication Primitive, page 86.
+ **/
+typedef struct
+{
+ /** \ref Endian "[LE]" The 16-bit PAN identifier of the entity from which
+ * the ASDU is being transferred. */
+ PanId_t srcPANID;
+ /** \ref Endian "[LE]" The device address of the entity from which
+ * the ASDU is being transferred. */
+ MAC_Addr_t srcAddress;
+ /** The addressing mode for the destination address used in this primitive.
+ * This parameter can take one of the values from the following list:
+ * \li 0x01 = 16-bit group address
+ * \li 0x02 = 16-bit NWK address, normally the broadcast address 0xffff
+ * \li 0x03 = 64-bit extended address.
+ **/
+ APS_AddrMode_t dstAddrMode;
+ /** \ref Endian "[LE]" The 16-bit PAN identifier of the entity or entities
+ * to which the ASDU is being transferred or the broadcast PANId 0xffff. */
+ PanId_t dstPANID;
+ /** \ref Endian "[LE]" The address of the entity or entities to which
+ * the ASDU is being transferred. */
+ MAC_Addr_t dstAddress;
+ /** \ref Endian "[LE]"
+ * The identifier of the profile for which this frame is intended. */
+ ProfileId_t profileId;
+ /** \ref Endian "[LE]" The identifier of the cluster, within the profile
+ * specified by the ProfileId parameter, which defines the application
+ * semantics of the ASDU. */
+ ClusterId_t clusterId;
+ /** The number of octets in the ASDU to be transmitted. */
+ IntrpLength_t asduLength;
+ /** The set of octets comprising the ASDU to be transferred. */
+ uint8_t *asdu;
+ /** The link quality observed during the reception of the ASDU. */
+ Lqi_t lqi;
+ /** RSSI observed during the reception of the ASDU. */
+ Lqi_t rssi;
+} INTRP_DataInd_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief INTRP-DATA request primitive's prototype.
+
+ \param[in] req - INTRP-DATA request parameters' structure pointer.
+
+ \return None.
+ ******************************************************************************/
+void INTRP_DataReq(INTRP_DataReq_t *const req);
+
+/**************************************************************************//**
+ \brief INTRP-DATA indication primitive's prototype.
+
+ \param[in] ind - INTRP-DATA indication parameters' structure pointer.
+
+ \return None.
+ ******************************************************************************/
+void INTRP_DataInd(INTRP_DataInd_t *ind);
+
+#endif /* _INTERPAN_ */
+#endif /* _INTRP_DATA_H */
+/** eof intrpData.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsAuthenticate.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsAuthenticate.h
new file mode 100644
index 00000000..2ca82e02
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsAuthenticate.h
@@ -0,0 +1,162 @@
+/**************************************************************************//**
+ \file apsAuthenticate.h
+
+ \brief Private interface of APS Authentication.
+
+ \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:
+ 2010-12-18 Max Gekk - Created.
+ Last change:
+ $Id: apsAuthenticate.h 17813 2011-07-04 14:11:12Z dloskutnikov $
+ ******************************************************************************/
+#if !defined _APS_AUTHENTICATE_H
+#define _APS_AUTHENTICATE_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+#include <apsCommand.h>
+#if defined _SECURITY_ && defined _LINK_SECURITY_
+#include <sspChallengeGen.h>
+#include <sspAuthentic.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+BEGIN_PACK
+/** Type of entity authentication initiator or responder challenge frame. */
+typedef struct PACK _ApsAuthChallengeFrame_t
+{
+ ApduCommandHeader_t header;
+ /** The KeyType field is 1 octet in length and shall be set to one of
+ * the non-reserved values in Table 4.35. See ZigBee spec r19, 4.4.9.7.1.2.1,
+ * page 485 and 4.4.9.7.2.2.1, page 486. Valid values:
+ * \li 0x00 - Active network key.
+ * \li 0x01 - Link key shared between initiator and responder.
+ * \note Value 0x01 is not supported. */
+ uint8_t keyType;
+ /** The KeySeqNumber sub-field shall be set to the key sequence number of
+ * the active network key. See ZigBee spec r19, 4.4.9.7.1.2.2, page 485
+ * and 4.4.9.7.2.2.2, page 486. */
+ uint8_t keySeqNumber;
+ /** The initiator field shall be set to the 64-bit extended address of
+ * the device that acts as the initiator of the scheme. See ZigBee spec r19,
+ * 4.4.9.7.1.3, page 485 and 4.4.9.7.2.3, page 486. */
+ uint8_t initiator[sizeof(ExtAddr_t)];
+ /** The responder field shall be set to the 64-bit extended address of
+ * the device that acts as the responder to the scheme. See ZigBee spec r19,
+ * 4.4.9.7.1.4, page 485 and 4.4.9.7.2.4, page 486. */
+ uint8_t responder[sizeof(ExtAddr_t)];
+ /** The challenge field shall be the octet representation of the challenge QEU
+ * generated by the initiator during action step 1 of sub-clause B.8.1.
+ * See ZigBee spec r19, 4.4.9.7.1.5, page 485 and 4.4.9.7.2.5, page 486. */
+ uint8_t challenge[CHALLENGE_SEQUENCE_SIZE];
+} ApsAuthChallengeFrame_t;
+
+/** Type of entity authentication MAC and data frame. */
+typedef struct PACK _ApsAuthMACandDataFrame_t
+{
+ ApduCommandHeader_t header;
+ /** The MAC field shall be the octet representation of the string MacTag2
+ * (MacTag1) generated by the initiator (responder) during action step 4 (8)
+ * of sub-clause B.8.1 (B.8.2). See ZigBee Specification r19, 4.4.9.7.3.2,
+ * page 487 and 4.4.9.7.4.2, page 488. */
+ uint8_t mac[HASH_SIZE];
+ /** The DataType field shall be set to 0x00 to indicate the frame counter
+ * associated with the active network key. ZigBee spec r19, 4.4.9.7.3.3. */
+ uint8_t dataType;
+ /** The Data field shall be octet representation of the string Text2 or Text1,
+ * i.e. the frame counter associated with the active network key. See ZigBee
+ * Specification r19, 4.4.9.7.3.4, page 487 and 4.4.9.7.4.4, page 488. */
+ uint32_t data;
+} ApsAuthMACandDataFrame_t;
+END_PACK
+
+/** Values of keyType subfield. See ZigBee spec r19, Table 4.35. */
+typedef enum _ApsAuthChallengeKeyType_t
+{
+ APS_AUTH_ACTIVE_NETWORK_KEY_TYPE = 0x00,
+ APS_AUTH_LINK_KEY_TYPE = 0x01
+} ApsAuthChallengeKeyType_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Main task handler of the authentication component.
+ ******************************************************************************/
+APS_PRIVATE void apsAuthReqTaskHandler(void);
+
+#if defined _HI_SECURITY_
+/**************************************************************************//**
+ \brief Reset all internal queues and variables of authentication component.
+ ******************************************************************************/
+APS_PRIVATE void apsAuthReset(void);
+
+/**************************************************************************//**
+ \brief Entity authentication challenge was received from responder.
+
+ Find original APSME-AUTHENTICATE.request and perform steps 4 and 5
+ from ZigBee Specification r19, section B.8.1, page 540.
+
+ \param[in] commandInd - parameters of the received command.
+ \return 'true' if memory for NWK_DataInd_t is unused by authentic component.
+ ******************************************************************************/
+APS_PRIVATE
+bool apsAuthInitiatorChallengeInd(const ApsCommandInd_t *const commandInd);
+
+/**************************************************************************//**
+ \brief Entity authentication challenge was received from initiator.
+
+ \param[in] commandInd - pointer to parameters of received authentication frame.
+ \return 'true' if memory for NWK_DataInd_t is unused by authentic component.
+ ******************************************************************************/
+APS_PRIVATE
+bool apsAuthResponderChallengeInd(const ApsCommandInd_t *const commandInd);
+
+/**************************************************************************//**
+ \brief Entity authentication MAC and Data was received from initiator.
+
+ \param[in] commandInd - pointer to parameters of received authentication frame.
+ \return 'true' if memory for NWK_DataInd_t is unused by authentic component.
+ ******************************************************************************/
+APS_PRIVATE
+bool apsAuthResponderMACandDataInd(const ApsCommandInd_t *const commandInd);
+
+/**************************************************************************//**
+ \brief Entity authentication MAC and Data was received from responder.
+
+ \param[in] commandInd - pointer to parameters of received authentication frame.
+ \return 'true' if memory for NWK_DataInd_t is unused by authentic component.
+ ******************************************************************************/
+APS_PRIVATE
+bool apsAuthInitiatorMACandDataInd(const ApsCommandInd_t *const commandInd);
+
+#else /* not _HI_SECURITY_ */
+
+#define apsAuthReset() (void)0
+#endif /* _HI_SECURITY_ */
+
+#else
+#define apsAuthReqTaskHandler NULL
+#endif /* _SECURITY_ and _LINK_SECURITY_ */
+
+
+#if !defined _HI_SECURITY_ || !defined _SECURITY_ || !defined _LINK_SECURITY_
+
+#define apsAuthInitiatorChallengeInd NULL
+#define apsAuthResponderChallengeInd NULL
+#define apsAuthResponderMACandDataInd NULL
+#define apsAuthInitiatorMACandDataInd NULL
+#endif
+#endif /* _APS_AUTHENTICATE_H */
+/** eof apsAuthenticate.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsBinding.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsBinding.h
new file mode 100644
index 00000000..e89d02b0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsBinding.h
@@ -0,0 +1,186 @@
+/**************************************************************************//**
+ \file apsBinding.h
+
+ \brief Private interface of APS binding.
+
+ \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:
+ 2010-10-05 Max Gekk - Created.
+ Last change:
+ $Id: apsBinding.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _APS_BINDING_H
+#define _APS_BINDING_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+#include <aps.h>
+#include <apsmeBind.h>
+#include <apsMemoryManager.h>
+
+#if defined _BINDING_
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define ACTIVE_BINDING_ENTRY_STATUS APS_INVALID_BINDING_STATUS
+#define ACTIVATE_BINDING_ENTRY(entry) \
+ (entry)->confirm.status = ACTIVE_BINDING_ENTRY_STATUS
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Size of the binding table. */
+typedef uint8_t ApsBindingTableSize_t;
+/** Type of a binding table index. */
+typedef ApsBindingTableSize_t ApsBindIndex_t;
+
+/** Type of the binding table. */
+typedef struct _ApsBindingTable_t
+{
+ /* Total amount of binding entries. */
+ ApsBindingTableSize_t size;
+ /* Array of binding entries. */
+ ApsBindingEntry_t *entry;
+} ApsBindingTable_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Reset the binding table and initialize it.
+
+ \param[in] powerFailureControl - stack restoring after power failure control bitfield;
+ affects on initialization procedure.
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsResetBindingTable(const NWK_PowerFailureControl_t powerFailureControl);
+
+/**************************************************************************//**
+ \brief Allocate a place in the binding table for new entry.
+
+ \param[in] req - pointer to request's parameters: source and destination
+ addresses, cluster identifier and etc. See APS_BindReq_t.
+ \return Pointer to new binding entry or NULL.
+ ******************************************************************************/
+APS_PRIVATE ApsBindingEntry_t* apsAllocBindingEntry(APS_BindReq_t *const req);
+
+/**************************************************************************//**
+ \brief Free allocated binding entry.
+
+ \param[in] entry - pointer to valid entry in the binding table.
+
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsFreeBindingEntry(ApsBindingEntry_t *const entry);
+
+/**************************************************************************//**
+ \brief Get pointer to next binding entry.
+
+ \code Example:
+ ApsBindingEntry_t *entry = NULL;
+
+ while (NULL != (entry = apsNextBind(entry, cluster, endpoint, addr)))
+ {
+ if (APS_GROUP_ADDRES == entry->dstAddrMode)
+ if (dstGroup == entry->dst.group)
+ // send message to group
+ ...
+ }
+ \endcode
+
+ \param[in] entry - pointer to previous binding entry
+ or NULL if it's initial call.
+ \param[in] clusterId - cluster identifier of next bind link.
+ \param[in] endpoint - endpoint number of next binding entry.
+ \param[in] extAddr - pointer to source IEEE address of next entry.
+
+ \return if next binding entry is found then return valid entry pointer
+ otherwise return NULL.
+ ******************************************************************************/
+APS_PRIVATE ApsBindingEntry_t* apsNextBind(ApsBindingEntry_t *entry,
+ const ClusterId_t clusterId, const Endpoint_t endpoint,
+ const ExtAddr_t *const extAddr);
+
+/**************************************************************************//**
+ \brief Find entry by bind request in the binding table.
+
+ This function initializes the status field to APS_SUCCESS_STATUS
+ if entry is found otherwise it writes APS_INVALID_PAREMETER_STATUS.
+
+ \param[in] req - bind or unbind request's parameters.
+ \parap[in] errorStatus - return this status if an entry is not found.
+
+ \return Pointer to an entry in the binding table or NULL.
+ ******************************************************************************/
+APS_PRIVATE ApsBindingEntry_t* apsFindBindingEntry(APS_BindReq_t *const req,
+ const APS_Status_t errorStatus);
+
+/**************************************************************************//**
+ \brief Is APS already bound or not?
+
+ It always writes APS_SUCCESS_STATUS to the status field
+ of APSME-BIND.confirm.
+
+ \param[in] req - bind or unbind request's parameters.
+
+ \return true is APS is not bound with given parameters otherwise false.
+ ******************************************************************************/
+APS_PRIVATE bool apsIsNotBound(APS_BindReq_t *const req);
+
+/**************************************************************************//**
+ \brief Copy binding information to the binding table.
+
+ \param[in] entry - pointer to an entry in the binding table.
+ \param[in] req - pointer to bind request's parameters.
+
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsCopyBindingInfo(ApsBindingEntry_t *const entry,
+ APS_BindReq_t *const req);
+
+/**************************************************************************//**
+ \brief Check binding to any group from given source endpoint.
+
+ \param[in] clusterId - cluster identifier of group binding link
+ \param[in] srcEndpoint - source endpoint of group binding link.
+
+ \return true if group bind link is found otherwise return false.
+ ******************************************************************************/
+APS_PRIVATE bool apsIsBoundToAnyGroup(const ClusterId_t clusterId,
+ const Endpoint_t srcEndpoint);
+
+/**************************************************************************//**
+ \brief Find bind link and try to send to bound devices.
+
+ \param[in] apsDataReq - pointer to initial APSDE-DATA.request's parameters.
+ \param[in] buffer - allocated buffer for internal transmission parameters.
+
+ \return APS_SUCCESS_STATUS if transmission is successfully.
+ ******************************************************************************/
+APS_PRIVATE APS_Status_t apsProcessIndirectDataReq(APS_DataReq_t *const apsDataReq,
+ ApsDataBuffer_t *const buffer);
+
+/**************************************************************************//**
+ \brief Find next bound device and try to send to it.
+
+ \param[in] apsDataReq - pointer to initial APSDE-DATA.request's parameters.
+ \param[in] buffer - allocated buffer for internal transmission parameters.
+
+ \return APS_SUCCESS_STATUS if transmission is successfully.
+ ******************************************************************************/
+APS_PRIVATE APS_Status_t apsSendToNextBoundDevice(APS_DataReq_t *const apsDataReq,
+ ApsDataBuffer_t *const buffer);
+
+#endif /* _BINDING_ */
+#endif /* _APS_BINDING_H */
+/** eof apsBinding.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsCommand.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsCommand.h
new file mode 100644
index 00000000..eb641c57
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsCommand.h
@@ -0,0 +1,185 @@
+/**************************************************************************//**
+ \file apsCommand.h
+
+ \brief Internal interface of APS command transmission.
+
+ \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:
+ 2011-02-19 Max Gekk - Created.
+ Last change:
+ $Id: apsCommand.h 17813 2011-07-04 14:11:12Z dloskutnikov $
+ ******************************************************************************/
+#if !defined _APS_COMMAND_H
+#define _APS_COMMAND_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwk.h>
+#include <apsCommon.h>
+#include <apsFrames.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Returns pointer to command payload */
+#define APS_GET_COMMAND_PAYLOAD(req) \
+ ((req)->service.allocateReq.confirm.nwkDataReq->nsdu)
+/** Returns pointer to NWK_DataReq, associated with command */
+#define APS_GET_ALLOCATED_COMMAND_BUFFER(req) \
+ ((req)->service.allocateReq.confirm.nwkDataReq)
+/** Returns command payload length */
+#define APS_GET_COMMAND_PAYLOAD_LENGTH(req) \
+ ((req)->service.allocateReq.nsduLength)
+
+#ifdef _LINK_SECURITY_
+/** APS command auxiliary header length */
+#define APS_COMMAND_AUXILIARY_HEADER_LENGTH \
+ (SSP_SECURITY_CONTROL_FIELD_LENGTH + SSP_FRAME_COUNTER_FIELD_LENGTH)
+/** APS command security fields size */
+#define APS_COMMAND_SECURITY_FIELDS_SIZE \
+ (APS_COMMAND_AUXILIARY_HEADER_LENGTH + APS_MAX_DATA_FRAME_FOOTER_LENGTH)
+#endif /* _LINK_SECURITY_ */
+
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Indicated command descriptor */
+typedef struct _ApsCommandInd_t
+{
+ /** Pointer to first octet of unaligned source extended address. */
+ const ExtAddr_t *srcExtAddr;
+ /** Pointer to NLDE-DATA.indication parameters of the received command. */
+ NWK_DataInd_t *nwkDataInd;
+ /* Type of key with the received command was secured. */
+ APS_Status_t securityStatus;
+} ApsCommandInd_t;
+
+/* Command identifier values are shown in Table 4.34 of ZigBee spec r19. */
+typedef enum _ApsCommandId_t
+{
+ APS_CMD_MIN_ID = 0x01,
+ APS_CMD_SKKE_1_ID = APS_CMD_MIN_ID,
+ APS_CMD_SKKE_2_ID = 0x02,
+ APS_CMD_SKKE_3_ID = 0x03,
+ APS_CMD_SKKE_4_ID = 0x04,
+ APS_CMD_TRANSPORT_KEY_ID = 0x05,
+ APS_CMD_UPDATE_DEVICE_ID = 0x06,
+ APS_CMD_REMOVE_DEVICE_ID = 0x07,
+ APS_CMD_REQUEST_KEY_ID = 0x08,
+ APS_CMD_SWITCH_KEY_ID = 0x09,
+ APS_CMD_EA_INIT_CHLNG_ID = 0x0a,
+ APS_CMD_EA_RSP_CHLNG_ID = 0x0b,
+ APS_CMD_EA_INIT_MAC_DATA_ID = 0x0c,
+ APS_CMD_EA_RSP_MAC_DATA_ID = 0x0d,
+ APS_CMD_TUNNEL_ID = 0x0e,
+ APS_CMD_MAX_ID = APS_CMD_TUNNEL_ID
+} ApsCommandId_t;
+
+BEGIN_PACK
+typedef struct PACK _ApduCommandBaseHeader_t
+{
+ ApduFrameControlField_t frameControl;
+ uint8_t apsCounter;
+} ApduCommandBaseHeader_t;
+
+typedef struct PACK _ApduCommandHeader_t
+{
+ ApduFrameControlField_t frameControl;
+ uint8_t apsCounter;
+ uint8_t commandId;
+} ApduCommandHeader_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _SECURITY_
+/**************************************************************************//**
+ \brief Initialization of ApsCommandReq_t structure by default values.
+
+ Following fields will be initialized:
+ \li nwkSecurity and apsSecurity to true
+ \li keyIdentifier to SSP_DATA_KEY_ID
+ \li extendedNonce to false
+ \li other fields to zero.
+
+ \param[in] commandReq - pointer to request's parameters to APS command trasmission.
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsSetCommandReqToDefault(ApsCommandReq_t *const commandReq);
+
+/**************************************************************************//**
+ \brief Module reset routine.
+
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsCommandReset(void);
+
+/**************************************************************************//**
+ \brief Prepare command frame header.
+
+ \param[out] header - pointer to memory to place header in.
+ \param[in] commandId - command identifier.
+
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE
+void apsCommandMakeHeader(ApduCommandHeader_t *header, ApsCommandId_t commandId);
+
+/**************************************************************************//**
+ \brief APS Command task handler.
+ ******************************************************************************/
+APS_PRIVATE void apsCommandReqTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Request to allocate memory for APS command and send it.
+
+ \param[in] commandReq - pointer to request's parameters to APS command trasmission.
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsCommandReq(ApsCommandReq_t *const commandReq);
+
+/**************************************************************************//**
+ \brief Process an incoming command frame.
+
+ \param[in] ind - pointer to NWK data indication structure.
+
+ \return True, if memory buffer can be released; false - otherwise.
+ ******************************************************************************/
+APS_PRIVATE bool apsCommandInd(NWK_DataInd_t *ind);
+
+/**************************************************************************//**
+ \brief Handler of decrypted or unsecured incoming commands.
+
+ \param[in] ind - pointer to data indication structure.
+ \param[in] securityStatus - type of key with the transport key command
+ was secured.
+
+ \return True, if memory buffer can be released; false - otherwise.
+ ******************************************************************************/
+bool apsUnsecuredNwkDataIndHandler(NWK_DataInd_t *const ind,
+ const ExtAddr_t *srcExtAddr, const APS_Status_t securityStatus);
+
+/**************************************************************************//**
+ \brief Prepared command transmission routine.
+
+ \param[in] req - command request pointer.
+
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsCommandNwkDataReq(ApsCommandReq_t *const req);
+
+#else
+#define apsCommandReqTaskHandler NULL
+#endif /* _SECURITY_ */
+#endif /* _APS_COMMAND_H */
+/** eof apsCommand.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsConfig.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsConfig.h
new file mode 100644
index 00000000..605ac055
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsConfig.h
@@ -0,0 +1,44 @@
+/**************************************************************************//**
+ \file apsConfig.h
+
+ \brief Configuration constants and definitions of APS layer.
+
+ \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:
+ 2011-07-03 Max Gekk - Created.
+ Last change:
+ $Id: apsConfig.h 17801 2011-07-04 08:55:01Z mgekk $
+******************************************************************************/
+#if !defined _APS_CONFIG_H
+#define _APS_CONFIG_H
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/* Rejection table timeouts counted in 500ms intervals.
+ * So we can use narrow data types. */
+#define APS_DUPLICATE_REJECTION_INTERVAL 512U
+
+#ifdef _APS_FRAGMENTATION_
+ #if defined _CERTIFICATION_
+ #define APS_INTERFRAME_DELAY (10*HAL_APPTIMERINTERVAL)
+ #else
+ #define APS_INTERFRAME_DELAY (HAL_APPTIMERINTERVAL)
+ #endif
+#endif
+
+/* Random delay for retransmission to decrease amount of collisions */
+#define RETRANSMISSION_RANDOM_DELAY_RANGE 0x1ff
+
+#define RETRANSMISSION_DELAY_WITH_NO_PHY_ACK 1000U
+
+#endif /* _APS_CONFIG_H */
+/** eof apsConfig.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsDataManager.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsDataManager.h
new file mode 100644
index 00000000..510a55b0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsDataManager.h
@@ -0,0 +1,164 @@
+/*************************************************************************//**
+ \file apsDataManager.h
+
+ \brief APS Data Manager header file
+
+ \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:
+ 06/06/07 A. Potashov - Created.
+*****************************************************************************/
+
+
+#ifndef _APS_DATAMANAGER_H
+#define _APS_DATAMANAGER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <bcEndian.h>
+#include <aps.h>
+#include <nwk.h>
+#include <appTimer.h>
+#include <apsFrames.h>
+#include <apsMemoryManager.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum _ApsFragmentationState_t
+{
+ APS_FRAG_WAITING_BLOCK_0,
+ APS_FRAG_WAITING_NEXT_BLOCK,
+ APS_FRAG_SENDING_ACK,
+ APS_FRAG_SENDING_LAST_ACK
+} ApsFragmentationState_t;
+
+typedef enum _ApsTransmittedDataHandlerState_t
+{
+ START_DATA_HANDLING_STATE,
+ DATA_DECRYPTION_STATE,
+ SEND_DATA_TO_BOUND_DEVICES_STATE,
+ FINISH_DATA_HANDLING_STATE
+} ApsTransmittedDataHandlerState_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/*****************************************************************************
+ Make a reset of APS Data Manager
+ Parameters: fullReset - reset all internal variables of APS-layer or not.
+ Returns: None
+*****************************************************************************/
+APS_PRIVATE void apsResetDataManager(const bool fullReset);
+
+
+/*****************************************************************************
+ APS Stop Event Handler
+ Parameters: options - options field APS_StopReq value
+ Returns: None
+******************************************************************************/
+APS_PRIVATE void apsStopDataManager(void);
+
+/*****************************************************************************
+ APS Data Manager Process function
+ Parameters: None
+ Returns: None
+*****************************************************************************/
+APS_PRIVATE void apsDataTaskHandler(void);
+
+/*****************************************************************************
+ APS Data Manager apsCounter get function
+ Parameters: None
+ Returns: apsCounter value
+*****************************************************************************/
+APS_PRIVATE uint8_t apsGetApsCounter(void);
+
+/*****************************************************************************
+ Routine for IEEE addressing. NWK address by Extended 64-bit address
+ mapping function.
+ Parameters: extAddr - extended 64-bit IEEE address pointer
+ Returns: valid unicast NWK short address pointer
+ NULL in other case
+*****************************************************************************/
+APS_PRIVATE const ShortAddr_t *apsFindShortByExt(const ExtAddr_t *const extAddr);
+
+APS_PRIVATE void apsMakeNwkDataResp(NWK_DataInd_t *ind);
+
+APS_PRIVATE void apsDmHotReset(void);
+
+/**************************************************************************//***
+ \brief Further processing of frame which have been indicated from NWK,
+ passed initial checkings and optionally was decrypted.
+
+ \param nwkInd - NLDE-DATA.indication primitive pointer.
+ securityStatus - securityStatus field value should be used in
+ APS_DataInd primitive.
+ \return true - if the NWK Data Response needs to be executed for this
+ indication, false - in other case.
+*******************************************************************************/
+APS_PRIVATE bool apsContinueNwkDataIndProcessing(NWK_DataInd_t *nwkDataInd,
+ APS_Status_t securityStatus);
+
+/*****************************************************************************
+ APSDE-DATA.request with Short Addressing Mode process function
+ Parameters: apsDataReq - APS_DataReq will be process
+ nwkDataReqMem - buffer for NWK_DataReq
+ Returns: APS_Status_t - status of operation
+*****************************************************************************/
+APS_PRIVATE APS_Status_t apsProcessShortAddrModeDataReq(APS_DataReq_t *apsDataReq,
+ ApsDataBuffer_t *buffer);
+
+/*****************************************************************************
+ \brief Prepare and call NLDE-DATA.request primitive.
+
+ \param[in] req - pointer to NLDE-DATA.request's parameters.
+ \return None.
+ *****************************************************************************/
+APS_PRIVATE void apsSendNwkDataReq(NWK_DataReq_t *req);
+
+/*****************************************************************************
+ \brief Main APS Handler of NLDE-DATA.confirm.
+
+ \param[in] conf - pointer to NLDE-DATA.confirm's parameters.
+ \return None.
+ *****************************************************************************/
+APS_PRIVATE void apsDataManagerNwkDataConf(NWK_DataConf_t *conf);
+
+/**************************************************************************//**
+ \brief Recalculates transmission timeouts.
+
+ \param transmission radius
+ \return APS Ack timeout
+ ******************************************************************************/
+APS_PRIVATE uint32_t apsCalculateApsAckTimeout(uint8_t radius);
+
+#if defined _SECURITY_ && defined _LINK_SECURITY_
+/*************************************************************************//**
+ \brief Frame encryption is finished
+
+ \param buffer - buffer wich was encrypted
+ \param status - status of operation
+ \return none
+*****************************************************************************/
+APS_PRIVATE void apsEncryptDataFrameConf(ApsDataBuffer_t *buffer, uint8_t* pdu,
+ uint8_t pduLength, uint8_t status);
+
+/*****************************************************************************
+ Indicates that sent frame which was previously encrypted is decrypted.
+ Parameters: buffer - APS memory buffer pointer.
+ Returns: None
+*****************************************************************************/
+APS_PRIVATE void apsDecryptSentFrameConf(ApsDataBuffer_t *buffer);
+#endif /* _SECURITY_ and _LINK_SECURITY_ */
+
+#endif //#ifndef _APSDATAMANAGER_H
+//eof apsDataManager.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsDbg.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsDbg.h
new file mode 100644
index 00000000..c37e86c3
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsDbg.h
@@ -0,0 +1,277 @@
+/**************************************************************************//**
+ \file apsDbg.h
+
+ \brief Constants for APS debugging and tracing.
+
+ \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:
+ 2007-11-09 A. Potashov - Created.
+ 2010-10-21 M. Gekk - Refactoring.
+ Last change:
+ $Id: apsDbg.h 18124 2011-08-02 13:20:14Z mgekk $
+ ******************************************************************************/
+#if !defined _APS_DBG_H
+#define _APS_DBG_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <dbg.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** APS assert code. Range 0x4000 - 0x4FFF. */
+typedef enum _ApsDbgCode_t
+{
+ APSTASKMANAGER_TASKHANDLER_0 = 0x4400,
+
+ APSBINDING_ISVALIDBINDINGPARAMETERS_0 = 0x4410,
+ APSBINDING_ISVALIDBINDINGPARAMETERS_1 = 0x4411,
+ APSBINDING_ISBOUNDTOANYGROUP_0 = 0x4412,
+ APSBINDING_PROCESSINDIRECTDATAREQ_0 = 0x4413,
+ APSBINDING_SENDTONEXTBOUNDDEVICE_0 = 0x4414,
+
+ APSBINDINGTABLE_ALLOCBINDINGENTRY_0 = 0x4420,
+ APSBINDINGTABLE_FREEBINDINGENTRY_0 = 0x4421,
+ APSBINDINGTABLE_FREEBINDINGENTRY_1 = 0x4422,
+ APSBINDINGTABLE_NEXTBIND_0 = 0x4423,
+ APSBINDINGTABLE_NEXTBIND_1 = 0x4424,
+ APSBINDINGTABLE_FINDBINDINGENTRY_0 = 0x4425,
+ APSBINDINGTABLE_FINDBINDINGENTRY_1 = 0x4426,
+ APSBINDINGTABLE_COPYBINDINGINFO_0 = 0x4427,
+ APSBINDINGTABLE_COPYBINDINGINFO_1 = 0x4428,
+ APSBINDINGTABLE_RESETBINDINGTABLE_0 = 0x4429,
+
+ APSGROUP_APSGROUPINDICATION_0 = 0x4430,
+ APSGROUP_APSGROUPINDICATION_1 = 0x4431,
+ APSGROUP_APSGROUPINDICATION_2 = 0x4432,
+
+ APSDATAMANAGER_PROCESSFRAGMENTEDRECEIVE_0 = 0x4440,
+ APSDATAMANAGER_RESETDUPLICATEREJECTIONTABLE_0 = 0x4441,
+ APSDATAMANAGER_DMHOTRESET_0 = 0x4442,
+ APSDATAMANAGER_DMHOTRESET_1 = 0x4443,
+ APSDATAMANAGER_MAKENWKDATARESP_0 = 0x4444,
+ APSDATAMANAGER_APDUACKHANDLER_0 = 0x4445,
+ APSDATAMANAGER_APDUUNICASTHANDLER_0 = 0x4446,
+ APSDATAMANAGER_GETACKBYDATABUFFER_0 = 0x4447,
+ APSDATAMANAGER_GETACKBYDATABUFFER_1 = 0x4448,
+ APSDATAMANAGER_NWKDATACONFPROCESS_0 = 0x4449,
+ APSDATAMANAGER_NWKDATACONFPROCESS_1 = 0x444A,
+ APSDATAMANAGER_NWKDATACONFPROCESS_2 = 0x444B,
+ APSDATAMANAGER_NWKDATACONFPROCESS_3 = 0x444C,
+ APSDATAMANAGER_NWKDATACONFPROCESS_4 = 0x444D,
+ APSDATAMANAGER_NWKDATACONFPROCESS_5 = 0x444E,
+ APSDATAMANAGER_HANDLETRANSMITTEDDATA_0 = 0x444F,
+ APSDATAMANAGER_APSDATAREQPROCESS_0 = 0x4450,
+ APSDATAMANAGER_APSPROCESSSHORTADDRMODEDATAREQ_0 = 0x4451,
+ APSDATAMANAGER_ACKFORFRAGMENTEDRECEIVECONFIRMHANDLER_0 = 0x4452,
+ APSDATAMANAGER_PROCESSFRAGMENTEDRECEIVE_1 = 0x4453,
+
+ APSSTATEMACHINE_RESETREQ_0 = 0x4460,
+ APSSTATEMACHINE_STARTREQ_0 = 0x4461,
+ APSSTATEMACHINE_STOPREQ_0 = 0x4462,
+ APSSTATEMACHINE_PROCESSEVENT_0 = 0x4463,
+ APSSTATEMACHINE_TASKHANDLER_0 = 0x4464,
+ APSSTATEMACHINE_TASKHANDLER_1 = 0x4465,
+ APSSTATEMACHINE_NWKRESETCONF_0 = 0x4466,
+ APSSTATEMACHINE_NWKRESETCONF_1 = 0x4467,
+ APSSTATEMACHINE_NWKRESETCONF_2 = 0x4468,
+ APSSTATEMACHINE_NWKRESETCONF_3 = 0x4469,
+ APSSTATEMACHINE_PROCESSSTARTEVENT_0 = 0x446A,
+ APSSTATEMACHINE_APSSTOPCONF_0 = 0x446B,
+ APSSTATEMACHINE_COMPLETESTOP_0 = 0x446C,
+ APSSTATEMACHINE_COMPLETESTOP_1 = 0x446D,
+ APSSTATEMACHINE_COMPLETESTOP_2 = 0x446E,
+
+ APSGROUPTABLE_APSADDGROUPREQ0 = 0x4470,
+ APSGROUPTABLE_APSREMOVEGROUPREQ0 = 0x4471,
+ APSGROUPTABLE_APSREMOVEALLGROUPSREQ0 = 0x4472,
+
+ APSMEMORYMANAGER_GETBUFFER_0 = 0x4480,
+ APSMEMORYMANAGER_GETBUFFER_1 = 0x4481,
+ APSMEMORYMANAGER_FREEBUFFER_0 = 0x4482,
+ APSMEMORYMANAGER_FREEBUFFER_1 = 0x4483,
+ APSMEMORYMANAGER_FREEBUFFER_2 = 0x4484,
+ APSMEMORYMANAGER_FREEBUFFER_3 = 0x4485,
+ APSMEMORYMANAGER_FREESECBUFFER_0 = 0x4486,
+ APSMEMORYMANAGER_APSFREEBUFFER_0 = 0x4487,
+ APSMEMORYMANAGER_APSGETSECBUFFER_0 = 0x4488,
+
+ APSSECURITYMANAGER_DECRYPTEDCOMMANDRECEIVEPROCESS_0 = 0x4490,
+ APSSMEKREQ_SMEKREQNWKDATAIND_0 = 0x44A0,
+
+ APSSMEKRESP_EKRESPSKKENWKCONF_0 = 0x44B0,
+ APSSMEKRESP_ESTABLISHKEYRESP_0 = 0x44B1,
+
+ APSSMSKR_SENDSKC_0 = 0x44C0,
+ APSSMTKR_SENDTKC_0 = 0x44D0,
+
+ APSSMSSP_SMSENDENCRYPTCONF_0 = 0x4500,
+ APSSMSSP_SMSSPPROCESS_0 = 0x4501,
+ APSSMSSP_SMSSPPROCESS_1 = 0x4502,
+ APSSMSSP_SMDECRYPTSENTFRAMECONF_0 = 0x4503,
+ APSSMSSP_DECRYPTANYFRAME_0 = 0x4504,
+
+ APSTUNNEL_NWKDATAIND_0 = 0x4510,
+ APSTUNNEL_SENDEMBEDDEDCOMMANDCONF_0 = 0x4511,
+ APSTUNNEL_TRANSPORTKEYREQ_0 = 0x4512,
+ APSTUNNEL_TRANSPORTKEYREQ_1 = 0x4513,
+
+ APSKEYPAIRSET_EXTRACTOUTSECCOUNTER_0 = 0x4520,
+ APSKEYPAIRSET_GETINFRAMECOUNTER_0 = 0x4521,
+ APSKEYPAIRSET_ALLOCKEYPAIR_0 = 0x4522,
+ APSKEYPAIRSET_SETOUTFRAMECOUNTER_0 = 0x4523,
+ APSKEYPAIRSET_SETINFRAMECOUNTER_0 = 0x4524,
+ APSKEYPAIRSET_GETKEYPAIRDEVICEADDRESS_0 = 0x4525,
+
+ APSINTERPAN_INTRPDATAREQ_0 = 0x4540,
+ APSINTERPAN_INTRPDATAREQ_1 = 0x4541,
+ APSINTERPAN_INTRPDATAREQ_2 = 0x4542,
+ APSINTERPAN_INTERPANMACDATACONF_0 = 0x4543,
+ APSINTERPAN_INTERPANMACDATACONF_1 = 0x4544,
+ APSINTERPAN_NWKINTRPDATAIND_0 = 0x4545,
+
+ APSAUTHENTICATE_AUTHENTICATEREQ_0 = 0x4550,
+ APSAUTHENTICATE_AUTHENTICATECONF_0 = 0x4551,
+ APSAUTHENTICATE_AUTHREQTASKHANDLER_0 = 0x4552,
+ APSAUTHENTICATE_APSAUTHREQTASKHANDLER_0 = 0x4552,
+ APSAUTHENTICATE_ALLOCNWKDATACONF_0 = 0x4553,
+ APSAUTHENTICATE_ALLOCNWKDATACONF_1 = 0x4554,
+ APSAUTHENTICATE_AUTHCHALLENGENWKCONF_0 = 0x4555,
+ APSAUTHENTICATE_AUTHINITIATORMACTAG2CONF_0 = 0x4556,
+ APSAUTHENTICATE_ALLOCMACANDDATAFRAMECONF_0 = 0x4557,
+ APSAUTHENTICATE_ALLOCMACANDDATAFRAMECONF_1 = 0x4558,
+ APSAUTHENTICATE_AUTHMACANDDATANWKCONF_0 = 0x4559,
+ APSAUTHENTICATE_APSAUTHRESPONDERMACTAG2CONF_0 = 0x455A,
+ APSAUTHENTICATE_STARTAUTHTIMER_0 = 0x455B,
+ APSAUTHENTICATE_AUTHENTICATEREQ_1 = 0x455C,
+
+ APSCOMMAND_COMMANDREQ_0 = 0x4560,
+ APSCOMMAND_COMMANDREQTASKHANDLER_0 = 0x4561,
+ APSCOMMAND_COMMANDREQTASKHANDLER_2 = 0x4562,
+ APSCOMMAND_COMMANDALLOCDATACONF_0 = 0x4563,
+ APSCOMMAND_COMMANDALLOCDATACONF_1 = 0x4564,
+ APSCOMMAND_COMMANDENCRYPTCONF_0 = 0x4565,
+ APSCOMMAND_COMMANDENCRYPTCONF_1 = 0x4566,
+ APSCOMMAND_COMMANDENCRYPTCONF_2 = 0x4567,
+ APSCOMMAND_NWKDATAREQ_0 = 0x4568,
+ APSCOMMAND_NWKDATAREQ_1 = 0x4569,
+ APSCOMMAND_NWKDATACONF_0 = 0x456A,
+ APSCOMMAND_UNSECUREDNWKDATAINDHANDLER_0 = 0x456B,
+
+ APSUPDATEDEVICE_UPDATEDEVICEREQ_0 = 0x4570,
+ APSUPDATEDEVICE_PREPAREUPDATEDEVICECOMMAND_0 = 0x4571,
+ APSUPDATEDEVICE_CONFIRMUPDATEDEVICECOMMAND_0 = 0x4572,
+ APSUPDATEDEVICE_UPDATEDEVICEIND_0 = 0x4573,
+
+ APSREMOVEDEVICE_REMOVEDEVICEREQ_0 = 0x4580,
+ APSREMOVEDEVICE_REMOVEDEVICEPREPARE_0 = 0x4581,
+ APSREMOVEDEVICE_REMOVEDEVICECONF_0 = 0x4582,
+ APSREMOVEDEVICE_REMOVEDEVICEIND_0 = 0x4583,
+
+ APSSWITCHKEY_SWITCHKEYREQ_0 = 0x4590,
+ APSSWITCHKEY_SWITCHKEYPREPARE_0 = 0x4591,
+ APSSWITCHKEY_SWITCHKEYCONF_0 = 0x4592,
+ APSSWITCHKEY_SWITCHKEYIND_0 = 0x4593,
+
+ APSSKKE_SKKEIND_0 = 0x45A0,
+ APSSKKE_SKKEIND_1 = 0x45A1,
+ APSSKKE_FORWARDSKKECOMMAND_0 = 0x45A2,
+ APSSKKE_SKKEFORWARDCONF_0 = 0x45A3,
+ APSSKKE_INITSKKEELEM_0 = 0x45A4,
+ APSSKKE_SETSKKETTL_0 = 0x45A5,
+ APSSKKE_SETSKKESTATE_0 = 0x45A6,
+ APSSKKE_PREPARESKKECOMMAND_0 = 0x45A7,
+ APSSKKE_PREPARESKKECOMMAND_1 = 0x45A8,
+ APSSKKE_SKKENWKDATACONF_0 = 0x45A9,
+ APSSKKE_FINDSKKEELEMBYNWKIND_0 = 0x45AA,
+
+ APSSKKEINITIATOR_ESTABLISHKEYREQ_0 = 0x45B0,
+ APSSKKEINITIATOR_ISKKECONF_0 = 0x45B1,
+ APSSKKEINITIATOR_SKKEINITIATORTASKHANDLER_0 = 0x45B2,
+ APSSKKEINITIATOR_ISKKETASKHANDLER_1 = 0x45B3,
+ APSSKKEINITIATOR_ISKKE1ALLOCFRAMECONF_0 = 0x45B4,
+ APSSKKEINITIATOR_ISKKE1NWKCONF_0 = 0x45B5,
+ APSSKKEINITIATOR_INITIATORSKKE2IND_1 = 0x45B6,
+ APSSKKEINITIATOR_ISKKECALCPARAMSCONF_0 = 0x45B7,
+ APSSKKEINITIATOR_ISKKE3ALLOCFRAMECONF_0 = 0x45B8,
+ APSSKKEINITIATOR_ISKKE3NWKCONF_0 = 0x45B9,
+ APSSKKEINITIATOR_ISKKE4IND_0 = 0x45BA,
+
+ APSSKKERESPONDER_RSKKE1IND_0 = 0x45C0,
+ APSSKKERESPONDER_ESTABLISHKEYRESP_0 = 0x45C1,
+ APSSKKERESPONDER_SKKERESPONDERTASKHANDLER_0 = 0x45C2,
+ APSSKKERESPONDER_RSKKECALCPARAMSCONF_0 = 0x45C3,
+ APSSKKERESPONDER_RSKKE2ALLOCFRAMECONF_0 = 0x45C4,
+ APSSKKERESPONDER_RSKKE2NWKCONF_0 = 0x45C5,
+ APSSKKERESPONDER_RSKKE4ALLOCFRAMECONF_0 = 0x45C6,
+ APSSKKERESPONDER_RSKKE4NWKCONF_0 = 0x45C7,
+ APSSKKERESPONDER_RSKKECONF_0 = 0x45C8,
+
+ APSREQUESTKEY_REQUESTKEYREQ_0 = 0x45F0,
+ APSREQUESTKEY_PREPAREREQUESTKEYCOMMAND_0 = 0x45F1,
+ APSREQUESTKEY_CONFIRMREQUESTKEYCOMMAND_0 = 0x45F2,
+ APSREQUESTKEY_REQUESTEDKEYRECEIVED_0 = 0x45F3,
+ APSREQUESTKEY_REQUESTKEYIND_0 = 0x45F4,
+ APSREQUESTKEY_REQUESTKEYCONF_0 = 0x45F5,
+
+ APSTRANSPORTKEY_TRANSPORTKEYREQ_0 = 0x4600,
+ APSTRANSPORTKEY_TRANSPORTKEYTASKHANDLER_0 = 0x4601,
+ APSTRANSPORTKEY_TRANSPORTKEYTASKHANDLER_1 = 0x4602,
+ APSTRANSPORTKEY_TRANSPORTKEYTASKHANDLER_2 = 0x4603,
+ APSTRANSPORTKEY_TRANSPORTKEYTASKHANDLER_3 = 0x4604,
+ APSTRANSPORTKEY_TRANSPORTKEYTASKHANDLER_4 = 0x4605,
+ APSTRANSPORTKEY_TRANSPORTKEYCONF_0 = 0x4606,
+ APSTRANSPORTKEY_CONFIRMTRANSPORTKEYCOMMAND_0 = 0x4607,
+ APSTRANSPORTKEY_TRANSPORTKEYIND_0 = 0x4608,
+ APSTRANSPORTKEY_FORWARDKEYTOCHILD_0 = 0x4609,
+
+ APSTRANSPORTAPPKEY_CHECKTRANSPORTAPPKEYREQ_0 = 0x4610,
+ APSTRANSPORTAPPKEY_CHECKTRANSPORTAPPKEYREQ_1 = 0x4611,
+ APSTRANSPORTAPPKEY_CHECKTRANSPORTAPPKEYREQ_2 = 0x4612,
+ APSTRANSPORTAPPKEY_TRANSPORTAPPKEYCOMMAND_0 = 0x4613,
+ APSTRANSPORTAPPKEY_PREPARETRANSPORTAPPKEYCOMMAND_0 = 0x4614,
+
+ APSTRANSPORTNWKKEY_CHECKTRANSPORTNWKKEYREQ_0 = 0x4620,
+ APSTRANSPORTNWKKEY_CHECKTRANSPORTNWKKEYREQ_1 = 0x4621,
+ APSTRANSPORTNWKKEY_TRANSPORTNWKKEYCOMMAND_0 = 0x4622,
+ APSTRANSPORTNWKKEY_PREPARETRANSPORTNWKKEYCOMMAND_0 = 0x4623,
+ APSTRANSPORTNWKKEY_PREPARETUNNELCOMMAND_0 = 0x4624,
+ APSTRANSPORTNWKKEY_PREPARETUNNELCOMMAND_1 = 0x4625,
+ APSTRANSPORTNWKKEY_TUNNELIND_0 = 0x4626,
+ APSTRANSPORTNWKKEY_SENDEMBEDDEDCOMMANDCONF_0 = 0x4627,
+
+ APSTRANSPORTTRUSTKEY_CHECKTRANSPORTTRUSTKEYREQ_0 = 0x4630,
+ APSTRANSPORTTRUSTKEY_CHECKTRANSPORTTRUSTKEYREQ_1 = 0x4631,
+ APSTRANSPORTTRUSTKEY_CHECKTRANSPORTTRUSTKEYREQ_2 = 0x4632,
+ APSTRANSPORTTRUSTKEY_TRANSPORTTRUSTKEYCOMMAND_0 = 0x4633,
+ APSTRANSPORTTRUSTKEY_PREPARETRANSPORTTRUSTKEYCOMMAND_0 = 0x4634,
+ APSTRANSPORTTRUSTKEY_TRANSPORTTRUSTKEYTOCHILDCONF_0 = 0x4635,
+
+ APSREJECTDUPLICATE_RESETDUPLICATEREJECTIONTABLE_0 = 0x4640
+
+} ApsDbgCode_t;
+
+/** Values of system log messages */
+typedef enum _ApsLogCodeId_t
+{
+ LOG_APS_RESET_REQ = 0x00,
+ LOG_APS_NWK_DATA_IND = 0x01,
+ LOG_APS_NWK_DATA_CONF_SUCCESS = 0x02,
+ LOG_APS_NWK_DATA_CONF_FAIL = 0x03,
+ LOG_APS_SEND_NWK_DATA_REQ = 0x04,
+ LOG_APS_SEND_ACK_REQ = 0x05,
+ LOG_APS_MAKE_RETRANSMISSION = 0x06
+} ApsLogCodeId_t;
+
+#endif /* _APS_DBG_H */
+/** eof apsDbg.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsEndpoint.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsEndpoint.h
new file mode 100644
index 00000000..a9c8ef64
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsEndpoint.h
@@ -0,0 +1,47 @@
+/**************************************************************************//**
+ \file apsEndpoint.h
+
+ \brief Private interface.of APS endpoints.
+
+ \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:
+ 2010-10-22 Max Gekk - Created.
+ Last change:
+ $Id: apsEndpoint.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _APS_ENDPOINT_H
+#define _APS_ENDPOINT_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsdeEndpoint.h>
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/******************************************************************************
+ \brief Search the registered endpoint descriptor.
+
+ \param[in] endpoint - valid endpoint number.
+
+ \return Valid endpoint descriptor pointer if one found NULL - at other case.
+ ******************************************************************************/
+APS_PRIVATE
+APS_EndpointReg_t* apsFindEndpoint(const Endpoint_t endpoint);
+
+/******************************************************************************
+ \brief Reset queue of endpoints.
+ ******************************************************************************/
+APS_PRIVATE void apsResetEndpoints(void);
+
+#endif /* _APS_ENDPOINT_H */
+/** eof apsEndpoint.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsFrames.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsFrames.h
new file mode 100644
index 00000000..ab19c903
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsFrames.h
@@ -0,0 +1,188 @@
+/*****************************************************************************
+ \file apsFrames.h
+
+ \brief
+
+ \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:
+ 16.04.2010 I.Vagulin - Created
+******************************************************************************/
+
+
+#ifndef _APSFRAMES_H_
+#define _APSFRAMES_H_
+
+#include <bcEndian.h>
+#include <dbg.h>
+#include <nwk.h>
+#include <apsCommon.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define APS_SM_KEY_SIZE 16
+
+#define APS_BROADCAST_MAC_RX_ON_SHORT_ADDRESS 0xfffd
+
+//APDU Frame Format
+
+//Frame control field - ApduFrameControlField_t
+
+//Frame Type subfield values
+#define APDU_FRAME_CONTROL_FIELD_DATA_FRAME_TYPE 0x00
+#define APDU_FRAME_CONTROL_FIELD_COMMAND_FRAME_TYPE 0x01
+#define APDU_FRAME_CONTROL_FIELD_ACK_FRAME_TYPE 0x02
+#define APDU_FRAME_CONTROL_FIELD_RESERVED_FRAME_TYPE 0x03
+
+//Delivery Mode subfield values
+#define APDU_FRAME_CONTROL_FIELD_UNICAST_MODE 0x00
+#define APDU_FRAME_CONTROL_FIELD_RESERVED_MODE 0x01
+#define APDU_FRAME_CONTROL_FIELD_BROADCAST_MODE 0x02
+#define APDU_FRAME_CONTROL_FIELD_GROUP_ADDRESSING_MODE 0x03
+
+//Ack Format subfiel values
+#define APDU_FRAME_CONTROL_FIELD_DATA_ACK_FORMAT 0x00
+#define APDU_FRAME_CONTROL_FIELD_COMMAND_ACK_FORMAT 0x01
+
+//Security subfield values
+#define APDU_FRAME_CONTROL_FIELD_NOTSECURED 0x00
+#define APDU_FRAME_CONTROL_FIELD_SECURED 0x01
+
+//Acknowledgement Request subfield values
+#define APDU_FRAME_CONTROL_FIELD_NOACK 0x00
+#define APDU_FRAME_CONTROL_FIELD_ACK 0x01
+
+//Extended Header Present subfield values
+#define APDU_FRAME_CONTROL_FIELD_EXTENDED_HEADER_NOT_PRESENT 0x00
+#define APDU_FRAME_CONTROL_FIELD_EXTENDED_HEADER_PRESENT 0x01
+
+
+//Extended Frame Control field - ApduExtendedFrameControlField_t
+//Fragmentation subfield values
+#define APDU_EXT_FRAME_CONTROL_FIELD_FRAGMENTATION_NOT_FRAGMENTED 0x00
+#define APDU_EXT_FRAME_CONTROL_FIELD_FRAGMENTATION_FIRST_FRAGMENT 0x01
+#define APDU_EXT_FRAME_CONTROL_FIELD_FRAGMENTATION_FRAGMENT 0x02
+#define APDU_EXT_FRAME_CONTROL_FIELD_FRAGMENTATION_RESERVED 0x03
+
+/* Maximum length of auxilary header for aps commands. */
+#define APS_MAX_AUXILIARY_HEADER_LENGTH 14U
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+//APDU Frame Format
+//Frame control field
+BEGIN_PACK
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(6, (
+ uint8_t frameType :2,
+ uint8_t deliveryMode :2,
+ uint8_t ackFormat :1,
+ uint8_t security :1,
+ uint8_t ackRequest :1,
+ uint8_t extendedHeaderPresent :1
+ ))
+} ApduFrameControlField_t;
+
+//Extended Frame Control field
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(2, (
+ uint8_t fragmentation :2,
+ uint8_t reserved :6
+ ))
+} ApduExtendedFrameControlField_t;
+
+typedef struct PACK
+{
+ ApduExtendedFrameControlField_t extendedFrameControl;
+ uint8_t blockNumber;
+ uint8_t ackBitfield;
+} ApduFragmentedAckExtendedHeaderSubframe_t;
+
+typedef struct PACK
+{
+ ApduExtendedFrameControlField_t extendedFrameControl;
+} ApduNotFragmentedAckExtendedHeaderSubframe_t;
+
+typedef struct PACK
+{
+ ApduExtendedFrameControlField_t extendedFrameControl;
+ uint8_t blockNumber;
+} ApduFragmentedDataExtendedHeaderSubframe_t;
+
+typedef struct PACK
+{
+ ApduExtendedFrameControlField_t extendedFrameControl;
+} ApduNotFragmentedDataExtendedHeaderSubframe_t;
+
+typedef struct PACK
+{
+ ApduFrameControlField_t frameControl;
+ uint8_t dstEndpoint;
+ uint16_t clusterId;
+ uint16_t profileId;
+ uint8_t srcEndpoint;
+ uint8_t apsCounter;
+ union PACK
+ {
+ ApduNotFragmentedDataExtendedHeaderSubframe_t notFragmentedExtHeaderSubframe;
+ ApduFragmentedDataExtendedHeaderSubframe_t fragmentedExtHeaderSubframe; //Extended header subframe
+ };
+} ApduDataFrameNongroup_t;
+
+typedef struct PACK
+{
+ ApduFrameControlField_t frameControl;
+ uint16_t groupAddress;
+ uint16_t clusterId;
+ uint16_t profileId;
+ uint8_t srcEndpoint;
+ uint8_t apsCounter;
+} ApduDataFrameGroup_t;
+
+typedef struct PACK
+{
+ ApduFrameControlField_t frameControl; //Frame Control field
+ uint8_t dstEndpoint; //Destination endpoint
+ uint16_t clusterId; //Cluster identifier
+ uint16_t profileId; //Profile identifier
+ uint8_t srcEndpoint; //Source endpoint
+ uint8_t apsCounter; //APS counter
+ union PACK
+ {
+ ApduNotFragmentedAckExtendedHeaderSubframe_t notFragmentedExtHeaderSubframe;
+ ApduFragmentedAckExtendedHeaderSubframe_t fragmentedExtHeaderSubframe; //Extended header subframe
+ };
+} ApduAcknowledgementFrame_t;
+
+typedef struct PACK
+{
+ ApduFrameControlField_t frameControl; //Frame Control field
+ uint8_t apsCounter; //APS counter
+} ApduCommandAcknowledgementFrame_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+#ifdef _LINK_SECURITY_
+/***************************************************************************//**
+ \brief Returns APS frame header size
+
+ \param[in] apdu - pointer to frame
+
+ \return size of APS frame header
+*******************************************************************************/
+APS_PRIVATE uint8_t apsGetHeaderSize(uint8_t *apdu);
+#endif /* _LINK_SECURITY_ */
+
+#endif /* _APSFRAMES_H_ */
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsGroup.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsGroup.h
new file mode 100644
index 00000000..022e23c6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsGroup.h
@@ -0,0 +1,66 @@
+/**************************************************************************//**
+ \file apsGroup.h
+
+ \brief Interface of APS Multicast Transmission.
+
+ \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:
+ 2010-10-12 Max Gekk - Created.
+ Last change:
+ $Id: apsGroup.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _APS_GROUP_H
+#define _APS_GROUP_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <aps.h>
+#include <apsMemoryManager.h>
+
+#if defined _APS_MULTICAST_
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/*****************************************************************************
+ \brief Group indication (APSDE-DATA.indication) to all group members.
+
+ \param[in] apsDataInd - pointer to APSDE-DATA.indication's parameters.
+ \return None.
+ *****************************************************************************/
+APS_PRIVATE void apsGroupIndication(APS_DataInd_t *const apsDataInd);
+
+/*****************************************************************************
+ \brief Process multicast packets from NWK layer.
+
+ \param[in] nwkDataInd - pointer to NLDE-DATA.indication parameters.
+ \param[in] securityStatus - kind of used security.
+
+ \return true - response for NWK_DataInd requered,
+ false - response for NWK_DataInd not required
+ and will be made in the future.
+ *****************************************************************************/
+APS_PRIVATE bool apsGroupPacketHandler(const NWK_DataInd_t *const nwkDataInd,
+ const APS_Status_t securityStatus);
+
+/*****************************************************************************
+ \brief Process APSDE-DATA.request with Group Addressing Mode
+
+ \param[in] apsDataReq - pointer to APSDE-DATA.request's parameters
+ \param[in] apsBuffer - pointer to APS buffer with NLDE-DATA.request.
+
+ \return APS_SUCCESS_STATUS
+ *****************************************************************************/
+APS_PRIVATE APS_Status_t apsProcessGroupAddrModeDataReq(APS_DataReq_t *apsDataReq,
+ ApsDataBuffer_t *apsBuffer);
+
+#endif /* _APS_MULTICAST_ */
+#endif /* _APS_GROUP_H */
+/** eof apsGroup.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsKeyPairSet.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsKeyPairSet.h
new file mode 100644
index 00000000..dce1a337
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsKeyPairSet.h
@@ -0,0 +1,116 @@
+/**************************************************************************//**
+ \file apsKeyPairSet.h
+
+ \brief Private interface of APS Key-Pair Set.
+
+ \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:
+ 2010-11-01 Max Gekk - Created.
+ Last change:
+ $Id: apsKeyPairSet.h 17813 2011-07-04 14:11:12Z dloskutnikov $
+ ******************************************************************************/
+#if !defined _APS_KEY_PAIR_SET_H
+#define _APS_KEY_PAIR_SET_H
+
+#if defined _LINK_SECURITY_
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsCryptoKeys.h>
+#include <sspCommon.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/* Size of APS security counter in bytes */
+#define APS_SECURITY_COUNTER_SIZE 4U
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/* Type of outgoing frame counter higher bytes. */
+typedef uint16_t ApsOutFrameCounterTop_t;
+/* Type of outgoing frame counter lower bytes. */
+typedef uint16_t ApsOutFrameCounterLow_t;
+
+/** Outgoing security frame counter handle type. */
+BEGIN_PACK
+typedef union PACK
+{
+ ApsOutFrameCounter_t value;
+ struct
+ {
+ LITTLE_ENDIAN_OCTET(2,
+ (ApsOutFrameCounterLow_t low,
+ ApsOutFrameCounterTop_t top))
+ } part;
+} ApsOutFrameCounterHandle_t;
+END_PACK
+
+/* Type of key-pair descriptor. */
+typedef struct _ApsKeyPairDescriptor_t
+{
+ /** A flag indicating that key-pair is used. */
+ bool busy;
+ /** A flag indicating that key-pair is authorized. */
+ bool auth;
+ /* Outgoing frame counter higher bytes. */
+ ApsOutFrameCounterTop_t outCounterTop;
+ /* Identifies the address of the entity with which this key-pair is shared. */
+ ExtAddr_t deviceAddress;
+ /* The actual value of the initial key:
+ master key for High Security and preinstalled link key for SE Security. */
+ uint8_t initialKey[SECURITY_KEY_SIZE];
+ /* The actual value of the link key. */
+ uint8_t linkKey[SECURITY_KEY_SIZE];
+} ApsKeyPairDescriptor_t;
+
+/* Type of incoming and outgoing counters. */
+typedef struct _ApsKeyCounters_t
+{
+ /* Outgoing frame counter lower bytes. */
+ ApsOutFrameCounterLow_t outCounterLow;
+ /* Incoming frame counter value corresponding to DeviceAddress. */
+ ApsInFrameCounter_t in;
+} ApsKeyCounters_t;
+
+/* Type of size of APS Key-Pair Set. */
+typedef uint8_t ApsKeyPairAmount_t;
+/* Type of Key-Pair Index. */
+typedef ApsKeyPairAmount_t ApsKeyPairIndex_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Get current value of outgoing frame counter and increment it.
+
+ \param[in] keyHandle - valid key handle.
+
+ \return Pointer to current value of outgoing frame counter.
+ ******************************************************************************/
+APS_PRIVATE
+ApsOutFrameCounter_t apsGetUpdatedOutFrameCounter(const APS_KeyHandle_t keyHandle);
+
+/**************************************************************************//**
+ \brief Get current value of incoming frame counter.
+
+ \param[in] handle - valid key handle.
+
+ \return Pointer to current value of incoming frame counter.
+ ******************************************************************************/
+APS_PRIVATE
+ApsInFrameCounter_t apsGetInFrameCounter(const APS_KeyHandle_t handle);
+
+#endif /* _LINK_SECURITY_ */
+
+#endif /* _APS_KEY_PAIR_SET_H */
+/** eof apsKeyPairSet.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsMemoryManager.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsMemoryManager.h
new file mode 100644
index 00000000..6206ca22
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsMemoryManager.h
@@ -0,0 +1,340 @@
+/*************************************************************************//**
+ \file apsMemoryManager.h
+
+ \brief The header file describes APS memory manager primitive.
+
+ \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
+
+*****************************************************************************/
+
+#ifndef APSMEMORYMANAGER_H_
+#define APSMEMORYMANAGER_H_
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <queue.h>
+#include <aps.h>
+#include <nwk.h>
+#include <appTimer.h>
+#include <apsmeBind.h>
+#include <apsFrames.h>
+#include <sspSfp.h>
+#include <sspAuthentic.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum
+{
+ APS_DM_DATA_BUFFER_TYPE,
+ APS_DM_ACK_DATA_BUFFER_TYPE,
+ APS_SM_FREE_BUFFER_TYPE,
+ APS_SM_AUR_SSP_AUTH_BUFFER_TYPE,
+ APS_SM_AUR_CHALLENGE_COMMAND_BUFFER_TYPE,
+ APS_SM_AUR_MAC_DATA_COMMAND_TYPE,
+ APS_SM_AUI_SSP_AUTH_BUFFER_TYPE,
+ APS_SM_AUI_CHALLENGE_COMMAND_BUFFER_TYPE,
+ APS_SM_AUI_MAC_COMMAND_BUFFER_TYPE,
+ APS_SM_SSPD_BUFFER_TYPE,
+ APS_SM_UDR_COMMAND_BUFFER_TYPE, //UpdateDevice command
+ APS_SM_RDR_COMMAND_BUFFER_TYPE, //RemoveDevice command
+ APS_SM_RKR_COMMAND_BUFFER_TYPE, //RequestKey command
+ APS_SM_SKR_COMMAND_BUFFER_TYPE, //RequestKey command
+ APS_SM_TKR_COMMAND_BUFFER_TYPE, //TransportKey command
+ APS_SM_TKI_COMMAND_BUFFER_TYPE,
+ APS_SM_COMMAND_IND_BUFFER_TYPE,
+ APS_TUNNEL_COMMAND_BUFFER_TYPE
+} ApsBufferType_t;
+
+typedef enum {
+ APS_DEFAULT_STATE,
+ APS_NLDE_DATA_CONF_WAIT_STATE,
+ APS_ACK_WAIT_STATE,
+ APS_ACK_RECEIVED_STATE,
+ APS_RETRANSMISSION_STATE,
+ APS_TIMEOUT_STATE,
+} ApsDataDescriptorState_t ;
+
+typedef enum
+{
+ APS_NLDE_DATA_REQ_BUFFER_TYPE, //Request for data transmission without ack waiting
+ APS_NLDE_DATA_REQ_WITH_ACK_BUFFER_TYPE, //Request for data transmission with ack waiting
+ APS_NLDE_DATA_REQ_ACK_BUFFER_TYPE, //Request for APS ACK transmission
+ APS_NLDE_DATA_REQ_BLOCK_BUFFER_TYPE, //Request for part of fragmented data transmission
+} ApsNldeDataReqType_t;
+
+typedef struct
+{
+#ifdef _SECURITY_
+#ifdef _LINK_SECURITY_
+ uint8_t headerLength;
+ QueueElement_t queueElement;
+ APS_Status_t securityStatus;
+ APS_KeyHandle_t keyHandle;
+#endif // _LINK_SECURITY_
+#endif //_SECURITY_
+
+ uint8_t busy:1;
+ ApsNldeDataReqType_t entryType:7;
+ ApsDataDescriptorState_t state:4;
+ //if request with ack requested data frame then it is a retries counter
+ uint8_t retriesCounter:4;
+
+ NWK_DataReq_t nwkDataReq; //NLDE-DATA.request primitive
+
+#ifdef _BINDING_
+ ApsBindingEntry_t *bindEntry;
+#endif
+} ApsDataDescriptor_t;
+
+typedef struct
+{
+ APS_DataReq_t *link; // request pointer
+ ApsBufferType_t type;
+ uint32_t timeout;
+ ApsDataDescriptor_t dataDescriptor;
+} ApsDataBuffer_t ;
+
+/*
+ APS Acknowledge buffer declaration
+*/
+typedef struct
+{
+ /* Current buffer status */
+ bool busy;
+ /* Determines type of encryption to be used for ack */
+ APS_Status_t securityStatus;
+ /* Link to relative NWK_DataInd entity */
+ NWK_DataInd_t *dataIndLink;
+
+ BEGIN_PACK
+ TOP_GUARD
+ struct PACK
+ {
+ uint8_t lowLevelHeader[NWK_NSDU_OFFSET];
+#ifdef _LINK_SECURITY_
+ uint8_t apsSecHeader[APS_AUXILIARY_HEADER_LENGTH];
+#endif /* _LINK_SECURITY_ */
+
+ union PACK
+ {
+ ApduAcknowledgementFrame_t dataAck; //Acknowledgement frame for data
+ ApduCommandAcknowledgementFrame_t commandAck; //Acknowledgement frame for command
+ } frame;
+#ifdef _LINK_SECURITY_
+ uint8_t apsSecFooter[APS_MAX_DATA_FRAME_FOOTER_LENGTH];
+#endif /* _LINK_SECURITY_ */
+
+#if (NWK_AFFIX_LENGTH - NWK_NSDU_OFFSET)
+ uint8_t lowLevelFooter[NWK_AFFIX_LENGTH - NWK_NSDU_OFFSET];
+#endif
+ };
+ BOTTOM_GUARD
+ END_PACK
+} ApsAckBuffer_t;
+
+typedef struct
+{
+ uint8_t buffersAmount;
+ ApsAckBuffer_t *buffers;
+} ApsAckBuffersPool_t;
+
+typedef struct
+{
+ uint8_t buffersAmount;
+ uint8_t maxAckCounter;
+ uint8_t maxReqCounter;
+ uint8_t ackCounter;
+ uint8_t reqCounter;
+ ApsDataBuffer_t *buffers;
+} ApsDataReqBuffersPool_t;
+
+#ifdef _APS_FRAGMENTATION_
+typedef struct
+{
+ uint8_t state;
+ uint8_t *buffers;
+ uint8_t *bufferLengths;
+ uint8_t maxBlocksAmount;
+ uint16_t blockSize;
+ uint32_t timeout;
+ uint8_t blocksAmount;
+ uint8_t currentWindowStartBlockNumber;
+ uint8_t ackBitfield;
+ uint16_t srcAddress;
+ uint8_t dstEndpoint;
+ uint16_t clusterId;
+ uint16_t profileId;
+ uint8_t srcEndpoint;
+ uint8_t apsCounter;
+ ApsDataBuffer_t apsBuffer;
+ ApsAckBuffer_t apsAckBuffer;
+ APS_Status_t securityStatus;
+} ApsFragmRxDescr_t;
+
+typedef struct
+{
+ uint8_t blockNumber;
+ uint8_t ackBlockNumber; // block number that expect ack, also it is first block number in the window
+ uint8_t blocksToTransmit; // block in window requires to transmit. 1 required transmission
+ uint8_t blocksCount;
+ uint8_t apsCounter;
+ uint8_t retryCounter;
+ HAL_AppTimer_t sendTimer; // timer that send frame per apsInterframeDelay
+ ApsDataBuffer_t *block; // memory for block
+ uint8_t *buffer;
+} ApsFragmTxDescr_t;
+#endif // _APS_FRAGMENTATION_
+
+/*
+ * APS sublayer memory structure.
+ */
+typedef struct
+{
+ ApsDataReqBuffersPool_t dataReqBuffersPool; // Buffers to execute APS Data requests
+ ApsAckBuffersPool_t ackBuffersPool; // Buffers to generate APS acknowledgements
+#ifdef _APS_FRAGMENTATION_
+ ApsFragmRxDescr_t apsFragmRxDescr;
+ ApsFragmTxDescr_t apsFragmTxDescr;
+#endif // _APS_FRAGMENTATION_
+} ApsMem_t;
+
+
+/******************************************************************************
+ Extern variables section
+******************************************************************************/
+extern ApsMem_t apsMem;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/*****************************************************************************
+ \brief Make a reset of APS Memory Manager
+
+ \param fullReset - reset all internal variables of APS-layer or not.
+ \retur none
+*****************************************************************************/
+APS_PRIVATE void apsResetMemoryManager(void);
+
+/***************************************************************************//**
+ \brief Allocates memory buffer for NLDE-DATA.request primitive specified by
+ parameter primitiveType.
+
+ \param primitiveType - type of buffer which will be allocated
+ APS_NLDE_DATA_REQ_BUFFER_TYPE - NLDE-DATA.request without frame
+ APS_NLDE_DATA_REQ_WITH_ACK_BUFFER_TYPE - NLDE-DATA.request with ack
+ required flag in APDU
+ APS_NLDE_DATA_REQ_ACK_BUFFER_TYPE - NLDE-DATA.request with ack frame
+ \return nonNULL buffer pointer if memory was allocated successfully
+ NULL - no free buffers available.
+*******************************************************************************/
+APS_PRIVATE ApsDataBuffer_t *apsGetBuffer(uint8_t primitiveType);
+
+/***************************************************************************//**
+ \brief Deallocate memory buffer
+
+ \param buffer - pointer to buffer to be freed.
+ \return None
+*******************************************************************************/
+APS_PRIVATE void apsFreeBuffer(void *buffer);
+
+/***************************************************************************//**
+ \brief Check memory availability for NLDE-DATA.request primitive to generate
+ APS acknowledge.
+
+ \param None
+ \return true - memory is available
+ false - in other case
+*******************************************************************************/
+APS_PRIVATE bool apsIsBufferAvailableForAck(void);
+
+/******************************************************************************
+ Inline functions section
+******************************************************************************/
+/*****************************************************************************
+ \brief Gives pointer to APS layer memory pool.
+
+ \param none
+ \retur pointer to APS memory pool.
+*****************************************************************************/
+INLINE ApsDataReqBuffersPool_t *apsGetDataReqBuffersMem(void)
+{
+ return &apsMem.dataReqBuffersPool;
+}
+
+/*****************************************************************************
+ \brief Gives pointer to APS layer acknowledgements memory pool.
+
+ \param none
+ \retur pointer to APS acknowledgements memory pool.
+*****************************************************************************/
+INLINE ApsAckBuffersPool_t *apsGetAckBuffersMem(void)
+{
+ return &apsMem.ackBuffersPool;
+}
+
+#ifdef _APS_FRAGMENTATION_
+/*****************************************************************************
+ \brief Gives pointer to APS layer fragmentation feature memory (Rx).
+
+ \param none
+ \retur pointer to fragmentation feature memory (Rx).
+*****************************************************************************/
+INLINE ApsFragmRxDescr_t *apsGetFragmRxDescrMem(void)
+{
+ return &apsMem.apsFragmRxDescr;
+}
+
+/*****************************************************************************
+ \brief Gives pointer to APS layer fragmentation feature memory (Tx).
+
+ \param none
+ \retur pointer to fragmentation feature memory (Tx).
+*****************************************************************************/
+INLINE ApsFragmTxDescr_t *apsGetFragmTxDescrMem(void)
+{
+ return &apsMem.apsFragmTxDescr;
+}
+
+/*****************************************************************************
+ \brief Resets structure which controls fragmented data receiption procedure.
+
+ \param none
+ \retur none
+*****************************************************************************/
+INLINE void apsResetFragmRxDescr(void)
+{
+ ApsFragmRxDescr_t *apsFragmRxDescr = apsGetFragmRxDescrMem();
+
+ apsFragmRxDescr->ackBitfield = 0;
+ apsFragmRxDescr->apsCounter = 0;
+ apsFragmRxDescr->blocksAmount = 0;
+ apsFragmRxDescr->clusterId = 0;
+ apsFragmRxDescr->currentWindowStartBlockNumber = 0;
+ apsFragmRxDescr->dstEndpoint = 0;
+ apsFragmRxDescr->profileId = 0;
+ apsFragmRxDescr->srcAddress = 0;
+ apsFragmRxDescr->srcEndpoint = 0;
+ apsFragmRxDescr->state = 0;
+ apsFragmRxDescr->timeout = 0;
+
+ memset(&apsFragmRxDescr->apsBuffer, 0, sizeof(apsFragmRxDescr->apsBuffer));
+ memset(&apsFragmRxDescr->apsAckBuffer, 0, sizeof(apsFragmRxDescr->apsAckBuffer));
+ memset(apsFragmRxDescr->buffers, 0,
+ apsFragmRxDescr->maxBlocksAmount * apsFragmRxDescr->blockSize + apsFragmRxDescr->maxBlocksAmount);
+
+ apsFragmRxDescr->apsBuffer.dataDescriptor.nwkDataReq.nsdu = (uint8_t *)&apsFragmRxDescr->apsAckBuffer.frame;
+}
+
+#endif // ifdef _APS_FRAGMENTATION_
+#endif /*APSMEMORYMANAGER_H_*/
+
+//eof apsMemoryManager.h
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsRejectDuplicate.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsRejectDuplicate.h
new file mode 100644
index 00000000..97b51223
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsRejectDuplicate.h
@@ -0,0 +1,47 @@
+/**************************************************************************//**
+ \file apsRejectDuplicate.h
+
+ \brief Private interface of the duplicate rejection table.
+
+ \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:
+ 2011-07-03 Max Gekk - Created.
+ Last change:
+ $Id: apsRejectDuplicate.h 17801 2011-07-04 08:55:01Z mgekk $
+ ******************************************************************************/
+#if !defined _APS_REJECT_DUPLICATE_H
+#define _APS_REJECT_DUPLICATE_H
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsCommon.h>
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/*****************************************************************************
+ \brief Is incoming packet is dublicate or not? Checks in the rejection table.
+
+ \param[in] srcAddr - short address of source node.
+ \param[in] counter - APS counter of incoming packet.
+
+ \return true - if incoming packet is duplicate otherwise return false.
+*****************************************************************************/
+APS_PRIVATE bool apsIsDuplicatePacket(const ShortAddr_t srcAddr,
+ const uint8_t counter);
+
+/******************************************************************************
+ \brief Reset the duplicate rejection table ana reinit timeouts.
+ ******************************************************************************/
+APS_PRIVATE void apsResetDuplicateRejectionTable(void);
+
+#endif /* _APS_REJECT_DUPLICATE_H */
+/** eof apsRejectDuplicate.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsRemoveDevice.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsRemoveDevice.h
new file mode 100644
index 00000000..7d9bf174
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsRemoveDevice.h
@@ -0,0 +1,61 @@
+/**************************************************************************//**
+ \file apsRemoveDevice.h
+
+ \brief Private interface of APS Remove Device.
+
+ \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:
+ 2011-03-18 A. Razinkov - Created.
+ Last change:
+ $Id: apsRemoveDevice.h 17470 2011-06-10 11:31:00Z mgekk $
+ ******************************************************************************/
+#ifndef _APS_REMOVE_DEVICE_H
+#define _APS_REMOVE_DEVICE_H
+
+#ifdef _SECURITY_
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsCommand.h>
+#include <nwk.h>
+#include <apsFrames.h>
+#include <apsmeRemoveDevice.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+BEGIN_PACK
+/** Type of APS remove device command frame. */
+typedef struct PACK _ApsRemoveDeviceFrame_t
+{
+ /** An APS header, which comprises frame control and addressing information. */
+ ApduCommandHeader_t header;
+ /** the 64-bit extended address of the device that is requested to be removed
+ * from the network. */
+ ExtAddr_t childAddress;
+} ApsRemoveDeviceFrame_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Remove device indication handler.
+
+ \param[in] commandInd - pointer to received command descriptor.
+
+ \return 'true' if NWK buffer with the command frame must be freed
+ otherwise return 'false'.
+ ******************************************************************************/
+APS_PRIVATE bool apsRemoveDeviceInd(const ApsCommandInd_t *const commandInd);
+
+#endif /* _SECURITY_ */
+#endif /* _APS_REMOVE_DEVICE_H */
+/** eof apsRemoveDevice.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsRequestKey.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsRequestKey.h
new file mode 100644
index 00000000..95ab7eba
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsRequestKey.h
@@ -0,0 +1,80 @@
+/**************************************************************************//**
+ \file apsRequestKey.h
+
+ \brief Private interface of APS Request Key.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2011-06-04 Max Gekk - Created.
+ Last change:
+ $Id: apsRequestKey.h 19032 2011-10-27 09:22:49Z mgekk $
+ ******************************************************************************/
+#if !defined _APS_REQUEST_KEY_H
+#define _APS_REQUEST_KEY_H
+
+#if defined _SECURITY_ && defined _LINK_SECURITY_
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsmeTransportKey.h>
+#include <apsCommand.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+BEGIN_PACK
+/* Request-Key Command Frame Format. See ZigBee spec r19, Figure 4.14. */
+typedef struct PACK _ApsRequestKeyFrame_t
+{
+ /** An APS header, which comprises frame control and addressing information. */
+ ApduCommandHeader_t header;
+ /* The key type field shall be set to 1 when the network key is being
+ * requested, shall be set to 2 when an application key is being requested.
+ * See ZigBee spec r19, 4.4.9.5.2, page 483. */
+ uint8_t keyType;
+ /* When the key type field is 2 (that is, an application key), the partner
+ * address field shall contain the extended 64-bit address of the partner
+ * device that shall be sent the key. See ZigBee spec r19, 4.4.9.5.3 */
+ uint8_t partnerAddress[sizeof(ExtAddr_t)];
+} ApsRequestKeyFrame_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Reset the internal queue and variables of APS Request Key component.
+ ******************************************************************************/
+APS_PRIVATE void apsRequestKeyReset(void);
+
+/**************************************************************************//**
+ \brief Transport key has been received, indicate to the upper-layer.
+
+ \param[in] transportKeyInd - pointer to parameters of received key.
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsRequestedKeyReceived(APS_TransportKeyInd_t *transportKeyInd);
+
+/**************************************************************************//**
+ \brief Request key indication handler.
+
+ \param[in] commandInd - pointer to received command descriptor.
+
+ \return 'true' if NWK buffer with the command frame must be freed
+ otherwise return 'false'.
+ ******************************************************************************/
+APS_PRIVATE bool apsRequestKeyInd(const ApsCommandInd_t *const commandInd);
+
+#else
+#define apsRequestKeyInd NULL
+#define apsRequestedKeyReceived(transportKeyInd) ((void)0)
+#endif /* _SECURITY_ and _LINK_SECURITY_ */
+
+#endif /* _APS_REQUEST_KEY_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSkke.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSkke.h
new file mode 100644
index 00000000..0758c7e4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSkke.h
@@ -0,0 +1,225 @@
+/**************************************************************************//**
+ \file apsSkke.h
+
+ \brief Private interface of symmetric-key key establishment implementation.
+
+ \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:
+ 2011-04-23 Max Gekk - Created.
+ Last change:
+ $Id: apsSkke.h 17813 2011-07-04 14:11:12Z dloskutnikov $
+ ******************************************************************************/
+#if !defined _APS_SKKE_H
+#define _APS_SKKE_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsCommand.h>
+#if defined _SECURITY_ && defined _LINK_SECURITY_ && defined _HI_SECURITY_
+#include <apsmeEstablishKey.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+/** Size of the data field in SKKE command frames. */
+#define APS_SKKE_DATA_SIZE 16U
+/* Maximum value of SKKE TTL. */
+#define APS_SKKE_INFINITY_TTL UINT32_MAX
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/* Type of internal state of SKKE responder or initiator. */
+typedef enum _ApsSkkeState_t
+{
+ APS_SKKE_REQ_STATE,
+ APS_WAIT_SKKE_2_STATE,
+ APS_WAIT_SKKE_4_STATE,
+ APS_SKKE_RESP_STATE,
+ APS_WAIT_SKKE_3_STATE
+} ApsSkkeState_t;
+
+BEGIN_PACK
+/** Type of generic SKKE command frame. See ZigBee spec r19, page 478. */
+typedef struct PACK _ApsSkkeFrame_t
+{
+ ApduCommandHeader_t header;
+ /** The 64-bit extended address of the device that acts as the initiator
+ * in the key-establishment protocol. See ZigBee spec r19, 4.4.9.1.2 */
+ uint8_t initiator[sizeof(ExtAddr_t)];
+ /** The 64-bit extended address of the device that acts as the responder
+ * in the key-establishment protocol. See ZigBee spec r19, 4.4.9.1.3 */
+ uint8_t responder[sizeof(ExtAddr_t)];
+ /** The content of the data field depends on the command identifier field:
+ * QEU for SKKE-1, QEV for SKKE-2, MacTag2 for SKKE-3, MacTag1 for SKKE-4. */
+ uint8_t data[APS_SKKE_DATA_SIZE];
+} ApsSkkeFrame_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Process an incoming SKKE command frame.
+
+ \param[in] commandInd - pointer to parameters of the received command:
+ - secured or not,
+ - extended address of source node,
+ - pointer to NLDE-DATA.indication's parameters.
+
+ \return 'true' - free NWK buffer for a SKKE command otherwise return 'false'.
+ ******************************************************************************/
+APS_PRIVATE bool apsSkkeInd(const ApsCommandInd_t *const commandInd);
+
+/**************************************************************************//**
+ \brief Initializes the common substructure of SKKE requests or response.
+
+ \param[in, out] skkeElem - pointer to the common element of SKKE request
+ or SKKE response. \sa ApsSkkeElem_t
+ \param[in] state - initial state of the SKKE request.
+ \param[in] ttl - time to live of the SKKE request.
+ \param[in] apsSkkeConf - confirmation function of the SKKE request or response.
+
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsInitSkkeElem(ApsSkkeElem_t *const skkeElem,
+ const ApsSkkeState_t state, const uint32_t ttl,
+ void (* apsSkkeConf)(struct _ApsSkkeElem_t*, APS_SkkeStatus_t));
+
+/**************************************************************************//**
+ \brief Find a first SKKE element by state and remove it from internal queue.
+
+ \param[in] state - state of the SKKE request or response.
+
+ \return Pointer to SKKE element or NULL if element isn't found.
+ ******************************************************************************/
+APS_PRIVATE ApsSkkeElem_t* apsFetchSkkeElem(const ApsSkkeState_t state);
+
+/**************************************************************************//**
+ \brief Is there an SKKE element with the given state?
+
+ \param[in] state - state of the SKKE request or response.
+
+ \return 'true' if any element is found otherwise return 'false'.
+ ******************************************************************************/
+APS_PRIVATE bool apsIsThereSkkeElem(const ApsSkkeState_t state);
+
+/**************************************************************************//**
+ \brief Set new TTL of the SKKE element.
+
+ \param[in, out] skkeElem - pointer to the common substructure of SKKE request
+ or SKKE response. \sa ApsSkkeElem_t
+ \param[in] ttl - time to live of the SKKE request or response.
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsSetSkkeTTL(ApsSkkeElem_t *const skkeElem, const uint32_t ttl);
+
+/**************************************************************************//**
+ \brief Set new state of the SKKE element.
+
+ \param[in, out] skkeElem - pointer to the common substructure of SKKE request
+ or SKKE response. \sa ApsSkkeElem_t
+ \param[in] state - new state of the SKKE request or response.
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsSetSkkeState(ApsSkkeElem_t *const skkeElem,
+ const ApsSkkeState_t state);
+
+/**************************************************************************//**
+ \brief Allocate memory for SKKE frame and NWK_DataReq_t structure in NWK.
+
+ \param[in] allocNwkDataReq - pointer to NWK DataReq allocation's parameters.
+ \param[in] nwkAllocDataConf - callback function. NWK-layer calls this function
+ when memory has been allocated.
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsSkkeAllocFrameReq(NWK_AllocDataReq_t *const allocNwkDataReq,
+ void (*nwkAllocDataConf)(NWK_AllocDataConf_t*));
+
+/**************************************************************************//**
+ \brief Prepare and fill fields of APS SKKE command frame.
+
+ \param[in] allocConf - pointer to confirmation structure with pointer to
+ allocated NWK_DataReq_t structure.
+ \param[in] commandId - identifier of APS security command frame.
+ \param[in] nwkDataReq - pointer to field in the SKKE request (reponse)
+ for saving pointer to allocated NWK_DataReq_t structure.
+ \param[in] data - pointer to value for the data field of APS SKKE frame.
+ \param[in] initiatorAddress - pointer to extended address of SKKE initiator.
+ \param[in] responderAddress - pointer to extended address of SKKE responser.
+
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsPrepareSkkeCommand(NWK_AllocDataConf_t *const allocConf,
+ const ApsCommandId_t commandId, NWK_DataReq_t **const skkeNwkDataReq,
+ const uint8_t *const data, const ExtAddr_t *const initiatorAddress,
+ const ExtAddr_t *const responderAddress);
+
+/**************************************************************************//**
+ \brief Prepare NWK_DataReq_t structure and send SKKE command frame.
+
+ \param[in] nwkDataReq - pointer to parameters of NLDE-DATA.request.
+ \param[in] nwkDataConf - NLDE-DATA confirm callback function's pointer.
+ \param[in] dstShortAddr - short address of partner (initiator or responder).
+ \param[in] secure - enable security on NWK layer.
+
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsSkkeNwkDataReq(NWK_DataReq_t *const nwkDataReq,
+ void (* nwkDataConf)(NWK_DataConf_t*), const ShortAddr_t dstShortAddr,
+ const bool secure);
+
+/**************************************************************************//**
+ \brief Process confirmation from NWK layer of transmission SKKE command.
+
+ \param[in] nwkDataConf - pointer to NLDE-DATA confirmation parameters.
+ \param[in] state - state of SKKE request or response for which SKKE command
+ was transmitted.
+ \param[in] apsSkkeCompareNwkReq - matching function of SKKE request
+ or response with NWK DataReq_t structure.
+ \param[in] txErrorStatus - return this SKKE status if transmission of SKKE
+ command is failure.
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsSkkeNwkDataConf(NWK_DataConf_t *const nwkDataConf,
+ const ApsSkkeState_t state,
+ bool (*apsSkkeCompareNwkReq)(const ApsSkkeElem_t*, NWK_DataReq_t*),
+ const APS_SkkeStatus_t txErrorStatus);
+
+/**************************************************************************//**
+ \brief Process indication from NWK layer about SKKE command.
+
+ \param[in] nwkDataInd - pointer to NLDE-DATA indication parameters.
+ \param[in] state - state of SKKE request or response for which SKKE command
+ is expected.
+ \param[in] apsSkkeCompareNwkInd - matching function of SKKE request
+ or response with NWK DataInd_t structure.
+ \param[in, out] skkeFrame - pointer to pointer to SKKE raw frame.
+ \return Pointer to SKKE element or NULL if it insn't found.
+ ******************************************************************************/
+APS_PRIVATE ApsSkkeElem_t* apsFindSkkeElemByNwkInd(const NWK_DataInd_t *const nwkDataInd,
+ const ApsSkkeState_t state,
+ bool (*apsSkkeCompareNwkInd)(const ApsSkkeElem_t*, const ApsSkkeFrame_t*),
+ ApsSkkeFrame_t **skkeFrame);
+
+/**************************************************************************//**
+ \brief Reset the internal queue and variables of SKKE component.
+ ******************************************************************************/
+APS_PRIVATE void apsSkkeReset(void);
+
+#else /* not _HI_SECURITY_ */
+
+#define apsSkkeInd NULL
+#define apsSkkeReset() ((void)0)
+#endif /* _HI_SECURITY_ */
+
+#endif /* _APS_SKKE_H */
+/** eof apsSkke.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSkkeInitiator.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSkkeInitiator.h
new file mode 100644
index 00000000..e533b58c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSkkeInitiator.h
@@ -0,0 +1,61 @@
+/**************************************************************************//**
+ \file apsSkkeInitiator.h
+
+ \brief Private interface of APS SKKE Initiator.
+
+ \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:
+ 2011-04-24 Max Gekk - Created.
+ Last change:
+ $Id: apsSkkeInitiator.h 17813 2011-07-04 14:11:12Z dloskutnikov $
+ ******************************************************************************/
+#if !defined _APS_SKKE_INITIATOR_H
+#define _APS_SKKE_INITIATOR_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwk.h>
+
+#if defined _HI_SECURITY_
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Main task handler of SKKE initiator.
+ ******************************************************************************/
+APS_PRIVATE void apsSkkeInitiatorTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Process SKKE-2 command frame from a responder.
+
+ \param[in] ind - pointer to NWK parameters of received SKKE-2 frame.
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsISkke2Ind(NWK_DataInd_t *ind);
+
+/**************************************************************************//**
+ \brief Process SKKE-4 command frame from a responder.
+
+ \param[in] ind - pointer to NWK parameters of received SKKE-4 frame.
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsISkke4Ind(NWK_DataInd_t *ind);
+
+#else /* no _HI_SECURITY_ */
+
+
+#define apsSkkeInitiatorTaskHandler NULL
+
+#endif /* _HI_SECURITY_ */
+
+#endif /* _APS_SKKE_INITIATOR_H */
+/** eof apsSkkeInitiator.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSkkeResponder.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSkkeResponder.h
new file mode 100644
index 00000000..dab279db
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSkkeResponder.h
@@ -0,0 +1,60 @@
+/**************************************************************************//**
+ \file apsSkkeResponder.h
+
+ \brief Private interface of APS SKKE Responder.
+
+ \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:
+ 2011-04-24 Max Gekk - Created.
+ Last change:
+ $Id: apsSkkeResponder.h 17813 2011-07-04 14:11:12Z dloskutnikov $
+ ******************************************************************************/
+#if !defined _APS_SKKE_RESPONDER_H
+#define _APS_SKKE_RESPONDER_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwk.h>
+
+#if defined _HI_SECURITY_
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Main task handler of SKKE responder.
+ ******************************************************************************/
+APS_PRIVATE void apsSkkeResponderTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Process SKKE-1 command frame from a initiator.
+
+ \param[in] ind - pointer to NWK parameters of received SKKE-1 frame.
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsRSkke1Ind(NWK_DataInd_t *ind);
+
+/**************************************************************************//**
+ \brief Process SKKE-3 command frame from a initiator.
+
+ \param[in] ind - pointer to NWK parameters of received SKKE-3 frame.
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsRSkke3Ind(NWK_DataInd_t *ind);
+
+#else /* _HI_SECURITY_ */
+
+
+#define apsSkkeResponderTaskHandler NULL
+
+#endif /* _HI_SECURITY_ */
+
+#endif /* _APS_SKKE_RESPONDER_H */
+/** eof apsSkkeResponder.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSmSsp.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSmSsp.h
new file mode 100644
index 00000000..11d82a9c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSmSsp.h
@@ -0,0 +1,80 @@
+/*************************************************************************//**
+ \file apsSmSsp.c
+
+ \brief APS SSP features header file
+
+ \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:
+ 07/11/07 A. Potashov - Created.
+*****************************************************************************/
+
+#ifndef _APSSMSSP_H
+#define _APSSMSSP_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <aps.h>
+#include <apsMemoryManager.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum
+{
+ APS_SM_SSPE_SUCCESS_STATUS = 0x00,
+ APS_SM_SSPE_START_STATUS,
+ APS_SM_SSPE_FAIL_STATUS,
+} ApsSspeStatus_t;
+
+
+#if defined _SECURITY_ && defined _LINK_SECURITY_
+typedef enum
+{
+ APS_SM_SSPD_SUCCESS_STATUS = 0x00,
+ APS_SM_SSPD_START_STATUS,
+ APS_SM_SSPD_FAIL_STATUS,
+} ApsSspdStatus_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/*****************************************************************************
+ APS Frame Encrypt Function
+ Parameters: buffer - APS Security Manager buffer pointer
+ dstExtAddr - destination extended address pointer
+ apduLength - APDU length
+ Returns: APS_SM_SSPE_START_STATUS - encryption process started
+ APS_SM_SSPE_FAIL_STATUS - encryption failed
+ APS_SM_SSPE_SUCCESS_STATUS - encryption not required
+ (not needed)
+*****************************************************************************/
+/**
+ * \brief request for encryption of data buffer
+ */
+APS_PRIVATE void apsEncryptDataFrame(ApsDataBuffer_t *buffer, uint8_t headerLength);
+
+APS_PRIVATE void apsSecurityTaskHandler(void);
+APS_PRIVATE void apsSecuredNwkDataIndHandler(NWK_DataInd_t *ind);
+
+/*****************************************************************************
+ Make a search of key-pair descriptor for extended address specified
+ Parameters: address - 64-bit IEEE device address pointer
+ Returns: NULL - key-pair descriptor not found
+ valid key-pair descriptor pointer - in other case
+*****************************************************************************/
+APS_PRIVATE void apsDecryptSentFrame(ApsDataBuffer_t *buffer);
+
+APS_PRIVATE void apsResetSmSsp(void);
+#else
+#define apsSecurityTaskHandler NULL
+#endif //_SECURITY_ and _LINK_SECURITY_
+#endif //#ifndef _APSSMSSP_H
+//eof apsSmSsp.h
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsState.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsState.h
new file mode 100644
index 00000000..f43aee2a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsState.h
@@ -0,0 +1,152 @@
+/**************************************************************************//**
+ \file apsState.h
+
+ \brief Set and check APS state.
+
+ \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:
+ 2010-10-09 Max Gekk - Created.
+ Last change:
+ $Id: apsState.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _APS_STATE_H
+#define _APS_STATE_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Identifiers of APS states. */
+typedef uint16_t ApsStateId_t;
+
+#define APS_INITIAL_STATE_ID 0x100
+#define APS_RESETTING_STATE_ID 0x200
+#define APS_RESET_STATE_ID 0x300
+#define APS_START_STATE_ID 0x400
+#define APS_STOPPING_STATE_ID 0x500
+#define APS_STOP_STATE_ID 0x600
+#define APS_HOT_RESETTING_STATE_ID 0x700
+
+/** Identifiers of APS components. */
+typedef uint8_t ApsComponentId_t;
+
+#define APS_CONTROL_MANAGER_ID 0x00
+#define APS_DATA_MANAGER_ID 0x01
+#define APS_SECURITY_MANAGER_ID 0x02
+#define APS_BIND_MANAGER_ID 0x03
+#define APS_AIB_MANAGER_ID 0x04
+#define APS_KEY_ESTABLISHMENT_ID 0x05
+#define APS_MAX_COMPONENT_ID 6
+
+/** Identifier masks of APS components. */
+typedef ApsStateId_t ApsComponent_t;
+
+#define APS_DENIED_ACCESS 0U
+#define APS_CONTROL_MANAGER (1U << APS_CONTROL_MANAGER_ID)
+#define APS_DATA_MANAGER (1U << APS_DATA_MANAGER_ID)
+#define APS_SECURITY_MANAGER (1U << APS_SECURITY_MANAGER_ID)
+#define APS_BIND_MANAGER (1U << APS_BIND_MANAGER_ID)
+#define APS_AIB_MANAGER (1U << APS_AIB_MANAGER_ID)
+#define APS_KEY_ESTABLISHMENT (1U << APS_KEY_ESTABLISHMENT_ID)
+
+/** APS component's permitions. */
+typedef ApsComponent_t ApsPermitions_t;
+
+#define APS_INITIAL_STATE_PERM APS_AIB_MANAGER
+#define APS_RESETING_STATE_PERM APS_DENIED_ACCESS
+#define APS_RESET_STATE_PERM (APS_AIB_MANAGER | APS_KEY_ESTABLISHMENT)
+#define APS_START_STATE_PERM \
+ (APS_CONTROL_MANAGER | APS_AIB_MANAGER | APS_SECURITY_MANAGER \
+ | APS_DATA_MANAGER | APS_BIND_MANAGER | APS_KEY_ESTABLISHMENT)
+#define APS_STOPPING_STATE_PERM APS_DENIED_ACCESS
+#define APS_STOP_STATE_PERM APS_AIB_MANAGER
+
+
+/** Global states of APS layer. */
+typedef ApsStateId_t ApsState_t;
+
+#define APS_NO_INIT_STATE 0U
+#define APS_INITIAL_STATE (APS_INITIAL_STATE_ID | APS_INITIAL_STATE_PERM)
+#define APS_RESETTING_STATE (APS_RESETTING_STATE_ID | APS_RESETING_STATE_PERM)
+#define APS_RESET_STATE (APS_RESET_STATE_ID | APS_RESET_STATE_PERM)
+#define APS_START_STATE (APS_START_STATE_ID | APS_START_STATE_PERM)
+#define APS_STOPPING_STATE (APS_STOPPING_STATE_ID | APS_STOPPING_STATE_PERM)
+#define APS_STOP_STATE (APS_STOP_STATE_ID | APS_STOP_STATE_PERM)
+#define APS_HOT_RESETTING_STATE \
+ (APS_HOT_RESETTING_STATE_ID | APS_RESETING_STATE_PERM)
+#define IS_VALID_APS_STATE(state) \
+ ((APS_INITIAL_STATE <= (state)) && ((state) <= APS_HOT_RESETTING_STATE))
+
+/******************************************************************************
+ Global variables section
+ ******************************************************************************/
+/** Current state of APS layer. */
+extern ApsState_t apsState;
+
+/******************************************************************************
+ Inline functions section
+ *****************************************************************************/
+/*****************************************************************************
+ \brief Peforms the setting of APS current state to specified state.
+
+ \param[in] newState - state will be set.
+ \return None.
+ *****************************************************************************/
+INLINE void apsSetState(const ApsState_t newState)
+{
+ apsState = newState;
+}
+
+/*****************************************************************************
+ \brief Returns the APS State Machine current state.
+ *****************************************************************************/
+INLINE ApsState_t apsGetState(void)
+{
+ return apsState;
+}
+/*****************************************************************************
+ \brief The function performs checking the certain layer component
+ availability in depending on the APS State Machine.
+
+ \param[in] component - identifier mask of APS component.
+ \return true - component specified is available,
+ false - component specified is unavailable.
+ *****************************************************************************/
+INLINE bool apsCheckState(const ApsComponent_t component)
+{
+ return APS_DENIED_ACCESS != (apsState & component);
+}
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/*****************************************************************************
+ \brief Main task handler of APS State Machine.
+ *****************************************************************************/
+APS_PRIVATE void apsStateMachineTaskHandler(void);
+
+/******************************************************************************
+ \brief Check stop procedure complete.
+
+ Checking all APS components are stopped and peform APS_StopConf if it is true.
+
+ \param[in] component - already stopped APS component.
+
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsCompleteStop(const ApsComponent_t component);
+
+#endif /* _APS_STATE_H */
+/** eof apsState.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSwitchKey.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSwitchKey.h
new file mode 100644
index 00000000..98a6e306
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsSwitchKey.h
@@ -0,0 +1,61 @@
+/**************************************************************************//**
+ \file apsSwitchKey.h
+
+ \brief Private interface of APS Switch Key.
+
+ \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:
+ 2011-03-21 A. Razinkov - Created.
+ Last change:
+ $Id: apsSwitchKey.h 17470 2011-06-10 11:31:00Z mgekk $
+ ******************************************************************************/
+#ifndef _APS_SWITCH_KEY_H
+#define _APS_SWITCH_KEY_H
+
+#ifdef _SECURITY_
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsCommand.h>
+#include <nwk.h>
+#include <apsFrames.h>
+#include <apsmeSwitchKey.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+BEGIN_PACK
+/** Type of APS remove device command frame. */
+typedef struct PACK _ApsSwitchKeyFrame_t
+{
+ /** An APS header, which comprises frame control and addressing information. */
+ ApduCommandHeader_t header;
+ /** A sequence number assigned to a network key by the Trust Center and used to
+ * distinguish network keys. */
+ uint8_t keySeqNumber;
+} ApsSwitchKeyFrame_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Switch key command indication handler.
+
+ \param[in] commandInd - pointer to received command descriptor.
+
+ \return 'true' if NWK buffer with the command frame must be freed
+ otherwise return 'false'.
+ ******************************************************************************/
+APS_PRIVATE bool apsSwitchKeyInd(const ApsCommandInd_t *const commandInd);
+
+#endif /* _SECURITY_ */
+#endif /* _APS_SWITCH_KEY_H */
+/** eof apsSwitchKey.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTaskManager.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTaskManager.h
new file mode 100644
index 00000000..04035896
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTaskManager.h
@@ -0,0 +1,68 @@
+/**************************************************************************//**
+ \file apsTaskManager.h
+
+ \brief Header file of APS task manager.
+
+ \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:
+ 2010-12-12 Max Gekk - Created.
+ Last change:
+ $Id: apsTaskManager.h 17470 2011-06-10 11:31:00Z mgekk $
+ ******************************************************************************/
+#if !defined _APS_TASK_MANAGER_H
+#define _APS_TASK_MANAGER_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Identifiers of APS task handlers. */
+typedef enum _ApsTaskID_t
+{
+ APS_TASK_STATE_MACHINE,
+ APS_TASK_DATA,
+ APS_TASK_SECURITY,
+ APS_TASK_COMMAND_REQ,
+ APS_TASK_AUTH_REQ,
+ APS_TASK_SKKE_REQ,
+ APS_TASK_SKKE_RESP,
+ APS_TASK_TRANSPORT_KEY,
+ APS_TASKS_SIZE
+} ApsTaskID_t;
+
+/** Bit array of APS task. If bit is '1' the task is posted. */
+typedef uint8_t ApsTaskBitMask_t;
+
+/** Type of iterator for task identifiers. */
+typedef uint8_t ApsTaskIdIter_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/******************************************************************************
+ \brief post APS task.
+
+ \param taskID - identifier of APS task.
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsPostTask(const ApsTaskID_t taskID);
+
+/******************************************************************************
+ \brief Reset the APS task manager.
+ ******************************************************************************/
+APS_PRIVATE void apsResetTaskManager(void);
+
+#endif /* _APS_TASK_MANAGER_H */
+/** eof apsTaskManager.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTransportAppKey.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTransportAppKey.h
new file mode 100644
index 00000000..63cd87e0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTransportAppKey.h
@@ -0,0 +1,84 @@
+/**************************************************************************//**
+ \file apsTransportAppKey.h
+
+ \brief Interface of transport application key.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2011-05-05 Max Gekk - Created.
+ Last change:
+ $Id: apsTransportAppKey.h 17813 2011-07-04 14:11:12Z dloskutnikov $
+ ******************************************************************************/
+#if !defined _APS_TRANSPORT_APP_KEY_H
+#define _APS_TRANSPORT_APP_KEY_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#if defined _SECURITY_ && defined _LINK_SECURITY_
+#include <apsTransportKey.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+BEGIN_PACK
+/** Type of Transport-Key Command Frame (see ZigBee spec r19, Figure 4.8
+ * with application master or link key descriptor field (see Figure 4.11). */
+typedef struct PACK _ApsTransportAppKeyFrame_t
+{
+ /** Common part of APS transport key command frame. */
+ ApsTransportKeyCommonFrame_t common;
+ /** The key sub-field shall contain a master or link key that is shared
+ * with the device identified in the partner address sub-field. See ZigBee
+ * Specification, 4.4.9.2.3.3, page 481. */
+ uint8_t key[SECURITY_KEY_SIZE];
+ /** The partner address sub-field shall contain the address of the other
+ * device that was sent this link or master key. */
+ uint8_t partnerAddress[sizeof(ExtAddr_t)];
+ /** The initiator flag sub-field shall be set to 1 if the device receiving
+ * this packet requested this key. Otherwise, this sub-field shall be set
+ * to 0. See ZigBee spec r19, 4.4.9.2.3.3, Figure 4.11, page 481. */
+ uint8_t initiatorFlag;
+} ApsTransportAppKeyFrame_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _TRUST_CENTRE_
+/**************************************************************************//**
+ \brief Checks specific parameters of Transport Application Key request.
+
+ \param[in] req - pointer to parameters of APSME-TRANSPORT-KEY.request.
+ \return Pointer to function for preparing and sending APS Transport Key command.
+ ******************************************************************************/
+APS_PRIVATE ApsTransportKeyCommand_t
+apsCheckTransportAppKeyReq(APS_TransportKeyReq_t *const req);
+#endif /* _TRUST_CENTRE_ */
+
+/**************************************************************************//**
+ \brief Process an incoming transport key command with application key.
+
+ \param[in] commandInd - pointer to received command descriptor.
+
+ \return 'false' if structure commandInd->nwkDataInd is used otherwise 'true'.
+ ******************************************************************************/
+APS_PRIVATE bool apsTransportAppKeyInd(const ApsCommandInd_t *const commandInd);
+
+#else
+#define apsTransportAppKeyInd(commandInd) (true)
+#endif /* _SECURITY_ and _LINK_SECURITY_ */
+
+#if !(defined _SECURITY_ && defined _LINK_SECURITY_ && defined _TRUST_CENTRE_)
+
+#define apsCheckTransportAppKeyReq(req) NULL
+#endif
+#endif /* _APS_TRANSPORT_APP_KEY_H */
+/** eof apsTransportAppKey.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTransportKey.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTransportKey.h
new file mode 100644
index 00000000..989f5dd6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTransportKey.h
@@ -0,0 +1,118 @@
+/**************************************************************************//**
+ \file apsTransportKey.h
+
+ \brief Private interface of transport key implementation.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2011-05-05 Max Gekk - Created.
+ Last change:
+ $Id: apsTransportKey.h 18405 2011-08-31 15:42:23Z mgekk $
+ ******************************************************************************/
+#if !defined _APS_TRANSPORT_KEY_H
+#define _APS_TRANSPORT_KEY_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsCommand.h>
+#include <apsmeTransportKey.h>
+
+#if defined _SECURITY_
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/* The macro checks the source is trusted - himself or Trust Center. */
+#define IS_SOURCE_TRUSTED(commandInd) ((commandInd)->nwkDataInd->boomerang \
+ || (APS_SECURED_HASH_OF_TRUST_CENTER_LINK_KEY_STATUS == (commandInd)->securityStatus) \
+ || (APS_SECURED_TRUST_CENTER_LINK_KEY_STATUS == (commandInd)->securityStatus))
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/* Type of function for preparing and sending a transport key command. */
+typedef void (* ApsTransportKeyCommand_t)(APS_TransportKeyReq_t *const req);
+BEGIN_PACK
+/* Type of common part of APS Transport Key command. */
+typedef struct PACK _ApsTransportKeyCommonFrame_t
+{
+ /** An APS header, which comprises frame control and addressing information. */
+ ApduCommandHeader_t header;
+ /** This field describes the type of key being transported. The different
+ * types of keys are enumerated in Table 4.12 of ZigBee spec r19. */
+ uint8_t keyType;
+} ApsTransportKeyCommonFrame_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Main task handler of APS Transport Key component.
+ ******************************************************************************/
+APS_PRIVATE void apsTransportKeyTaskHandler(void);
+
+#if defined _TRUST_CENTRE_
+/**************************************************************************//**
+ \brief Process confirmation of APS transport key command transmission.
+
+ \param[in] commandReq - pointer to APS command request.
+ \param[in] status - command transmission status.
+
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void apsConfirmTransportKeyCommand(ApsCommandReq_t *const commandReq,
+ const APS_Status_t status);
+
+/**************************************************************************//**
+ \brief Initialization of common fields of APS Transport key command frame.
+
+ \param[in] commonFields - common sub-frame of transport key frame.
+ \param[in] keyType - type of key in the transport key command frame.
+
+ \return None.
+ ******************************************************************************/
+APS_PRIVATE void
+apsInitCommonTransportKeyFields(ApsTransportKeyCommonFrame_t *const commonFields,
+ const APS_TransportKeyType_t keyType);
+#endif /* _TRUST_CENTRE_ */
+
+/**************************************************************************//**
+ \brief Process an incoming transport key command frame.
+
+ \param[in] commandInd - pointer to received command descriptor.
+ \return 'true' if NWK_DataInd_t structure is not used otherwise return 'false'.
+ ******************************************************************************/
+APS_PRIVATE bool apsTransportKeyInd(const ApsCommandInd_t *const commandInd);
+
+/**************************************************************************//**
+ \brief Forward a transport key command to unauthenticated child.
+
+ \param[in] commandInd - pointer to received command descriptor.
+ \param[in] dstExtAddr - pointer to raw extended address from received frame.
+ \param[in] apsSendKeyToChildConf - NLDE-DATA confirm callback function's pointer.
+
+ \return 'true' if NWK_DataInd_t structure is not used otherwise return 'false'.
+ ******************************************************************************/
+APS_PRIVATE bool apsForwardKeyToChild(const ApsCommandInd_t *const commandInd,
+ const uint8_t *const dstExtAddr,
+ void (* apsSendKeyToChildConf)(NWK_DataConf_t *conf));
+
+/**************************************************************************//**
+ \brief Reset the internal queue and variables of Transport Key component.
+ ******************************************************************************/
+APS_PRIVATE void apsTransportKeyReset(void);
+
+#else
+#define apsTransportKeyTaskHandler NULL
+#define apsTransportKeyReset() (void)0
+#endif /* _SECURITY_ */
+#endif /* _APS_TRANSPORT_KEY_H */
+/** eof apsTransportKey.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTransportNwkKey.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTransportNwkKey.h
new file mode 100644
index 00000000..c1406631
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTransportNwkKey.h
@@ -0,0 +1,130 @@
+/**************************************************************************//**
+ \file apsTransportNwkKey.h
+
+ \brief Interface of NWK key transport.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2011-05-15 Max Gekk - Created.
+ Last change:
+ $Id: apsTransportNwkKey.h 17549 2011-06-15 09:36:29Z mgekk $
+ ******************************************************************************/
+#if !defined _APS_TRANSPORT_NWK_KEY_H
+#define _APS_TRANSPORT_NWK_KEY_H
+
+#if defined _SECURITY_
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsTransportKey.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+/* Tunneled auxiliary header consists of:
+ * - security control field (1 octet),
+ * - frame counter field (4 octets),
+ * - source address (8 octets) */
+#define APS_TUNNELED_AUXILIARY_HEADER_LEN 13
+/* See ZigBee spec. r18, page 493, Table 4.38. For security level = 0x05. */
+#define APS_TUNNELED_MIC_LEN 4
+
+#define APS_TRANSPORT_NWK_KEY_PAYLOAD_LEN \
+ (sizeof(ApsTransportNwkKeyFrame_t) - sizeof(ApduCommandHeader_t))
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+BEGIN_PACK
+/** Type of Transport-Key Command Frame (see ZigBee spec r19, Figure 4.8
+ * with network key descriptor field (see Figure 4.10, page 480). */
+typedef struct PACK _ApsTransportNwkKeyFrame_t
+{
+ /** Common part of APS transport key command frame. */
+ ApsTransportKeyCommonFrame_t common;
+ /** The key sub-field shall contain a network key. */
+ uint8_t key[SECURITY_KEY_SIZE];
+ /** The sequence number sub-field shall contain the sequence number associated
+ * with this network key. See ZigBee spec r19, 4.4.9.2.3.2 */
+ NWK_KeySeqNum_t keySeqNumber;
+ /** The destination address sub-field shall contain the address of the device
+ * which should use this network key. See ZigBee spec r19, page 480. */
+ uint8_t destinationAddress[sizeof(ExtAddr_t)];
+ /** The source address field sub-shall contain the address of the device
+ * (for example, the Trust Center) which originally sent this network key.
+ * See ZigBee Specification r19, 4.4.9.2.3.2, page 480. */
+ uint8_t sourceAddress[sizeof(ExtAddr_t)];
+} ApsTransportNwkKeyFrame_t;
+
+/**
+ * \brief Tunnel command frame payload.
+ *
+ * See ZigBee spec. r18, 4.4.9.8, page 490, Figure 4.22.
+ **/
+typedef struct PACK _ApsTunnelCommandFrame_t
+{
+ /** An APS header, which comprises frame control and addressing information. */
+ ApduCommandHeader_t header;
+ /** The 64-bit extended address of the device that is to receive the tunnelled command. */
+ uint8_t dstAddr[sizeof(ExtAddr_t)];
+ /** APS base header of the tunneled command: frame control and APS counter. */
+ ApduCommandBaseHeader_t tunneledHeader;
+ /** The tunneled auxiliary frame indicate that a link key was used
+ * and shall included the extended nonce field. ZigBee spec. r18, 4.4.9.8.3, page 491.*/
+ uint8_t tunneledAuxHeader[APS_TUNNELED_AUXILIARY_HEADER_LEN];
+ /** Identifier of the tunneled APS command. */
+ uint8_t commandId;
+ /** The tunnelled command field shall be the APS command frame to be sent to the
+ * destination. See ZigBee spec. r18, 4.4.9.8.4 and Figure 4.22. */
+ uint8_t tunneledPayload[APS_TRANSPORT_NWK_KEY_PAYLOAD_LEN];
+ /** Tunneled APS MIC. See ZigBee spec. r18, page 490, Figure 4.22. */
+ uint8_t mic[APS_TUNNELED_MIC_LEN];
+} ApsTunnelCommandFrame_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _TRUST_CENTRE_
+/**************************************************************************//**
+ \brief Checks specific parameters of Transport Nwk Key request.
+
+ \param[in] req - pointer to parameters of APSME-TRANSPORT-KEY.request.
+ \return Pointer to function for preparing and sending APS Transport Key command.
+ ******************************************************************************/
+APS_PRIVATE ApsTransportKeyCommand_t
+apsCheckTransportNwkKeyReq(APS_TransportKeyReq_t *const req);
+#endif /* _TRUST_CENTRE_ */
+
+/**************************************************************************//**
+ \brief Processing of a tunneling APS command.
+
+ Extracting the embedded tunnel command and send it to destination.
+
+ \param[in] commandInd - pointer to parameter's structure of received frame.
+ \return 'true' if NWK buffer should be released otherwise 'false'.
+ ******************************************************************************/
+APS_PRIVATE bool apsTunnelInd(const ApsCommandInd_t *const commandInd);
+
+/**************************************************************************//**
+ \brief Process an incoming transport key command with NWK key.
+
+ \param[in] commandInd - pointer to received command descriptor.
+
+ \return 'false' if structure commandInd->nwkDataInd is used otherwise 'true'.
+ ******************************************************************************/
+APS_PRIVATE bool apsTransportNwkKeyInd(const ApsCommandInd_t *const commandInd);
+
+#if !defined _TRUST_CENTRE_
+#define apsCheckTransportNwkKeyReq(req) NULL
+#endif
+#endif /* _SECURITY_ */
+#endif /* _APS_TRANSPORT_NWK_KEY_H */
+/** eof apsTransportNwkKey.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTransportTrustKey.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTransportTrustKey.h
new file mode 100644
index 00000000..3a7c8626
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsTransportTrustKey.h
@@ -0,0 +1,83 @@
+/**************************************************************************//**
+ \file apsTransportTrustKey.h
+
+ \brief Interface of transport key from the trust center.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2011-05-08 Max Gekk - Created.
+ Last change:
+ $Id: apsTransportTrustKey.h 17813 2011-07-04 14:11:12Z dloskutnikov $
+ ******************************************************************************/
+#if !defined _APS_TRANSPORT_TRUST_KEY_H
+#define _APS_TRANSPORT_TRUST_KEY_H
+
+#if defined _SECURITY_ && defined _LINK_SECURITY_
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsTransportKey.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+BEGIN_PACK
+/** Type of Transport-Key Command Frame (see ZigBee spec r19, Figure 4.8
+ * with trust center master or link key descriptor field (see Figure 4.9). */
+typedef struct PACK _ApsTransportTrustKeyFrame_t
+{
+ /** Common part of APS transport key command frame. */
+ ApsTransportKeyCommonFrame_t common;
+ /** The key sub-field shall contain the master key that should be used to set
+ * up link keys with the Trust Center or link key. */
+ uint8_t key[SECURITY_KEY_SIZE];
+ /** The destination address sub-field shall contain the address of the device
+ * which should use this master or link key. ZigBee spec r19, page 480. */
+ uint8_t destinationAddress[sizeof(ExtAddr_t)];
+ /** The source address sub-field shall contain the address of the device (for
+ * example, the Trust Center) which originally sent this master key.
+ * See ZigBee Specification r19, 4.4.9.2.3.1, page 480. */
+ uint8_t sourceAddress[sizeof(ExtAddr_t)];
+} ApsTransportTrustKeyFrame_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _TRUST_CENTRE_
+/**************************************************************************//**
+ \brief Checks specific parameters of Transport Trust Key request.
+
+ \param[in] req - pointer to parameters of APSME-TRANSPORT-KEY.request.
+ \return Pointer to function for preparing and sending APS Transport Key command.
+ ******************************************************************************/
+APS_PRIVATE ApsTransportKeyCommand_t
+apsCheckTransportTrustKeyReq(APS_TransportKeyReq_t *const req);
+#endif /* _TRUST_CENTRE_ */
+
+/**************************************************************************//**
+ \brief Process an incoming trust link or master key.
+
+ \param[in] commandInd - pointer to received command descriptor.
+
+ \return 'false' if structure commandInd->nwkDataInd is used otherwise 'true'.
+ ******************************************************************************/
+APS_PRIVATE bool apsTransportTrustKeyInd(const ApsCommandInd_t *const commandInd);
+
+#else
+#define apsTransportTrustKeyInd(commandInd) (true)
+#endif /* _SECURITY_ and _LINK_SECURITY_ */
+
+#if !(defined _SECURITY_ && defined _LINK_SECURITY_ && defined _TRUST_CENTRE_)
+
+#define apsCheckTransportTrustKeyReq(req) NULL
+#endif
+#endif /* _APS_TRANSPORT_TRUST_KEY_H */
+/* eof apsTransportTrustKey.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsUpdateDevice.h b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsUpdateDevice.h
new file mode 100644
index 00000000..39765708
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/APS/include/private/apsUpdateDevice.h
@@ -0,0 +1,64 @@
+/**************************************************************************//**
+ \file apsUpdateDevice.h
+
+ \brief Private interface of APS Update Device.
+
+ \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:
+ 2010-12-18 Max Gekk - Created.
+ Last change:
+ $Id: apsUpdateDevice.h 17470 2011-06-10 11:31:00Z mgekk $
+ ******************************************************************************/
+#if !defined _APS_UPDATE_DEVICE_H
+#define _APS_UPDATE_DEVICE_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <apsCommand.h>
+#include <nwk.h>
+#include <apsFrames.h>
+
+#if defined _SECURITY_
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+BEGIN_PACK
+/** Type of APS update device command frame. */
+typedef struct PACK _ApsUpdateDeviceFrame_t
+{
+ /** An APS header, which comprises frame control and addressing information. */
+ ApduCommandHeader_t header;
+ /** The 64-bit extended address of the device whose status is being updated.*/
+ ExtAddr_t deviceAddress;
+ /** The 16-bit network address of the device whose status is being updated. */
+ ShortAddr_t deviceShortAddress;
+ /** The status field shall be assigned a value as described for the Status
+ * parameter in ZigBee spec r19, Table 4.20. */
+ uint8_t status;
+} ApsUpdateDeviceFrame_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Update device indication handler.
+
+ \param[in] commandInd - pointer to received command descriptor.
+
+ \return 'true' if NWK buffer with the command frame must be freed
+ otherwise return 'false'.
+ ******************************************************************************/
+APS_PRIVATE bool apsUpdateDeviceInd(const ApsCommandInd_t *const commandInd);
+
+#endif /* _SECURITY_ */
+#endif /* _APS_UPDATE_DEVICE_H */
+/** eof apsUpdateDevice.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/BoardConfig b/digital/zigbit/bitcloud/stack/Components/BSP/BoardConfig
new file mode 100644
index 00000000..c1d952b9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/BoardConfig
@@ -0,0 +1,106 @@
+ifeq ($(BOARD), BOARD_MESHBEAN)
+ BSP_LIB = BSPMeshBean
+ BOARDCFLAGS = -D_BUTTONS_
+ BOARDCFLAGS += -D_TEMPERATURE_SENSOR_
+ BOARDCFLAGS += -D_LIGHT_SENSOR_
+ BOARDCFLAGS += -D_BATTERY_SENSOR_
+ BOARDCFLAGS += -D_LEDS_
+ BOARDCFLAGS += -D_SLIDERS_
+ BOARDCFLAGS += -DBSP_MNZB_EVB_SUPPORT=1
+endif
+
+ifeq ($(BOARD), BOARD_RAVEN)
+ BSP_LIB = BSPRaven
+ BOARDCFLAGS = -D_LCD_
+ BOARDCFLAGS += -D_TEMPERATURE_SENSOR_
+ BOARDCFLAGS += -D_BATTERY_SENSOR_
+endif
+
+ifeq ($(BOARD), BOARD_USB_DONGLE)
+ BSP_LIB = BSPAtmlUsbDongle
+ BOARDCFLAGS = -D_LEDS_
+endif
+
+ifeq ($(BOARD), BOARD_STK600)
+ BSP_LIB = BSPStk600
+ BOARDCFLAGS = -D_BUTTONS_
+ BOARDCFLAGS += -D_LEDS_
+endif
+
+ifeq ($(BOARD), BOARD_STK500)
+ BSP_LIB = BSPStk500
+ BOARDCFLAGS = -D_BUTTONS_
+ BOARDCFLAGS += -D_LEDS_
+endif
+
+ifeq ($(BOARD), BOARD_MESHBEAN_TURBO)
+ BSP_LIB = BSPMeshBeanTurbo
+ BOARDCFLAGS = -D_LEDS_
+ BOARDCFLAGS += -D_SLIDERS_
+ BOARDCFLAGS += -D_BUTTONS_
+endif
+
+ifeq ($(BOARD), BOARD_MESHBEAN_LAN)
+ BSP_LIB = BSPMeshBeanLan
+ BOARDCFLAGS = -D_LEDS_
+ BOARDCFLAGS += -D_BUTTONS_
+endif
+
+ifeq ($(BOARD), BOARD_SAM7X_EK)
+ BSP_LIB = BSPSam7xEk
+ BOARDCFLAGS = -D_LEDS_
+ BOARDCFLAGS += -D_JOYSTICK_
+endif
+
+ifeq ($(BOARD), BOARD_SAM3S_EK)
+ BSP_LIB = BSPSam3sEk
+ BOARDCFLAGS = -D_LEDS_
+endif
+
+ifeq ($(BOARD), BOARD_CUSTOM_3)
+ BSP_LIB = BSPCustom3
+ BOARDCFLAGS = -D_LEDS_
+endif
+
+ifeq ($(BOARD), BOARD_CUSTOM_1)
+ BSP_LIB = BSPCustom1
+ BOARDCFLAGS = -D_LEDS_
+ BOARDCFLAGS += -D_BUTTONS_
+ BOARDCFLAGS += -D_RS485CONTROL_
+endif
+
+ifeq ($(BOARD), BOARD_CUSTOM_2)
+ BSP_LIB = BSPCustom2
+ BOARDCFLAGS = -D_LEDS_
+ BOARDCFLAGS += -D_BUTTONS_
+ BOARDCFLAGS += -D_RS485CONTROL_
+ BOARDCFLAGS += -D_USBCONTROL_
+endif
+
+ifeq ($(BOARD), BOARD_RCB)
+ BSP_LIB = BSPRcb
+ BOARDCFLAGS = -D_LEDS_
+endif
+
+ifeq ($(BOARD), BOARD_AVR32_EVK1105)
+ BSP_LIB = BSPAvr32Evk1105
+ BOARDCFLAGS = -D_LEDS_
+ BOARDCFLAGS += -D_BUTTONS_
+endif
+
+ifeq ($(BOARD), BOARD_XPLAIN)
+ BSP_LIB = BSPXplain
+ BOARDCFLAGS = -D_LEDS_
+ BOARDCFLAGS += -D_BUTTONS_
+endif
+
+ifeq ($(BOARD), BOARD_REB_CBB)
+ BSP_LIB = BSPRebCbb
+ BOARDCFLAGS = -D_LEDS_
+ BOARDCFLAGS += -D_BUTTONS_
+endif
+
+ifeq ($(BOARD), BOARD_SIMULATOR)
+ BSP_LIB = BSPsim
+ BOARDCFLAGS = -D_LEDS_
+endif
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/BoardConfig.h b/digital/zigbit/bitcloud/stack/Components/BSP/BoardConfig.h
new file mode 100644
index 00000000..41c464d2
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/BoardConfig.h
@@ -0,0 +1,89 @@
+/***************************************************************************//**
+\file BoardConfig.h
+
+\brief Definition of board-specific periphery for each platform.
+
+\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).
+*******************************************************************************/
+#ifdef BOARD_MESHBEAN
+ #define _BUTTONS_
+ #define _TEMPERATURE_SENSOR_
+ #define _LIGHT_SENSOR_
+ #define _LEDS_
+ #define _SLIDERS_
+#endif
+#ifdef BOARD_RAVEN
+ #define _LCD_
+ #define _TEMPERATURE_SENSOR_
+ #define _BATTERY_SENSOR_
+#endif
+#ifdef BOARD_USB_DONGLE
+ #define _LEDS_
+#endif
+#ifdef BOARD_STK600
+ #define _BUTTONS_
+ #define _LEDS_
+#endif
+#ifdef BOARD_STK500
+ #define _BUTTONS_
+ #define _LEDS_
+#endif
+#ifdef BOARD_MESHBEAN_TURBO
+ #define _LEDS_
+ #define _SLIDERS_
+ #define _BUTTONS_
+#endif
+#ifdef BOARD_MESHBEAN_LAN
+ #define _LEDS_
+ #define _BUTTONS_
+#endif
+#ifdef BOARD_SAM7X_EK
+ #define _LEDS_
+ #define _JOYSTICK_
+#endif
+#ifdef BOARD_SAM3S_EK
+ #define _LEDS_
+#endif
+#ifdef BOARD_SAM3S_PIRRD
+ #define _LEDS_
+#endif
+#ifdef BOARD_RF231USBRD
+ #define _LEDS_
+#endif
+#ifdef BOARD_CUSTOM_3
+ #define _LEDS_
+#endif
+#ifdef BOARD_CUSTOM_1
+ #define _LEDS_
+ #define _BUTTONS_
+ #define _RS485CONTROL_
+#endif
+#ifdef BOARD_CUSTOM_2
+ #define _LEDS_
+ #define _BUTTONS_
+ #define _RS485CONTROL_
+ #define _USBCONTROL_
+#endif
+#ifdef BOARD_RCB
+ #define _LEDS_
+#endif
+#ifdef BOARD_AVR32_EVK1105
+ #define _LEDS_
+ #define _BUTTONS_
+#endif
+#ifdef BOARD_XPLAIN
+ #define _LEDS_
+ #define _BUTTONS_
+#endif
+#ifdef BOARD_REB_CBB
+ #define _LEDS_
+ #define _BUTTONS_
+#endif
+#ifdef BOARD_SIMULATOR
+ #define _LEDS_
+#endif
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/battery.h b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/battery.h
new file mode 100644
index 00000000..5bdc91fe
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/battery.h
@@ -0,0 +1,63 @@
+/**************************************************************************//**
+\file battery.h
+
+\brief Interface to the battery sensor.
+
+\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:
+ 29/06/07 E. Ivanov - Created
+******************************************************************************/
+
+#ifndef _BATTERY_H
+#define _BATTERY_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+// \cond
+#include <types.h>
+#include <sensors.h>
+// \endcond
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Opens the component to use.
+\return
+ BC_SUCCESS - the component is ready to been use. \n
+ BC_FAIL - otherwise.
+******************************************************************************/
+result_t openBattery(void);
+
+/**************************************************************************//**
+\brief Closes component.
+\return
+ BC_SUCCESS - always.
+******************************************************************************/
+result_t closeBattery(void);
+
+/**************************************************************************//**
+\brief Starts ADC request on battery channel.
+\param[in]
+ callback - callback method.
+\param[in]
+ data - battery data.
+ Can use (4ul * data * 125ul * 3ul) / (1024ul * 100ul) formula to count \n
+ battery data in Volts.
+\return
+ BC_FAIL - battery component was not opened.
+ BC_SUCCESS - other case.
+******************************************************************************/
+result_t readBatteryData(BspBatteryCb_t);
+
+#endif /* _BATTERY_H */
+// eof battery.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/bspDbg.h b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/bspDbg.h
new file mode 100644
index 00000000..b3bb6013
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/bspDbg.h
@@ -0,0 +1,40 @@
+/***************************************************************************//**
+ \file bspDbg.h
+
+ \brief Assert codes for BSP
+
+ \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:
+ 10/06/10 D. Loskutnikov - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _BSPDBG_H
+#define _BSPDBG_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <dbg.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+enum
+{
+ TSL2550_UNEXPECTED_STATE = 0x9000,
+};
+
+#endif /* _BSPDBG_H */
+
+// eof bspDbg.h
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/bspLeds.h b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/bspLeds.h
new file mode 100644
index 00000000..fc088281
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/bspLeds.h
@@ -0,0 +1,70 @@
+/***************************************************************************//**
+\file bspLeds.h
+
+\brief Declaration of leds defines.
+
+\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:
+ 29/05/07 E. Ivanov - Created
+*******************************************************************************/
+
+#ifndef _BSPLEDS_H
+#define _BSPLEDS_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+// \cond
+#include <gpio.h>
+#include <leds.h>
+// \endcond
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+#define halInitRedLed() GPIO_0_make_out()
+#define halUnInitRedLed() GPIO_0_make_in()
+#define halReadRedLed() GPIO_0_read()
+#define halToggleRedLed() GPIO_0_toggle()
+
+#define halInitYellowLed() GPIO_1_make_out()
+#define halUnInitYellowLed() GPIO_1_make_in()
+#define halReadYellowLed() GPIO_1_read()
+#define halToggleYellowLed() GPIO_1_toggle()
+
+#define halInitGreenLed() GPIO_2_make_out()
+#define halUnInitGreenLed() GPIO_2_make_in()
+#define halReadGreenLed() GPIO_2_read()
+#define halToggleGreenLed() GPIO_2_toggle()
+
+#if BSP_MNZB_EVB_SUPPORT == 1
+ #define halOnRedLed() GPIO_0_set()
+ #define halOffRedLed() GPIO_0_clr()
+
+ #define halOnYellowLed() GPIO_1_set()
+ #define halOffYellowLed() GPIO_1_clr()
+
+ #define halOnGreenLed() GPIO_2_set()
+ #define halOffGreenLed() GPIO_2_clr()
+#else
+ /* Atmel MeshBean boards */
+ #define halOnRedLed() GPIO_0_clr()
+ #define halOffRedLed() GPIO_0_set()
+
+ #define halOnYellowLed() GPIO_1_clr()
+ #define halOffYellowLed() GPIO_1_set()
+
+ #define halOnGreenLed() GPIO_2_clr()
+ #define halOffGreenLed() GPIO_2_set()
+#endif /* BSP_MNZB_EVB_SUPPORT */
+
+#endif /*_BSPLEDS_H*/
+// eof bspLeds.h
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/bspTaskManager.h b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/bspTaskManager.h
new file mode 100644
index 00000000..a2198513
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/bspTaskManager.h
@@ -0,0 +1,60 @@
+/**************************************************************************//**
+\file bspTaslManager.h
+
+\brief Declarations of enums and functions of BSP task manager.
+
+\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:
+ 29/05/07 E. Ivanov - Created
+*******************************************************************************/
+
+#ifndef _BSPTASKHANDLER_H
+#define _BSPTASKHANDLER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+// \cond
+#include <types.h>
+#include <taskManager.h>
+// \endcond
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+enum
+{
+ BSP_BUTTONS = (uint8_t)1 << 0,
+ BSP_TEMPERATURE = (uint8_t)1 << 1,
+ BSP_LIGHT = (uint8_t)1 << 2,
+ BSP_BATTERY = (uint8_t)1 << 3,
+};
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+extern volatile uint8_t bspTaskFlags;
+
+/******************************************************************************
+ Inline static functions section
+******************************************************************************/
+/***************************************************************************//**
+\brief posting bsp task for task manager.
+\param[in]
+ flag - task number
+*******************************************************************************/
+INLINE void bspPostTask(uint8_t flag)
+{
+ bspTaskFlags |= flag;
+ SYS_PostTask(BSP_TASK_ID);
+}
+
+#endif /* _BSPTASKHANDLER_H */
+// eof bspTaskManager.h
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/lm73.h b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/lm73.h
new file mode 100644
index 00000000..29cf29e2
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/lm73.h
@@ -0,0 +1,66 @@
+/**************************************************************************//**
+\file lm73.h
+
+\brief Declarations of lm73 interface.
+
+\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:
+ 29/05/07 E. Ivanov - Created
+*******************************************************************************/
+
+#ifndef _LM73_SENSOR_H
+#define _LM73_SENSOR_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Opens the component to use.
+
+\return
+ BC_SUCCESS - the component is ready to been use. \n
+ BC_FAIL - otherwise.
+******************************************************************************/
+result_t openLm73(void);
+
+/**************************************************************************//**
+\brief Performs the test if the component have completed request.
+
+\return
+ BC_FAIL - the previous request is not completed.
+ BC_SUCCESS - otherwise.
+******************************************************************************/
+result_t closeLm73(void);
+
+/**************************************************************************//**
+\brief Reads data from lm73 sensor.
+\param[in]
+ f - callback method.
+\param[in]
+ result - the result of the requested operation.
+ true - operation finished successfully,
+ false - some error has occured.
+\param[in]
+ data - sensor data.
+\return
+ BC_FAIL - the previous request was not completed,
+ the address of callback is 0, i2c interface is busy,
+ there is error on i2c interface.
+ BC_SUCCESS - other case.
+******************************************************************************/
+result_t readLm73Data(void (*f)(bool result, int16_t data));
+
+#endif /* _LM73_SENSOR_H */
+// eof lm73.h
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/pwrCtrl.h b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/pwrCtrl.h
new file mode 100644
index 00000000..6a25e942
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/pwrCtrl.h
@@ -0,0 +1,47 @@
+/**************************************************************************//**
+\file pwrCtrl.h
+
+\brief Interface to the power control module.
+
+\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:
+ 29/05/07 E. Ivanov - Created
+*******************************************************************************/
+
+#ifndef _POWERCTRL_H
+#define _POWERCTRL_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Powers on periphery.
+
+\param[in]
+ id - number of periphery
+******************************************************************************/
+void bspOnPeriphery(uint8_t id);
+
+/**************************************************************************//**
+\brief Powers off periphery.
+
+\param[in]
+ id - number of periphery
+******************************************************************************/
+void bspOffPeriphery(uint8_t id);
+
+#endif /* _POWERCTRL_H */
+// eof pwrCtrl.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/tsl2550.h b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/tsl2550.h
new file mode 100644
index 00000000..de869031
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/include/tsl2550.h
@@ -0,0 +1,64 @@
+/**************************************************************************//**
+\file tsl2550.h
+
+\brief Declarations of tsl2550 interface.
+
+\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:
+ 29/06/07 E. Ivanov - Created
+*******************************************************************************/
+
+#ifndef _TSL2550_SENSOR_H
+#define _TSL2550_SENSOR_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+// \cond
+#include <types.h>
+// \endcond
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Opens the component to use.
+\return
+ BC_SUCCESS - the component is ready to been use. \n
+ BC_FAIL - otherwise.
+******************************************************************************/
+result_t openTsl2550(void);
+
+/**************************************************************************//**
+\brief Performs the test if the component have uncompleted request.
+\return
+ BC_FAIL - the previous request is not completed. \n
+ BC_SUCCES - otherwise.
+******************************************************************************/
+result_t closeTsl2550(void);
+
+/**************************************************************************//**
+\brief Reads data from tsl2550 sensor.
+\param[in]
+ result - the result of the requested operation.
+ true - operation finished successfully, false - some error has
+ occured.
+\param[in]
+ data - sensor data.
+\return
+ BC_FAIL - the previous request was not completed, \n
+ the address of callback is 0, i2c interface is busy, \n
+ there is error on i2c interface. \n
+ BC_SUCCESS - other case.
+******************************************************************************/
+result_t readTsl2550Data(void (*f)(bool result, int16_t data));
+
+#endif /* _TSL2550_SENSOR_H */
+// eof tsl2550.h
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/battery.c b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/battery.c
new file mode 100644
index 00000000..63facdb3
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/battery.c
@@ -0,0 +1,168 @@
+/**************************************************************************//**
+\file battery.c
+
+\brief This module is used for measurment battery voltage.
+
+\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:
+ 29/06/07 E. Ivanov - Created
+******************************************************************************/
+#if APP_DISABLE_BSP != 1
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <battery.h>
+#include <adc.h>
+#include <bspTaskManager.h>
+#include <types.h>
+
+#if BSP_MNZB_EVB_SUPPORT == 1
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define BATTERY_AMOUNT_DISPERSION 2
+#define MAX_AMOUNT_COUNTER 20
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+// battery states
+typedef enum
+{
+ IDLE, // idle
+ BUSY, // opened and ready to be used
+ DATA // performs request
+} batteryStates_t;
+
+// battery descriptor
+typedef struct
+{
+ uint8_t batteryData;
+ BspBatteryCb_t batteryCallback; // callback
+} BatteryControl_t;
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+// Monitors current state
+static batteryStates_t batteryState = IDLE;
+static BatteryControl_t batteryControl;
+static HAL_AdcParams_t adcParam;
+static uint8_t batExpectation;
+static uint8_t batAmountCnt;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Callback about ADC request was completed.
+\param[in]
+ data - result of ADC.
+******************************************************************************/
+void batteryCallback(void)
+{
+ batAmountCnt++;
+ if ((batteryControl.batteryData > (batExpectation + BATTERY_AMOUNT_DISPERSION)) ||
+ (batteryControl.batteryData < (batExpectation - BATTERY_AMOUNT_DISPERSION)))
+ {
+ batExpectation = batteryControl.batteryData;
+ batAmountCnt = 0;
+ }
+
+ if (MAX_AMOUNT_COUNTER == batAmountCnt)
+ {
+ batAmountCnt = 0;
+ batExpectation = 0;
+ bspPostTask(BSP_BATTERY);
+ return;
+ }
+
+ batteryState = BUSY;
+ readBatteryData(batteryControl.batteryCallback);
+}
+
+/**************************************************************************//**
+\brief Opens the component to use.
+\return
+ BC_SUCCESS - the component is ready to been use. \n
+ BC_FAIL - otherwise.
+******************************************************************************/
+result_t openBattery(void)
+{
+ if (IDLE == batteryState)
+ {
+ adcParam.bufferPointer = &(batteryControl.batteryData);
+ adcParam.callback = batteryCallback;
+ adcParam.resolution = RESOLUTION_8_BIT;
+ adcParam.sampleRate = ADC_4800SPS;
+ adcParam.selectionsAmount = 1;
+ adcParam.voltageReference = AREF;
+ batteryState = BUSY;
+ HAL_OpenAdc(&adcParam);
+ return BC_SUCCESS;
+ }
+ return BC_FAIL;
+}
+
+/**************************************************************************//**
+\brief Closes component.
+\return
+ BC_SUCCESS - always.
+******************************************************************************/
+result_t closeBattery(void)
+{
+ if (IDLE == batteryState)
+ return BC_FAIL;
+ batteryState = IDLE;
+ HAL_CloseAdc();
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief Starts ADC request on battery channel.
+\param[in]
+ data - sensor data.
+\return
+ BC_FAIL - battery component was not opened. \n
+ BC_SUCCESS - other case.
+******************************************************************************/
+result_t readBatteryData(BspBatteryCb_t cb)
+{
+ if (BUSY != batteryState)
+ return BC_FAIL;
+ batteryState = DATA;
+ batteryControl.batteryCallback = cb;
+ HAL_ReadAdc(HAL_ADC_CHANNEL0);
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief BSP battery handler.
+******************************************************************************/
+void bspBatteryHandler(void)
+{
+ int16_t value;
+
+ // 1250 - 1.25 V reference voltage expressed in mV (1250 mV)
+ // 3 - battery voltage is divided by 3 on the MeshBean board
+ // 256 - steps for 8 bit ADC
+ // Resulting value is a true battery voltage expressed in mV
+ value = (batteryControl.batteryData * 1250ul * 3ul) / 256ul;
+
+ batteryState = BUSY;
+ batteryControl.batteryCallback(value);
+}
+#endif /* BSP_MNZB_EVB_SUPPORT */
+
+#endif // APP_DISABLE_BSP != 1
+
+// eof battery.c
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/bspTaskManager.c b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/bspTaskManager.c
new file mode 100644
index 00000000..d63f62da
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/bspTaskManager.c
@@ -0,0 +1,121 @@
+/**************************************************************************//**
+\file bspTaskManager.c
+
+\brief Implemenattion of BSP task manager.
+
+\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:
+ 29/05/07 E. Ivanov - Created
+******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <bspTaskManager.h>
+#include <atomic.h>
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief BSP button handler.
+******************************************************************************/
+void bspButtonsHandler(void);
+
+/**************************************************************************//**
+\brief BSP lm73 handler.
+******************************************************************************/
+void bspLM73Handler(void);
+void bspTemperatureSensorHandler(void);
+
+/**************************************************************************//**
+\brief BSP tsl2550 handler.
+******************************************************************************/
+void bspTsl2550Handler(void);
+void bspLightSensorHandler(void);
+
+/**************************************************************************//**
+\brief BSP battery handler.
+******************************************************************************/
+void bspBatteryHandler(void);
+void bspEmptyBatteryHandler(void);
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+volatile uint8_t bspTaskFlags = 0;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief BSP task handler.
+******************************************************************************/
+#if APP_DISABLE_BSP != 1
+
+void BSP_TaskHandler(void)
+{
+ if (bspTaskFlags & BSP_BUTTONS)
+ {
+ bspTaskFlags &= (~BSP_BUTTONS);
+ bspButtonsHandler();
+ }
+ if (bspTaskFlags & BSP_TEMPERATURE)
+ {
+ bspTaskFlags &= (~BSP_TEMPERATURE);
+ bspLM73Handler();
+ }
+ if (bspTaskFlags & BSP_LIGHT)
+ {
+ bspTaskFlags &= (~BSP_LIGHT);
+ bspTsl2550Handler();
+ }
+ if (bspTaskFlags & BSP_BATTERY)
+ {
+ bspTaskFlags &= (~BSP_BATTERY);
+#if BSP_MNZB_EVB_SUPPORT == 1
+ bspBatteryHandler();
+#else
+ bspEmptyBatteryHandler();
+#endif // BSP_MNZB_EVB_SUPPORT == 1
+ }
+ if (bspTaskFlags)
+ {
+ SYS_PostTask(BSP_TASK_ID);
+ }
+}
+
+#else // APP_DISABLE_BSP != 1
+
+void BSP_TaskHandler(void)
+{
+ if (bspTaskFlags & BSP_TEMPERATURE)
+ {
+ bspTaskFlags &= (~BSP_TEMPERATURE);
+ bspTemperatureSensorHandler();
+ }
+ if (bspTaskFlags & BSP_LIGHT)
+ {
+ bspTaskFlags &= (~BSP_LIGHT);
+ bspLightSensorHandler();
+ }
+ if (bspTaskFlags & BSP_BATTERY)
+ {
+ bspTaskFlags &= (~BSP_BATTERY);
+ bspEmptyBatteryHandler();
+ }
+ if (bspTaskFlags)
+ {
+ SYS_PostTask(BSP_TASK_ID);
+ }
+}
+
+#endif // APP_DISABLE_BSP != 1
+
+// eof bspTaskManager.c
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/buttons.c b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/buttons.c
new file mode 100644
index 00000000..8867a82b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/buttons.c
@@ -0,0 +1,239 @@
+/**************************************************************************//**
+\file buttons.c
+
+\brief Implementation of buttons interface.
+
+\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:
+ 30/05/08 A. Khromykh - Created
+*******************************************************************************/
+#if APP_DISABLE_BSP != 1
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <buttons.h>
+#include <irq.h>
+#include <appTimer.h>
+#include <bspTaskManager.h>
+#include <gpio.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define BSP_readKEY0() GPIO_IRQ_6_read()
+#define BSP_readKEY1() GPIO_IRQ_7_read()
+#define PRESSED 1
+#define RELEASED 0
+#define BSP_BUTTONS_IDLE 0
+#define BSP_BUTTONS_BUSY 1
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef struct
+{
+ uint8_t currentState0 : 1;
+ uint8_t currentState1 : 1;
+ uint8_t wasPressed0 : 1;
+ uint8_t wasPressed1 : 1;
+ uint8_t waitReleased0 : 1;
+ uint8_t waitReleased1 : 1;
+} BSP_buttonsAction_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief HAL's event handlers about KEY 0 has changed state.
+******************************************************************************/
+void bspKey0InterruptHandler(void);
+
+/**************************************************************************//**
+\brief HAL's event handlers about KEY 1 has changed state.
+******************************************************************************/
+void bspKey1InterruptHandler(void);
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+static uint8_t state = BSP_BUTTONS_IDLE;
+static volatile BSP_buttonsAction_t buttonsAction;
+static BSP_ButtonsEventFunc_t bspButtonPressHandle; // callback
+static BSP_ButtonsEventFunc_t bspButtonReleaseHandle; // callback
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Initializes buttons module.
+******************************************************************************/
+static void bspInitButtons(void)
+{
+ HAL_RegisterIrq(IRQ_6, IRQ_LOW_LEVEL, bspKey0InterruptHandler);
+ HAL_RegisterIrq(IRQ_7, IRQ_LOW_LEVEL, bspKey1InterruptHandler);
+
+ if (BSP_readKEY0())
+ buttonsAction.currentState0 = RELEASED;
+ else
+ buttonsAction.currentState0 = PRESSED;
+
+ if (BSP_readKEY1())
+ buttonsAction.currentState1 = RELEASED;
+ else
+ buttonsAction.currentState1 = PRESSED;
+
+ HAL_EnableIrq(IRQ_6);
+ HAL_EnableIrq(IRQ_7);
+}
+
+/**************************************************************************//**
+\brief Registers handlers for button events.
+
+\param[in]
+ pressed - the handler to process pressing the button
+\param[in]
+ released - the handler to process releasing the button
+\param[in]
+ bn - button number.
+\return
+ BC_FAIL - buttons module is busy, \n
+ BC_SUCCESS in other case.
+******************************************************************************/
+result_t BSP_OpenButtons(void (*pressed)(uint8_t bn), void (*released)(uint8_t bn))
+{
+ if (state != BSP_BUTTONS_IDLE)
+ return BC_FAIL;
+ state = BSP_BUTTONS_BUSY;
+ bspButtonPressHandle = pressed;
+ bspButtonReleaseHandle = released;
+ bspInitButtons();
+ return BC_SUCCESS;
+};
+
+/**************************************************************************//**
+\brief Cancel buttons handlers.
+\return
+ BC_FAIL - buttons module was not opened, \n
+ BC_SUCCESS in other case.
+******************************************************************************/
+result_t BSP_CloseButtons(void)
+{
+ if (state != BSP_BUTTONS_BUSY)
+ return BC_FAIL;
+ HAL_UnregisterIrq(IRQ_6);
+ HAL_UnregisterIrq(IRQ_7);
+ bspButtonPressHandle = NULL;
+ bspButtonReleaseHandle = NULL;
+ state = BSP_BUTTONS_IDLE;
+ return BC_SUCCESS;
+};
+
+/**************************************************************************//**
+\brief Reads state of buttons.
+
+\return
+ Current buttons state in a binary way. \n
+ Bit 0 defines state of the button 1, \n
+ bit 1 defines state of the button 2.
+******************************************************************************/
+uint8_t BSP_ReadButtonsState(void)
+{
+ uint8_t state = 0;
+
+ if (buttonsAction.currentState0)
+ state = 0x01;
+
+ if (buttonsAction.currentState1)
+ state |= 0x02;
+
+ return state;
+}
+
+/**************************************************************************//**
+\brief HAL's event about KEY has changed state.
+******************************************************************************/
+void bspKey0InterruptHandler(void)
+{
+ HAL_DisableIrq(IRQ_6);
+ buttonsAction.currentState0 = PRESSED;
+ buttonsAction.wasPressed0 = 1;
+ bspPostTask(BSP_BUTTONS);
+}
+
+/**************************************************************************//**
+\brief HAL's event about KEY has changed state.
+******************************************************************************/
+void bspKey1InterruptHandler(void)
+{
+ HAL_DisableIrq(IRQ_7);
+ buttonsAction.currentState1 = PRESSED;
+ buttonsAction.wasPressed1 = 1;
+ bspPostTask(BSP_BUTTONS);
+}
+
+/**************************************************************************//**
+\brief BSP's event about KEY has changed state.
+******************************************************************************/
+void bspButtonsHandler(void)
+{
+ if (buttonsAction.wasPressed0)
+ {
+ buttonsAction.wasPressed0 = 0;
+ buttonsAction.waitReleased0 = 1;
+ if (NULL != bspButtonPressHandle)
+ bspButtonPressHandle(BSP_KEY0);
+ }
+
+ if (buttonsAction.waitReleased0)
+ {
+ if (BSP_readKEY0())
+ {
+ buttonsAction.waitReleased0 = 0;
+ buttonsAction.currentState0 = RELEASED;
+ if (NULL != bspButtonReleaseHandle)
+ bspButtonReleaseHandle(BSP_KEY0);
+ HAL_EnableIrq(IRQ_6);
+ }
+ else
+ {
+ bspPostTask(BSP_BUTTONS);
+ }
+ }
+
+ if (buttonsAction.wasPressed1)
+ {
+ buttonsAction.wasPressed1 = 0;
+ buttonsAction.waitReleased1 = 1;
+ if (NULL != bspButtonPressHandle)
+ bspButtonPressHandle(BSP_KEY1);
+ }
+
+ if (buttonsAction.waitReleased1)
+ {
+ if (BSP_readKEY1())
+ {
+ buttonsAction.waitReleased1 = 0;
+ buttonsAction.currentState1 = RELEASED;
+ if (NULL != bspButtonReleaseHandle)
+ bspButtonReleaseHandle(BSP_KEY1);
+ HAL_EnableIrq(IRQ_7);
+ }
+ else
+ {
+ bspPostTask(BSP_BUTTONS);
+ }
+ }
+}
+
+#endif // APP_DISABLE_BSP != 1
+
+// end of buttons.c
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/fakeBSP.c b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/fakeBSP.c
new file mode 100644
index 00000000..77aa9c51
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/fakeBSP.c
@@ -0,0 +1,359 @@
+/***************************************************************************//**
+\file fakeBSP.c
+
+\brief Implementation of fake board-specific periphery.
+
+\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:
+ 28/04/11 A. Malkin - Created
+*******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <joystick.h>
+#include <bspTaskManager.h>
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+#if (APP_DISABLE_BSP == 1) || (BSP_MNZB_EVB_SUPPORT != 1)
+void(* readBatteryDataCallback)(int16_t data);
+#endif //(APP_DISABLE_BSP == 1) || (BSP_MNZB_EVB_SUPPORT != 1)
+#if APP_DISABLE_BSP == 1
+void(* readTemperatureDataCallback)(bool error, int16_t data);
+void(* readLightDataCallback)(bool error, int16_t data);
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+ Buttons
+******************************************************************************/
+/**************************************************************************//**
+\brief Registers handlers for button events.
+
+\param[in]
+ pressed - the handler to process pressing the button
+\param[in]
+ released - the handler to process releasing the button
+\param[in]
+ bn - button number.
+
+\return
+ BC_SUCCESS - always.
+******************************************************************************/
+result_t BSP_OpenButtons(void (*pressed)(uint8_t bn), void (*released)(uint8_t bn))
+{
+ (void)pressed;
+ (void)released;
+
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief Cancel buttons handlers.
+
+\return
+ BC_SUCCESS - always.
+******************************************************************************/
+result_t BSP_CloseButtons(void)
+{
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief Reads state of buttons.
+
+\return
+ Current buttons state in a binary way. \n
+ Bit 0 defines state of the button 1, \n
+ bit 1 defines state of the button 2.
+******************************************************************************/
+uint8_t BSP_ReadButtonsState(void)
+{
+ return 0;
+}
+
+/******************************************************************************
+ Sensors
+******************************************************************************/
+/***************************************************************************//**
+\brief Opens temperature sensor.
+
+\return
+ BC_SUCCESS - always.
+*******************************************************************************/
+result_t BSP_OpenTemperatureSensor(void)
+{
+ return BC_SUCCESS;
+}
+
+/***************************************************************************//**
+\brief Closes the temperature sensor.
+
+\return
+ BC_SUCCESS - always.
+*******************************************************************************/
+result_t BSP_CloseTemperatureSensor(void)
+{
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief Reads data from the temperature sensor.
+\param[in]
+ result - the result of the requested operation.
+ true - operation finished successfully, false - some error has
+ occured.
+\param[in]
+ data - sensor data.
+
+\return
+ BC_SUCCESS - always.
+******************************************************************************/
+result_t BSP_ReadTemperatureData(void (*f)(bool result, int16_t data))
+{
+ readTemperatureDataCallback = f;
+
+ bspPostTask(BSP_TEMPERATURE);
+
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief BSP task handler for temperature sensor.
+******************************************************************************/
+void bspTemperatureSensorHandler(void)
+{
+ readTemperatureDataCallback(true, 0);
+}
+
+/***************************************************************************//**
+\brief Opens the light sensor.
+
+\return
+ BC_SUCCESS - always.
+*******************************************************************************/
+result_t BSP_OpenLightSensor(void)
+{
+ return BC_SUCCESS;
+}
+
+/***************************************************************************//**
+\brief Closes the light sensor.
+
+\return
+ BC_SUCCESS - always.
+*******************************************************************************/
+result_t BSP_CloseLightSensor(void)
+{
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief Reads data from the light sensor.
+\param[in]
+ result - the result of the requested operation.
+ true - operation finished successfully, false - some error has
+ occured.
+\param[in]
+ data - sensor data.
+
+\return
+ BC_SUCCESS - always.
+******************************************************************************/
+result_t BSP_ReadLightData(void (*f)(bool result, int16_t data))
+{
+ readLightDataCallback = f;
+
+ bspPostTask(BSP_LIGHT);
+
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief BSP task handler for light sensor.
+******************************************************************************/
+void bspLightSensorHandler(void)
+{
+ readLightDataCallback(true, 0);
+}
+
+/******************************************************************************
+ Leds
+******************************************************************************/
+/**************************************************************************//**
+\brief Opens leds module to use.
+
+\return
+ operation state
+******************************************************************************/
+result_t BSP_OpenLeds(void)
+{
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief Closes leds module.
+
+\return
+ operation state
+******************************************************************************/
+result_t BSP_CloseLeds(void)
+{
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief Turns on the LED.
+
+\param[in]
+ id - number of led
+******************************************************************************/
+void BSP_OnLed(uint8_t id)
+{
+ (void)id;
+}
+
+/**************************************************************************//**
+\brief Turns off the LED.
+
+\param[in]
+ id - number of led
+******************************************************************************/
+void BSP_OffLed(uint8_t id)
+{
+ (void)id;
+}
+
+/**************************************************************************//**
+\brief Changes the LED state to opposite.
+
+\param[in]
+ id - number of led
+******************************************************************************/
+void BSP_ToggleLed(uint8_t id)
+{
+ (void)id;
+}
+
+/******************************************************************************
+ Sliders
+******************************************************************************/
+/**************************************************************************//**
+\brief Reads the sliders.
+
+\return
+ state of 3 on-board DIP-switches.User can uses SLIDER0, SLIDER1, SLIDER2
+ defines to test state. Value 1 indicates that slider is on.
+******************************************************************************/
+uint8_t BSP_ReadSliders(void)
+{
+ return 0;
+}
+
+#endif // APP_DISABLE_BSP == 1
+
+/******************************************************************************
+ Joystick
+******************************************************************************/
+/******************************************************************************
+\brief Registers handler for joystick events.
+
+\param[in]
+ state - joystick state.
+
+\return
+ BC_FAIL - joystick module is busy,
+ BC_SUCCESS in other cases.
+******************************************************************************/
+result_t BSP_OpenJoystick(void (*generalHandler)(BSP_JoystickState_t state))
+{
+ (void)generalHandler;
+
+ return BC_SUCCESS;
+}
+
+/******************************************************************************
+\brief Cancel joystick handlers.
+
+\return
+ BC_FAIL - joystick module was not opened,
+ BC_SUCCESS in other cases.
+******************************************************************************/
+result_t BSP_CloseJoystick(void)
+{
+ return BC_SUCCESS;
+}
+
+/******************************************************************************
+\brief Reads state of joystick.
+
+\return
+ Current joystick state.
+******************************************************************************/
+BSP_JoystickState_t BSP_ReadJoystickState(void)
+{
+ return 0;
+}
+
+#if (APP_DISABLE_BSP == 1) || (BSP_MNZB_EVB_SUPPORT != 1)
+/***************************************************************************//**
+\brief Opens the battery sensor.
+
+\return
+ BC_SUCCESS - always.
+*******************************************************************************/
+result_t BSP_OpenBatterySensor(void)
+{
+ return BC_SUCCESS;
+}
+
+/***************************************************************************//**
+\brief Closes the battery sensor.
+
+\return
+ BC_SUCCESS - always.
+*******************************************************************************/
+result_t BSP_CloseBatterySensor(void)
+{
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief Reads data from battery sensor.
+
+\param[in]
+ data - sensor data.
+
+\return
+ BC_SUCCESS - always.
+******************************************************************************/
+result_t BSP_ReadBatteryData(void (*f)(int16_t data))
+{
+ readBatteryDataCallback = f;
+
+ bspPostTask(BSP_BATTERY);
+
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief BSP task handler for battery sensor.
+******************************************************************************/
+void bspEmptyBatteryHandler(void)
+{
+ readBatteryDataCallback(0);
+}
+#endif //(APP_DISABLE_BSP == 1) || (BSP_MNZB_EVB_SUPPORT != 1)
+
+// eof fakeBSP.c
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/leds.c b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/leds.c
new file mode 100644
index 00000000..d03e7154
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/leds.c
@@ -0,0 +1,139 @@
+/***************************************************************************//**
+\file leds.c
+
+\brief The module to access to the leds.
+
+\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:
+ 29/05/07 E. Ivanov - Created
+*******************************************************************************/
+#if APP_DISABLE_BSP != 1
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <bspLeds.h>
+#include <sensors.h>
+#include <pwrCtrl.h>
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Inits LEDs control module.
+******************************************************************************/
+static void initLeds(void)
+{
+ halInitRedLed();
+ halInitYellowLed();
+ halInitGreenLed();
+}
+
+/**************************************************************************//**
+\brief Opens leds module to use.
+
+\return
+ operation state
+******************************************************************************/
+result_t BSP_OpenLeds(void)
+{
+ initLeds();
+#if BSP_MNZB_EVB_SUPPORT == 1
+ bspOnPeriphery(SENSOR_LED);
+#endif /* BSP_MNZB_EVB_SUPPORT */
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief Closes leds module.
+
+\return
+ operation state
+******************************************************************************/
+result_t BSP_CloseLeds(void)
+{
+#if BSP_MNZB_EVB_SUPPORT == 1
+ bspOffPeriphery(SENSOR_LED);
+#endif /* BSP_MNZB_EVB_SUPPORT */
+ halUnInitRedLed();
+ halUnInitYellowLed();
+ halUnInitGreenLed();
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief Turns on the LED.
+
+\param[in]
+ id - number of led
+******************************************************************************/
+void BSP_OnLed(uint8_t id)
+{
+ switch (id)
+ {
+ case LED_RED:
+ halOnRedLed();
+ break;
+ case LED_GREEN:
+ halOnGreenLed();
+ break;
+ case LED_YELLOW:
+ halOnYellowLed();
+ break;
+ }
+}
+
+/**************************************************************************//**
+\brief Turns off the LED.
+
+\param[in]
+ id - number of led
+******************************************************************************/
+void BSP_OffLed(uint8_t id)
+{
+ switch (id)
+ {
+ case LED_RED:
+ halOffRedLed();
+ break;
+ case LED_GREEN:
+ halOffGreenLed();
+ break;
+ case LED_YELLOW:
+ halOffYellowLed();
+ break;
+ }
+}
+
+/**************************************************************************//**
+\brief Changes the LED state to opposite.
+
+\param[in]
+ id - number of led
+******************************************************************************/
+void BSP_ToggleLed(uint8_t id)
+{
+ switch (id)
+ {
+ case LED_RED:
+ halToggleRedLed();
+ break;
+ case LED_GREEN:
+ halToggleGreenLed();
+ break;
+ case LED_YELLOW:
+ halToggleYellowLed();
+ break;
+ }
+}
+
+#endif // APP_DISABLE_BSP != 1
+
+// eof leds.c
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/lm73.c b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/lm73.c
new file mode 100644
index 00000000..bc31454f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/lm73.c
@@ -0,0 +1,184 @@
+/**************************************************************************//**
+\file lm73.c
+
+\brief This module provides access to lm73 the sensor. \n
+ Continues conversion released only.
+
+\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:
+ 29/05/07 E. Ivanov - Created
+******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <lm73.h>
+#include <i2cPacket.h>
+#include <bspTaskManager.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+// device address on i2c bus
+#define LM73_DEVICE_ADDRESS (0x92 >> 1)
+
+// device registers internal address
+#define LM73_DATA_REGISTER 0x00
+#define LM73_CONFIGURATION_REGISTER 0x01
+#define LM73_UPPER_LIMIT_REGISTER 0x02
+#define LM73_LOWER_LIMIT_REGISTER 0x03
+#define LM73_CONTROL_STATUS_REGISTER 0x04
+#define LM73_IDENTIFICATION_REGISTER 0x07
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+// states
+typedef enum
+{
+ IDLE, // idle
+ DATA // performs request
+} Lm73States_t;
+
+typedef struct
+{
+ int32_t lm73Data; // Contains the result of sampling
+ bool lm73Result; // Result of operation. true - there are no errors, false - in other case.
+ void(* lm73Callback)(bool error, int16_t data); // callback
+} Lm73Control_t;
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+Lm73States_t lm73State = IDLE; // Monitors current state
+Lm73Control_t lm73Control;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Opens the component to use.
+
+\return
+ BC_SUCCESS - the component is ready to been use. \n
+ BC_FAIL - otherwise.
+******************************************************************************/
+result_t openLm73(void)
+{
+ if (IDLE == lm73State)
+ return BC_SUCCESS;
+
+ return BC_FAIL;
+}
+
+/**************************************************************************//**
+\brief Performs the test if the component have completed request.
+
+\return
+ BC_FAIL - the previous request is not completed. \n
+ BC_SUCCESS - otherwise.
+******************************************************************************/
+result_t closeLm73(void)
+{
+ if (IDLE == lm73State)
+ return BC_SUCCESS;
+
+ return BC_FAIL;
+}
+
+/**************************************************************************//**
+\brief The notice on that the packet has been read.
+
+\param[in]
+ result - the result of operation
+******************************************************************************/
+void lm73I2cPacketReadDone(bool result)
+{
+ int16_t i;
+
+ lm73Control.lm73Result = result; // stores the result of operation
+ if (false == lm73Control.lm73Result)
+ { // there were some errors on the i2c interface
+ lm73Control.lm73Data = 0;
+ bspPostTask(BSP_TEMPERATURE);
+ return;
+ }
+
+ if (DATA == lm73State)
+ {
+ i = (uint8_t)lm73Control.lm73Data;
+ i <<= 8;
+ i |= ((lm73Control.lm73Data >> 8) & 0x00FF);
+ lm73Control.lm73Data = (i >> 7);
+ bspPostTask(BSP_TEMPERATURE);
+ }
+}
+
+/**************************************************************************//**
+\brief Reads data from lm73 sensor.
+
+\param[in]
+ f - callback method.
+\param[in]
+ result - the result of the requested operation.
+ true - operation finished successfully, false - some error has
+ occured.
+\param[in]
+ data - sensor data.
+
+\return
+ BC_FAIL - the previous request was not completed,
+ the address of callback is 0, i2c interface is busy,
+ there is error on i2c interface. \n
+ BC_SUCCESS - other case.
+******************************************************************************/
+result_t readLm73Data(void (*f)(bool result, int16_t data))
+{
+ HAL_i2cMode_t i2cMode;
+ HAL_I2cParams_t i2cParam;
+
+ if (IDLE != lm73State)
+ return BC_FAIL;
+
+ if (!f)
+ return BC_FAIL;
+
+ i2cMode.clockrate = I2C_CLOCK_RATE_62;
+ if (-1 == HAL_OpenI2cPacket(&i2cMode))
+ return BC_FAIL;
+ lm73State = DATA;
+ lm73Control.lm73Callback = f;
+
+ i2cParam.data = (uint8_t*)(&lm73Control.lm73Data);
+ i2cParam.f = lm73I2cPacketReadDone;
+ i2cParam.id = LM73_DEVICE_ADDRESS;
+ i2cParam.length = 2;
+ i2cParam.lengthAddr = HAL_NO_INTERNAL_ADDRESS;
+
+ if (-1 == HAL_ReadI2cPacket(&i2cParam))
+ {
+ lm73State = IDLE;
+ HAL_CloseI2cPacket();
+ return BC_FAIL;
+ }
+
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief BSP task handler.
+******************************************************************************/
+void bspLM73Handler(void)
+{
+ HAL_CloseI2cPacket(); // free
+ lm73State = IDLE;
+ lm73Control.lm73Callback(lm73Control.lm73Result, lm73Control.lm73Data);
+}
+
+// eof lm73.c
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/pwrCtrl.c b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/pwrCtrl.c
new file mode 100644
index 00000000..305b80a2
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/pwrCtrl.c
@@ -0,0 +1,91 @@
+/***************************************************************************//**
+\file pwrCtrl.c
+
+\brief The module to control the power on periphery.
+
+\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:
+ 29/05/07 E. Ivanov - Created
+*******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <pwrCtrl.h>
+#include <gpio.h>
+
+#if BSP_MNZB_EVB_SUPPORT == 1
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Checks if amplifier is used.
+\return true - is used, \n
+ false - is not used.
+******************************************************************************/
+bool HAL_IsAmplifierUsed(void);
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+uint8_t bspPowerControl = 0;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Powers on periphery.
+
+\param[in]
+ id - periphery id.
+******************************************************************************/
+void bspOnPeriphery(uint8_t id)
+{
+ if (!bspPowerControl)
+ {
+ GPIO_8_make_out();
+
+ if (HAL_IsAmplifierUsed())
+ GPIO_8_clr();
+ else
+ GPIO_8_set();
+
+ GPIO_7_make_out();
+ GPIO_7_set();
+ }
+ bspPowerControl |= (1 << id);
+}
+
+
+/**************************************************************************//**
+\brief Powers off periphery.
+
+\param[in]
+ id - periphery id.
+******************************************************************************/
+void bspOffPeriphery(uint8_t id)
+{
+ bspPowerControl &= ~(1 << id);
+ if (bspPowerControl)
+ return;
+
+ GPIO_8_make_out();
+
+ if (HAL_IsAmplifierUsed())
+ GPIO_8_set();
+ else
+ GPIO_8_clr();
+
+ GPIO_7_make_out();
+ GPIO_7_clr();
+}
+
+#endif /* BSP_MNZB_EVB_SUPPORT */
+// eof pwrCtrl.c
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/sensors.c b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/sensors.c
new file mode 100644
index 00000000..7e0eae1c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/sensors.c
@@ -0,0 +1,196 @@
+/**************************************************************************//**
+\file sensors.h
+
+\brief Implementation of sensors interface.
+
+\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:
+ 12/05/08 A. Khromykh - Created
+*******************************************************************************/
+#if APP_DISABLE_BSP != 1
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <sensors.h>
+#include <pwrCtrl.h>
+#include <lm73.h>
+#include <tsl2550.h>
+#include <battery.h>
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/***************************************************************************//**
+\brief Opens temperature sensor.
+
+\return
+ BC_FAIL - sensor has been already open. \n
+ BC_SUCCESS - otherwise.
+*******************************************************************************/
+result_t BSP_OpenTemperatureSensor(void)
+{
+ result_t result;
+
+ if (BC_SUCCESS == (result = openLm73()))
+ {
+#if BSP_MNZB_EVB_SUPPORT == 1
+ bspOnPeriphery(SENSOR_TEMPERATURE);
+#endif /* BSP_MNZB_EVB_SUPPORT */
+ }
+ return result;
+}
+
+/***************************************************************************//**
+\brief Closes the temperature sensor.
+
+\return
+ BC_FAIL - if a hardware error has occured or
+ there is uncompleted ReadData request. \n
+ BC_SUCCESS - otherwise.
+*******************************************************************************/
+result_t BSP_CloseTemperatureSensor(void)
+{
+ result_t result;
+
+ if (BC_SUCCESS == (result = closeLm73()))
+ {
+#if BSP_MNZB_EVB_SUPPORT == 1
+ bspOffPeriphery(SENSOR_TEMPERATURE);
+#endif /* BSP_MNZB_EVB_SUPPORT */
+ }
+ return result;
+}
+
+/**************************************************************************//**
+\brief Reads data from the temperature sensor.
+\param[in]
+ result - the result of the requested operation.
+ true - operation finished successfully, false - some error has
+ occured.
+\param[in]
+ data - sensor data.
+\return
+ BC_FAIL - previous request was not completed. \n
+ BC_SUCCESS - otherwise.
+******************************************************************************/
+result_t BSP_ReadTemperatureData(void (*f)(bool result, int16_t data))
+{
+ return readLm73Data(f);
+}
+
+/***************************************************************************//**
+\brief Opens the light sensor.
+\return
+ BC_FAIL - sensor has been already open. \n
+ BC_SUCCESS - otherwise.
+*******************************************************************************/
+result_t BSP_OpenLightSensor(void)
+{
+ result_t result;
+
+ if (BC_SUCCESS == (result = openTsl2550()))
+ {
+#if BSP_MNZB_EVB_SUPPORT == 1
+ bspOnPeriphery(SENSOR_LIGHT);
+#endif /* BSP_MNZB_EVB_SUPPORT */
+ }
+ return result;
+}
+
+/***************************************************************************//**
+\brief Closes the light sensor.
+\return
+ BC_FAIL - if a hardware error has occured or
+ there is uncompleted ReadData request. \n
+ BC_SUCCESS - otherwise.
+*******************************************************************************/
+result_t BSP_CloseLightSensor(void)
+{
+ result_t result;
+
+ if (BC_SUCCESS == (result = closeTsl2550()))
+ {
+#if BSP_MNZB_EVB_SUPPORT == 1
+ bspOffPeriphery(SENSOR_LIGHT);
+#endif /* BSP_MNZB_EVB_SUPPORT */
+ }
+ return result;
+}
+
+/**************************************************************************//**
+\brief Reads data from the light sensor.
+\param[in]
+ result - the result of the requested operation.
+ true - operation finished successfully, false - some error has
+ occured.
+\param[in]
+ data - sensor data.
+\return
+ BC_FAIL - previous request was not completed. \n
+ BC_SUCCESS - otherwise.
+******************************************************************************/
+result_t BSP_ReadLightData(void (*f)(bool result, int16_t data))
+{
+ return readTsl2550Data(f);
+}
+
+#if BSP_MNZB_EVB_SUPPORT == 1
+/***************************************************************************//**
+\brief Opens the battery sensor.
+\return
+ BC_FAIL - sensor has been already open. \n
+ BC_SUCCESS - otherwise.
+*******************************************************************************/
+result_t BSP_OpenBatterySensor(void)
+{
+ result_t result;
+
+ if (BC_SUCCESS == (result = openBattery()))
+ {
+ bspOnPeriphery(SENSOR_BATTERY);
+ }
+ return result;
+}
+
+/***************************************************************************//**
+\brief Closes the battery sensor.
+\return
+ BC_FAIL - sensor was not opened. \n
+ BC_SUCCESS - otherwise.
+*******************************************************************************/
+result_t BSP_CloseBatterySensor(void)
+{
+ result_t result;
+
+ if (BC_SUCCESS == (result = closeBattery()))
+ {
+ bspOffPeriphery(SENSOR_BATTERY);
+ }
+ return result;
+}
+
+/**************************************************************************//**
+\brief Reads data from battery sensor.
+\param[in]
+ data - sensor data.
+\return
+ BC_FAIL - previous request was not completed, or sensor was not opened. \n
+ BC_SUCCESS - otherwise.
+******************************************************************************/
+result_t BSP_ReadBatteryData(BspBatteryCb_t cb)
+{
+ return readBatteryData(cb);
+}
+#endif /* BSP_MNZB_EVB_SUPPORT */
+
+#endif // APP_DISABLE_BSP != 1
+
+//end of sensors.c
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/sliders.c b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/sliders.c
new file mode 100644
index 00000000..db417cdb
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/sliders.c
@@ -0,0 +1,59 @@
+/**************************************************************************//**
+\file sliders.h
+
+\brief Implementation of the sliders.
+
+\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:
+ 29/06/07 E. Ivanov - Created
+******************************************************************************/
+#if APP_DISABLE_BSP != 1
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <gpio.h>
+#include <sliders.h>
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Reads the sliders.
+
+\return
+ state of 3 on­board DIP­switches.User can uses SLIDER0, SLIDER1, SLIDER2
+ defines to test state. Value 1 indicates that slider is on.
+******************************************************************************/
+uint8_t BSP_ReadSliders(void)
+{
+ uint8_t result;
+
+ GPIO_3_make_in(); GPIO_3_make_pullup();
+ GPIO_4_make_in(); GPIO_4_make_pullup();
+ GPIO_5_make_in(); GPIO_5_make_pullup();
+ /* NOP was added for correct work on 8 MHz frequency.
+ clck i\o is not equal clck cpu.
+ CPU must wait for I\O system 1 clock for synchronization. */
+ NOP;
+ result = GPIO_3_read() * SLIDER0;
+ result |= GPIO_4_read() * SLIDER1;
+ result |= GPIO_5_read() * SLIDER2;
+ GPIO_3_make_in();
+ GPIO_4_make_in();
+ GPIO_5_make_in();
+
+ return (~result) & 0x07;
+}
+
+#endif // APP_DISABLE_BSP != 1
+
+// end of sliders.c
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/tsl2550.c b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/tsl2550.c
new file mode 100644
index 00000000..9011c6fd
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/tsl2550.c
@@ -0,0 +1,457 @@
+/**************************************************************************//**
+\file tsl2550.c
+
+\brief Implementation of access to tsl2550 the sensor, light sensor.
+
+\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:
+ 29/06/07 E. Ivanov - Created
+******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <tsl2550.h>
+#include <i2cPacket.h>
+#include <bspTaskManager.h>
+#include <appTimer.h>
+#include <bspDbg.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+// device address on i2c bus
+#define TSL_DEVICE_ADDRESS 0x39
+
+// device registers internal address
+#define TSL_READ_CHANNEL0_COMMAND 0x43
+#define TSL_READ_CHANNEL1_COMMAND 0x83
+#define TSL_POWERDOWN_COMMAND 0x00
+#define TSL_POWERUP_COMMAND 0x03
+#define TSL_EXTENDED_RANGE_COMMAND 0x1D
+#define TSL_STANDARD_RANGE_COMMAND 0x18
+
+// standard mode max
+#define TSL_MAX_LUX_VALUE 1846
+
+// Conversion time (400ms typ by datasheet). Choose a little more to be on a safe side.
+#define TSL_CONVERSION_TIME 500
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+// states
+typedef enum
+{
+ OFF,
+ IDLE,
+ POWERUP,
+ POWERUP_ERR,
+ DATA,
+ DATA_ERR,
+} Tsl2550States_t;
+
+typedef struct
+{
+ Tsl2550States_t state;
+ uint8_t ch0;
+ uint8_t ch1;
+ void(* callback)(bool result, int16_t data); // data callback pointer
+} Tsl2550Control_t;
+
+/******************************************************************************
+ Constants section
+******************************************************************************/
+PROGMEM_DECLARE(const uint8_t tsl2550Ratio[129]) =
+{
+100,100,100,100,100,100,100,100,
+100,100,100,100,100,100, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 98, 98, 98, 98, 98,
+ 98, 98, 97, 97, 97, 97, 97, 96,
+ 96, 96, 96, 95, 95, 95, 94, 94,
+ 93, 93, 93, 92, 92, 91, 91, 90,
+ 89, 89, 88, 87, 87, 86, 85, 84,
+ 83, 82, 81, 80, 79, 78, 77, 75,
+ 74, 73, 71, 69, 68, 66, 64, 62,
+ 60, 58, 56, 54, 52, 49, 47, 44,
+ 42, 41, 40, 40, 39, 39, 38, 38,
+ 37, 37, 37, 36, 36, 36, 35, 35,
+ 35, 35, 34, 34, 34, 34, 33, 33,
+ 33, 33, 32, 32, 32, 32, 32, 31,
+ 31, 31, 31, 31, 30, 30, 30, 30,
+ 30
+};
+
+PROGMEM_DECLARE(const uint16_t tsl2550Count[128]) =
+{
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 18, 20, 22, 24, 26, 28, 30,
+ 32, 34, 36, 38, 40, 42, 44, 46,
+ 49, 53, 57, 61, 65, 69, 73, 77,
+ 81, 85, 89, 93, 97, 101, 105, 109,
+ 115, 123, 131, 139, 147, 155, 163, 171,
+ 179, 187, 195, 203, 211, 219, 227, 235,
+ 247, 263, 279, 295, 311, 327, 343, 359,
+ 375, 391, 407, 423, 439, 455, 471, 487,
+ 511, 543, 575, 607, 639, 671, 703, 735,
+ 767, 799, 831, 863, 895, 927, 959, 991,
+1039,1103,1167,1231,1295,1359,1423,1487,
+1551,1615,1679,1743,1807,1871,1935,1999,
+2095,2223,2351,2479,2607,2735,2863,2991,
+3119,3247,3375,3503,3631,3759,3887,4015
+};
+
+/******************************************************************************
+ Static function prototypes section
+******************************************************************************/
+static bool tsl2550StartReading(void);
+static void tsl2550StartFirstReading(void);
+static void tsl2550I2cPacketReadDoneCh1(bool result);
+static void tsl2550I2cPacketWriteDoneCh1(bool result);
+static void tsl2550I2cPacketReadDoneCh0(bool result);
+static void tsl2550I2cPacketWriteDoneCh0(bool result);
+static void tsl2550I2cPowerupDone(bool result);
+static bool tsl2550StartPowerup(void);
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+
+static Tsl2550Control_t tsl2550Control = {.state = OFF};
+
+/**************************************************************************//**
+\brief Opens the component to use.
+
+\return
+ BC_SUCCESS - the component is ready to be used. \n
+ BC_FAIL - otherwise.
+******************************************************************************/
+result_t openTsl2550(void)
+{
+ if (IDLE == tsl2550Control.state || OFF == tsl2550Control.state)
+ return BC_SUCCESS;
+
+ return BC_FAIL;
+}
+
+/**************************************************************************//**
+\brief Performs the test if the component have completed request.
+
+\return
+ BC_FAIL - the previous request is not completed. \n
+ BC_SUCCES - otherwise.
+******************************************************************************/
+result_t closeTsl2550(void)
+{
+ if (IDLE == tsl2550Control.state || OFF == tsl2550Control.state)
+ return BC_SUCCESS;
+
+ return BC_FAIL;
+}
+
+/**************************************************************************//**
+\brief Reads data from tsl2550 sensor.
+
+\param[in]
+ f - callback method
+\param[in]
+ result - the result of the requested operation.
+ true - operation finished successfully, false - some error has
+ occured.
+\param[in]
+ data - sensor data.
+
+\return
+ BC_FAIL - the previous request was not completed,
+ the address of callback is 0, i2c interface is busy,
+ there is error on i2c interface. \n
+ BC_SUCCESS - in other case.
+******************************************************************************/
+result_t readTsl2550Data(void (*f)(bool result, int16_t data))
+{
+ HAL_i2cMode_t i2cMode = {.clockrate = I2C_CLOCK_RATE_62};
+
+ if (NULL == f)
+ return BC_FAIL;
+
+ if (OFF == tsl2550Control.state) // Sensor is in powerdown mode, powerup it before reading
+ {
+ if (-1 == HAL_OpenI2cPacket(&i2cMode))
+ return BC_FAIL;
+
+ if (false == tsl2550StartPowerup())
+ {
+ HAL_CloseI2cPacket();
+ return BC_FAIL;
+ }
+ tsl2550Control.state = POWERUP;
+ }
+ else if (IDLE == tsl2550Control.state)
+ {
+ if (-1 == HAL_OpenI2cPacket(&i2cMode))
+ return BC_FAIL;
+
+ if (false == tsl2550StartReading())
+ {
+ HAL_CloseI2cPacket();
+ return BC_FAIL;
+ }
+ tsl2550Control.state = DATA;
+ }
+ else
+ {
+ return BC_FAIL;
+ }
+
+ tsl2550Control.callback = f;
+
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief BSP tsl2550 handler.
+******************************************************************************/
+void bspTsl2550Handler(void)
+{
+ uint8_t result = false;
+ uint16_t lux = 0;
+
+ HAL_CloseI2cPacket(); // free
+
+ switch (tsl2550Control.state)
+ {
+ case POWERUP_ERR:
+ tsl2550Control.state = OFF;
+ break;
+
+ case DATA_ERR:
+ tsl2550Control.state = IDLE;
+ break;
+
+ case DATA:
+ {
+ uint32_t count0 = 0, count1 = 0;
+ uint8_t ratio = 128; // default scaling factor
+ uint8_t R;
+
+ tsl2550Control.state = IDLE;
+
+ if (tsl2550Control.ch0 & tsl2550Control.ch1 & 0x80)
+ {
+ memcpy_P(&count0, &tsl2550Count[tsl2550Control.ch0 & 0x7F], sizeof(uint16_t));
+ memcpy_P(&count1, &tsl2550Count[tsl2550Control.ch1 & 0x7F], sizeof(uint16_t));
+
+ if (!count0 || (count0 <= count1)) // count1 cannot be greater than count0
+ break;
+
+ ratio = ((uint32_t)(count1 * 128ul) / count0);
+ // calculate lux
+ // the "256" is a scaling factor
+ memcpy_P(&R, &tsl2550Ratio[ratio], sizeof(uint8_t));
+ lux = ((count0 - count1) * R) / 256;
+ // range check lux
+ if (lux > TSL_MAX_LUX_VALUE)
+ lux = TSL_MAX_LUX_VALUE;
+
+ result = true;
+ }
+ }
+ break;
+
+ default:
+ ASSERT(false, TSL2550_UNEXPECTED_STATE);
+ tsl2550Control.state = IDLE;
+ break;
+ }
+
+ tsl2550Control.callback(result, lux);
+}
+
+/**************************************************************************//**
+\brief Callback that reading from tsl2550 was completed.
+
+\param[in]
+ result - contains result of operation.
+ if result is false there was problem on i2c interface.
+******************************************************************************/
+static void tsl2550I2cPacketReadDoneCh1(bool result)
+{
+ if (false == result)
+ tsl2550Control.state = DATA_ERR;
+
+ bspPostTask(BSP_LIGHT);
+}
+
+/**************************************************************************//**
+\brief Callback that writing command to tsl2550 was completed.
+
+\param[in]
+ result - contains result of operation.
+ if result is false there was problem on i2c interface.
+******************************************************************************/
+static void tsl2550I2cPacketWriteDoneCh1(bool result)
+{
+ HAL_I2cParams_t i2cParam =
+ {
+ .data = &tsl2550Control.ch1,
+ .f = tsl2550I2cPacketReadDoneCh1,
+ .id = TSL_DEVICE_ADDRESS,
+ .length = 1,
+ .lengthAddr = HAL_NO_INTERNAL_ADDRESS,
+ };
+
+ if ((false == result) || (-1 == HAL_ReadI2cPacket(&i2cParam)))
+ {
+ tsl2550Control.state = DATA_ERR;
+ bspPostTask(BSP_LIGHT);
+ }
+}
+
+/**************************************************************************//**
+\brief Callback that reading from tsl2550 was completed.
+
+\param[in]
+ result - contains result of operation.
+ if result is false there was problem on i2c interface.
+******************************************************************************/
+static void tsl2550I2cPacketReadDoneCh0(bool result)
+{
+ HAL_I2cParams_t i2cParam =
+ {
+ .data = &tsl2550Control.ch1,
+ .f = tsl2550I2cPacketWriteDoneCh1,
+ .id = TSL_DEVICE_ADDRESS,
+ .length = 1,
+ .lengthAddr = HAL_NO_INTERNAL_ADDRESS,
+ };
+
+ tsl2550Control.ch1 = TSL_READ_CHANNEL1_COMMAND;
+
+ if ((false == result) || (-1 == HAL_WriteI2cPacket(&i2cParam)))
+ {
+ tsl2550Control.state = DATA_ERR;
+ bspPostTask(BSP_LIGHT);
+ }
+}
+
+/**************************************************************************//**
+\brief Callback that writing command to tsl2550 was completed.
+
+\param[in]
+ result - contains result of operation.
+ if result is false there was problem on i2c interface.
+******************************************************************************/
+static void tsl2550I2cPacketWriteDoneCh0(bool result)
+{
+ HAL_I2cParams_t i2cParam =
+ {
+ .data = &tsl2550Control.ch0,
+ .f = tsl2550I2cPacketReadDoneCh0,
+ .id = TSL_DEVICE_ADDRESS,
+ .length = 1,
+ .lengthAddr = HAL_NO_INTERNAL_ADDRESS,
+ };
+
+ if ((false == result) || (-1 == HAL_ReadI2cPacket(&i2cParam)))
+ {
+ tsl2550Control.state = DATA_ERR;
+ bspPostTask(BSP_LIGHT);
+ }
+}
+
+/**************************************************************************//**
+\brief Start tsl2550 read sequence.
+
+\return
+ false - i2c packet wasn't sent
+ true - in other case.
+******************************************************************************/
+static bool tsl2550StartReading(void)
+{
+ HAL_I2cParams_t i2cParam =
+ {
+ .data = &tsl2550Control.ch0,
+ .f = tsl2550I2cPacketWriteDoneCh0,
+ .id = TSL_DEVICE_ADDRESS,
+ .length = 1,
+ .lengthAddr = HAL_NO_INTERNAL_ADDRESS,
+ };
+
+ tsl2550Control.ch0 = TSL_READ_CHANNEL0_COMMAND;
+
+ return (-1 != HAL_WriteI2cPacket(&i2cParam)) ? true : false;
+}
+
+/**************************************************************************//**
+\brief Callback on completion of tsl2550's delay after powerup.
+******************************************************************************/
+static void tsl2550StartFirstReading(void)
+{
+ if (false == tsl2550StartReading())
+ {
+ tsl2550Control.state = DATA_ERR;
+ bspPostTask(BSP_LIGHT);
+ return;
+ }
+
+ tsl2550Control.state = DATA;
+}
+
+/**************************************************************************//**
+\brief Callback on completion of tsl2550 powerup.
+
+\param[in]
+ result - contains result of operation.
+ if result is false there was problem on i2c interface.
+******************************************************************************/
+static void tsl2550I2cPowerupDone(bool result)
+{
+ static HAL_AppTimer_t tsl2550PowerupTimer =
+ {
+ .interval = TSL_CONVERSION_TIME * 2, // Wait for conversions on two channels one-after-one
+ .mode = TIMER_ONE_SHOT_MODE,
+ .callback = tsl2550StartFirstReading,
+ };
+
+ if (false == result)
+ {
+ tsl2550Control.state = POWERUP_ERR;
+ bspPostTask(BSP_LIGHT);
+ return;
+ }
+
+ HAL_StartAppTimer(&tsl2550PowerupTimer);
+}
+
+/**************************************************************************//**
+\brief Start tsl2550 powerup sequence.
+
+\return
+ false - i2c packet wasn't sent
+ true - in other case.
+******************************************************************************/
+static bool tsl2550StartPowerup(void)
+{
+ HAL_I2cParams_t i2cParam =
+ {
+ .data = &tsl2550Control.ch0,
+ .f = tsl2550I2cPowerupDone,
+ .id = TSL_DEVICE_ADDRESS,
+ .length = 1,
+ .lengthAddr = HAL_NO_INTERNAL_ADDRESS,
+ };
+
+ tsl2550Control.ch0 = TSL_POWERUP_COMMAND;
+
+ return (-1 != HAL_WriteI2cPacket(&i2cParam)) ? true : false;
+}
+
+// eof tsl2550.c
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/Makefile b/digital/zigbit/bitcloud/stack/Components/BSP/Makefile
new file mode 100644
index 00000000..0b972813
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/Makefile
@@ -0,0 +1,221 @@
+COMPONENTS_PATH = ..
+include $(MAKERULES)
+include ./BoardConfig
+
+###### LIB ##########
+ifeq ($(BOARD), BOARD_MESHBEAN)
+ BUILDDIR = ./MESHBEAN
+else ifeq ($(BOARD), BOARD_RAVEN)
+ BUILDDIR = ./RAVEN
+else ifeq ($(BOARD), BOARD_STK500)
+ BUILDDIR = ./ATML_STK500
+else ifeq ($(BOARD), BOARD_STK600)
+ BUILDDIR = ./ATML_STK600
+else ifeq ($(BOARD), BOARD_USB_DONGLE)
+ BUILDDIR = ./ATML_USB_DONGLE
+else ifeq ($(BOARD), BOARD_MESHBEAN_LAN)
+ BUILDDIR = ./MESHBEAN_LAN
+else ifeq ($(BOARD), BOARD_MESHBEAN_TURBO)
+ BUILDDIR = ./MESHBEAN_TURBO
+else ifeq ($(BOARD), BOARD_SAM7X_EK)
+ BUILDDIR = ./ATML_SAM7X_EK
+else ifeq ($(BOARD), BOARD_SAM3S_EK)
+ BUILDDIR = ./ATML_SAM3S_EK
+else ifeq ($(BOARD), BOARD_SAM3S_EK)
+ BUILDDIR = ./RF231USBRD
+else ifeq ($(BOARD), BOARD_CUSTOM_1)
+ BUILDDIR = ./CUSTOM_1
+else ifeq ($(BOARD), BOARD_CUSTOM_2)
+ BUILDDIR = ./CUSTOM_2
+else ifeq ($(BOARD), BOARD_CUSTOM_3)
+ BUILDDIR = ./CUSTOM_3
+else ifeq ($(BOARD), BOARD_RCB)
+ BUILDDIR = ./RCB
+else ifeq ($(BOARD), BOARD_AVR32_EVK1105)
+ BUILDDIR = ./AVR32_EVK1105
+else ifeq ($(BOARD), BOARD_XPLAIN)
+ BUILDDIR = ./XPLAIN
+else ifeq ($(BOARD), BOARD_REB_CBB)
+ BUILDDIR = ./REB_CBB
+else ifeq ($(BOARD), BOARD_SIMULATOR)
+ BUILDDIR = ./SIMULATOR
+else
+ $(error unknown BOARD)
+endif
+
+# Compiler flags extending with "debug info" compiler flag.
+CFLAGS += $(CFLAGS_DBG)
+
+# Hardware flags.
+CFLAGS += $(CFLAGS_HW)
+
+LIBDIR = ./lib
+LISTDIR = ./list
+LDFLAGS = -L$(LIBDIR)
+PROG = BSP.elf
+LIBS = $(LIBDIR)/lib$(BSP_LIB).a
+
+##### PATHS FLAGS OF INCLUDES #########
+CFLAGS += -I$(BUILDDIR)/include
+CFLAGS += -I$(BUILDDIR)/../include
+CFLAGS += -I$(HAL_PATH)/include
+CFLAGS += -I$(HAL_HWD_COMMON_PATH)/include
+CFLAGS += -I$(SE_PATH)/include
+
+BSPFLAGS=$(CFLAGS)
+ifeq ($(BOARD), BOARD_SAM7X_EK)
+ BSPFLAGS=$(patsubst %$(ARM_MODE_THUMBS_CFLAGS),,$(CFLAGS)) $(ARM_MODE_ARM_CFLAGS)
+ BSPFLAGS += -I$(FREE_RTOS_PATH)/
+ BSPFLAGS += -I$(FREE_RTOS_PATH)/include
+endif
+
+ifeq ($(BOARD), BOARD_MESHBEAN)
+modules = \
+ leds \
+ pwrCtrl \
+ bspTaskManager \
+ buttons \
+ lm73 \
+ tsl2550 \
+ battery \
+ sliders \
+ sensors \
+ fakeBSP
+else ifeq ($(BOARD), BOARD_RAVEN)
+modules = \
+ lcd \
+ bspTaskManager \
+ joystik \
+ sipc \
+ sensors \
+ fakeBSP
+else ifeq ($(BOARD), BOARD_STK500)
+modules = \
+ leds \
+ pwrCtrl \
+ bspTaskManager \
+ buttons \
+ battery \
+ sliders \
+ sensors \
+ fakeBSP
+else ifeq ($(BOARD), BOARD_STK600)
+modules = \
+ leds \
+ buttons \
+ bspTaskManager \
+ fakeBSP
+else ifeq ($(BOARD), BOARD_USB_DONGLE)
+modules = \
+ leds \
+ bspTaskManager \
+ fakeBSP
+else ifeq ($(BOARD), BOARD_MESHBEAN_LAN)
+modules = \
+ leds \
+ buttons \
+ bspTaskManager \
+ fakeBSP
+else ifeq ($(BOARD), BOARD_MESHBEAN_TURBO)
+modules = \
+ leds \
+ buttons \
+ sliders \
+ bspTaskManager \
+ fakeBSP
+else ifeq ($(BOARD), BOARD_SAM7X_EK)
+modules = \
+ leds \
+ joystick \
+ bspTaskManager \
+ fakeBSP
+else ifeq ($(BOARD), BOARD_SAM3S_EK)
+modules = \
+ leds \
+ bspTaskManager \
+ fakeBSP
+else ifeq ($(BOARD), BOARD_RF231USBRD)
+modules = \
+ leds \
+ bspTaskManager \
+ fakeBSP
+else ifeq ($(BOARD), BOARD_CUSTOM_1)
+modules = \
+ leds \
+ buttons \
+ hexSwitch \
+ bspTaskManager \
+ rs485Controller \
+ fakeBSP
+else ifeq ($(BOARD), BOARD_CUSTOM_2)
+modules = \
+ leds \
+ buttons \
+ hexSwitch \
+ bspTaskManager \
+ rs485Controller \
+ usbController \
+ fakeBSP
+else ifeq ($(BOARD), BOARD_CUSTOM_3)
+modules = \
+ leds \
+ bspTaskManager \
+ fakeBSP
+else ifeq ($(BOARD), BOARD_RCB)
+modules = \
+ leds \
+ bspTaskManager \
+ buttons \
+ fakeBSP
+else ifeq ($(BOARD), BOARD_AVR32_EVK1105)
+modules = \
+ leds \
+ bspTaskManager \
+ buttons \
+ fakeBSP
+else ifeq ($(BOARD), BOARD_XPLAIN)
+modules = \
+ leds \
+ bspTaskManager \
+ buttons \
+ fakeBSP
+else ifeq ($(BOARD), BOARD_REB_CBB)
+modules = \
+ leds \
+ bspTaskManager \
+ buttons \
+ fakeBSP
+else ifeq ($(BOARD), BOARD_SIMULATOR)
+modules = \
+ leds \
+ bspTaskManager \
+ fakeBSP
+endif
+
+
+objects = $(addsuffix .o,$(addprefix $(BUILDDIR)/objs/,$(modules)))
+sources = $(addsuffix .c,$(addprefix $(BUILDDIR)/src/,$(modules)))
+
+###### TARGETS ################
+all: component_label LIB_BSP
+component_label:
+ @echo
+ @echo ----------------------------------------------------
+ @echo Board Support library creation.
+ @echo ----------------------------------------------------
+
+################
+$(BUILDDIR)/objs/%.o: $(BUILDDIR)/src/%.c
+ $(CC) $(BSPFLAGS) $^ -o $@
+
+################
+LIB_BSP : $(objects)
+ $(AR) $(AR_KEYS) $(LIBDIR)/lib$(BSP_LIB).a $(objects)
+ $(SIZE) -td $(LIBDIR)/lib$(BSP_LIB).a
+################
+clean:
+ @echo
+ @echo ----------------------------------------------------
+ @echo Board Support component cleaning.
+ @echo ----------------------------------------------------
+ rm -f $(objects) $(LIBS) $(LISTDIR)/*.*
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/RCB/include/bspLeds.h b/digital/zigbit/bitcloud/stack/Components/BSP/RCB/include/bspLeds.h
new file mode 100644
index 00000000..8bfb459f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/RCB/include/bspLeds.h
@@ -0,0 +1,68 @@
+/***************************************************************************//**
+\file bspLeds.h
+
+\brief Declaration of leds defines.
+
+\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:
+ 26.08.09 A. Taradov - Created
+*******************************************************************************/
+
+#ifndef _BSPLEDS_H
+#define _BSPLEDS_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+// \cond
+#include <gpio.h>
+#include <leds.h>
+// \endcond
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+#define halInitFirstLed() GPIO_E2_make_out()
+#define halUnInitFirstLed() GPIO_E2_make_in()
+#define halOnFirstLed() GPIO_E2_clr()
+#define halOffFirstLed() GPIO_E2_set()
+#define halReadFirstLed() GPIO_E2_read()
+#define halToggleFirstLed() GPIO_E2_toggle()
+
+#define halInitSecondLed() GPIO_E3_make_out()
+#define halUnInitSecondLed() GPIO_E3_make_in()
+#define halOnSecondLed() GPIO_E3_clr()
+#define halOffSecondLed() GPIO_E3_set()
+#define halReadSecondLed() GPIO_E3_read()
+#define halToggleSecondLed() GPIO_E3_toggle()
+
+#if (APP_USART_CHANNEL == USART_CHANNEL_USBFIFO) && defined(ATMEGA128RFA1)
+
+#define halInitThirdLed()
+#define halUnInitThirdLed()
+#define halOnThirdLed()
+#define halOffThirdLed()
+#define halReadThirdLed()
+#define halToggleThirdLed()
+
+#else
+
+#define halInitThirdLed() GPIO_E4_make_out()
+#define halUnInitThirdLed() GPIO_E4_make_in()
+#define halOnThirdLed() GPIO_E4_clr()
+#define halOffThirdLed() GPIO_E4_set()
+#define halReadThirdLed() GPIO_E4_read()
+#define halToggleThirdLed() GPIO_E4_toggle()
+
+#endif // APP_USART_CHANNEL == USART_CHANNEL_USBFIFO
+
+#endif /*_BSPLEDS_H*/
+// eof bspLeds.h
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/RCB/include/bspTaskManager.h b/digital/zigbit/bitcloud/stack/Components/BSP/RCB/include/bspTaskManager.h
new file mode 100644
index 00000000..2bd88abb
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/RCB/include/bspTaskManager.h
@@ -0,0 +1,60 @@
+/**************************************************************************//**
+\file bspTaslManager.h
+
+\brief Declarations of enums and functions of BSP task manager.
+
+\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:
+ 26.08.09 A. Taradov - Created
+*******************************************************************************/
+
+#ifndef _BSPTASKHANDLER_H
+#define _BSPTASKHANDLER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+// \cond
+#include <types.h>
+#include <taskManager.h>
+// \endcond
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+enum
+{
+ BSP_BUTTONS = (uint8_t)1 << 0,
+ BSP_TEMPERATURE = (uint8_t)1 << 1,
+ BSP_LIGHT = (uint8_t)1 << 2,
+ BSP_BATTERY = (uint8_t)1 << 3,
+};
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+extern volatile uint8_t bspTaskFlags;
+
+/******************************************************************************
+ Inline static functions section
+******************************************************************************/
+/***************************************************************************//**
+\brief posting bsp task for task manager.
+\param[in]
+ flag - task number
+*******************************************************************************/
+INLINE void bspPostTask(uint8_t flag)
+{
+ bspTaskFlags |= flag;
+ SYS_PostTask(BSP_TASK_ID);
+}
+
+#endif /* _BSPTASKHANDLER_H */
+// eof bspTaskManager.h
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/RCB/src/bspTaskManager.c b/digital/zigbit/bitcloud/stack/Components/BSP/RCB/src/bspTaskManager.c
new file mode 100644
index 00000000..65c80e55
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/RCB/src/bspTaskManager.c
@@ -0,0 +1,86 @@
+/**************************************************************************//**
+\file bspTaskManager.c
+
+\brief Implemenattion of BSP task manager.
+
+\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:
+ 26.08.09 A. Taradov - Created
+******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <bspTaskManager.h>
+#include <atomic.h>
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief BSP button handler.
+******************************************************************************/
+void bspButtonsHandler(void);
+
+/**************************************************************************//**
+\brief BSP temperature sensor handler.
+******************************************************************************/
+void bspTemperatureSensorHandler(void);
+
+/**************************************************************************//**
+\brief BSP light sensor handler.
+******************************************************************************/
+void bspLightSensorHandler(void);
+
+/**************************************************************************//**
+\brief BSP battery handler.
+******************************************************************************/
+void bspEmptyBatteryHandler(void);
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+volatile uint8_t bspTaskFlags = 0;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief BSP task handler.
+******************************************************************************/
+void BSP_TaskHandler(void)
+{
+#if APP_DISABLE_BSP != 1
+ if (bspTaskFlags & BSP_BUTTONS)
+ {
+ bspTaskFlags &= ~BSP_BUTTONS;
+ bspButtonsHandler();
+ }
+#endif //APP_DISABLE_BSP != 1
+ if (bspTaskFlags & BSP_TEMPERATURE)
+ {
+ bspTaskFlags &= (~BSP_TEMPERATURE);
+ bspTemperatureSensorHandler();
+ }
+ if (bspTaskFlags & BSP_LIGHT)
+ {
+ bspTaskFlags &= (~BSP_LIGHT);
+ bspLightSensorHandler();
+ }
+ if (bspTaskFlags & BSP_BATTERY)
+ {
+ bspTaskFlags &= (~BSP_BATTERY);
+ bspEmptyBatteryHandler();
+ }
+ if (bspTaskFlags)
+ SYS_PostTask(BSP_TASK_ID);
+}
+
+// eof bspTaskManager.c
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/RCB/src/buttons.c b/digital/zigbit/bitcloud/stack/Components/BSP/RCB/src/buttons.c
new file mode 100644
index 00000000..8139394a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/RCB/src/buttons.c
@@ -0,0 +1,187 @@
+/**************************************************************************//**
+\file buttons.c
+
+\brief Implementation of buttons interface.
+
+\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:
+ 21.08.09 A. Taradov - Created
+*******************************************************************************/
+#if APP_DISABLE_BSP != 1
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <buttons.h>
+#include <irq.h>
+#include <appTimer.h>
+#include <bspTaskManager.h>
+#include <gpio.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define BSP_readKEY0() GPIO_E5_read()
+#define PRESSED 1
+#define RELEASED 0
+#define BSP_BUTTONS_IDLE 0
+#define BSP_BUTTONS_BUSY 1
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef struct
+{
+ uint8_t currentState0 : 1;
+ uint8_t wasPressed0 : 1;
+ uint8_t waitReleased0 : 1;
+} BSP_buttonsAction_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief HAL's event handlers about KEY 0 has changed state.
+******************************************************************************/
+void bspKey0InterruptHandler(void);
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+static uint8_t state = BSP_BUTTONS_IDLE;
+static volatile BSP_buttonsAction_t buttonsAction;
+static BSP_ButtonsEventFunc_t bspButtonPressHandle; // callback
+static BSP_ButtonsEventFunc_t bspButtonReleaseHandle; // callback
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Initializes buttons module.
+******************************************************************************/
+static void bspInitButtons(void)
+{
+ GPIO_E5_make_in();
+ GPIO_E5_make_pullup();
+
+ HAL_RegisterIrq(IRQ_5, IRQ_LOW_LEVEL, bspKey0InterruptHandler);
+
+ if (BSP_readKEY0())
+ buttonsAction.currentState0 = RELEASED;
+ else
+ buttonsAction.currentState0 = PRESSED;
+
+ HAL_EnableIrq(IRQ_5);
+}
+
+/**************************************************************************//**
+\brief Registers handlers for button events.
+
+\param[in]
+ pressed - the handler to process pressing the button
+\param[in]
+ released - the handler to process releasing the button
+\param[in]
+ bn - button number.
+\return
+ BC_FAIL - buttons module is busy, \n
+ BC_SUCCESS in other case.
+******************************************************************************/
+result_t BSP_OpenButtons(void (*pressed)(uint8_t bn), void (*released)(uint8_t bn))
+{
+ if (state != BSP_BUTTONS_IDLE)
+ return BC_FAIL;
+ state = BSP_BUTTONS_BUSY;
+ bspButtonPressHandle = pressed;
+ bspButtonReleaseHandle = released;
+ bspInitButtons();
+ return BC_SUCCESS;
+};
+
+/**************************************************************************//**
+\brief Cancel buttons handlers.
+\return
+ BC_FAIL - buttons module was not opened, \n
+ BC_SUCCESS in other case.
+******************************************************************************/
+result_t BSP_CloseButtons(void)
+{
+ if (state != BSP_BUTTONS_BUSY)
+ return BC_FAIL;
+ HAL_UnregisterIrq(IRQ_5);
+ bspButtonPressHandle = NULL;
+ bspButtonReleaseHandle = NULL;
+ state = BSP_BUTTONS_IDLE;
+ return BC_SUCCESS;
+};
+
+/**************************************************************************//**
+\brief Reads state of buttons.
+
+\return
+ Current buttons state in a binary way. \n
+ Bit 0 defines state of the button 1, \n
+ bit 1 defines state of the button 2.
+******************************************************************************/
+uint8_t BSP_ReadButtonsState(void)
+{
+ uint8_t state = 0;
+
+ if (buttonsAction.currentState0)
+ state = 0x01;
+
+ return state;
+}
+
+/**************************************************************************//**
+\brief HAL's event about KEY has changed state.
+******************************************************************************/
+void bspKey0InterruptHandler(void)
+{
+ HAL_DisableIrq(IRQ_5);
+ buttonsAction.currentState0 = PRESSED;
+ buttonsAction.wasPressed0 = 1;
+ bspPostTask(BSP_BUTTONS);
+}
+
+/**************************************************************************//**
+\brief BSP's event about KEY has changed state.
+******************************************************************************/
+void bspButtonsHandler(void)
+{
+ if (buttonsAction.wasPressed0)
+ {
+ buttonsAction.wasPressed0 = 0;
+ buttonsAction.waitReleased0 = 1;
+ if (NULL != bspButtonPressHandle)
+ bspButtonPressHandle(BSP_KEY0);
+ }
+
+ if (buttonsAction.waitReleased0)
+ {
+ if (BSP_readKEY0())
+ {
+ buttonsAction.waitReleased0 = 0;
+ buttonsAction.currentState0 = RELEASED;
+ if (NULL != bspButtonReleaseHandle)
+ bspButtonReleaseHandle(BSP_KEY0);
+ HAL_EnableIrq(IRQ_5);
+ }
+ else
+ {
+ bspPostTask(BSP_BUTTONS);
+ }
+ }
+}
+
+#endif // APP_DISABLE_BSP != 1
+
+// end of buttons.c
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/RCB/src/fakeBSP.c b/digital/zigbit/bitcloud/stack/Components/BSP/RCB/src/fakeBSP.c
new file mode 100644
index 00000000..b7454d82
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/RCB/src/fakeBSP.c
@@ -0,0 +1,356 @@
+/***************************************************************************//**
+\file fakeBSP.c
+
+\brief Implementation of fake board-specific periphery.
+
+\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:
+ 05/05/11 A. Malkin - Created
+*******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <joystick.h>
+#include <bspTaskManager.h>
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+void(* readTemperatureDataCallback)(bool error, int16_t data);
+void(* readLightDataCallback)(bool error, int16_t data);
+void(* readBatteryDataCallback)(int16_t data);
+
+#if APP_DISABLE_BSP == 1
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+ Leds
+******************************************************************************/
+/**************************************************************************//**
+\brief Opens leds module to use.
+
+\return
+ operation state
+******************************************************************************/
+result_t BSP_OpenLeds(void)
+{
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief Closes leds module.
+
+\return
+ operation state
+******************************************************************************/
+result_t BSP_CloseLeds(void)
+{
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief Turns on the LED.
+
+\param[in]
+ id - number of led
+******************************************************************************/
+void BSP_OnLed(uint8_t id)
+{
+ (void)id;
+}
+
+/**************************************************************************//**
+\brief Turns off the LED.
+
+\param[in]
+ id - number of led
+******************************************************************************/
+void BSP_OffLed(uint8_t id)
+{
+ (void)id;
+}
+
+/**************************************************************************//**
+\brief Changes the LED state to opposite.
+
+\param[in]
+ id - number of led
+******************************************************************************/
+void BSP_ToggleLed(uint8_t id)
+{
+ (void)id;
+}
+
+/******************************************************************************
+ Buttons
+******************************************************************************/
+/**************************************************************************//**
+\brief Registers handlers for button events.
+
+\param[in]
+ pressed - the handler to process pressing the button
+\param[in]
+ released - the handler to process releasing the button
+\param[in]
+ bn - button number.
+
+\return
+ BC_SUCCESS - always.
+******************************************************************************/
+result_t BSP_OpenButtons(void (*pressed)(uint8_t bn), void (*released)(uint8_t bn))
+{
+ (void)pressed;
+ (void)released;
+
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief Cancel buttons handlers.
+
+\return
+ BC_SUCCESS - always.
+******************************************************************************/
+result_t BSP_CloseButtons(void)
+{
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief Reads state of buttons.
+
+\return
+ Current buttons state in a binary way. \n
+ Bit 0 defines state of the button 1, \n
+ bit 1 defines state of the button 2.
+******************************************************************************/
+uint8_t BSP_ReadButtonsState(void)
+{
+ return 0;
+}
+
+#endif // APP_DISABLE_BSP == 1
+
+/******************************************************************************
+ Sensors
+******************************************************************************/
+/***************************************************************************//**
+\brief Opens temperature sensor.
+
+\return
+ BC_SUCCESS - always.
+*******************************************************************************/
+result_t BSP_OpenTemperatureSensor(void)
+{
+ return BC_SUCCESS;
+}
+
+/***************************************************************************//**
+\brief Closes the temperature sensor.
+
+\return
+ BC_SUCCESS - always.
+*******************************************************************************/
+result_t BSP_CloseTemperatureSensor(void)
+{
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief Reads data from the temperature sensor.
+\param[in]
+ result - the result of the requested operation.
+ true - operation finished successfully, false - some error has
+ occured.
+\param[in]
+ data - sensor data.
+
+\return
+ BC_SUCCESS - always.
+******************************************************************************/
+result_t BSP_ReadTemperatureData(void (*f)(bool result, int16_t data))
+{
+ readTemperatureDataCallback = f;
+
+ bspPostTask(BSP_TEMPERATURE);
+
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief BSP task handler for temperature sensor.
+******************************************************************************/
+void bspTemperatureSensorHandler(void)
+{
+ readTemperatureDataCallback(true, 0);
+}
+
+/***************************************************************************//**
+\brief Opens the light sensor.
+
+\return
+ BC_SUCCESS - always.
+*******************************************************************************/
+result_t BSP_OpenLightSensor(void)
+{
+ return BC_SUCCESS;
+}
+
+/***************************************************************************//**
+\brief Closes the light sensor.
+
+\return
+ BC_SUCCESS - always.
+*******************************************************************************/
+result_t BSP_CloseLightSensor(void)
+{
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief Reads data from the light sensor.
+\param[in]
+ result - the result of the requested operation.
+ true - operation finished successfully, false - some error has
+ occured.
+\param[in]
+ data - sensor data.
+
+\return
+ BC_SUCCESS - always.
+******************************************************************************/
+result_t BSP_ReadLightData(void (*f)(bool result, int16_t data))
+{
+ readLightDataCallback = f;
+
+ bspPostTask(BSP_LIGHT);
+
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief BSP task handler for light sensor.
+******************************************************************************/
+void bspLightSensorHandler(void)
+{
+ readLightDataCallback(true, 0);
+}
+
+/***************************************************************************//**
+\brief Opens the battery sensor.
+
+\return
+ BC_SUCCESS - always.
+*******************************************************************************/
+result_t BSP_OpenBatterySensor(void)
+{
+ return BC_SUCCESS;
+}
+
+/***************************************************************************//**
+\brief Closes the battery sensor.
+
+\return
+ BC_SUCCESS - always.
+*******************************************************************************/
+result_t BSP_CloseBatterySensor(void)
+{
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief Reads data from battery sensor.
+
+\param[in]
+ data - sensor data.
+
+\return
+ BC_SUCCESS - always.
+******************************************************************************/
+result_t BSP_ReadBatteryData(void (*f)(int16_t data))
+{
+ readBatteryDataCallback = f;
+
+ bspPostTask(BSP_BATTERY);
+
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief BSP task handler for battery sensor.
+******************************************************************************/
+void bspEmptyBatteryHandler(void)
+{
+ readBatteryDataCallback(0);
+}
+
+/******************************************************************************
+ Sliders
+******************************************************************************/
+/**************************************************************************//**
+\brief Reads the sliders.
+
+\return
+ state of 3 on-board DIP-switches.User can uses SLIDER0, SLIDER1, SLIDER2
+ defines to test state. Value 1 indicates that slider is on.
+******************************************************************************/
+uint8_t BSP_ReadSliders(void)
+{
+ return 0;
+}
+
+/******************************************************************************
+ Joystick
+******************************************************************************/
+/******************************************************************************
+\brief Registers handler for joystick events.
+
+\param[in]
+ state - joystick state.
+
+\return
+ BC_FAIL - joystick module is busy,
+ BC_SUCCESS in other cases.
+******************************************************************************/
+result_t BSP_OpenJoystick(void (*generalHandler)(BSP_JoystickState_t state))
+{
+ (void)generalHandler;
+
+ return BC_SUCCESS;
+}
+
+/******************************************************************************
+\brief Cancel joystick handlers.
+
+\return
+ BC_FAIL - joystick module was not opened,
+ BC_SUCCESS in other cases.
+******************************************************************************/
+result_t BSP_CloseJoystick(void)
+{
+ return BC_SUCCESS;
+}
+
+/******************************************************************************
+\brief Reads state of joystick.
+
+\return
+ Current joystick state.
+******************************************************************************/
+BSP_JoystickState_t BSP_ReadJoystickState(void)
+{
+ return 0;
+}
+
+// eof fakeBSP.c
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/RCB/src/leds.c b/digital/zigbit/bitcloud/stack/Components/BSP/RCB/src/leds.c
new file mode 100644
index 00000000..48a26fd3
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/RCB/src/leds.c
@@ -0,0 +1,124 @@
+/***************************************************************************//**
+\file leds.c
+
+\brief The module to access to the leds.
+
+\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:
+ 05.08.09 A. Taradov - Created
+*******************************************************************************/
+#if APP_DISABLE_BSP != 1
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <bspLeds.h>
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Opens leds module to use.
+
+\return
+ operation state
+******************************************************************************/
+result_t BSP_OpenLeds(void)
+{
+ halInitFirstLed();
+ halInitSecondLed();
+ halInitThirdLed();
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief Closes leds module.
+
+\return
+ operation state
+******************************************************************************/
+result_t BSP_CloseLeds(void)
+{
+ halUnInitFirstLed();
+ halUnInitSecondLed();
+ halUnInitThirdLed();
+ return BC_SUCCESS;
+}
+
+/**************************************************************************//**
+\brief Turns the LED on.
+
+\param[in]
+ id - number of led
+******************************************************************************/
+void BSP_OnLed(uint8_t id)
+{
+ switch (id)
+ {
+ case LED_FIRST:
+ halOnFirstLed();
+ break;
+ case LED_SECOND:
+ halOnSecondLed();
+ break;
+ case LED_THIRD:
+ halOnThirdLed();
+ break;
+ }
+}
+
+/**************************************************************************//**
+\brief Turns the LED off.
+
+\param[in]
+ id - number of led
+******************************************************************************/
+void BSP_OffLed(uint8_t id)
+{
+ switch (id)
+ {
+ case LED_FIRST:
+ halOffFirstLed();
+ break;
+ case LED_SECOND:
+ halOffSecondLed();
+ break;
+ case LED_THIRD:
+ halOffThirdLed();
+ break;
+ }
+}
+
+/**************************************************************************//**
+\brief Toggles LED state.
+
+\param[in]
+ id - number of led
+******************************************************************************/
+void BSP_ToggleLed(uint8_t id)
+{
+ switch (id)
+ {
+ case LED_FIRST:
+ halToggleFirstLed();
+ break;
+ case LED_SECOND:
+ halToggleSecondLed();
+ break;
+ case LED_THIRD:
+ halToggleThirdLed();
+ break;
+ }
+}
+
+#endif // APP_DISABLE_BSP != 1
+
+// eof leds.c
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/include/buttons.h b/digital/zigbit/bitcloud/stack/Components/BSP/include/buttons.h
new file mode 100644
index 00000000..316c80d9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/include/buttons.h
@@ -0,0 +1,96 @@
+/***************************************************************************//**
+ \file buttons.h
+
+ \brief The header file describes the buttons interface.
+
+ \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:
+ 29/05/07 E. Ivanov - Created
+*******************************************************************************/
+
+#ifndef _BSPBUTTONS_H
+#define _BSPBUTTONS_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+// \cond
+#include <types.h>
+// \endcond
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+// \cond
+#define BSP_KEY0 ((uint8_t)1 << 0)
+#define BSP_KEY1 ((uint8_t)1 << 1)
+#define BSP_KEY2 ((uint8_t)1 << 2)
+#define BSP_KEY3 ((uint8_t)1 << 3)
+#define BSP_KEY4 ((uint8_t)1 << 4)
+#define BSP_KEY5 ((uint8_t)1 << 5)
+#define BSP_KEY6 ((uint8_t)1 << 6)
+#define BSP_KEY7 ((uint8_t)1 << 7)
+// for avr32_evk1105
+#define BSP_UP 0
+#define BSP_DOWN 1
+#define BSP_RIGHT 2
+#define BSP_LEFT 3
+#define BSP_ENTER 4
+// \endcond
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+// \cond
+typedef void (*BSP_ButtonsEventFunc_t)(uint8_t);
+// \endcond
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Registers handlers for button events.
+\param[in]
+ pressed - the handler to process pressing of the button \n
+ bn - button number.
+\param[in]
+ released - the handler to process releasing of the button \n
+ bn - button number.
+\return
+ BC_FAIL - buttons module is busy, \n
+ BC_SUCCESS - otherwise.
+******************************************************************************/
+result_t BSP_OpenButtons(void (*pressed)(uint8_t bn), void (*released)(uint8_t bn));
+
+/**************************************************************************//**
+\brief Cancel buttons handlers.
+\return
+ BC_FAIL - buttons module was not opened, \n
+ BC_SUCCESS - otherwise.
+******************************************************************************/
+result_t BSP_CloseButtons(void);
+
+/**************************************************************************//**
+\brief Reads state of the buttons.
+\return
+ Current buttons state in a binary way. \n
+ Bit 0 defines the state of button 1, \n
+ bit 1 defines the state of button 2 (for meshbean). \n
+ Bit 0 defines the state of up, \n
+ bit 1 defines the state of down, \n
+ bit 2 defines the state of right, \n
+ bit 3 defines the state of left, \n
+ bit 4 defines the state of enter(for avr32_evk1105).
+******************************************************************************/
+uint8_t BSP_ReadButtonsState(void);
+
+#endif /* _BSPBUTTONS_H */
+//eof buttons.h
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/include/hexSwitch.h b/digital/zigbit/bitcloud/stack/Components/BSP/include/hexSwitch.h
new file mode 100644
index 00000000..f052fa83
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/include/hexSwitch.h
@@ -0,0 +1,45 @@
+/**************************************************************************//**
+ \file hexSwitch.h
+
+ \brief Interface of hex switch.
+
+ \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:
+ 7/10/08 A. Khromykh - Created
+******************************************************************************/
+#ifndef _HEXSWITCH_H
+#define _HEXSWITCH_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define HEX_SWITCH_FIRST 0
+#define HEX_SWITCH_SECOND 1
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Read the hex switch.
+
+\param[in]
+ nmSwitch - hex switch number
+
+\return
+ hex code.
+******************************************************************************/
+uint8_t BSP_ReadHexSwitch(uint8_t nmSwitch);
+
+#endif /* _HEXSWITCH_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/include/joystick.h b/digital/zigbit/bitcloud/stack/Components/BSP/include/joystick.h
new file mode 100644
index 00000000..d2c8581e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/include/joystick.h
@@ -0,0 +1,74 @@
+/***************************************************************************//**
+ \file joystick.h
+
+ \brief The header file describes the joystick interface.
+
+ \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:
+ 10/09/07 A. Khromykh - Created
+*******************************************************************************/
+
+#ifndef _BSPJOYSTICK_H
+#define _BSPJOYSTICK_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+// \cond
+#include <types.h>
+// \endcond
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/*! \brief joystick states */
+typedef enum
+{
+ JOYSTICK_LEFT,
+ JOYSTICK_RIGHT,
+ JOYSTICK_UP,
+ JOYSTICK_DOWN,
+ JOYSTICK_PUSH
+} BSP_JoystickState_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Opens component and registers handler for joystick events.
+\param[in]
+ generalHandler - the joystick handler
+\param[in]
+ state - joystick state 
+\return
+ BC_FAIL - joystick module is busy, \n
+ BC_SUCCESS - joystick module is free.
+******************************************************************************/
+result_t BSP_OpenJoystick(void (*generalHandler)(BSP_JoystickState_t state));
+
+/**************************************************************************//**
+\brief closes joystick component.
+
+\return
+ BC_FAIL - joystick module was not opened, \n
+ BC_SUCCESS - joystick module was closed.
+******************************************************************************/
+result_t BSP_CloseJoystick(void);
+
+/**************************************************************************//**
+\brief Reads state of joystick.
+
+\return
+   Joystick state.
+******************************************************************************/
+BSP_JoystickState_t BSP_ReadJoystickState(void);
+
+#endif /* _BSPJOYSTICK_H */
+//eof joystick.h
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/include/lcd.h b/digital/zigbit/bitcloud/stack/Components/BSP/include/lcd.h
new file mode 100644
index 00000000..82650936
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/include/lcd.h
@@ -0,0 +1,140 @@
+/**************************************************************************//**
+ \file lcd.h
+
+ \brief The header file describes enums and functions of BSP LCD controller.
+
+ \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:
+ 17/12/08 E. ALuzhetsky - Created
+*******************************************************************************/
+
+#ifndef _LCD_H
+#define _LCD_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+// \cond
+#include <types.h>
+#include <taskManager.h>
+// \endcond
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+typedef enum
+{
+ // Symbols
+ LCD_CMD_SYMB_RAVEN_ON = 0x00,
+ LCD_CMD_SYMB_RAVEN_OFF = 0x01,
+
+ LCD_CMD_SYMB_BELL_ON = 0x02,
+ LCD_CMD_SYMB_BELL_OFF = 0x03,
+
+ LCD_CMD_SYMB_TONE_ON = 0x04,
+ LCD_CMD_SYMB_TONE_OFF = 0x05,
+
+ LCD_CMD_SYMB_MIC_ON = 0x06,
+ LCD_CMD_SYMB_MIC_OFF = 0x07,
+
+ LCD_CMD_SYMB_SPEAKER_ON = 0x08,
+ LCD_CMD_SYMB_SPEAKER_OFF = 0x09,
+
+ LCD_CMD_SYMB_KEY_ON = 0x0a,
+ LCD_CMD_SYMB_KEY_OFF = 0x0b,
+
+ LCD_CMD_SYMB_ATT_ON = 0x0c,
+ LCD_CMD_SYMB_ATT_OFF = 0x0d,
+
+ LCD_CMD_SYMB_SPACE_SUN = 0x0e,
+ LCD_CMD_SYMB_SPACE_MOON = 0x0f,
+ LCD_CMD_SYMB_SPACE_OFF = 0x10,
+
+ LCD_CMD_SYMB_CLOCK_AM = 0x11,
+ LCD_CMD_SYMB_CLOCK_PM = 0x12,
+ LCD_CMD_SYMB_CLOCK_OFF = 0x13,
+
+ LCD_CMD_SYMB_TRX_RX = 0x14,
+ LCD_CMD_SYMB_TRX_TX = 0x15,
+ LCD_CMD_SYMB_TRX_OFF = 0x16,
+
+ LCD_CMD_SYMB_IP_ON = 0x17,
+ LCD_CMD_SYMB_IP_OFF = 0x18,
+
+ LCD_CMD_SYMB_PAN_ON = 0x19,
+ LCD_CMD_SYMB_PAN_OFF = 0x1a,
+
+ LCD_CMD_SYMB_ZLINK_ON = 0x1b,
+ LCD_CMD_SYMB_ZLINK_OFF = 0x1c,
+
+ LCD_CMD_SYMB_ZIGBEE_ON = 0x1d,
+ LCD_CMD_SYMB_ZIGBEE_OFF = 0x1e,
+
+ LCD_CMD_SYMB_ANTENNA_LEVEL_0 = 0x1f,
+ LCD_CMD_SYMB_ANTENNA_LEVEL_1 = 0x20,
+ LCD_CMD_SYMB_ANTENNA_LEVEL_2 = 0x21,
+ LCD_CMD_SYMB_ANTENNA_OFF = 0x22,
+
+ //LCD_CMD_SYMB_BAT // bettery symbol is controlled by ATMega3290...
+
+ LCD_CMD_SYMB_ENV_OPEN = 0x23,
+ LCD_CMD_SYMB_ENV_CLOSE = 0x24,
+ LCD_CMD_SYMB_ENV_OFF = 0x25,
+
+ LCD_CMD_SYMB_TEMP_CELSIUS = 0x26,
+ LCD_CMD_SYMB_TEMP_FAHRENHEIT = 0x27,
+ LCD_CMD_SYMB_TEMP_OFF = 0x28,
+
+ LCD_CMD_SYMB_MINUS_ON = 0x29,
+ LCD_CMD_SYMB_MINUS_OFF = 0x2a,
+
+ LCD_CMD_SYMB_DOT_ON = 0x2b,
+ LCD_CMD_SYMB_DOT_OFF = 0x2c,
+
+ LCD_CMD_SYMB_COL_ON = 0x2d,
+ LCD_CMD_SYMB_COL_OFF = 0x2e,
+
+ // Led
+ LCD_CMD_LED_ON = 0x2f,
+ LCD_CMD_LED_TOGGLE = 0x30,
+ LCD_CMD_LED_OFF = 0x31,
+} BspLcdCmd_t ;
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+/******************************************************************************
+ Function prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Initializes UART to control LCD.
+******************************************************************************/
+extern void BSP_OpenLcd(void);
+
+/**************************************************************************//**
+\brief Sends the command to the LCD.
+******************************************************************************/
+extern void BSP_SendLcdCmd(BspLcdCmd_t cmdId);
+
+/**************************************************************************//**
+\brief Sends the message to the LCD.
+******************************************************************************/
+extern void BSP_SendLcdMsg(const char *str);
+
+/**************************************************************************//**
+\brief Checks whether the LCD command transmission is finished or not.
+
+\param void
+\return 1 in case if empty, 0 otherwise
+******************************************************************************/
+extern int BSP_IsLcdOperationCompleted(void);
+
+#endif /* _LCD_H */
+// eof lcd.h
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/include/leds.h b/digital/zigbit/bitcloud/stack/Components/BSP/include/leds.h
new file mode 100644
index 00000000..a75bb28c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/include/leds.h
@@ -0,0 +1,83 @@
+/************************************************************//**
+ \file leds.h
+
+ \brief The header file describes the leds interface.
+
+ \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:
+ 29/05/07 E. Ivanov - Created
+*****************************************************************/
+
+#ifndef _LEDS_H
+#define _LEDS_H
+
+/****************************************************************
+ Includes section
+*****************************************************************/
+// \cond
+#include <types.h>
+// \endcond
+
+/****************************************************************
+ Define(s) section
+*****************************************************************/
+#define LED_FIRST 0
+#define LED_SECOND 1
+#define LED_THIRD 2
+#define LED_FOURTH 3
+#define LED_FIFTH 4
+#define LED_SIXTH 5
+#define LED_SEVENTH 6
+#define LED_EIGHTH 7
+#define LED_RED LED_FIRST
+#define LED_YELLOW LED_SECOND
+#define LED_GREEN LED_THIRD
+#define LED_BLUE LED_FOURTH
+
+/****************************************************************
+ Prototypes section
+*****************************************************************/
+/************************************************************//**
+\brief Opens leds module to use.
+\return
+ BC_SUCCESS - always.
+****************************************************************/
+result_t BSP_OpenLeds(void);
+
+/************************************************************//**
+\brief Closes leds module.
+\return
+ BC_SUCCESS - always.
+****************************************************************/
+result_t BSP_CloseLeds(void);
+
+/************************************************************//**
+\brief Turns on a led.
+\param[in]
+ id - number of the led to proceed. Must be chosen from defines.
+****************************************************************/
+void BSP_OnLed(uint8_t id);
+
+/************************************************************//**
+\brief Turns off a led.
+\param[in]
+ id - number of the led to proceed. Must be chosen from defines.
+****************************************************************/
+void BSP_OffLed(uint8_t id);
+
+/************************************************************//**
+\brief Switches the led state to the opposite.
+\param[in]
+ id - number of the led to proceed. Must be chosen from defines.
+****************************************************************/
+void BSP_ToggleLed(uint8_t id);
+
+#endif /* _LEDS_H */
+// eof leds.h
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/include/rs232Controller.h b/digital/zigbit/bitcloud/stack/Components/BSP/include/rs232Controller.h
new file mode 100644
index 00000000..b3cf887e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/include/rs232Controller.h
@@ -0,0 +1,89 @@
+/************************************************************//**
+ \file rs232Controller.h
+
+ \brief Functions for RS232 level converter interface.
+
+ \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:
+ 28.09.09 A. Taradov - Created
+*****************************************************************/
+#ifndef _RS232CONTROLLER_H
+#define _RS232CONTROLLER_H
+
+/*****************************************************************
+ Includes section
+*****************************************************************/
+#include <gpio.h>
+
+/************************************************************//**
+\brief Enable RS232 level converter.
+****************************************************************/
+static inline void BSP_EnableRs232(void)
+{
+#if BSP_ENABLE_RS232_CONTROL == 1
+ #if defined(RCB_ATMEGA128RFA1)
+ // ~EN
+ GPIO_D4_make_out();
+ GPIO_D4_clr();
+
+ // FORCEON
+ GPIO_D6_make_out();
+ GPIO_D6_set();
+
+ // ~FORCEOFF
+ GPIO_D7_make_out();
+ GPIO_D7_set();
+ #elif defined(RCB230_V31) || defined(RCB230_V32) || defined(RCB230_V331) || defined(RCB231_V402) || \
+ defined(RCB231_V411) || defined(RCB212_V532)
+ // ~EN
+ GPIO_13_make_out();
+ GPIO_13_clr();
+
+ // FORCEON
+ GPIO_15_make_out();
+ GPIO_15_set();
+
+ // ~FORCEOFF
+ GPIO_16_make_out();
+ GPIO_16_set();
+ #elif defined(BOARD_SAM3S_EK)
+ // ~EN
+ GPIO_PA23_make_out();
+ GPIO_PA23_clr();
+ #else
+ #error 'Unsupported board.'
+ #endif
+#endif
+};
+
+/************************************************************//**
+\brief Disable RS232 level converter.
+****************************************************************/
+static inline void BSP_DisableRs232(void)
+{
+#if BSP_ENABLE_RS232_CONTROL == 1
+ #if defined(RCB_ATMEGA128RFA1)
+ GPIO_D4_make_in();
+ GPIO_D6_make_in();
+ GPIO_D7_make_in();
+ #elif defined(RCB230_V31) || defined(RCB230_V32) || defined(RCB230_V331) || defined(RCB231_V402) || \
+ defined(RCB231_V411) || defined(RCB212_V532)
+ GPIO_13_make_in();
+ GPIO_15_make_in();
+ GPIO_16_make_in();
+ #elif defined(BOARD_SAM3S_EK)
+ GPIO_PA23_make_in();
+ #else
+ #error 'Unsupported board.'
+ #endif
+#endif
+};
+
+#endif /* _RS232CONTROLLER_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/include/rs485Controller.h b/digital/zigbit/bitcloud/stack/Components/BSP/include/rs485Controller.h
new file mode 100644
index 00000000..7323b032
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/include/rs485Controller.h
@@ -0,0 +1,33 @@
+/************************************************************//**
+ \file rs485Controller.h
+
+ \brief The header file describes functions for enabling\disabling rs485 interface.
+
+ \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:
+ 12/11/08 A. Khromykh - Created
+*****************************************************************/
+#ifndef _RS485CONTROLLER_H
+#define _RS485CONTROLLER_H
+
+/****************************************************************
+ Prototypes section
+*****************************************************************/
+/************************************************************//**
+\brief Enable RTS driving for RS485 driver.
+****************************************************************/
+void BSP_EnableRs485(void);
+
+/************************************************************//**
+\brief Disable RTS driving for RS485 driver.
+****************************************************************/
+void BSP_DisableRs485(void);
+
+#endif /* _RS485CONTROLLER_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/include/sensors.h b/digital/zigbit/bitcloud/stack/Components/BSP/include/sensors.h
new file mode 100644
index 00000000..740c6a05
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/include/sensors.h
@@ -0,0 +1,137 @@
+/**************************************************************************//**
+ \file sensors.h
+
+ \brief The header file describes the sensors interface.
+
+ \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:
+ 29/05/07 E. Ivanov - Created
+*******************************************************************************/
+
+#ifndef _SENSORS_H
+#define _SENSORS_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+// \cond
+#include <types.h>
+// \endcond
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+// \cond
+#define SENSOR_LIGHT 1
+#define SENSOR_TEMPERATURE 2
+#define SENSOR_BATTERY 3
+#define SENSOR_LED 4
+// \endcond
+
+typedef void (*BspTemperatureCb_t)(bool result, int16_t data);
+typedef void (*BspBatteryCb_t)(int16_t data);
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/***************************************************************************//**
+\brief Opens temperature sensor.
+\return
+ BC_FAIL - sensor has been already open. \n
+ BC_SUCCESS - otherwise.
+*******************************************************************************/
+result_t BSP_OpenTemperatureSensor(void);
+
+/***************************************************************************//**
+\brief Closes the temperature sensor.
+\return
+ BC_FAIL - if a hardware error has occured or
+ there is uncompleted ReadData request. \n
+ BC_SUCCESS - otherwise.
+*******************************************************************************/
+result_t BSP_CloseTemperatureSensor(void);
+
+/**************************************************************************//**
+\brief Reads data from the temperature sensor.
+\param[in]
+ f - callback.
+ result - the result of the requested operation.
+ true - operation finished successfully, false - some error has
+ occured.
+ data - sensor data.
+\return
+ BC_FAIL - previous request was not completed. \n
+ BC_SUCCESS - otherwise.
+******************************************************************************/
+result_t BSP_ReadTemperatureData(BspTemperatureCb_t f);
+
+/***************************************************************************//**
+\brief Opens the light sensor.
+\return
+ BC_FAIL - sensor has been already open. \n
+ BC_SUCCESS - otherwise.
+*******************************************************************************/
+result_t BSP_OpenLightSensor(void);
+
+/***************************************************************************//**
+\brief Closes the light sensor.
+\return
+ BC_FAIL - if a hardware error has occured or
+ there is uncompleted ReadData request. \n
+ BC_SUCCESS - otherwise.
+*******************************************************************************/
+result_t BSP_CloseLightSensor(void);
+
+/**************************************************************************//**
+\brief Reads data from the light sensor.
+\param[in]
+ f - callback.
+ result - the result of the requested operation.
+ true - operation finished successfully, false - some error has
+ occured.
+ data - sensor data.
+\return
+ BC_FAIL - previous request was not completed. \n
+ BC_SUCCESS - otherwise.
+******************************************************************************/
+result_t BSP_ReadLightData(void (*f)(bool result, int16_t data));
+
+/***************************************************************************//**
+\brief Opens the battery sensor.
+\return
+ BC_FAIL - sensor has been already open. \n
+ BC_SUCCESS - otherwise.
+*******************************************************************************/
+result_t BSP_OpenBatterySensor(void);
+
+/***************************************************************************//**
+\brief Closes the battery sensor.
+\return
+ BC_FAIL - sensor was not opened. \n
+ BC_SUCCESS - otherwise.
+*******************************************************************************/
+result_t BSP_CloseBatterySensor(void);
+
+/**************************************************************************//**
+\brief Reads data from battery sensor.
+\param[in]
+ callback - callback function.
+ data - sensor data.
+ Can use (4ul * data * 125ul * 3ul) / (1024ul * 100ul) formula to count \n
+ battery data in Volts (for avr).
+\return
+ BC_FAIL - previous request was not completed, or sensor was not opened. \n
+ BC_SUCCESS - otherwise.
+******************************************************************************/
+result_t BSP_ReadBatteryData(BspBatteryCb_t cb);
+
+#endif/* _SENSORS_H */
+// eof sensors.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/include/sliders.h b/digital/zigbit/bitcloud/stack/Components/BSP/include/sliders.h
new file mode 100644
index 00000000..67c19e93
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/include/sliders.h
@@ -0,0 +1,43 @@
+/**************************************************************************//**
+ \file sliders.h
+
+ \brief The header file describes the sliders interface.
+
+ \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:
+ 29/06/07 E. Ivanov - Created
+******************************************************************************/
+
+#ifndef _SLIDERS_H
+#define _SLIDERS_H
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define SLIDER0 (1 << 0)
+#define SLIDER1 (1 << 1)
+#define SLIDER2 (1 << 2)
+#define SLIDER3 (1 << 3)
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Reads the sliders.
+\return
+ State of onboard DIP switches. Use the ::SLIDER0, ::SLIDER1, ::SLIDER2,
+ ::SLIDER3 constants to check state. Bit value 1 indicates that the
+ corresponding slider is on.\n
+ Note that the ::SLIDER3 is available on MeshBean LAN and Turbo board only.
+******************************************************************************/
+uint8_t BSP_ReadSliders(void);
+
+#endif /* _SLIDERS_H */
+// eof sliders.h
diff --git a/digital/zigbit/bitcloud/stack/Components/BSP/include/usbController.h b/digital/zigbit/bitcloud/stack/Components/BSP/include/usbController.h
new file mode 100644
index 00000000..518efe42
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/BSP/include/usbController.h
@@ -0,0 +1,42 @@
+/************************************************************//**
+ \file usbController.h
+
+ \brief The header file describes functions for driving usb line.
+
+ \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:
+ 12/11/08 A. Khromykh - Created
+*****************************************************************/
+#ifndef _USBCONTROLLER_H
+#define _USBCONTROLLER_H
+
+/****************************************************************
+ Prototypes section
+*****************************************************************/
+/************************************************************//**
+\brief Turn on pull-up on D+.
+****************************************************************/
+void BSP_EnableUsb(void);
+
+/************************************************************//**
+\brief Turn off pull-up on D+.
+****************************************************************/
+void BSP_DisableUsb(void);
+
+/************************************************************//**
+\brief Read VBUS line for detection of usb cable connection.
+
+\return
+ 0 - cable is not connected.
+ 1 - cable is not connected.
+****************************************************************/
+uint8_t BSP_ReadVBUS(void);
+
+#endif /* _USBCONTROLLER_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/ConfigServer/Makefile b/digital/zigbit/bitcloud/stack/Components/ConfigServer/Makefile
new file mode 100644
index 00000000..ceb387df
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ConfigServer/Makefile
@@ -0,0 +1,76 @@
+COMPONENTS_PATH = ..
+include $(MAKERULES)
+
+# Compiler flags extending with Confiuration server parameters.
+CFLAGS += $(CFLAGS_CS)
+
+# Compiler flags extending with "debug info" compiler flag.
+CFLAGS += $(CFLAGS_DBG)
+
+# Hardware flags.
+CFLAGS += $(CFLAGS_HW)
+
+##### PATHS FLAGS OF INCLUDES #########
+CFLAGS += -I$(CS_PATH)/include/
+CFLAGS += -I$(CS_PATH)/include/private
+CFLAGS += -I$(SE_PATH)/include
+CFLAGS += -I$(ZDO_PATH)/include
+CFLAGS += -I$(ZDO_PATH)/include/private
+CFLAGS += -I$(NWK_PATH)/include
+CFLAGS += -I$(NWK_PATH)/include/private
+CFLAGS += -I$(APS_PATH)/include
+CFLAGS += -I$(APS_PATH)/include/private
+CFLAGS += -I$(MAC_PHY_PATH)/include
+CFLAGS += -I$(MAC_PHY_PATH)/MAC_ENV/include
+CFLAGS += -I$(MAC_PHY_PATH)/MAC_HWD_PHY/include
+CFLAGS += -I$(MAC_PHY_PATH)/MAC_HWI/include
+CFLAGS += -I$(HAL_PATH)/include
+CFLAGS += -I$(HAL_HWD_COMMON_PATH)/include
+CFLAGS += -I$(SSP_PATH)/include
+CFLAGS += -I$(PDS_PATH)/include
+CFLAGS += -I$(PDS_PATH)/include/private
+CFLAGS += -I$(TC_PATH)/include
+CFLAGS += -I$(ZCL_PATH)/include
+
+###### LIB #########
+BUILDDIR = $(CS_PATH)
+LIBDIR = $(BUILDDIR)/lib
+LISTDIR = $(BUILDDIR)/list
+LDFLAGS = -L$(LIBDIR)
+LIB = $(LIBDIR)/lib$(CS_LIB).a
+
+modules = \
+ configServer \
+ csMem \
+ csPersistentMem
+
+objects = $(addsuffix .o,$(addprefix $(BUILDDIR)/objs/,$(modules)))
+sources = $(addsuffix .c,$(addprefix $(BUILDDIR)/src/,$(modules)))
+
+###### TARGETS ################
+all: component_label $(LIB)
+component_label:
+ @echo
+ @echo ----------------------------------------------------
+ @echo Config Server library creation.
+ @echo ----------------------------------------------------
+
+################
+$(BUILDDIR)/objs/%.o: $(BUILDDIR)/src/%.c
+ $(CC_MSG)
+ $(Q)$(CC) $(CFLAGS) $^ -o $@
+
+################
+$(LIB): $(objects)
+ $(AR_MSG)
+ $(Q)$(AR) $(AR_KEYS) $(LIB) $(objects)
+ $(SIZE_MSG)
+ $(Q)$(SIZE) -td $(LIB)
+
+################
+clean:
+ @echo
+ @echo ----------------------------------------------------
+ @echo Config Server component cleaning.
+ @echo ----------------------------------------------------
+ rm -f $(PROG) $(BUILDDIR)/objs/*.o $(LIB) $(LISTDIR)/*.*
diff --git a/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/configServer.h b/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/configServer.h
new file mode 100644
index 00000000..aba06dc4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/configServer.h
@@ -0,0 +1,158 @@
+/**************************************************************************//**
+ \file configServer.h
+
+ \brief
+ Configuration Server header file
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2010 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 18.10.10 A. Razinkov - Created.
+******************************************************************************/
+
+#ifndef _CONFIG_SERVER_H
+#define _CONFIG_SERVER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <csDefaults.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/*
+ * \brief List of the Configuration Server parameter identifiers.
+ * Identifiers are automatically sorted by memory location
+ * and item types (atomic parameter or memory region).
+ */
+typedef enum _CS_MemoryItemId_t
+{
+#define SEPARATOR(id)
+#define DUMMY_MEMORY(id)
+#define RAM_PARAMETER(id, addr) id,
+#define FLASH_PARAMETER(id, addr)
+#define MEMORY_REGION(id, addr)
+#include "csParamTable.h"
+#undef SEPARATOR
+#undef DUMMY_MEMORY
+#undef RAM_PARAMETER
+#undef FLASH_PARAMETER
+#undef MEMORY_REGION
+
+ CS_FLASH_PARAMETERS_START_ID,
+#define SEPARATOR(id)
+#define DUMMY_MEMORY(id)
+#define RAM_PARAMETER(id, addr)
+#define FLASH_PARAMETER(id, addr) id,
+#define MEMORY_REGION(id, addr)
+#include "csParamTable.h"
+#undef SEPARATOR
+#undef DUMMY_MEMORY
+#undef RAM_PARAMETER
+#undef FLASH_PARAMETER
+#undef MEMORY_REGION
+
+#define SEPARATOR(id)
+#define DUMMY_MEMORY(id) id,
+#define RAM_PARAMETER(id, addr)
+#define FLASH_PARAMETER(id, addr)
+#define MEMORY_REGION(id, addr) id,
+#include "csParamTable.h"
+#undef SEPARATOR
+#undef DUMMY_MEMORY
+#undef RAM_PARAMETER
+#undef FLASH_PARAMETER
+#undef MEMORY_REGION
+
+} CS_MemoryItemId_t;
+
+/******************************************************************************
+ Functions prototypes section
+******************************************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/****************************************************************************//**
+\brief Configuration Server initialization
+******************************************************************************/
+void CS_Init(void);
+
+/******************************************************************************//**
+\brief Gets the value of the parameter specified by an ID and writes it at the provided address in memory
+
+The function reads a value of a ConfigServer parameter specified by its ID. A parameter ID is a constant
+which name can be obtained by adding "_ID" suffix to the name of the parameter as it can be observed
+in csDefaults.h. For example, the identifier of the CS_NWK_PANID parameter will be CS_NWK_PANID_ID.
+The function copies the value of the parameter to the location in memory specified by the second argument.
+An example of a typical use of the function is reading the extended address of the current device:
+
+\code
+ExtAddr_t ownExtAddr;
+CS_ReadParameter(CS_UID_ID, &ownExtAddr);
+\endcode
+
+\param[in] parameterId - an ID of the parameter to be read
+\param[out] memoryPtr - a variable to which the value of the parameter is written
+******************************************************************************/
+void CS_ReadParameter(CS_MemoryItemId_t parameterId, void *memoryPtr);
+
+/******************************************************************************//**
+\brief Sets a value of a certain ConfigServer parameter specified by ID
+
+The function assigns the specified parameter to a new value. The value is copied from the address
+specified by the second argument, while the first takes a parameter identifier formed by adding "_ID"
+suffix to the parameter's name. For example, to set a specific value for own extended address
+proceed with the following:
+
+\code
+ExtAddr_t ownExtAddr = 0x0123456789ABCDEF;
+CS_WriteParameter(CS_UID_ID, &ownExtAddr);
+\endcode
+
+\param[in] parameterId - an ID of the parameter being written
+\param[out] memoryPtr - a pointer to a new value of the parameter
+******************************************************************************/
+void CS_WriteParameter(CS_MemoryItemId_t parameterId, const void *parameterValue);
+
+/***********************************************************************************//**
+\brief Gets a pointer to the memory allocated for a specific internal structure
+
+The function is used to obtain a pointer to the memory marked with a special identifier. The memory
+is allocated by the stack for certain internl buffers and table. For example, this function can be
+emplued to get the contents of bidning, routing, key pair descrptors, or other tables. For some of
+these objects there is a dedicated API in BitCloud, in such cases the application must use this API.
+In case the API is absent the user can use this function to observe the contents of the momory, but
+must not use the pointer obtained with the function to write data to the memory. Otherwise, the memory
+may be corrupted and the application may encounter an unexpected failure. For all purposes when it
+is needed to write data to the tables, ButCloud provides appropriate API.
+The function should be provided with an address of a pointer variable which will be assigned to
+the starting point of the memory.
+
+ \param[in] memoryId - and ID of a parameter or a specific part of the memory
+ \param[out] memoryPtr - a pointer to which a starting address of the memory is written
+
+***************************************************************************************/
+void CS_GetMemory(CS_MemoryItemId_t memoryId, void **memoryPtr);
+
+/**************************************************************************//**
+\brief Set persist default values
+*****************************************************************************/
+void CS_PdsDefaultValue(void);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* _CONFIG_SERVER_H */
+/* eof configServer.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/csDefaults.h b/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/csDefaults.h
new file mode 100644
index 00000000..4bda4a33
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/csDefaults.h
@@ -0,0 +1,1381 @@
+/**************************************************************************//**
+ \file csDefaults.h
+
+ \brief
+ Configuration Server parameters default values.
+ The contents of this file must not be changed by a user. Any default value can be redefined
+ in the application \c configuration.h file.
+
+ Most of the parameters descriptions include the following standard remarks:
+
+ \li <b>Value range</b> notes describe possible values that can be taken by a parameter;
+ \li <b>C-type</b> stands for the type in code that can be used to hold a value of a parameter;
+ \li <b>Can be set</b> indicates when a parameter can be changed: <i>at compile time only</i>, <i>at any time before network start</i>, or <i>at any time</i>;
+ \li if a parameter is stored in EEPROM memory so that its value does not change after hardware reset, while
+ other parameters restore their default values, then it is marked as <b>Persistent</b>; note that only
+ run-time parameters can be persistent.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2010 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 19.10.10 A. Razinkov - Created.
+******************************************************************************/
+
+#ifndef _CSDEFAULTS_H
+#define _CSDEFAULTS_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <stackVersion.h>
+#include <aps.h>
+
+/* MISRA killing for IAR compiler */
+#ifdef __IAR_SYSTEMS_ICC__
+ #ifndef _SYSTEM_BUILD
+ #pragma system_include
+ #endif
+#endif
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+#ifdef CS_APS_DATA_REQ_BUFFER_SIZE
+ #error CS_APS_DATA_REQ_BUFFER_SIZE definition is renamed to CS_APS_DATA_REQ_BUFFERS_AMOUNT - please, use the new name.
+#endif
+#ifdef CS_APS_ACK_FRAME_BUFFER_SIZE
+ #error CS_APS_ACK_FRAME_BUFFER_SIZE definition is renamed to CS_APS_ACK_FRAME_BUFFERS_AMOUNT - please, use the new name.
+#endif
+
+//BOOST mode is enabled automatically only for 11, 10, 9, 8, 7, 6 dBm(s) all other power valuses do not use BOOST mode.
+//! \brief RF transmission power
+/*!
+The parameter specifies the TX power of the transceiver device, is measured in dBm(s).
+After the node has entered the network the value can only be changed via
+the ZDO_SetTxPowerReq() function.
+
+<b>Value range:</b> depends on the hardware
+<b>C-type:</b> int8_t \n
+<b>Can be set:</b> at any time \n
+<b>Persistent:</b> Yes
+*/
+#ifndef CS_RF_TX_POWER
+/* It was TX_PWR_3_0DBM. */
+#define CS_RF_TX_POWER 0
+#endif
+
+//! \brief Determines the device extended address
+/*! 64-bit Unique Identifier (UID). If this value is 0 stack will try to read
+hardware UID from external UID or EEPROM chip. at startup. Location of hardware
+UID is platform dependend and it may not be available on all platforms. If the latter
+case then UID value must be provided by user via this parameter. This parameter must
+be unique for each device in a network.
+
+<b>Value range:</b> any 64-bit value except for broadcast extended addresses
+(see apsCommon.h) \n
+<b>C-type:</b> ExtAddr_t \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> Yes
+*/
+#ifndef CS_UID
+#define CS_UID 0x0000000000000000LL
+#endif
+
+//! \brief The maximum duration in ms of frame transmission
+/*!
+The parameter is used in some internal calculations as the maximum duration
+of transmitting a frame to the air. The default value should not be changed by the user.
+
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_MAX_FRAME_TRANSMISSION_TIME
+#define CS_MAX_FRAME_TRANSMISSION_TIME 5
+#endif
+
+//! \brief Size of MAC RX buffer to store data frames
+/*!
+The parameter specifies a size of the buffer used by the MAC component for
+data frames. The default value must not be changed by the user.
+
+<b>Value range:</b> the value must be greater than 131 \n
+<b>C-type:</b> uint16_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_MAC_FRAME_RX_BUFFER_SIZE
+#define CS_MAC_FRAME_RX_BUFFER_SIZE 132
+#endif
+
+#if defined(AT86RF212) || defined(CUSTOMRF3)
+#ifndef CS_LBT_MODE
+#define CS_LBT_MODE false
+#endif
+#endif
+
+#ifdef _MAC2_
+//! \brief MAC transaction persistence time
+/*!
+The parameter determines how long a frame received by the parent of a sleeping
+end device is stored. If the end device does not polls for data during this time, then
+the frame is dropped.
+
+For more details see MAC PIB attributes, Table 86 in IEEE 802.15.4-2006.
+
+<b>C-type:</b> uint32_t \n
+<b>Can be set:</b> at any time \n
+<b>Persistent:</b> No
+*/
+// (by default in MAC = 7680L)
+#ifndef CS_MAC_TRANSACTION_TIME
+#define CS_MAC_TRANSACTION_TIME 7680L
+#endif
+
+#else //_MAC2_
+
+//! \brief Specifies receiver state (enabled or disabled) during inactive period for an end device
+/*!
+The parameter is taken into account on end devices only. Other devices behave as
+if the parameter equals \c true.
+
+If on an end device the parameter equals \c true,
+then the end device can receive data at any time, radio is always on, and
+its parent, which is informed about the parameter's value during association,
+sends data to the child immediately upon receiving a frame for the child.
+
+Switching the parameter to \c false on an end devices turns on indirect delivery:
+the end device's parent suspends data delivery to the child until it receives
+a polling request from the child; on the end device radio is only on when data is
+being sent.
+
+<b>Value range:</b> \c true or \c false \n
+<b>C-type:</b> bool \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> Yes
+*/
+#ifndef CS_RX_ON_WHEN_IDLE
+#define CS_RX_ON_WHEN_IDLE false
+#endif
+
+// \cond internal
+//! \brief Protocol version identifier. Could not be changed by user.
+#ifndef CS_PROTOCOL_VERSION
+#define CS_PROTOCOL_VERSION 0x02
+#endif
+//! \brief Stack profile identifier (Zigbee PRO profile is equal to 2). Could not be changed by user.
+#ifndef CS_STACK_PROFILE
+#define CS_STACK_PROFILE 0x02
+#endif
+// \endcond
+//! \brief Default value for the type of a device
+/*!
+ZigBee device type determines network behavior of a given device and functions it
+can perform. To give a brief overview, each networks contains exacty one coordinator and
+an arbirtary number of routers and end devices; an end device does not have children, data
+ is passed through the parent, that is, a router or the coordinator.
+
+<b>Value range:</b> \n
+::DEVICE_TYPE_COORDINATOR (0) - the coordinator\n
+::DEVICE_TYPE_ROUTER (1) - a router\n
+::DEVICE_TYPE_END_DEVICE (2) - an end device
+
+<b>C-type:</b> DeviceType_t \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> Yes
+*/
+#ifndef CS_DEVICE_TYPE
+#define CS_DEVICE_TYPE DEVICE_TYPE_ROUTER
+#endif
+
+//! \brief The size of the neighbor table
+/*!
+The parameter determines the size of the neighbor table which is used to store
+beacon responses from nearby devices. The parameter puts an upper bound
+over the amount of child devices possible for the node.
+
+<b>Value range:</b> at minimum 1, the maximum value is limited to the available memory \n
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_NEIB_TABLE_SIZE
+ #define CS_NEIB_TABLE_SIZE 7
+#elif CS_NEIB_TABLE_SIZE == 0
+ #undef CS_NEIB_TABLE_SIZE
+ #define CS_NEIB_TABLE_SIZE 1
+ #warning CS_NEIB_TABLE_SIZE was set to 1
+#endif
+
+//! \brief The maximum number of direct children that a given device (the coordinator or a router) can have
+/*!
+The parameter is only enabled for routers and the coordinator. An end device can not
+have children. If an actual number of children reaches a parameter's value, the node
+will have not been able to accept any more children joining the network. The parameter can be
+set to 0 on a router thus preventing it from accepting any children and can be help form a
+desired network topology. For example, if the parameter is set to 0 on all routers, then the
+coordinator will be the only device that can have children and the network will have star topology.
+
+<b>Value range:</b> from 0 to ::CS_NEIB_TABLE_SIZE \n
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_MAX_CHILDREN_AMOUNT
+#define CS_MAX_CHILDREN_AMOUNT 6
+#endif
+//! \brief The maximum number of routers among the direct children of the device
+/*!
+The parameter determines how many routers the device can have as children. Note that the maximum number of
+end devices is equal to ::CS_MAX_CHILDREN_AMOUNT - ::CS_MAX_CHILDREN_ROUTER_AMOUNT.
+
+<b>Value range:</b> from 0 to ::CS_MAX_CHILDREN_AMOUNT \n
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+ */
+#ifndef CS_MAX_CHILDREN_ROUTER_AMOUNT
+#define CS_MAX_CHILDREN_ROUTER_AMOUNT 2
+#endif
+//! \brief The maximum depth of a network
+/*!
+The parameter determines the maximum depth of a network tree formed by
+child-parent relationships between nodes.
+
+While joining the network the node receives beacon responses from potential
+parents containing their actual network depth and declines those which show values not
+less than the maximum network depth on the joining device. A potential parent will also reject a
+beacon from the joining device and will not sent a response if the joining device shows the network
+depth greater than it is allowed on the potential parent. This logic is enabled if the parameter value
+is not greater than 15. If its value is greater than 15, then device does not perform any checkings of
+the network depth, neither when joining a network nor when accepting other nodes as children.
+This allows forming long chains of devices across considerable distances.
+
+The stack also uses the parameter to calculate several timeouts. Besides, the parameter determines the maximum radius
+of a data packet, that is, the maximum number of hops that a packet may travel, which is calculated by
+the following formula:
+
+<i>maximum radius = 2 * MIN(2 * maxNetworkDepth, 255)</i> \n
+
+These uses of the parameter do not change if its value is greater than 15. Therefore to enable
+transmitting data over long chains of devices, the parameter should be set to a real desired network depth,
+rather than to an accidental value over 15.
+
+The parameter should be the same on all devices in the network.
+
+<b>Value range:</b> from 0 to 255 \n
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_MAX_NETWORK_DEPTH
+#define CS_MAX_NETWORK_DEPTH 5
+#endif
+
+//! \brief The method of automatic address assignment
+/*!
+If ::CS_NWK_UNIQUE_ADDR equals \c 0 this parameter is used to determine
+the assignment method that is applied when a device enters the network to choose
+a short address. Otherwise, the parameter is ignored.
+
+<b>Value range:</b> \n
+NWK_ADDR_ALLOC_DISTRIBUTED (equals 0) - distributed address allocation; the stack
+applies a special recurrent algorithm to form a kind of a search tree from the network to simplify routing \n
+NWK_ADDR_ALLOC_STOCHASTIC (equals 2) - the address is set to a random value, different
+from all other short addresses in the network \n
+NWK_ADDR_ALLOC_FROM_UID (equals 3) - two lower bytes of the extended address are used
+for the short address
+
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_ADDRESS_ASSIGNMENT_METHOD
+#define CS_ADDRESS_ASSIGNMENT_METHOD 2
+#endif
+
+
+#if defined(AT86RF212) || defined(CUSTOMRF3)
+/* Channel number range
+ Page 0 (BPSK modulation is used and supported IEEE 802.15.4 2003/2006 )
+ channel 0: 868 MHz | 20 Kbit/sec
+ channels 1 - 10: 915 MHz | 40 Kbit/sec
+ Page 2 (O-QPSK modulation is used and supported IEEE 802.15.4 2006)
+ channel 0: 868 MHz | 100 Kbit/sec
+ channels 1 - 10: 915 MHz | 250 Kbit/sec
+
+ BOOST mode is enabled automatically only for 11, 10, 9, 8, 7, 6 dBm. All other power values do not use BOOST mode.
+*/
+//! \brief 32-bit mask of channels to be scanned before network is started
+/*!
+Channels that should be used are marked with logical 1 at corresponding bit
+location.
+
+\note For 900 MHz band you also need to specify channel page
+
+<b>Value range:</b> 32-bit values: \n
+Valid channel numbers for 2.4 GHz band are 0x0b - 0x1a \n
+Valid channel numbers for 900 MHz band are 0x00 - 0x0a
+
+<b>C-type:</b> uint32_t \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> Yes
+*/
+ #ifndef CS_CHANNEL_MASK
+ #define CS_CHANNEL_MASK 0x00000002L
+ #endif
+//! \brief Number of a channel page to be used
+/*!
+Channel page number defines band and modulation scheme that will be
+used for communication.
+
+<b>Value range:</b>
+ 0 - 915MHz (BPSK-40, channels 0x01 - 0x0a), 868MHz (BPSK-20, channel 0x00) \n
+ 2 - 915MHz (O-QPSK-250, channels 0x01 - 0x0a), 868Mhz (O-QPSK-100, channel 0x00) \n
+ 5 - 780MHz (O-QPSK-250, channels 0x00 - 0x03, Chinese band)
+
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> Yes
+*/
+ #ifndef CS_CHANNEL_PAGE
+ #define CS_CHANNEL_PAGE 0
+ #endif
+
+#else // AT86RF230/230B/231
+//! \brief 32-bit mask of channels to be scanned before network is started
+/*!
+Channels that should be used are marked with logical 1 at corresponding bit
+location.
+
+\note For 900 MHz band you also need to specify channel page
+
+<b>Value range:</b> 32-bit values: \n
+Valid channel numbers for 2.4 GHz band are 0x0b - 0x1a \n
+Valid channel numbers for 900 MHz band are 0x00 - 0x0a
+
+<b>C-type:</b> uint32_t \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> Yes
+*/
+ #ifndef CS_CHANNEL_MASK
+ #define CS_CHANNEL_MASK 0x00010000L
+ #endif
+//! \brief Number of a channel page to be used. Ignored in the case of AT86RF230/230B/231 RF chip.
+ #ifndef CS_CHANNEL_PAGE
+ #define CS_CHANNEL_PAGE 0
+ #endif
+#endif
+
+//! \brief Extended PAN ID of the network to which the device should join
+/*!
+The parameter specifies the predefined extended PANID of the network to be formed
+(for the coordinator) or joined (for a router or an end device). For a router or an end device
+ the parameter can equal 0 allowing them to join the first suitable network that they discover.
+
+<b>Value range:</b> All 64-bit values except for 0xFFFFFFFFFFFFFFFFLL;
+specify a value in the \c 0x123456789ABCDEFLL format. \n
+<b>C-type:</b> ExtPanId_t (equal to uint64_t) \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> Yes
+*/
+#ifndef CS_EXT_PANID
+#define CS_EXT_PANID CS_UID
+#endif
+//! \brief An actual value of the extended PANID after network has started
+/*!
+Is automatically written by the stack with an actual extended PANID of the network
+to which the device joined. The parameter should not be changed while the device is
+in the network.
+
+<b>Value range:</b> All 64-bit values, specify a value in the \c 0x123456789ABCDEFLL format. \n
+<b>C-type:</b> ExtPanId_t (equal to uint64_t) \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> Yes.*/
+#ifndef CS_NWK_EXT_PANID
+#define CS_NWK_EXT_PANID 0LL
+#endif
+/*! \brief Determines whether the static or automatic addressing mode will be used for the short address
+
+If set to \c 1, the ::CS_NWK_ADDR will be used as the device's short address.
+Otherwise, the short address is assigned automatically by the stack. An actual assignment
+method is specified in ::CS_ADDRESS_ASSIGNMENT_METHOD.
+
+<b>Value range:</b> \c 1 or \c 0 \n
+<b>C-type:</b> bool \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> Yes
+*/
+#ifndef CS_NWK_UNIQUE_ADDR
+#define CS_NWK_UNIQUE_ADDR 0
+#endif
+//! \brief Device's short address if ::CS_NWK_UNIQUE_ADDR equals 1
+/*!
+If static addressing is applied the stack uses the value of the parameter as a short address. Otherwise,
+the stack assigns the parameter to a randomly chosen value unique within the network. In both cases
+after the network start the parameter holds actual short address of the device. While the device is in
+the network its value must not be changed.
+
+Note that the coordinator short address always equals \c 0x0000.
+
+<b>Value range:</b> 0x0000 - 0xFFF8 \n
+<b>C-type:</b> ShortAddr_t \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> Yes
+*/
+#ifndef CS_NWK_ADDR
+#define CS_NWK_ADDR 0xFFFF
+#endif
+//! \brief End device sleep period given in milliseconds
+/*!
+On an end device this parameter determines the duration of a sleep period. Falling asleep is
+performed with the ZDO_SleepReq() request. After sleeping period exceeds the node is awakened and
+the application receives an indication via ZDO_WakeUpInd().
+If the parameter's value is 0, then after the node falls asleep it can only be awakened by a
+hardware interrupt; a callback for a given IRQ is registered via HAL_RegisterIrq().
+On a router or the coordinator, the parameter is used in two ways:
+
+1) To remove information about lost child end devices. If a parent receives no data polls or data
+frames from the child end device for
+CS_NWK_END_DEVICE_MAX_FAILURES*(CS_END_DEVICE_SLEEP_PERIOD + CS_INDIRECT_POLL_RATE) ms,
+then it assumes it to be lost and deletes all information about such child.
+
+2) To determine whether to store or drop a message addressed to a child end device. The parent
+estimates the time when its child end device will wake up by adding this value to the moment when the last poll
+request has been received. If the time till end device wake up is greater than CS_MAC_TRANSACTION_TIME
+the frame is stored. Otherwise, the frame is dropped.
+
+<b>Value range:</b> any value valid for the C-type; add "L" after a value \n
+<b>C-type:</b> uint32_t \n
+<b>Can be set:</b> at any time \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_END_DEVICE_SLEEP_PERIOD
+#define CS_END_DEVICE_SLEEP_PERIOD 10000L
+#endif
+
+//! \brief Full Function Device sleep period given in milliseconds
+#ifndef CS_FFD_SLEEP_PERIOD
+#define CS_FFD_SLEEP_PERIOD 10000L
+#endif
+
+//! \brief Encryption time of maximum-size packet in ms. Decryption time is equal to encryption time.
+#ifndef CS_ENCRYPTION_TIME
+#if defined(_SECURITY_)
+ #ifdef _MAC_HW_AES_
+ #define CS_ENCRYPTION_TIME 18 // HW encryption
+ #else
+ #define CS_ENCRYPTION_TIME 119 // SW encryption
+ #endif
+#else
+ #define CS_ENCRYPTION_TIME 0ul
+#endif
+#endif
+
+//! \brief Duration of internal processing of the maximum-size packet (without encryption)
+#define CS_PACKET_PROCESS_INSIDE 7
+
+//! \brief A period in ms of polling a parent for data by an end device
+/*!
+On a sleeping end device the parameter determines a period with which poll requests
+are sent to the parent while the end device is awaken. A parent of a sleeping end device
+uses the parameter to calculate estimates of the time when the next poll request from a child
+will be received.
+
+<b>Value range:</b> any value valid for the C-type \n
+<b>C-type:</b> uint32_t \n
+<b>Can be set:</b> at any time \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_INDIRECT_POLL_RATE
+#define CS_INDIRECT_POLL_RATE 1000
+#endif
+
+//! \brief A value used to calculate the length of time to spend scanning each channel
+/*!
+While scanning channels during network join the node keeps listening to each channel
+specified by the ::CS_CHANNEL_MASK for a period of time calculated according to the
+formula that for the 2.4GHz frequency band is: \n
+
+<i>960 * 16 * (2 raised to a power n + 1) microseconds,</i>
+
+providing n is a value of this parameter. Note that the formula for the Sub-GHz employs
+another constant instead of 16.
+
+<b>Value range:</b> 0x00-0x0e \n
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at any time \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_SCAN_DURATION
+#define CS_SCAN_DURATION 0x05
+#endif
+//! \brief Specifies whether the device accepts children joining via MAC association
+/*!
+If the parameter being switched between \c 0xff and \c 0x00, determines whether the device
+accepts or not a child joining the network via MAC association, that is, if the joining device does not
+possess the PANID value of the network and its PANID parameter is set to 0.
+
+The parameter can be set before the netwrok start only. Once the device entered the netwrok it can
+only switch the parameter with the help of a permit duration ZDP request.
+
+<b>Value range:</b> 0xff means "always on", 0x00 means "always off" \n
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> No
+ */
+#ifndef CS_PERMIT_DURATION
+#define CS_PERMIT_DURATION 0xff
+#endif
+//! \brief Enables or disables the multicast transmission mode at the NWK layer
+/*!
+If the parameter is set to \true multicasting on the NWK level is used, otherwise,
+multicasting on the APS level is applied. The parameter is recommended to be set to
+\c true. For detail refer to ZigBee specification.
+
+<b>Value range:</b> \c true or \c false \n
+<b>C-type:</b> bool \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_NWK_USE_MULTICAST
+#define CS_NWK_USE_MULTICAST true
+#endif
+
+//! \brief Indicates whether a complex descriptor is available on this device
+/*!
+<b>Value range:</b> \c true or \c false \n
+<b>C-type:</b> bool \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> Yes
+*/
+#ifndef CS_COMPLEX_DESCRIPTOR_AVAILABLE
+#define CS_COMPLEX_DESCRIPTOR_AVAILABLE false
+#endif
+
+//! \brief Specifies whether a user descriptor is available on this device
+/*!
+A user descriptor is simply a string that can be assigned to a device and requested
+by other devices in the network to identify the device. A user descriptor can read
+and set on a remote device as well as on the local device with the help of corresponding
+ZDP requests.
+
+<b>Value range:</b> \c true or \c false \n
+<b>C-type:</b> bool \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> Yes
+*/
+#ifndef CS_USER_DESCRIPTOR_AVAILABLE
+#define CS_USER_DESCRIPTOR_AVAILABLE true
+#endif
+
+//! \brief The stack version
+/*!
+This is a read-only parameter specifying the stack version
+used by the device.
+
+<b>C-type:</b> uint32_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_STACK_VERSION
+#define CS_STACK_VERSION CS_STACK_VERSION_VALUE
+#endif
+
+#ifdef _COMMISSIONING_
+//! \brief Persistent memory storing interval (ms)
+#ifndef CS_PDS_STORING_INTERVAL
+#define CS_PDS_STORING_INTERVAL 300000UL /* 5 minutes */
+#endif
+
+//! \brief Enabales or disables the power failure feature.
+#ifdef _POWER_FAILURE_
+#ifndef CS_POWER_FAILURE
+#define CS_POWER_FAILURE false
+#endif
+#endif /* _POWER_FAILURE_ */
+#endif /* _COMMISSIONING_ */
+
+// by default in MAC = 7680L
+//! \brief MAC transaction persistence time measured in ms
+/*!
+The parameter determines the maximum interval (in ms) a frame addressed to a sleeping
+end device can be stored on the parent node. If the end device does not poll for data
+during this time, then the frame is dropped.
+
+<b>Value range:</b> all unsinged 32-bit integers\n
+<b>C-type:</b> uint32_t \n
+<b>Can be set:</b> at any time \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_MAC_TRANSACTION_TIME
+#define CS_MAC_TRANSACTION_TIME ((uint32_t)CS_END_DEVICE_SLEEP_PERIOD + ((uint32_t)CS_INDIRECT_POLL_RATE * 3ul))
+#endif
+
+//! \brief The size of the APS duplicate rejection table
+/*!
+The duplicate rejection table is used by APS to store information about incoming
+unicast messages in order to reject messages that have been already received and processed.
+Following ZigBee specification, the parameter should be not less than 1.
+
+<b>Value range:</b> greater than 1 \n
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_DUPLICATE_REJECTION_TABLE_SIZE
+#define CS_DUPLICATE_REJECTION_TABLE_SIZE 10
+#endif
+
+//! \brief The maximum number of records in the NWK route table.
+/*!
+The parameter sets the maximum number of records that can be kept in the
+NWK route table. The table is used by NWK to store information about established
+routes. Each table entry specifies the next-hop short address for a route from the
+current node to a given destination node. The table is being filled automatically
+during route discovery. An entry is added when a route is discovered.
+
+Since the end device always sends a frame directly to its parent its route table size
+should be set to 0.
+
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#if defined _ROUTER_ || defined _COORDINATOR_
+ #if !defined CS_ROUTE_TABLE_SIZE
+ #define CS_ROUTE_TABLE_SIZE 4
+ #endif
+ #if CS_ROUTE_TABLE_SIZE == 0
+ #undef CS_ROUTE_TABLE_SIZE
+ #define CS_ROUTE_TABLE_SIZE 1
+ #warning CS_ROUTE_TABLE_SIZE was set to 1
+ #endif
+#else // _ENDDEVICE_
+ #undef CS_ROUTE_TABLE_SIZE
+ #define CS_ROUTE_TABLE_SIZE 0
+#endif // _ROUTER_ or _COORDINATOR_
+
+//! \brief The maximum number of records in the NWK address map table
+/*!
+The parameter sets the maximum number of records in the address map table used by
+NWK to store pairs of corresponding short and extended addresses. The stack appeals
+to the table when a data frame is being sent to a specified extended address to extract
+the corresponding short address. If it fails to find the short address, an error is reported.
+
+<b>C-type:</b> NwkSizeOfAddressMap_t (typedef for uint8_t) \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_ADDRESS_MAP_TABLE_SIZE
+#define CS_ADDRESS_MAP_TABLE_SIZE 5
+#endif
+#if CS_ADDRESS_MAP_TABLE_SIZE == 0
+ #undef CS_ADDRESS_MAP_TABLE_SIZE
+ #define CS_ADDRESS_MAP_TABLE_SIZE 1
+ #warning CS_ADDRESS_MAP_TABLE_SIZE was set to 1
+#endif
+
+//! \brief The maximum number of records in the NWK route discovery table
+/*!
+The parameter specifies the size of the route discovery table used by NWK to store
+next-hop addresses of the nodes for routes that are not yet established. Upon exausting
+the capacity of the table, the stack starts rewriting old entries. If the size of the route table
+is big enough after all used routes are established the table may not be used.
+
+Since the end device always sends a frame directly to its parent its route discovery table size
+should be set to 0.
+
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#if defined _ROUTER_ || defined _COORDINATOR_
+ #if !defined CS_ROUTE_DISCOVERY_TABLE_SIZE
+ #define CS_ROUTE_DISCOVERY_TABLE_SIZE 3
+ #endif
+ #if CS_ROUTE_DISCOVERY_TABLE_SIZE == 0
+ #undef CS_ROUTE_DISCOVERY_TABLE_SIZE
+ #define CS_ROUTE_DISCOVERY_TABLE_SIZE 1
+ #warning CS_ROUTE_DISCOVERY_TABLE_SIZE was set to 1
+ #endif
+#else // _ENDDEVICE_
+ #undef CS_ROUTE_DISCOVERY_TABLE_SIZE
+ #define CS_ROUTE_DISCOVERY_TABLE_SIZE 0
+#endif // _ROUTER_ or _COORDINATOR_
+
+#if !defined CS_NWK_BUFFERS_AMOUNT
+ #define CS_NWK_BUFFERS_AMOUNT 4
+#endif // CS_NWK_BUFFERS_AMOUNT
+
+//!\brief The size of the passive acknoledgement table
+#if !defined CS_NWK_PASSIVE_ACK_AMOUNT
+ #define CS_NWK_PASSIVE_ACK_AMOUNT 8
+#endif // CS_NWK_PASSIVE_ACK_AMOUNT
+
+//!\brief The size of of the broadcast transmission table
+/*!
+The broadcast transmission table is used for tracking incoming broadcast messages
+to mark messages that have already been processed by the node. This causes only one
+copy for each broadcast message to be processed. An entry for a broadcast message is
+stored for a certain period of time and then removed.
+
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#if !defined CS_NWK_BTT_SIZE
+ #define CS_NWK_BTT_SIZE 8
+#endif
+
+//!\brief The size of of the group table
+/*!
+The size cannot be 0. The group table stores pairs of a group address and an endpoint. Upon
+receiving a frame addressed to members of a certain group which include the current node as well
+the stack fires indications on all endpoints registered with the group address.
+
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#if defined CS_GROUP_TABLE_SIZE
+ #if CS_GROUP_TABLE_SIZE == 0
+ #undef CS_GROUP_TABLE_SIZE
+ #define CS_GROUP_TABLE_SIZE 1
+ #warning CS_GROUP_TABLE_SIZE was set to 1
+ #endif
+#else
+ #define CS_GROUP_TABLE_SIZE 1
+#endif
+
+//! \brief The number of buffers for data requests on the APS layer
+/*!
+The parameter specifies the number of buffers that are allocated by APS
+to store data requests parameters. The parameter puts an upper bound to the number of
+data requests that can be processed by APS simultaneously. If all buffers are in
+use and a new data request appears, it is kept in a queue until a buffer is released.
+
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_APS_DATA_REQ_BUFFERS_AMOUNT
+ #ifdef _SECURITY_
+ #define CS_APS_DATA_REQ_BUFFERS_AMOUNT 3
+ #else // !_SECURITY_
+ #define CS_APS_DATA_REQ_BUFFERS_AMOUNT 2
+ #endif // _SECURITY_
+#endif
+
+//! \brief The number of buffers for acknowledgement messages sent by APS
+/*!
+This parameter determines the amount of memory that needs to be allocted for a special type
+of buffers used by APS to store payloads for acknowledgement frames. The need to use the buffers
+occurs when the node receives a frame that has to be acknowledged. That is, the APS component on
+the node has to send an acknowledgement frame. For frames initiated by the application, the memory for
+a payload is to be allocated by the application on its own, while the payload memory for an acknowledgement
+frame shall be reserved by APS. The request parameters are still stored in the data request buffers.
+
+Typically, a value of this parameter equals ::CS_APS_DATA_REQ_BUFFERS_AMOUNT - 1.
+
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+// To send APS ACK both types of buffers are used (.._DATA_REQ_.. and .._ACK_FRAME_..)
+#ifndef CS_APS_ACK_FRAME_BUFFERS_AMOUNT
+ #define CS_APS_ACK_FRAME_BUFFERS_AMOUNT 2
+#endif
+
+//! \brief The maximum number of transmissoin retries allowed at the APS layer
+/*!
+The parameter sets the number of attempts that will be made by APS layer to
+transmit a data frame. If all these attempts fail due to underlying layers failures,
+then APS response with an error status.
+
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_APS_MAX_FRAME_RETRIES
+ #define CS_APS_MAX_FRAME_RETRIES 3
+#elif CS_APS_MAX_FRAME_RETRIES > 5
+ #undef CS_APS_MAX_FRAME_RETRIES
+ #define CS_APS_MAX_FRAME_RETRIES 5
+ #warning CS_APS_MAX_FRAME_RETRIES was set to 5
+#endif
+
+#ifndef CS_DTR_WAKEUP
+#define CS_DTR_WAKEUP false
+#endif
+
+/*! \brief If the number of consecutives link status frames given by this parameter is missed
+from a neighbor it is removed from the neigbor table
+
+For all neighbors except for end device children the stack tracks the time of receiving link statuses.
+If link statuses are not received from a given neighbor for this parameter's value times of link status
+period (typically 15 seconds), then the neighbor is deleted from the neighbor table.
+
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at any time \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_NWK_MAX_LINK_STATUS_FAILURES
+#define CS_NWK_MAX_LINK_STATUS_FAILURES 3
+#endif
+
+/*! \brief Is used to calculate the length of time after which a not responding
+end device child is considered lost
+
+A sleeping end device is considered lost and a corresponding notification is raised on the
+parent, if the end device does not polls for data for the time span which duration is calculated by
+the following formula:
+\code
+CS_NWK_END_DEVICE_MAX_FAILURES * (CS_END_DEVICE_SLEEP_PERIOD + CS_INDIRECT_POLL_RATE)
+\endcode
+
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at any time \n
+<b>Persistent:</b> No
+ */
+#ifndef CS_NWK_END_DEVICE_MAX_FAILURES
+#define CS_NWK_END_DEVICE_MAX_FAILURES 3
+#endif
+
+//! \brief The maximum number of records in the binding table
+/*!
+The parameter sets the size of the binding table used by APS to store binding
+links, which are structures containing information about source and destination
+extended addresses and endpoints for unicast bindings and just group addresses
+as destinations for group bindings. If the binding is going to be applied to send
+a data frame, then the corresponding entry shall be first inserted into the table via
+the APS_BindingReq() function.
+
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#ifdef _BINDING_
+#ifndef CS_APS_BINDING_TABLE_SIZE
+ #define CS_APS_BINDING_TABLE_SIZE 1
+#endif
+#endif //_BINDING_
+
+#ifdef _APS_FRAGMENTATION_
+//! \brief The maximum number of blocks the asdu can be split into
+/*!
+This parameter limits the number of pieces to which the data sent with one APS request
+can be split i f the fragmentation feature is applied. Thus it also limits the maximum amount
+of data sent by the application with a single request:\n
+maximum data length = ::CS_APS_MAX_BLOCKS_AMOUNT * ::CS_APS_BLOCK_SIZE if the latter
+parameter is not 0, else \n
+maximum data length = ::CS_APS_MAX_BLOCKS_AMOUNT * ::APS_MAX_ASDU_SIZE.
+
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+ */
+#ifndef CS_APS_MAX_BLOCKS_AMOUNT
+#define CS_APS_MAX_BLOCKS_AMOUNT 0
+#endif
+
+//! \brief The block size that is used for fragments in fragmented transmission
+/*!
+If the value is 0, then the maximum possible size is used for the block size, that is, the value
+of ::CS_APS_MAX_ASDU_SIZE. The parameter and ::CS_APS_MAX_BLOCKS_AMOUNT are
+ also used to determine an amount of memory allocated for a special buffer that keeps parts of
+incoming fragmented message until all of them are received.
+
+<b>C-type:</b> uint16_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_APS_BLOCK_SIZE
+#define CS_APS_BLOCK_SIZE 0
+#endif
+#if ((CS_APS_BLOCK_SIZE > APS_MAX_ASDU_SIZE) || (CS_APS_BLOCK_SIZE == 0))
+ #undef CS_APS_BLOCK_SIZE
+ #define CS_APS_BLOCK_SIZE APS_MAX_ASDU_SIZE
+#endif
+
+//! \brief Maximum transmission window size (in blocks)
+/*!
+The parameter determines how many pieces of a fragmented message are sent before
+waiting for an aknowledgement. After acknowledgement is received another
+portion of frames are sent and so on.
+
+<b>Value range:</b> greater than 0 \n
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_APS_MAX_TRANSMISSION_WINDOW_SIZE
+ #ifdef _ZHP_SECURITY_
+ #define CS_APS_MAX_TRANSMISSION_WINDOW_SIZE 1
+ #else
+ #define CS_APS_MAX_TRANSMISSION_WINDOW_SIZE 3
+ #endif
+#endif
+
+#endif /* _APS_FRAGMENTATION_ */
+
+
+/*****************************************************************************
+ Security related defines
+*****************************************************************************/
+
+#ifdef _SECURITY_
+/*! \brief Turns on/off security features
+
+The parameter shall be configured before the network start. If it is set
+to \c false, authentication is not applied as well as encryption of data frames,
+therefore the device will only be able to enter networks without security.
+
+<b>Value range:</b> \c true of \c false \n
+<b>C-type:</b> bool \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_SECURITY_ON
+#define CS_SECURITY_ON true
+#endif
+
+/*! \brief A timeout for authentication procedures
+
+A timeout is started when connection with a parent is established. If the
+security related procedures that are performed after this will not be completed
+before the timeout exceeds, the device will fail joining the network. A value is
+measured in milliseconds.
+
+<b>C-type:</b> uint32_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_APS_SECURITY_TIMEOUT_PERIOD
+#define CS_APS_SECURITY_TIMEOUT_PERIOD (2 * 1000 * 10)
+#endif
+
+//! \brief Default address of the trust center
+/*!
+The parameter specifies the trust center extended address. The stack makes use of the
+parameter to support various opertaions in networks with security enabled. For correct network operation
+the parameter's value must coincide with the actual trust center address.
+
+In case the trust center extended address is unknown, for example, for testing purposes, the
+parameter can be set to the universal trust center address which equals ::APS_SM_UNIVERSAL_TRUST_CENTER_EXT_ADDRESS.
+
+<b>Value range:</b> All 64-bit values except for 0xFFFFFFFFFFFFFFFFLL,
+specify a value in the \c 0x123456789ABCDEFLL format. \n
+<b>C-type:</b> ExtAddr_t \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> Yes
+*/
+#ifndef CS_APS_TRUST_CENTER_ADDRESS
+#define CS_APS_TRUST_CENTER_ADDRESS 0xAAAAAAAAAAAAAAAALL
+#endif
+//! \brief ZDO security status.
+/*!
+The parameter is used to determine the security type.
+
+<b>Value range:</b> 0,3 - for standard security; 1 - for stdlink security; 1,2,3 - for high security. \n
+0 - network key is preconfigured ; \n
+1 - network join without master key, but with the trust center link key, which must be set via APS_SetLinkKey();\n
+2 - network join employs the trust center master key, which must be set via APS_SetMasterKey(); \n
+3 - <i>for standard security:</i>network key is not preconfigured, but rather received from the
+ trust center in an unencrypted frame;
+ <i>for high security:</i>the trust center master key is not preconfigured, but rather received
+ from the trust center during network join.
+
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> Yes
+ */
+#ifndef CS_ZDO_SECURITY_STATUS
+#define CS_ZDO_SECURITY_STATUS 0
+#endif
+/*! \brief The maximum number of network keys that can be stored on the device
+
+A device in a secured network can keep several network keys up to the value of this
+parameter. Upon frame reception the device extracts key sequence number from the auxiliary
+header of the frame and decrypts the message with the network key corresponding to this
+sequence number. Besides, one key is considered active for each device; this is the key that
+is used for encrypting outgoing frames.
+
+Network keys are distributed by the trust center with the help of the APS_TransportKeyReq()
+command. A switch to a new active network key is also initiated by the trust center, which
+should use the APS_SwitchKeyReq() function.
+
+<b>C-type:</b> NwkKeyAmount_t (typedef for uint8_t) \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_NWK_SECURITY_KEYS_AMOUNT
+#define CS_NWK_SECURITY_KEYS_AMOUNT 1
+#endif
+/*! \brief Default value of the network key
+
+This is a parameter to store a value of the network key which is used to encrypt a part of a
+data frame occupied by the NWK payload. This type of encryption is applied in both the standard and
+high security mode. The high security mode also enables encryption of the APS payload with a link
+key, but if the \c txOptions.useNwkKey field in APS request parameters is set to 0, the
+APS payload is ecrypted with the network key.
+
+The network key must be predefined if standard security is used with ::CS_ZDO_SECURITY_STATUS
+set to 0. For all other values of ::CS_ZDO_SECURITY_STATUS the network key is received from the
+trust center during device authentication. Note that in the standard security mode with
+::CS_ZDO_SECURITY_STATUS equal to 3 the network key is trasferred to the joining device
+in an unencrypted frame.
+
+<b>Value range:</b> all 128-bit values \n
+<b>C-type:</b> uint8_t[16] or any compatible \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_NETWORK_KEY
+#define CS_NETWORK_KEY {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
+#endif
+// \cond internal
+// Default security level.When calculating APS_MAX_ASDU_SIZE assumed that this parameter is 5.
+#ifndef CS_SECURITY_LEVEL
+#define CS_SECURITY_LEVEL 0x05U
+#endif
+#if CS_SECURITY_LEVEL != 0x05U
+#error Parameter CS_SECURITY_LEVEL must be 5.
+#endif
+
+// Default nwkSecureAllFrames attribute value in NIB.
+#ifndef CS_SECURITY_ALL_FRAMES
+#define CS_SECURITY_ALL_FRAMES true
+#endif
+// \endcond
+/*! \brief The maximum number of authentication requests that the trust center can process simultaneously
+
+The parameter is used on the trust center to allocate memory for buffers used
+during joining device authentication. A value of the parameter determines how many
+authentication request the stack on the trust center can process at once.
+
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_MAX_TC_AUTHENTIC_PROCESS_AMOUNT
+ #define CS_MAX_TC_AUTHENTIC_PROCESS_AMOUNT 1
+#endif
+
+#ifdef _TC_PERMISSION_TABLE_
+//! \brief For a trust center, the maximum amount of records in the permission table
+ #ifndef CS_MAX_TC_ALLOWED_DEVICES_AMOUNT
+ #define CS_MAX_TC_ALLOWED_DEVICES_AMOUNT 5
+ #endif
+#endif
+
+#ifdef _LINK_SECURITY_
+//! \brief The maximum number of entries in APS key-pair set
+/*!
+The parameter is used in stadard security with link keys and in high security
+to specify the size of the APS key-pair set. The APS key-pair set stores pairs of corresponding
+extended address and a link key or a mster key.
+For each node with which the current node is going to communicate it must keep an entry with
+the remote node extended address and a link key. If the link key is unknown, the node can request
+the trust center for it via APS_RequestKeyReq(). The trust center must store a link key or a master
+key depending on the CS_SECURITY_STATUS used for each node it is going to authenticate.
+Entries can also be added manually by APS_SetLinkKey() and APS_SetMasterKey().
+
+<b>Value range:</b> 1 - 255 \n
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_APS_KEY_PAIR_DESCRIPTORS_AMOUNT
+#define CS_APS_KEY_PAIR_DESCRIPTORS_AMOUNT 3
+#endif
+
+//\cond internal
+//Not used in the stack
+#ifndef CS_MASTER_KEY
+#define CS_MASTER_KEY {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
+#endif
+
+#ifndef CS_MAX_TC_ESTABLISH_KEY_AMOUNT
+#define CS_MAX_TC_ESTABLISH_KEY_AMOUNT 1
+#endif
+//\endcond
+#endif
+
+
+#endif
+
+/*! \brief The number of network join attempts ZDO performs before it reports failure
+
+Determines the maximum number of attempts to enter a network performed by the stack
+during network start. Upon each attempt ZDO sends a beacon request and collects
+beacon responses from nearby devices all over again. A pause length between two attempts
+is given by the ::CS_ZDO_JOIN_INTERVAL parameter.
+
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_ZDO_JOIN_ATTEMPTS
+#define CS_ZDO_JOIN_ATTEMPTS 4
+#endif
+
+/*! \brief The interval between two network join attempts
+
+The parameter specifies the time span in milliseconds between two attempts
+to join the network. See ::CS_ZDO_JOIN_ATTEMPTS description.
+
+<b>C-type:</b> uint32_t \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_ZDO_JOIN_INTERVAL
+#define CS_ZDO_JOIN_INTERVAL 1000
+#endif
+
+/*! \brief ZDP response waiting timeout in millisecods. To use automatically calculated value set to 0
+
+The parameter determines the length of time for which the reply in response to a ZDP request
+is waited. if the response is not received before the timeout exceeds the confirmation callback for
+the ZDP request is called to report a failure status.
+
+<b>C-type:</b> uint16_t \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_ZDP_RESPONSE_TIMEOUT
+#define CS_ZDP_RESPONSE_TIMEOUT 0
+#endif
+
+//! \brief TC Keep-Alive polling interval, should be in the range 5-20 minutes.
+#ifndef CS_ZDO_TC_KEEP_ALIVE_INTERVAL
+#define CS_ZDO_TC_KEEP_ALIVE_INTERVAL 20
+#endif
+
+
+//! \brief Indication to use a predefined network PANID value
+/*!
+If a predefined value is required to be used for the network PANID, the parameter
+shall be set to \c true. Otherwise, it shall be set to \c false.
+
+<b>Value range:</b> \c true or \c false \n
+<b>C-type:</b> bool \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> Yes
+*/
+#ifndef CS_NWK_PREDEFINED_PANID
+#define CS_NWK_PREDEFINED_PANID false
+#endif
+
+//! \brief A predefined short PANID value
+/*!
+The parameter holds the short PANID value generated randomly if ::CS_NWK_PREDEFINED_PANID
+equals \c false. Otherwise, the predefined parameter's value is
+used as the short PANID.
+
+<b>Value range:</b> 16-bit values from the range 0x0000 - 0xFFFE \n
+<b>C-type:</b> PanId_t (typedef for uint16_t) \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> Yes
+*/
+#ifndef CS_NWK_PANID
+#define CS_NWK_PANID 0x1234
+#endif
+// \cond internal
+/*! 16-bit manufacturer code allocated by the ZigBee Alliance.
+ * See ZigBee Manufacturer Code Database, 053874r16, Atmel code. */
+#ifndef CS_MANUFACTURER_CODE
+#define CS_MANUFACTURER_CODE 0x1014
+#endif
+
+#if defined _ROUTER_ || defined _COORDINATOR_
+ #if !defined CS_JOIN_IND_OBJ_AMOUNT
+ #define CS_JOIN_IND_OBJ_AMOUNT (CS_NWK_BUFFERS_AMOUNT >> 1)
+ #endif
+#else // _ENDDEVICE_
+ #undef CS_JOIN_IND_OBJ_AMOUNT
+ #define CS_JOIN_IND_OBJ_AMOUNT 0
+#endif // _ROUTER_ or _COORDINATOR_
+
+/* Maximum number of records in the route cache */
+#if defined _NWK_ROUTE_CACHE_ && (defined _ROUTER_ || defined _COORDINATOR_)
+ #if !defined CS_ROUTE_CACHE_SIZE
+ #define CS_ROUTE_CACHE_SIZE 4
+ #endif /* CS_ROUTE_CACHE_SIZE */
+ #if CS_ROUTE_CACHE_SIZE == 0
+ #undef CS_ROUTE_CACHE_SIZE
+ #define CS_ROUTE_CACHE_SIZE 1
+ #warning CS_ROUTE_CACHE_SIZE was set to 1
+ #endif
+#else /* no route cache */
+ #undef CS_ROUTE_CACHE_SIZE
+ #define CS_ROUTE_CACHE_SIZE 0
+#endif
+
+/** The time in milliseconds between concentrator route discoveries.
+ * ZigBee spec r18, Table 3.44, page 348. */
+#if !defined NWK_CONCENTRATOR_DISCOVERY_TIME
+ #define NWK_CONCENTRATOR_DISCOVERY_TIME 20000UL /* milliseconds */
+#endif
+
+// \endcond
+#endif //_MAC2_
+
+#ifdef _ZCL_
+#ifndef CS_ZCL_ATTRIBUTE_REPORT_TIMER_INTERVAL
+ #define CS_ZCL_ATTRIBUTE_REPORT_TIMER_INTERVAL 4000
+#endif
+
+#ifndef CS_ZCL_MEMORY_BUFFERS_AMOUNT
+ #define CS_ZCL_MEMORY_BUFFERS_AMOUNT 5
+#endif
+
+#ifdef _OTAU_
+/** \brief The default address of an upgrade server
+
+The parameter indicates how the OTAU client will search for OTAU servers in the network.
+If one of broadcast addresses is specified, the client will attempt to find all devices supporting
+the OTAU server cluster and will request new images from the first server that will respond.
+Otherwise, the client will try to connect to a particular device with the specified extended
+address.
+
+The parameter is valid for OTAU clients only.
+
+<b>Value range:</b> any 64-bit value: \n
+\li \c 0x0000000000000000ull, \c 0xFFFFFFFFFFFFFFFFull - a server discovery request is broadcasted
+\li otherwise, the client tries to connect to a particular node
+
+<b>C-type:</b> ExtAddr_t \n
+<b>Can be set:</b> at any time before an OTAU start \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_ZCL_OTAU_DEFAULT_UPGRADE_SERVER_IEEE_ADDRESS
+ #define CS_ZCL_OTAU_DEFAULT_UPGRADE_SERVER_IEEE_ADDRESS 0xFFFFFFFFFFFFFFFFull
+#endif
+/** \brief The interval in milliseconds between two attempts to find an upgrade server
+
+The parameter is valid for OTAU clients only.
+
+<b>Value range:</b> any 32-bit value \n
+<b>C-type:</b> uint32_t \n
+<b>Can be set:</b> at any time before an OTAU start \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_ZCL_OTAU_SERVER_DISCOVERY_PERIOD
+ #define CS_ZCL_OTAU_SERVER_DISCOVERY_PERIOD 60000ul
+#endif
+/** Default values of OTAU session. */
+/** \brief The amount of servers the OTAU client can listen to during upgrade server discovery
+
+The OTAU client can store information about several discovered OTAU servers. However, the client
+device tries to connect to discovered servers one by one until the first successful attempt and then
+communicates and uploads the whole image from the fisrt suitable server.
+
+The parameter is valid for OTAU clients only.
+
+<b>Value range:</b> at least 1 \n
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_ZCL_OTAU_DISCOVERED_SERVER_AMOUNT
+ #define CS_ZCL_OTAU_DISCOVERED_SERVER_AMOUNT 1
+#endif
+/** \brief The number of clients that the OTAU server can serve simultaneously
+
+If this parameter equals 1, the OTAU server will upgrade devices in the network
+one by one. However, the server can process more than one client sessions at a time,
+if this parameter is greater than 1.
+
+The parameter is valid for OTAU servers only.
+
+<b>Value range:</b> at least 1 \n
+<b>C-type:</b> uint8_t \n
+<b>Can be set:</b> at compile time only \n
+<b>Persistent:</b> No
+*/
+#ifndef CS_ZCL_OTAU_CLIENT_SESSION_AMOUNT
+ #define CS_ZCL_OTAU_CLIENT_SESSION_AMOUNT 1
+#endif
+/** \brief Usage of page request for OTAU
+*/
+#ifndef CS_ZCL_OTAU_IMAGE_PAGE_REQUEST_USAGE
+ #define CS_ZCL_OTAU_IMAGE_PAGE_REQUEST_USAGE 1
+#endif
+/** \brief Timeout between Image Block Response packet sent form server to client
+
+The value indicates how fast the server shall send the data (via Image Block Response command) to the client.
+The value is determined by the client.
+The server shall wait at the minimum the (response) spacing value before sending more data to the client.
+The value is in milliseconds.
+*/
+#ifndef CS_ZCL_OTAU_IMAGE_PAGE_REQUEST_RESPONSE_SPACING
+ #define CS_ZCL_OTAU_IMAGE_PAGE_REQUEST_RESPONSE_SPACING 200
+#endif
+/** \brief Page size
+
+The value indicates the number of bytes to be sent by the server before the client sends another Image Page Request command.
+In general, page size value shall be larger than the maximum data size value.
+*/
+#if CS_ZCL_OTAU_IMAGE_PAGE_REQUEST_USAGE == 1
+ #ifndef CS_ZCL_OTAU_IMAGE_PAGE_REQUEST_PAGE_SIZE
+ #define CS_ZCL_OTAU_IMAGE_PAGE_REQUEST_PAGE_SIZE 256
+ #endif
+#else
+ #undef CS_ZCL_OTAU_IMAGE_PAGE_REQUEST_PAGE_SIZE
+ #define CS_ZCL_OTAU_IMAGE_PAGE_REQUEST_PAGE_SIZE 1
+#endif //CS_ZCL_OTAU_IMAGE_PAGE_REQUEST_USAGE == 1
+/** \brief OTAU buffer for missed block responses during page request
+*/
+#if CS_ZCL_OTAU_IMAGE_PAGE_REQUEST_USAGE == 1
+ #ifndef CS_ZCL_OTAU_MISSED_BLOCKS_BUFFER_SIZE
+ #define CS_ZCL_OTAU_MISSED_BLOCKS_BUFFER_SIZE 8
+ #endif
+#else
+ #undef CS_ZCL_OTAU_MISSED_BLOCKS_BUFFER_SIZE
+ #define CS_ZCL_OTAU_MISSED_BLOCKS_BUFFER_SIZE 1
+#endif //CS_ZCL_OTAU_IMAGE_PAGE_REQUEST_USAGE == 1
+
+#endif //_OTAU_
+#endif //_ZCL_
+
+#ifndef CS_BAN_TABLE_SIZE
+ #define CS_BAN_TABLE_SIZE 1
+#endif /* _MAC_BAN_NODE_ */
+
+/** \brief The maximum route cost between two nodes for direct delivery
+
+A data frame is routed directly to the neighbor only if the route cost, read
+from the neighbor table, is less than the value of the parameter. If the route
+cost is greater than the value of the parameter, route discovery will be
+initiated to find an indirect route to the neighbor.
+
+<b>Value range:</b> 0 - 8 \n
+0 - ignore information in the neighbor table (always start route discovery) \n
+8 - always send data directly to a neighbor
+
+<b>C-type:</b> NwkLinkCost_t (typedef for uint8_t) \n
+<b>Can be set:</b> at any time before network start \n
+<b>Persistent:</b> No
+ */
+#ifndef CS_MAX_NEIGHBOR_ROUTE_COST
+ #define CS_MAX_NEIGHBOR_ROUTE_COST 8U
+#endif
+
+/******************************************************************************
+ Functions prototypes section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Set Configuration Server memory to its default state
+******************************************************************************/
+void csSetToDefault(void);
+
+#endif // _CSDEFAULTS_H
+/* eof cdDefaults.h*/
diff --git a/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/csPersistentMem.h b/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/csPersistentMem.h
new file mode 100644
index 00000000..f065a345
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/csPersistentMem.h
@@ -0,0 +1,42 @@
+/******************************************************************************
+ \file csPersistentMem.h
+
+ \brief
+ Configuration Server persistent memory to store in EEPROM
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2010 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 28.10.10 A. Razinkov - Created.
+******************************************************************************/
+
+#ifndef _CSPERSISTENTMEM_H_
+#define _CSPERSISTENTMEM_H_
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <configServer.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+// Offsets in EEPROM
+#define SYSTEM_BASE_EEPROM_ADDRESS 0x0004
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef struct _CS_PersistantData_t
+{
+ void* value;
+ int16_t offset;
+} CS_PersistantData_t;
+
+#endif /* _CSPERSISTENTMEM_H_ */
diff --git a/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/private/csBuffers.h b/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/private/csBuffers.h
new file mode 100644
index 00000000..bb00718e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/private/csBuffers.h
@@ -0,0 +1,151 @@
+/******************************************************************************
+ \file csBuffers.h
+
+ \brief
+ BitCloud memory buffers
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2010 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 21.10.10 A. Razinkov - Created.
+******************************************************************************/
+
+#ifndef _CSBUFFERS_H_
+#define _CSBUFFERS_H_
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#ifndef _MAC2_
+#include <apsConfigServer.h>
+#include <nwkConfigServer.h>
+#else
+#include <configServer.h>
+#endif
+
+#ifdef _SECURITY_
+#include <tcAuthentic.h>
+#endif /* _SECURITY */
+#ifdef _LINK_SECURITY_
+#include <tcKeyEstablish.h>
+#endif /* _LINK_SECURITY_ */
+
+#ifdef _ZCL_
+#include <zclMemoryManager.h>
+ #ifdef _OTAU_
+#include <zclOTAUCluster.h>
+#include <zclOtauDiscovery.h>
+#include <zclOtauManager.h>
+ #endif /* _OTAU_ */
+#endif /* _ZCL_ */
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+/**//**
+ * \brief Stack buffers list
+ */
+typedef struct _CS_StackBuffers_t
+{
+ /* MAC buffers */
+ uint8_t csMacFrameRxBuffer[CS_MAC_FRAME_RX_BUFFER_SIZE];
+#ifndef _MAC2_
+ MAC_PanDescriptor_t csMacPanDescriptorBuffer[CS_NEIB_TABLE_SIZE];
+#ifdef _MAC_BAN_NODE_
+ MAC_BanTableEntry_t csBanTable[CS_BAN_TABLE_SIZE];
+#endif /* _MAC_BAN_NODE_ */
+
+ /* NWK buffers */
+ Neib_t csNeibTable[CS_NEIB_TABLE_SIZE];
+ MutableNeib_t csMutableNeibTable[CS_NEIB_TABLE_SIZE];
+#if CS_ROUTE_CACHE_SIZE > 0
+ NwkRouteCacheRecord_t csRouteCache[CS_ROUTE_CACHE_SIZE];
+#endif
+#if CS_NWK_BUFFERS_AMOUNT > 0
+ NwkPacket_t csNwkBuffer[CS_NWK_BUFFERS_AMOUNT];
+#endif
+#if CS_ROUTE_TABLE_SIZE > 0
+ NwkRoutingTableEntry_t csRoutingTable[CS_ROUTE_TABLE_SIZE];
+#endif
+#if CS_ROUTE_DISCOVERY_TABLE_SIZE > 0
+ NwkRouteDiscoveryEntry_t csRouteDiscoveryTable[CS_ROUTE_DISCOVERY_TABLE_SIZE];
+#endif
+#if CS_ADDRESS_MAP_TABLE_SIZE > 0
+ NwkAddressMapEntry_t csAddressMapTable[CS_ADDRESS_MAP_TABLE_SIZE];
+#endif
+#if CS_NWK_BTT_SIZE > 0
+ SYS_DuplicateTableEntry_t csBTR[CS_NWK_BTT_SIZE];
+#endif
+#ifdef _GROUP_TABLE_
+ NWK_GroupTableEntry_t csGroupTable[CS_GROUP_TABLE_SIZE];
+#endif
+#ifdef _SECURITY_
+ NWK_SecurityKey_t csNwkSecKeys[CS_NWK_SECURITY_KEYS_AMOUNT];
+ NWK_SecurityFrameCounters_t csNwkSecCounters[CS_NWK_SECURITY_KEYS_AMOUNT];
+#endif /* _SECURITY_ */
+
+ /* APS buffers */
+#if CS_APS_DATA_REQ_BUFFERS_AMOUNT > 0
+ ApsDataBuffer_t csApsDataReqBuffer[CS_APS_DATA_REQ_BUFFERS_AMOUNT];
+#endif
+#if CS_APS_ACK_FRAME_BUFFERS_AMOUNT > 0
+ ApsAckBuffer_t csApsAckFrameBuffer[CS_APS_ACK_FRAME_BUFFERS_AMOUNT];
+#endif
+#if CS_JOIN_IND_OBJ_AMOUNT > 0
+ NwkJoinIndObj_t csJoinIndObjects[CS_JOIN_IND_OBJ_AMOUNT];
+#endif
+#if CS_DUPLICATE_REJECTION_TABLE_SIZE > 0
+ SYS_DuplicateTableEntry_t csDuplicateRejectionTable[CS_DUPLICATE_REJECTION_TABLE_SIZE];
+#endif
+#if defined(_BINDING_) && (CS_APS_BINDING_TABLE_SIZE > 0)
+ ApsBindingEntry_t csApsBindingTable[CS_APS_BINDING_TABLE_SIZE];
+#endif /* _BINDING_ */
+#if defined(_APS_FRAGMENTATION_) && (CS_APS_MAX_BLOCKS_AMOUNT > 0)
+ uint8_t csFragmentationMemoryPool[CS_APS_MAX_BLOCKS_AMOUNT * CS_APS_BLOCK_SIZE + CS_APS_MAX_BLOCKS_AMOUNT];
+ uint8_t csFragmentationPacketBuffer[APS_AFFIX_LENGTH + CS_APS_BLOCK_SIZE];
+#endif /* _APS_FRAGMENTATION_ */
+
+ /* Trust Center buffers */
+#ifdef _SECURITY_
+ #if CS_MAX_TC_AUTHENTIC_PROCESS_AMOUNT > 0
+ TC_AuthenticObj_t csTcAuthenticProcessBuffer[CS_MAX_TC_AUTHENTIC_PROCESS_AMOUNT];
+ #endif
+ #if defined(_TC_PERMISSION_TABLE_) && (CS_MAX_TC_ALLOWED_DEVICES_AMOUNT > 0)
+ ExtAddr_t csTcDevicePermissionTable[CS_MAX_TC_ALLOWED_DEVICES_AMOUNT];
+ #endif
+ #ifdef _LINK_SECURITY_
+ ApsKeyPairDescriptor_t csApsKeyPairDescriptors[CS_APS_KEY_PAIR_DESCRIPTORS_AMOUNT];
+ ApsKeyCounters_t csApsKeyCounters[CS_APS_KEY_PAIR_DESCRIPTORS_AMOUNT];
+ #if CS_MAX_TC_ESTABLISH_KEY_AMOUNT > 0
+ TC_KeyEstablishObj_t csTcEstablishKeyBuffer[CS_MAX_TC_ESTABLISH_KEY_AMOUNT];
+ #endif
+ #endif /* _LINK_SECURITY_ */
+
+#endif /* _SECURITY_ */
+
+ /* ZCL buffers */
+#ifdef _ZCL_
+ ZclMmBufferDescriptor_t zclMmBuffers[CS_ZCL_MEMORY_BUFFERS_AMOUNT];
+ #ifdef _OTAU_
+ ZclOtauDiscoveryResult_t csOtauDiscoveryResult[CS_ZCL_OTAU_DISCOVERED_SERVER_AMOUNT];
+ ZclOtauServerTransac_t csOtauSimultaneousClientSession[CS_ZCL_OTAU_CLIENT_SESSION_AMOUNT];
+ ZclOtauMissedBlockResponses_t csOtauMissedBlocksBuffer[CS_ZCL_OTAU_MISSED_BLOCKS_BUFFER_SIZE];
+ uint8_t csOtauImagePageDataBuffer[CS_ZCL_OTAU_IMAGE_PAGE_REQUEST_PAGE_SIZE];
+ #endif /* _OTAU_ */
+#endif /* _ZCL_ */
+
+#if (defined _NWK_PASSIVE_ACK_) && (CS_NWK_PASSIVE_ACK_AMOUNT > 0)
+ NwkPassiveAckEntry_t csNwkPassiveAckTable[CS_NWK_PASSIVE_ACK_AMOUNT];
+#endif
+#endif /* _MAC2_ */
+} CS_StackBuffers_t;
+
+#endif /* _CSBUFFERS_H_ */
+/* eof csBuffers.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/private/csDbg.h b/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/private/csDbg.h
new file mode 100644
index 00000000..3908e385
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/private/csDbg.h
@@ -0,0 +1,32 @@
+/******************************************************************************
+ \file csDbg.h
+
+ \brief
+ Configuration Server debug info
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2010 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 22.10.10 A. Razinkov - Created.
+******************************************************************************/
+
+#ifndef _CSDBG_H_
+#define _CSDBG_H_
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <dbg.h>
+
+typedef enum
+{
+ CS_CSGETITEM0 = 0x6000
+} CS_DbgCodeId_t;
+
+#endif /* _CSDBG_H_ */
diff --git a/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/private/csParamTable.h b/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/private/csParamTable.h
new file mode 100644
index 00000000..8d65d589
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/private/csParamTable.h
@@ -0,0 +1,304 @@
+/******************************************************************************
+ \file csParamTable.h
+
+ \brief
+ Configuration Server parameters information table
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2010 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 22.12.10 A. Razinkov - Created.
+******************************************************************************/
+
+/* This table contains information about particular paramter displacement address,
+ * memory type it occupies (FLASH or RAM), and its representation in memory
+ * (as memory region or atomic entity).
+ *
+ * This table should be inlined to external module.
+ * RAM_PARAMETER(id, addr), FLASH_PARAMETER(id, addr), MEMORY_REGION(idm addr),
+ * SEPARATOR(id) and DUMMY_MEMORY(id) macroses should be defined first to provide
+ * specific table morphing.
+ *
+ * SEPARATOR(id) macro is used to separate atomic parameters stored in RAM from
+ * the ones stored in FLASH. It's the only restriction on parameters order in this table.
+ * Memory regions could be described everywhere.
+ *
+ * DUMMY_MEMORY(id) macro is used to specify few stack buffers sizes during the application
+ * compilation phase.
+ */
+
+RAM_PARAMETER(CS_UID_ID, csPIB.macAttr.extAddr)
+RAM_PARAMETER(CS_MAX_FRAME_TRANSMISSION_TIME_ID, csPIB.macAttr.maxFrameTransmissionTime)
+RAM_PARAMETER(CS_MAC_TRANSACTION_TIME_ID, csSIB.csMacTransactionTime)
+RAM_PARAMETER(CS_RF_TX_POWER_ID, csSIB.csRfTxPower)
+#ifndef _MAC2_
+RAM_PARAMETER(CS_MAX_NEIGHBOR_ROUTE_COST_ID, csNIB.maxNeighborRouteCost)
+RAM_PARAMETER(CS_NWK_EXT_PANID_ID, csNIB.extendedPanId)
+RAM_PARAMETER(CS_NWK_ADDR_ID, csNIB.networkAddress)
+RAM_PARAMETER(CS_NWK_PARENT_ADDR_ID, csNIB.parentNetworkAddress)
+RAM_PARAMETER(CS_NWK_DEPTH_ID, csNIB.depth)
+RAM_PARAMETER(CS_NWK_UNIQUE_ADDR_ID, csNIB.uniqueAddr)
+RAM_PARAMETER(CS_CHANNEL_PAGE_ID, csNIB.channelPage)
+RAM_PARAMETER(CS_NWK_USE_MULTICAST_ID, csSIB.csNwkUseMulticast)
+RAM_PARAMETER(CS_NWK_MAX_LINK_STATUS_FAILURES_ID, csSIB.csNwkMaxLinkStatusFailures)
+RAM_PARAMETER(CS_NWK_END_DEVICE_MAX_FAILURES_ID, csSIB.csNwkEndDeviceMaxFailures)
+RAM_PARAMETER(CS_NWK_LOGICAL_CHANNEL_ID, csSIB.csNwkLogicalChannel)
+RAM_PARAMETER(CS_NWK_PANID_ID, csSIB.csNwkPanid)
+RAM_PARAMETER(CS_NWK_PREDEFINED_PANID_ID, csSIB.csNwkPredefinedPanid)
+RAM_PARAMETER(CS_PROTOCOL_VERSION_ID, csNIB.protocolVersion)
+RAM_PARAMETER(CS_STACK_PROFILE_ID, csNIB.stackProfile)
+RAM_PARAMETER(CS_SCAN_DURATION_ID, csZIB.scanDuration)
+RAM_PARAMETER(CS_PERMIT_DURATION_ID, csZIB.permitJoinDuration)
+RAM_PARAMETER(CS_EXT_PANID_ID, csSIB.csExtPANID)
+RAM_PARAMETER(CS_CHANNEL_MASK_ID, csZIB.channelMask)
+RAM_PARAMETER(CS_INDIRECT_POLL_RATE_ID, csSIB.csIndirectPollRate)
+RAM_PARAMETER(CS_END_DEVICE_SLEEP_PERIOD_ID, csSIB.csEndDeviceSleepPeriod)
+RAM_PARAMETER(CS_FFD_SLEEP_PERIOD_ID, csSIB.csFfdSleepPeriod)
+RAM_PARAMETER(CS_RX_ON_WHEN_IDLE_ID, csSIB.csRxOnWhenIdle)
+RAM_PARAMETER(CS_COMPLEX_DESCRIPTOR_AVAILABLE_ID, csSIB.csComplexDescriptorAvailable)
+RAM_PARAMETER(CS_USER_DESCRIPTOR_AVAILABLE_ID, csSIB.csUserDescriptorAvailable)
+RAM_PARAMETER(CS_ZDP_USER_DESCRIPTOR_ID, csSIB.csUserDescriptor)
+RAM_PARAMETER(CS_DEVICE_TYPE_ID, csNIB.deviceType)
+RAM_PARAMETER(CS_ZDO_JOIN_ATTEMPTS_ID, csSIB.csZdoJoinAttempts)
+RAM_PARAMETER(CS_ZDO_JOIN_INTERVAL_ID, csSIB.csZdoJoinInterval)
+RAM_PARAMETER(CS_APS_MAX_FRAME_RETRIES_ID, csSIB.csApsMaxFrameRetries)
+RAM_PARAMETER(CS_ZDP_RESPONSE_TIMEOUT_ID, csZIB.zdpResponseTimeout)
+RAM_PARAMETER(CS_DTR_WAKEUP_ID, csSIB.csDtrWakeup)
+#endif
+
+#ifdef AT86RF212
+RAM_PARAMETER(CS_LBT_MODE_ID, csSIB.csLbtMode)
+#endif
+#ifdef _NWK_CONCENTRATOR_
+RAM_PARAMETER(CS_CONCENTRATOR_DISCOVERY_TIME_ID, csSIB.csNwkConcentratorDiscoveryTime)
+#endif
+#ifdef _TC_SWAPOUT_
+RAM_PARAMETER(CS_ZDO_TC_KEEP_ALIVE_INTERVAL_ID, csSIB.csZdoTcKeepAliveInterval)
+#endif
+#ifdef _APS_FRAGMENTATION_
+RAM_PARAMETER(CS_APS_MAX_TRANSMISSION_WINDOW_SIZE_ID, csSIB.csApsMaxTransmissionWindowSize)
+#endif
+#ifdef _COMMISSIONING_
+RAM_PARAMETER(CS_PDS_STORING_INTERVAL_ID, csSIB.csPdsStoringInterval)
+ #ifdef _POWER_FAILURE_
+RAM_PARAMETER(CS_POWER_FAILURE_ID, csSIB.csPowerFailure)
+ #endif /* _POWER_FAILURE_ */
+#endif /* _COMMISSIONING_ */
+
+#ifdef _ZCL_
+RAM_PARAMETER(CS_ZCL_ATTRIBUTE_REPORT_TIMER_INTERVAL_ID, csSIB.csZclAttributeReportTimerInterval)
+ #ifdef _OTAU_
+RAM_PARAMETER(CS_ZCL_OTAU_DEFAULT_UPGRADE_SERVER_IEEE_ADDRESS_ID, csSIB.csOtauDefaultServerAddress)
+RAM_PARAMETER(CS_ZCL_OTAU_DEFAULT_SERVER_DISCOVERY_PERIOD_ID, csSIB.csOtauServerDiscoveryPeriod)
+RAM_PARAMETER(CS_ZCL_OTAU_IMAGE_PAGE_REQUEST_USAGE_ID, csSIB.csOtauServerPageRequestUsage)
+ #endif /* _OTAU_ */
+#endif /* _ZCL_ */
+#ifdef _SECURITY_
+RAM_PARAMETER(CS_NETWORK_KEY_ID, defaultKey)
+RAM_PARAMETER(CS_SECURITY_ON_ID, csSIB.csSecurityOn)
+RAM_PARAMETER(CS_SECURITY_LEVEL_ID, csNIB.securityIB.securityLevel)
+RAM_PARAMETER(CS_SECURITY_ALL_FRAMES_ID, csNIB.securityIB.secureAllFrames)
+RAM_PARAMETER(CS_ZDO_SECURITY_STATUS_ID, csSIB.csZdoSecurityStatus)
+RAM_PARAMETER(CS_APS_TRUST_CENTER_ADDRESS_ID, csAIB.trustCenterAddress)
+#endif /* _SECURITY_ */
+
+SEPARATOR(CS_FLASH_PARAMETERS_START_ID)
+FLASH_PARAMETER(CS_MAC_FRAME_RX_BUFFER_SIZE_ID, csReadOnlyItems.csMacFrameRxBufferSize)
+#ifndef _MAC2_
+FLASH_PARAMETER(CS_NEIB_TABLE_SIZE_ID, csReadOnlyItems.csNeibTableSize)
+FLASH_PARAMETER(CS_ROUTE_CACHE_SIZE_ID, csReadOnlyItems.csNwkRouteCacheSize)
+#endif
+FLASH_PARAMETER(CS_MAC_PAN_DESCRIPTOR_AMOUNT_ID, csReadOnlyItems.csMacPanDescriptorAmount)
+FLASH_PARAMETER(CS_MAX_CHILDREN_AMOUNT_ID, csReadOnlyItems.csMaxChildrenAmount)
+FLASH_PARAMETER(CS_MAX_CHILDREN_ROUTER_AMOUNT_ID, csReadOnlyItems.csMaxChildrenRouterAmount)
+FLASH_PARAMETER(CS_MAX_NETWORK_DEPTH_ID, csReadOnlyItems.csMaxNetworkDepth)
+FLASH_PARAMETER(CS_ADDRESS_ASSIGNMENT_METHOD_ID, csReadOnlyItems.csAddressAssignmentMethod)
+FLASH_PARAMETER(CS_NWK_BUFFERS_AMOUNT_ID, csReadOnlyItems.csNwkBuffersAmount)
+FLASH_PARAMETER(CS_JOIN_IND_OBJ_AMOUNT_ID, csReadOnlyItems.csJoinIndObjAmount)
+FLASH_PARAMETER(CS_ROUTE_TABLE_SIZE_ID, csReadOnlyItems.csRouteTableSize)
+#ifndef _MAC2_
+FLASH_PARAMETER(CS_ADDRESS_MAP_TABLE_SIZE_ID, csReadOnlyItems.csAddressMapTableSize)
+#endif
+FLASH_PARAMETER(CS_ROUTE_DISCOVERY_TABLE_SIZE_ID, csReadOnlyItems.csRouteDiscoveryTableSize)
+FLASH_PARAMETER(CS_BTT_SIZE_ID, csReadOnlyItems.csNwkBttSize)
+FLASH_PARAMETER(CS_MANUFACTURER_CODE_ID, csReadOnlyItems.csManufacturerCode)
+FLASH_PARAMETER(CS_APS_DATA_REQ_BUFFERS_AMOUNT_ID, csReadOnlyItems.csApsDataReqBuffersAmount)
+FLASH_PARAMETER(CS_APS_ACK_FRAME_BUFFERS_AMOUNT_ID, csReadOnlyItems.csApsAckFrameBuffesAmount)
+FLASH_PARAMETER(CS_DUPLICATE_REJECTION_TABLE_SIZE_ID, csReadOnlyItems.csDuplicateRejectionTableSize)
+FLASH_PARAMETER(CS_STACK_VERSION_ID, csReadOnlyItems.csStackVersion)
+
+#ifdef _MAC_BAN_NODE_
+FLASH_PARAMETER(CS_BAN_TABLE_SIZE_ID, csReadOnlyItems.csMacBanTableSize)
+#endif
+#ifdef _GROUP_TABLE_
+FLASH_PARAMETER(CS_GROUP_TABLE_SIZE_ID, csReadOnlyItems.csGroupTableSize)
+#endif
+#ifdef _NWK_PASSIVE_ACK_
+FLASH_PARAMETER(CS_NWK_PASSIVE_ACK_AMOUNT_ID, csReadOnlyItems.csPassiveAckAmount)
+#endif
+#ifdef _BINDING_
+FLASH_PARAMETER(CS_APS_BINDING_TABLE_SIZE_ID, csReadOnlyItems.csApsBindingTableSize)
+#endif
+#ifdef _APS_FRAGMENTATION_
+FLASH_PARAMETER(CS_APS_MAX_BLOCKS_AMOUNT_ID, csReadOnlyItems.csApsMaxBlocksAmount)
+FLASH_PARAMETER(CS_APS_BLOCK_SIZE_ID, csReadOnlyItems.csApsBlockSize)
+#endif
+#ifdef _ZCL_
+FLASH_PARAMETER(CS_ZCL_MEMORY_BUFFERS_AMOUNT_ID, csReadOnlyItems.csZclMemoryBuffersAmount)
+ #ifdef _OTAU_
+FLASH_PARAMETER(CS_ZCL_OTAU_DISCOVERED_SERVER_AMOUNT_ID, csReadOnlyItems.csOtauDiscoveredServerAmount)
+FLASH_PARAMETER(CS_ZCL_OTAU_CLIENT_SESSION_AMOUNT_ID, csReadOnlyItems.csOtauClientSessionAmount)
+FLASH_PARAMETER(CS_ZCL_OTAU_IMAGE_PAGE_REQUEST_RESPONSE_SPACING_ID, csReadOnlyItems.csOtauServerPageRequestResponseSpacing)
+FLASH_PARAMETER(CS_ZCL_OTAU_IMAGE_PAGE_REQUEST_PAGE_SIZE_ID, csReadOnlyItems.csOtauServerPageSize)
+FLASH_PARAMETER(CS_ZCL_OTAU_MISSED_BLOCKS_BUFFER_SIZE_ID, csReadOnlyItems.csOtauClientMissedBlocksBufferSize)
+ #endif /* _OTAU_ */
+#endif
+#ifdef _SECURITY_
+FLASH_PARAMETER(CS_APS_SECURITY_TIMEOUT_PERIOD_ID, csReadOnlyItems.csApsSecurityTimeoutPeriod)
+ #ifdef _TRUST_CENTRE_
+FLASH_PARAMETER(CS_MAX_TC_AUTHENTIC_PROCESS_AMOUNT_ID, csReadOnlyItems.csMaxTcAuthenticProcessAmount)
+ #ifdef _TC_PERMISSION_TABLE_
+FLASH_PARAMETER(CS_MAX_TC_ALLOWED_DEVICES_AMOUNT_ID, csReadOnlyItems.csMaxTcAllowedDevicesAmount)
+ #endif /* _TC_PERMISSION_TABLE_ */
+ #endif /* _TRUST_CENTRE_ */
+#endif /* _SECURITY_ */
+#ifdef _LINK_SECURITY_
+FLASH_PARAMETER(CS_APS_KEY_PAIR_DESCRIPTORS_AMOUNT_ID, csReadOnlyItems.csApsKeyPairDescriptorsAmount)
+ #ifdef _TRUST_CENTRE_
+FLASH_PARAMETER(CS_MAX_TC_ESTABLISH_KEY_AMOUNT_ID, csReadOnlyItems.csMaxTcEstablishKeyAmount)
+ #endif /* _TRUST_CENTRE_ */
+#endif /* _LINK_SECURITY_ */
+
+MEMORY_REGION(CS_MAC_FRAME_RX_BUFFER_ID, stackBuffers.csMacFrameRxBuffer)
+#ifndef _MAC2_
+MEMORY_REGION(CS_NEIB_TABLE_ID, stackBuffers.csNeibTable)
+MEMORY_REGION(CS_MAC_PAN_DESCRIPTOR_BUFFER_ID, stackBuffers.csMacPanDescriptorBuffer)
+MEMORY_REGION(CS_MUTABLE_NEIB_TABLE_ID, stackBuffers.csMutableNeibTable)
+#endif
+
+#ifdef _MAC_BAN_NODE_
+MEMORY_REGION(CS_BAN_TABLE_ID, stackBuffers.csBanTable)
+#endif
+
+#if CS_ROUTE_CACHE_SIZE > 0
+MEMORY_REGION(CS_ROUTE_CACHE_ID, stackBuffers.csRouteCache)
+#else
+DUMMY_MEMORY(CS_ROUTE_CACHE_ID)
+#endif /* CS_ROUTE_CACHE_SIZE > 0 */
+
+#if CS_NWK_BUFFERS_AMOUNT > 0
+MEMORY_REGION(CS_NWK_BUFFERS_ID, stackBuffers.csNwkBuffer)
+#else
+DUMMY_MEMORY(CS_NWK_BUFFERS_ID)
+#endif /* CS_NWK_BUFFERS_AMOUNT > 0 */
+
+#if CS_JOIN_IND_OBJ_AMOUNT > 0
+MEMORY_REGION(CS_JOIN_IND_OBJ_ID, stackBuffers.csJoinIndObjects)
+#else
+DUMMY_MEMORY(CS_JOIN_IND_OBJ_ID)
+#endif /* CS_JOIN_IND_OBJ_AMOUNT > 0 */
+
+#if CS_DUPLICATE_REJECTION_TABLE_SIZE > 0
+MEMORY_REGION(CS_DUPLICATE_REJECTION_TABLE_ID, stackBuffers.csDuplicateRejectionTable)
+#else
+DUMMY_MEMORY(CS_DUPLICATE_REJECTION_TABLE_ID)
+#endif /* CS_DUPLICATE_REJECTION_TABLE_SIZE > 0 */
+
+#if CS_ROUTE_TABLE_SIZE > 0
+MEMORY_REGION(CS_ROUTE_TABLE_ID, stackBuffers.csRoutingTable)
+#else
+DUMMY_MEMORY(CS_ROUTE_TABLE_ID)
+#endif /* CS_ROUTE_TABLE_SIZE > 0 */
+
+#if CS_ADDRESS_MAP_TABLE_SIZE > 0
+MEMORY_REGION(CS_ADDRESS_MAP_TABLE_ID, stackBuffers.csAddressMapTable)
+#else
+DUMMY_MEMORY(CS_ADDRESS_MAP_TABLE_ID)
+#endif /* CS_ADDRESS_MAP_TABLE_SIZE > 0 */
+
+#if CS_ROUTE_DISCOVERY_TABLE_SIZE > 0
+MEMORY_REGION(CS_ROUTE_DISCOVERY_TABLE_ID, stackBuffers.csRouteDiscoveryTable)
+#else
+DUMMY_MEMORY(CS_ROUTE_DISCOVERY_TABLE_ID)
+#endif /* CS_ROUTE_DISCOVERY_TABLE_SIZE > 0 */
+
+#if CS_NWK_BTT_SIZE > 0
+MEMORY_REGION(CS_BTT_ID, stackBuffers.csBTR)
+#else
+DUMMY_MEMORY(CS_BTT_ID)
+#endif /* CS_NWK_BTT_SIZE > 0 */
+
+#if CS_APS_DATA_REQ_BUFFERS_AMOUNT > 0
+MEMORY_REGION(CS_APS_DATA_REQ_BUFFER_ID, stackBuffers.csApsDataReqBuffer)
+#else
+DUMMY_MEMORY(CS_APS_DATA_REQ_BUFFER_ID)
+#endif /* CS_APS_DATA_REQ_BUFFERS_AMOUNT > 0 */
+
+#if CS_APS_ACK_FRAME_BUFFERS_AMOUNT > 0
+MEMORY_REGION(CS_APS_ACK_FRAME_BUFFER_ID, stackBuffers.csApsAckFrameBuffer)
+#else
+DUMMY_MEMORY(CS_APS_ACK_FRAME_BUFFER_ID)
+#endif /* CS_APS_ACK_FRAME_BUFFERS_AMOUNT > 0 */
+
+#if defined(_APS_FRAGMENTATION_) && (CS_APS_MAX_BLOCKS_AMOUNT > 0)
+MEMORY_REGION(CS_APS_FRAGMENTATION_MEMORY_POOL_ID, stackBuffers.csFragmentationMemoryPool)
+MEMORY_REGION(CS_APS_FRAGMENTATION_PACKET_BUFFER_ID, stackBuffers.csFragmentationPacketBuffer)
+#else
+DUMMY_MEMORY(CS_APS_FRAGMENTATION_MEMORY_POOL_ID)
+DUMMY_MEMORY(CS_APS_FRAGMENTATION_PACKET_BUFFER_ID)
+#endif /* _APS_FRAGMENTATION_ */
+
+#ifdef _GROUP_TABLE_
+MEMORY_REGION(CS_GROUP_TABLE_ID, stackBuffers.csGroupTable)
+#endif
+#ifdef _BINDING_
+MEMORY_REGION(CS_APS_BINDING_TABLE_ID, stackBuffers.csApsBindingTable)
+#endif
+
+#ifdef _ZCL_
+MEMORY_REGION(CS_ZCL_MEMORY_BUFFERS_ID, stackBuffers.zclMmBuffers)
+ #ifdef _OTAU_
+MEMORY_REGION(CS_ZCL_OTAU_DISCOVERED_SERVER_RESULT_ID, stackBuffers.csOtauDiscoveryResult)
+MEMORY_REGION(CS_ZCL_OTAU_CLIENT_SESSION_MEMORY_ID, stackBuffers.csOtauSimultaneousClientSession)
+MEMORY_REGION(CS_ZCL_OTAU_MISSED_BLOCKS_BUFFER_ID, stackBuffers.csOtauMissedBlocksBuffer)
+MEMORY_REGION(CS_ZCL_OTAU_PAGE_REQUEST_PAGE_BUFFER_ID, stackBuffers.csOtauImagePageDataBuffer)
+ #endif /* _OTAU_ */
+#endif
+
+#ifdef _SECURITY_
+MEMORY_REGION(CS_NWK_SECURITY_IB_ID, csNIB.securityIB)
+MEMORY_REGION(CS_NWK_SECURITY_KEYS_ID, stackBuffers.csNwkSecKeys)
+MEMORY_REGION(CS_NWK_MUTABLE_SECURITY_IB_ID, stackBuffers.csNwkSecCounters)
+ #ifdef _TRUST_CENTRE_
+ #if (CS_MAX_TC_AUTHENTIC_PROCESS_AMOUNT > 0)
+MEMORY_REGION(CS_TC_AUTHENTIC_PROCESS_BUFFER_ID, stackBuffers.csTcAuthenticProcessBuffer)
+ #else
+DUMMY_MEMORY(CS_TC_AUTHENTIC_PROCESS_BUFFER_ID)
+ #endif /* (CS_MAX_TC_AUTHENTIC_PROCESS_AMOUNT > 0) */
+ #if defined(_TC_PERMISSION_TABLE_) && (CS_MAX_TC_ALLOWED_DEVICES_AMOUNT > 0)
+MEMORY_REGION(CS_TC_PERMISSION_TABLE_ID, stackBuffers.csTcDevicePermissionTable)
+ #else
+DUMMY_MEMORY(CS_TC_PERMISSION_TABLE_ID)
+ #endif /* defined(_TC_PERMISSION_TABLE_) & (CS_MAX_TC_ALLOWED_DEVICES_AMOUNT > 0) */
+ #endif /* _TRUST_CENTRE_ */
+#endif /* _SECURITY_ */
+#ifdef _LINK_SECURITY_
+MEMORY_REGION(CS_APS_KEY_PAIR_DESCRIPTORS_ID, stackBuffers.csApsKeyPairDescriptors)
+MEMORY_REGION(CS_APS_KEY_PAIR_COUNTERS_ID, stackBuffers.csApsKeyCounters)
+ #if defined(_TRUST_CENTRE_) && (CS_MAX_TC_ESTABLISH_KEY_AMOUNT > 0)
+MEMORY_REGION(CS_TC_ESTABLISH_KEY_BUFFER_ID, stackBuffers.csTcEstablishKeyBuffer)
+ #else
+DUMMY_MEMORY(CS_TC_ESTABLISH_KEY_BUFFER_ID)
+ #endif /* defined _LINK_SECURITY_ & defined(_TRUST_CENTRE_) & (CS_MAX_TC_ESTABLISH_KEY_AMOUNT > 0)*/
+
+#endif /* _LINK_SECURITY_ */
+
+#if (defined _NWK_PASSIVE_ACK_) && (CS_NWK_PASSIVE_ACK_AMOUNT > 0)
+MEMORY_REGION(CS_NWK_PASSIVE_ACK_TABLE_ID, stackBuffers.csNwkPassiveAckTable)
+#endif /* _NWK_PASSIVE_ACK_ */
diff --git a/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/private/csSIB.h b/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/private/csSIB.h
new file mode 100644
index 00000000..618959c3
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/private/csSIB.h
@@ -0,0 +1,207 @@
+/******************************************************************************
+ \file csSIB.h
+
+ \brief
+ BitCloud stack information base
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2010 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 21.10.10 A. Razinkov - Created.
+******************************************************************************/
+
+#ifndef _CSSIB_H_
+#define _CSSIB_H_
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <csDefaults.h>
+#ifdef _MAC_BAN_NODE_
+ #include <macBanNode.h>
+#endif /* _MAC_BAN_NODE_ */
+#ifndef _MAC2_
+ #include <apsConfigServer.h>
+ #include <nwkConfigServer.h>
+#endif
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/**//**
+ * \brief Config Server parameter handler
+ */
+typedef struct _CS_MemoryItem_t
+{
+ union
+ {
+ const void FLASH_PTR* flashValue;
+ void* ramValue;
+ } value;
+ uint16_t size;
+} CS_MemoryItem_t;
+
+/**//**
+ * \brief Read-only parametres, stored in FLASH
+ */
+typedef struct _CS_ReadOnlyItems_t
+{
+ /* MAC parameters */
+ uint16_t csMacFrameRxBufferSize;
+#ifdef _MAC_BAN_NODE_
+ MAC_BanTableSize_t csMacBanTableSize;
+#endif /* _MAC_BAN_NODE_ */
+
+ /* NWK parameters */
+#ifndef _MAC2_
+ NwkRouteCacheSize_t csNwkRouteCacheSize;
+ NwkSizeOfNeighborTable_t csNeibTableSize;
+ NwkSizeOfAddressMap_t csAddressMapTableSize;
+#endif
+ uint8_t csMacPanDescriptorAmount;
+ uint8_t csMaxChildrenAmount;
+ uint8_t csMaxChildrenRouterAmount;
+ uint8_t csMaxNetworkDepth;
+ uint8_t csAddressAssignmentMethod;
+ uint8_t csNwkBuffersAmount;
+ uint8_t csJoinIndObjAmount;
+ uint8_t csRouteTableSize;
+ uint8_t csRouteDiscoveryTableSize;
+ uint8_t csNwkBttSize;
+#ifdef _GROUP_TABLE_
+ uint8_t csGroupTableSize;
+#endif /* _GROUP_TABLE_ */
+#ifdef _NWK_PASSIVE_ACK_
+ uint8_t csPassiveAckAmount;
+#endif /* _NWK_PASSIVE_ACK_ */
+
+ /* APS parameters */
+ uint8_t csApsDataReqBuffersAmount;
+ uint8_t csApsAckFrameBuffesAmount;
+ uint8_t csDuplicateRejectionTableSize;
+#ifdef _BINDING_
+ uint8_t csApsBindingTableSize;
+#endif /* _BINDING_ */
+#ifdef _APS_FRAGMENTATION_
+ uint8_t csApsMaxBlocksAmount;
+ uint16_t csApsBlockSize;
+#endif /* _APS_FRAGMENTATION_ */
+
+ /* ZCL parameters */
+#ifdef _ZCL_
+ uint8_t csZclMemoryBuffersAmount;
+ #ifdef _OTAU_
+ uint8_t csOtauDiscoveredServerAmount;
+ uint8_t csOtauClientSessionAmount;
+ uint16_t csOtauServerPageRequestResponseSpacing;
+ uint16_t csOtauServerPageSize;
+ uint8_t csOtauClientMissedBlocksBufferSize;
+ #endif /* _OTAU_ */
+#endif /* _ZCL_ */
+
+ /* Other parameters */
+ uint32_t csStackVersion;
+ uint16_t csManufacturerCode;
+
+ /* Security parameters */
+#ifdef _SECURITY_
+#ifdef _TRUST_CENTRE_
+ uint8_t csMaxTcAuthenticProcessAmount;
+ #ifdef _TC_PERMISSION_TABLE_
+ uint8_t csMaxTcAllowedDevicesAmount;
+ #endif /* _TC_PERMISSION_TABLE_ */
+#endif /* _TRUST_CENTRE_ */
+ uint32_t csApsSecurityTimeoutPeriod;
+#ifdef _LINK_SECURITY_
+ #ifdef _TRUST_CENTRE_
+ uint8_t csMaxTcEstablishKeyAmount;
+ #endif /* _TRUST_CENTRE_ */
+ uint8_t csApsKeyPairDescriptorsAmount;
+#endif /* _LINK_SECURITY_ */
+
+#endif /* _SECURITY_ */
+} CS_ReadOnlyItems_t;
+
+/**//**
+ * \brief Common stack information base
+ */
+typedef struct _SIB_t
+{
+ /* MAC parameters */
+ uint32_t csMacTransactionTime;
+ int8_t csRfTxPower;
+#ifdef AT86RF212
+ bool csLbtMode;
+#endif /* AT86RF212 */
+#ifndef _MAC2_
+
+ /* NWK parameters */
+ PanId_t csNwkPanid;
+ bool csNwkUseMulticast;
+ uint8_t csNwkMaxLinkStatusFailures;
+ uint8_t csNwkEndDeviceMaxFailures;
+ uint8_t csNwkLogicalChannel;
+ bool csNwkPredefinedPanid;
+#ifdef _NWK_CONCENTRATOR_
+ uint32_t csNwkConcentratorDiscoveryTime;
+#endif
+
+ /* ZDO parameters */
+ uint32_t csEndDeviceSleepPeriod;
+ uint32_t csFfdSleepPeriod;
+ bool csRxOnWhenIdle;
+ bool csComplexDescriptorAvailable;
+ bool csUserDescriptorAvailable;
+ uint32_t csIndirectPollRate;
+ uint8_t csZdoJoinAttempts;
+ uint32_t csZdoJoinInterval;
+ UserDescriptor_t csUserDescriptor; /* to EEPROM */
+ ExtPanId_t csExtPANID; /* user-defined PAN ID */
+#ifdef _TC_SWAPOUT_
+ uint8_t csZdoTcKeepAliveInterval;
+#endif // _TC_SWAPOUT_
+
+ /* APS parameters */
+ uint8_t csApsMaxFrameRetries;
+#ifdef _APS_FRAGMENTATION_
+ uint8_t csApsMaxTransmissionWindowSize;
+#endif /* _APS_FRAGMENTATION_ */
+
+ /* PDS parameters*/
+ bool csDtrWakeup;
+
+ /* ZCL parameters */
+#ifdef _ZCL_
+ uint16_t csZclAttributeReportTimerInterval;
+ #ifdef _OTAU_
+ ExtAddr_t csOtauDefaultServerAddress;
+ uint32_t csOtauServerDiscoveryPeriod;
+ bool csOtauServerPageRequestUsage;
+ #endif /* _OTAU_ */
+#endif /* _ZCL_ */
+
+ /* Other parameters */
+#ifdef _COMMISSIONING_
+ uint32_t csPdsStoringInterval;
+ #ifdef _POWER_FAILURE_
+ bool csPowerFailure;
+ #endif /* _POWER_FAILURE_ */
+#endif /* _COMMISSIONING_ */
+
+ /* Security parameters */
+#ifdef _SECURITY_
+ bool csSecurityOn;
+ uint8_t csZdoSecurityStatus;
+#endif /* _SECURITY_ */
+#endif /* _MAC2_ */
+} SIB_t;
+
+#endif /* _CSSIB_H_ */
+/* eof csSIB.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/stackVersion.h b/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/stackVersion.h
new file mode 100644
index 00000000..10d23dd9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ConfigServer/include/stackVersion.h
@@ -0,0 +1,3 @@
+// This is automatically generated file, do not edit it.
+#undef CS_STACK_VERSION_VALUE
+#define CS_STACK_VERSION_VALUE 0x010d002e
diff --git a/digital/zigbit/bitcloud/stack/Components/ConfigServer/src/configServer.c b/digital/zigbit/bitcloud/stack/Components/ConfigServer/src/configServer.c
new file mode 100644
index 00000000..104776a2
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ConfigServer/src/configServer.c
@@ -0,0 +1,244 @@
+/******************************************************************************
+ \file configServer.c
+
+ \brief
+ Configuration Server implementation
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2010 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 19.10.10 A. Razinkov - Created.
+******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <configServer.h>
+#include <macenvMem.h>
+#include <csSIB.h>
+#include <csDbg.h>
+#include <csBuffers.h>
+#ifdef _POWER_FAILURE_
+#include <pdsDataServer.h>
+#endif /* _POWER_FAILURE_ */
+#ifndef _MAC2_
+#include <zdoZib.h>
+#else
+#include <macenvPib.h>
+#endif
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+#define IS_MEMORY_AREA(item) (0 == (item).size)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum _CS_MemoryLocation_t
+{
+ CS_MEMORY_LOCATION_FLASH,
+ CS_MEMORY_LOCATION_RAM
+} CS_MemoryLocation_t;
+
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+extern PIB_t csPIB;
+extern SIB_t csSIB;
+#ifndef _MAC2_
+extern NIB_t csNIB;
+extern ZIB_t csZIB;
+#endif
+extern CS_MemoryItem_t PROGMEM_DECLARE(csMemoryItems[]);
+extern CS_StackBuffers_t stackBuffers;
+
+/******************************************************************************
+ Functions prototypes section
+******************************************************************************/
+static CS_MemoryItem_t csGetItem(CS_MemoryItemId_t itemId);
+static CS_MemoryLocation_t csGetItemLocation(CS_MemoryItemId_t itemId);
+
+/******************************************************************************
+ Implementation section
+******************************************************************************/
+/******************************************************************************
+\brief Configuration Server initialization
+******************************************************************************/
+void CS_Init(void)
+{
+ csSetToDefault();
+#ifdef _COMMISSIONING_
+ PDS_Init();
+#endif /* _COMMISSIONING_ */
+}
+
+/******************************************************************************
+\brief Gets the parameter specified by it's identifier
+
+\param[in] parameterId - ID of the parameter being read
+\param[out] parameterValue - pointer to the memory
+
+******************************************************************************/
+void CS_ReadParameter(CS_MemoryItemId_t parameterId, void *parameterValue)
+{
+ if (parameterValue)
+ {
+ CS_MemoryItem_t item = csGetItem(parameterId);
+
+ /* Read item value from memory it's placed. This is not valid for memory areas -
+ * use CS_GetMemory() instead */
+ if (CS_MEMORY_LOCATION_FLASH == csGetItemLocation(parameterId))
+ memcpy_P(parameterValue, item.value.flashValue, item.size);
+ else
+ memcpy(parameterValue, item.value.ramValue, item.size);
+ }
+}
+
+/******************************************************************************
+\brief Sets the parameter specified by it's identifier
+
+\param[in] parameterId - ID of the parameter being written
+\param[out] parameterValue - pointer to the parameter
+
+******************************************************************************/
+void CS_WriteParameter(CS_MemoryItemId_t parameterId, const void *parameterValue)
+{
+ if (parameterValue && (CS_MEMORY_LOCATION_RAM == csGetItemLocation(parameterId)))
+ {
+ CS_MemoryItem_t item = csGetItem(parameterId);
+
+ if (!IS_MEMORY_AREA(item))
+ memcpy(item.value.ramValue, parameterValue, item.size);
+ }
+}
+
+/******************************************************************************
+\brief Gets allocated memory specified by memory identifier
+
+\param[in] memoryId - memory area Id
+\param[out] memoryPtr - pointer to the memory
+
+******************************************************************************/
+void CS_GetMemory(CS_MemoryItemId_t memoryId, void **memoryPtr)
+{
+ CS_MemoryItem_t item = csGetItem(memoryId);
+
+ if (IS_MEMORY_AREA(item))
+ *((void **)memoryPtr) = item.value.ramValue;
+}
+
+/******************************************************************************
+\brief Set PDS default
+
+******************************************************************************/
+void CS_PdsDefaultValue(void)
+{
+ csPIB.macAttr.extAddr = CCPU_TO_LE64(CS_UID);
+ csSIB.csRfTxPower = CS_RF_TX_POWER;
+#ifndef _MAC2_
+ csSIB.csExtPANID = CCPU_TO_LE64(CS_EXT_PANID);
+ csZIB.channelMask = CS_CHANNEL_MASK;
+ csNIB.channelPage = CS_CHANNEL_PAGE;
+ csNIB.deviceType = CS_DEVICE_TYPE;
+ csSIB.csRxOnWhenIdle = (CS_DEVICE_TYPE == DEVICE_TYPE_END_DEVICE) ? CS_RX_ON_WHEN_IDLE : true;
+ csSIB.csComplexDescriptorAvailable = CS_COMPLEX_DESCRIPTOR_AVAILABLE;
+ csSIB.csUserDescriptorAvailable = CS_USER_DESCRIPTOR_AVAILABLE;
+ csSIB.csNwkPanid = CCPU_TO_LE16(CS_NWK_PANID);
+ csSIB.csNwkPredefinedPanid = CS_NWK_PREDEFINED_PANID,
+ csNIB.networkAddress = CCPU_TO_LE16(CS_NWK_ADDR);
+ csNIB.uniqueAddr = CS_NWK_UNIQUE_ADDR;
+ csSIB.csDtrWakeup = CS_DTR_WAKEUP;
+#if defined(_POWER_FAILURE_)
+ csNIB.parentNetworkAddress = CCPU_TO_LE16(0xFFFF);
+ csNIB.depth = 0;
+ csNIB.extendedPanId = CCPU_TO_LE64(CS_NWK_EXT_PANID);
+ csSIB.csNwkLogicalChannel = 0;
+ csSIB.csPowerFailure = CS_POWER_FAILURE;
+#endif /* _POWER_FAILURE_ */
+#if defined(_SECURITY_)
+ csAIB.trustCenterAddress = CCPU_TO_LE64(CS_APS_TRUST_CENTER_ADDRESS);
+ csSIB.csZdoSecurityStatus = CS_ZDO_SECURITY_STATUS;
+#endif /* _SECURITY_ */
+
+ /* Parameters not to store in EEPROM */
+ csNIB.maxNeighborRouteCost = CS_MAX_NEIGHBOR_ROUTE_COST;
+ csSIB.csNwkMaxLinkStatusFailures = CS_NWK_MAX_LINK_STATUS_FAILURES;
+ csSIB.csNwkEndDeviceMaxFailures = CS_NWK_END_DEVICE_MAX_FAILURES;
+#ifdef AT86RF212
+ csSIB.csLbtMode = CS_LBT_MODE;
+#endif /* AT86RF212 */
+#if defined(_SECURITY_)
+ csSIB.csSecurityOn = CS_SECURITY_ON;
+#endif /* _SECURITY_ */
+
+ /* Buffers cleaning */
+#if defined(_POWER_FAILURE_)
+ memset(&stackBuffers.csNeibTable, 0, CS_NEIB_TABLE_SIZE);
+ #if defined(_BINDING_) && (CS_APS_BINDING_TABLE_SIZE > 0)
+ memset(&stackBuffers.csApsBindingTable, 0, CS_APS_BINDING_TABLE_SIZE);
+ #endif /* _BINDING_ */
+ #if defined(_SECURITY_)
+ {
+ csNIB.securityIB.securityLevel = CS_SECURITY_LEVEL;
+ csNIB.securityIB.secureAllFrames = CS_SECURITY_ALL_FRAMES;
+ NWK_ResetSecurityIB(NWK_GetDefaultPowerFailureControl());
+ }
+ #endif /* _SECURITY_ */
+#endif /* _POWER_FAILURE_ */
+#if defined (_GROUP_TABLE_)
+ memset(&stackBuffers.csGroupTable, 0, CS_GROUP_TABLE_SIZE);
+#endif /* _GROUP_TABLE_ */
+#if defined(_SECURITY_)
+ #if defined(_TC_PERMISSION_TABLE_) && CS_MAX_TC_ALLOWED_DEVICES_AMOUNT > 0
+ memset(&stackBuffers.csTcDevicePermissionTable, 0, CS_MAX_TC_ALLOWED_DEVICES_AMOUNT);
+ #endif /* _TC_PERMISSION_TABLE_ */
+ #if defined _LINK_SECURITY_ && CS_APS_KEY_PAIR_DESCRIPTORS_AMOUNT > 0
+
+ memset(&stackBuffers.csApsKeyPairDescriptors, 0, CS_APS_KEY_PAIR_DESCRIPTORS_AMOUNT);
+ #endif /* _LINK_SECURITY_ */
+
+#endif /* _SECURITY_ */
+#endif /* _MAC2_ */
+}
+
+/******************************************************************************
+\brief Returns Configuration Server item by it's identifier
+
+\param[in] itemId - ID of the parameter
+
+\return - Configuration Server item
+******************************************************************************/
+static CS_MemoryItem_t csGetItem(CS_MemoryItemId_t itemId)
+{
+ CS_MemoryItem_t item;
+
+ /* Read item info from the FLASH */
+ memcpy_P(&item, &csMemoryItems[itemId], sizeof(CS_MemoryItem_t));
+ assert(item.value.flashValue, CS_CSGETITEM0);
+ return item;
+}
+
+/******************************************************************************
+\brief Returns the location where item placed
+
+\param[in] itemId - ID of the parameter
+
+\return - item location: FLASH or RAM
+******************************************************************************/
+static CS_MemoryLocation_t csGetItemLocation(CS_MemoryItemId_t itemId)
+{
+ if (CS_FLASH_PARAMETERS_START_ID < itemId)
+ return CS_MEMORY_LOCATION_FLASH;
+ else
+ return CS_MEMORY_LOCATION_RAM;
+}
+
+/* eof configServer.c */
diff --git a/digital/zigbit/bitcloud/stack/Components/ConfigServer/src/csMem.c b/digital/zigbit/bitcloud/stack/Components/ConfigServer/src/csMem.c
new file mode 100644
index 00000000..c92061e6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ConfigServer/src/csMem.c
@@ -0,0 +1,289 @@
+/******************************************************************************
+ \file csMem.c
+
+ \brief
+ BitCloud information bases memory
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2010 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 21.10.10 A. Razinkov - Created.
+******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <csBuffers.h>
+#include <macenvMem.h>
+#ifndef _MAC2_
+#include <zdoZib.h>
+#endif
+#include <csSIB.h>
+#include <csDefaults.h>
+#include <configServer.h>
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+
+/* BitCloud information bases allocation */
+PIB_t csPIB;
+#ifndef _MAC2_
+NIB_t csNIB;
+ZIB_t csZIB;
+AIB_t csAIB;
+#endif
+SIB_t csSIB;
+
+/* BitCloud memory buffers allocation */
+CS_StackBuffers_t stackBuffers;
+
+/* FLASH memory allocation to store read-only parameters */
+
+/* Default information bases item values */
+#ifndef _MAC2_
+NIB_t PROGMEM_DECLARE(defaultNIB) =
+{
+#if defined _SECURITY_
+ .securityIB = {
+ .securityLevel = CS_SECURITY_LEVEL,
+ .secureAllFrames = CS_SECURITY_ALL_FRAMES,
+ .keyAmount = CS_NWK_SECURITY_KEYS_AMOUNT,
+ .key = stackBuffers.csNwkSecKeys,
+ .counter = stackBuffers.csNwkSecCounters
+ },
+#endif
+ .deviceType = CS_DEVICE_TYPE,
+ .addrAlloc = CS_ADDRESS_ASSIGNMENT_METHOD,
+ .symLink = true,
+ .uniqueAddr = CS_NWK_UNIQUE_ADDR,
+ .stackProfile = CS_STACK_PROFILE,
+ .protocolVersion = CS_PROTOCOL_VERSION,
+ .maxDepth = CS_MAX_NETWORK_DEPTH,
+ .maxNeighborRouteCost = CS_MAX_NEIGHBOR_ROUTE_COST,
+ .channelPage = CS_CHANNEL_PAGE,
+ .logicalChannel = 0,
+ .networkAddress = CCPU_TO_LE16(CS_NWK_ADDR),
+ .panId = CCPU_TO_LE16(CS_NWK_PANID),
+ .extendedPanId = CCPU_TO_LE64(CS_NWK_EXT_PANID), /* uses as joined-to-network flag */
+ .maxRouters = CS_MAX_CHILDREN_ROUTER_AMOUNT,
+ .maxEndDevices = CS_MAX_CHILDREN_AMOUNT - CS_MAX_CHILDREN_ROUTER_AMOUNT
+};
+
+ZIB_t PROGMEM_DECLARE(defaultZIB) =
+{
+ .permitJoinDuration = CS_PERMIT_DURATION,
+ .channelMask = CS_CHANNEL_MASK,
+ .zdpResponseTimeout = CS_ZDP_RESPONSE_TIMEOUT,
+ .scanDuration = CS_SCAN_DURATION,
+};
+
+AIB_t PROGMEM_DECLARE(defaultAIB) =
+{
+ .nonMemberRadius = APS_AIB_NONMEMBER_RADIUS_DEFAULT_VALUE, /* See ZigBee spec r19, Table 2.24. */
+#ifdef _SECURITY_
+ .trustCenterAddress = CCPU_TO_LE64(CS_APS_TRUST_CENTER_ADDRESS),
+#endif /* _SECURITY_ */
+};
+#endif /* !_MAC2_*/
+
+SIB_t PROGMEM_DECLARE(defaultSIB) =
+{
+ /* MAC parameters */
+ .csMacTransactionTime = CS_MAC_TRANSACTION_TIME,
+ .csRfTxPower = CS_RF_TX_POWER,
+#ifdef AT86RF212
+ .csLbtMode = CS_LBT_MODE,
+#endif //AT86RF212
+#ifndef _MAC2_
+
+ /* NWK parameters */
+ .csNwkPanid = CCPU_TO_LE16(CS_NWK_PANID),
+ .csNwkUseMulticast = CS_NWK_USE_MULTICAST,
+ .csNwkMaxLinkStatusFailures = CS_NWK_MAX_LINK_STATUS_FAILURES,
+ .csNwkEndDeviceMaxFailures = CS_NWK_END_DEVICE_MAX_FAILURES,
+ .csNwkLogicalChannel = 0,
+ .csNwkPredefinedPanid = CS_NWK_PREDEFINED_PANID,
+#ifdef _NWK_CONCENTRATOR_
+ .csNwkConcentratorDiscoveryTime = NWK_CONCENTRATOR_DISCOVERY_TIME,
+#endif
+
+ /* ZDO parameters */
+ .csEndDeviceSleepPeriod = CS_END_DEVICE_SLEEP_PERIOD,
+ .csFfdSleepPeriod = CS_FFD_SLEEP_PERIOD,
+ .csRxOnWhenIdle = (CS_DEVICE_TYPE == DEVICE_TYPE_END_DEVICE) ? CS_RX_ON_WHEN_IDLE : true,
+ .csComplexDescriptorAvailable = CS_COMPLEX_DESCRIPTOR_AVAILABLE,
+ .csUserDescriptorAvailable = CS_USER_DESCRIPTOR_AVAILABLE,
+ .csUserDescriptor = {.FieldLength = ZDP_USER_DESC_FIELD_SIZE, .FieldName = "Atmel "},
+ .csIndirectPollRate = CS_INDIRECT_POLL_RATE,
+ .csZdoJoinAttempts = CS_ZDO_JOIN_ATTEMPTS,
+ .csZdoJoinInterval = CS_ZDO_JOIN_INTERVAL,
+ .csExtPANID = CCPU_TO_LE64(CS_EXT_PANID), /* user-defined PAN ID */
+#ifdef _TC_SWAPOUT_
+ .csZdoTcKeepAliveInterval = CS_ZDO_TC_KEEP_ALIVE_INTERVAL,
+#endif // _TC_SWAPOUT_
+
+ /* APS parameters */
+ .csApsMaxFrameRetries = CS_APS_MAX_FRAME_RETRIES,
+#ifdef _APS_FRAGMENTATION_
+ .csApsMaxTransmissionWindowSize = CS_APS_MAX_TRANSMISSION_WINDOW_SIZE,
+#endif /* _APS_FRAGMENTATION_ */
+
+ /* PDS parameters*/
+ .csDtrWakeup = CS_DTR_WAKEUP,
+
+ /* ZCL parameters */
+#ifdef _ZCL_
+ .csZclAttributeReportTimerInterval = CS_ZCL_ATTRIBUTE_REPORT_TIMER_INTERVAL,
+ #ifdef _OTAU_
+ .csOtauDefaultServerAddress = CS_ZCL_OTAU_DEFAULT_UPGRADE_SERVER_IEEE_ADDRESS,
+ .csOtauServerDiscoveryPeriod = CS_ZCL_OTAU_SERVER_DISCOVERY_PERIOD,
+ .csOtauServerPageRequestUsage = CS_ZCL_OTAU_IMAGE_PAGE_REQUEST_USAGE,
+ #endif /* _OTAU_ */
+#endif /* _ZCL_ */
+
+ /* Other parameters */
+#ifdef _COMMISSIONING_
+ .csPdsStoringInterval = CS_PDS_STORING_INTERVAL,
+ #ifdef _POWER_FAILURE_
+ .csPowerFailure = CS_POWER_FAILURE,
+ #endif /* _POWER_FAILURE_ */
+#endif /* _COMMISSIONING_ */
+
+ /* Security parameters */
+#ifdef _SECURITY_
+ .csSecurityOn = CS_SECURITY_ON,
+ .csZdoSecurityStatus = CS_ZDO_SECURITY_STATUS,
+#endif /* _SECURITY_ */
+#endif /* _MAC2_ */
+};
+
+#ifdef _SECURITY_
+uint8_t defaultKey[SECURITY_KEY_SIZE] = CS_NETWORK_KEY;
+#endif /* _SECURITY_ */
+
+CS_ReadOnlyItems_t PROGMEM_DECLARE(csReadOnlyItems) =
+{
+ /* MAC parameters */
+ .csMacFrameRxBufferSize = CS_MAC_FRAME_RX_BUFFER_SIZE,
+#ifdef _MAC_BAN_NODE_
+ .csMacBanTableSize = CS_BAN_TABLE_SIZE,
+#endif /* _MAC_BAN_NODE_ */
+
+ /* NWK parameters */
+#ifndef _MAC2_
+ .csNwkRouteCacheSize = CS_ROUTE_CACHE_SIZE,
+ .csNeibTableSize = CS_NEIB_TABLE_SIZE,
+ .csMacPanDescriptorAmount = CS_NEIB_TABLE_SIZE,
+ .csMaxChildrenAmount = CS_MAX_CHILDREN_AMOUNT,
+ .csMaxChildrenRouterAmount = CS_MAX_CHILDREN_ROUTER_AMOUNT,
+ .csMaxNetworkDepth = CS_MAX_NETWORK_DEPTH,
+ .csAddressAssignmentMethod = CS_ADDRESS_ASSIGNMENT_METHOD,
+ .csNwkBuffersAmount = CS_NWK_BUFFERS_AMOUNT,
+ .csJoinIndObjAmount = CS_JOIN_IND_OBJ_AMOUNT,
+ .csRouteTableSize = CS_ROUTE_TABLE_SIZE,
+ .csAddressMapTableSize = CS_ADDRESS_MAP_TABLE_SIZE,
+ .csRouteDiscoveryTableSize = CS_ROUTE_DISCOVERY_TABLE_SIZE,
+ .csNwkBttSize = CS_NWK_BTT_SIZE,
+#ifdef _GROUP_TABLE_
+ .csGroupTableSize = CS_GROUP_TABLE_SIZE,
+#endif /* _GROUP_TABLE_ */
+#ifdef _NWK_PASSIVE_ACK_
+ .csPassiveAckAmount = CS_NWK_PASSIVE_ACK_AMOUNT,
+#endif /* _NWK_PASSIVE_ACK_ */
+
+ /* APS parameters */
+ .csApsDataReqBuffersAmount = CS_APS_DATA_REQ_BUFFERS_AMOUNT,
+ .csApsAckFrameBuffesAmount = CS_APS_ACK_FRAME_BUFFERS_AMOUNT,
+ .csDuplicateRejectionTableSize = CS_DUPLICATE_REJECTION_TABLE_SIZE,
+#ifdef _BINDING_
+ .csApsBindingTableSize = CS_APS_BINDING_TABLE_SIZE,
+#endif /* _BINDING_ */
+#ifdef _APS_FRAGMENTATION_
+ .csApsMaxBlocksAmount = CS_APS_MAX_BLOCKS_AMOUNT,
+ .csApsBlockSize = CS_APS_BLOCK_SIZE,
+#endif /* _APS_FRAGMENTATION_ */
+
+#ifdef _ZCL_
+ .csZclMemoryBuffersAmount = CS_ZCL_MEMORY_BUFFERS_AMOUNT,
+ #ifdef _OTAU_
+ .csOtauDiscoveredServerAmount = CS_ZCL_OTAU_DISCOVERED_SERVER_AMOUNT,
+ .csOtauClientSessionAmount = CS_ZCL_OTAU_CLIENT_SESSION_AMOUNT,
+ .csOtauServerPageRequestResponseSpacing = CS_ZCL_OTAU_IMAGE_PAGE_REQUEST_RESPONSE_SPACING,
+ .csOtauServerPageSize = CS_ZCL_OTAU_IMAGE_PAGE_REQUEST_PAGE_SIZE,
+ .csOtauClientMissedBlocksBufferSize = CS_ZCL_OTAU_MISSED_BLOCKS_BUFFER_SIZE,
+ #endif /* _OTAU_ */
+#endif /* _ZCL_ */
+
+#ifdef _SECURITY_
+ .csApsSecurityTimeoutPeriod = CS_APS_SECURITY_TIMEOUT_PERIOD,
+#ifdef _TRUST_CENTRE_
+ .csMaxTcAuthenticProcessAmount = CS_MAX_TC_AUTHENTIC_PROCESS_AMOUNT,
+ #ifdef _TC_PERMISSION_TABLE_
+ .csMaxTcAllowedDevicesAmount = CS_MAX_TC_ALLOWED_DEVICES_AMOUNT,
+ #endif /* _TC_PERMISSION_TABLE_ */
+#endif /* _TRUST_CENTRE_ */
+#ifdef _LINK_SECURITY_
+ #ifdef _TRUST_CENTRE_
+ .csMaxTcEstablishKeyAmount = CS_MAX_TC_ESTABLISH_KEY_AMOUNT,
+ #endif /* _TRUST_CENTRE_ */
+ .csApsKeyPairDescriptorsAmount = CS_APS_KEY_PAIR_DESCRIPTORS_AMOUNT,
+#endif /* _LINK_SECURITY_ */
+#endif /* _SECURITY_ */
+ /* Other parameters */
+ .csStackVersion = CS_STACK_VERSION,
+ .csManufacturerCode = CCPU_TO_LE16(CS_MANUFACTURER_CODE),
+#endif /* !_MAC2_*/
+};
+
+/*
+ * \brief Configuration Server items information table stored in FLASH.
+ * Table record contains informaion about corresponding item displacement and size.
+ * Records are automatically sorted by item location and type
+ * (atomic parameter or memory region).
+ */
+#define SEPARATOR(id) {{NULL}, 0},
+#define DUMMY_MEMORY(id) {{NULL}, 0},
+#define FLASH_PARAMETER(id, addr) {{(const void FLASH_PTR*)&(addr)}, sizeof(addr)},
+#define RAM_PARAMETER(id, addr) {{(const void FLASH_PTR*)&(addr)}, sizeof(addr)},
+#define MEMORY_REGION(id, addr) {{(const void FLASH_PTR*)&(addr)}, 0},
+CS_MemoryItem_t PROGMEM_DECLARE(csMemoryItems[]) =
+{
+ #include "csParamTable.h"
+};
+#undef SEPARATOR
+#undef DUMMY_MEMORY
+#undef FLASH_PARAMETER
+#undef RAM_PARAMETER
+#undef MEMORY_REGION
+
+/******************************************************************************
+ Implementation section
+******************************************************************************/
+
+/******************************************************************************
+\brief Set Configuration Server memory to its default state
+******************************************************************************/
+void csSetToDefault(void)
+{
+ /* Restore information bases default values from FLASH */
+ memset(&csPIB, 0x00, sizeof(PIB_t));
+ csPIB.macAttr.extAddr = CCPU_TO_LE64(CS_UID);
+ csPIB.macAttr.maxFrameTransmissionTime = CS_MAX_FRAME_TRANSMISSION_TIME;
+
+#ifndef _MAC2_
+ memcpy_P(&csNIB, &defaultNIB, sizeof(NIB_t));
+ memcpy_P(&csZIB, &defaultZIB, sizeof(ZIB_t));
+ memcpy_P(&csAIB, &defaultAIB, sizeof(AIB_t));
+#endif
+ memcpy_P(&csSIB, &defaultSIB, sizeof(SIB_t));
+ memset(&stackBuffers, 0x00, sizeof(CS_StackBuffers_t));
+}
+
+/* eof csMem.c */
diff --git a/digital/zigbit/bitcloud/stack/Components/ConfigServer/src/csPersistentMem.c b/digital/zigbit/bitcloud/stack/Components/ConfigServer/src/csPersistentMem.c
new file mode 100644
index 00000000..a6f5fb34
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ConfigServer/src/csPersistentMem.c
@@ -0,0 +1,221 @@
+/******************************************************************************
+ \file csPersistentMem.c
+
+ \brief
+ Configuration Server persistent memory to store in EEPROM
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2010 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 28.10.10 A. Razinkov - Created.
+******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <csPersistentMem.h>
+#include <macenvMem.h>
+#ifndef _MAC2_
+#include <apsConfigServer.h>
+#include <nwkConfigServer.h>
+#endif
+#include <csSIB.h>
+#include <csBuffers.h>
+#ifndef _MAC2_
+#include <zdoZib.h>
+#endif
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+/* Macros used to define records in csPersistentMemTable table*/
+#define PERSISTREC(id, address) {address, RECORD_OFFSET(CS_PersistentDataOffsets_t, id)}
+#define RECORD_OFFSET(struct_type, field_name) (offsetof(struct_type, field_name) + SYSTEM_BASE_EEPROM_ADDRESS)
+
+#ifdef _COMMISSIONING_
+#define PERSISTENT_ITEMS_AMOUNT (ARRAY_SIZE(csPersistentMemTable))
+#define PERSISTENT_MEMORY_SIZE (sizeof(CS_PersistentDataOffsets_t))
+#else
+#define PERSISTENT_ITEMS_AMOUNT 0U
+#define PERSISTENT_MEMORY_SIZE 0U
+#endif /* _COMMISSIONING_ */
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/*
+ * Persistence module used to save some of ConfigServer items to EEPROM.
+ * Items to save enumerated in csPersistentMemTable, stored in FLASH.
+ * This table consists of CS_PersistantData_t records.
+ * Every record have 2 values: address (in RAM) of item to save and the offset - address in
+ * EEPROM, were item will be placed.
+ * Size of area occupied by item calculated by difference from offset of next item.
+ *
+ * Macros PERSISTREC(id, address) is used to mount records in csPersistentMemTable.
+ * It automatically calculates the offsets for each item with the help of RECORD_OFFSET macros.
+ * When all macroses gets expanded, code looks like this:
+ *
+ * typedef struct {
+ * uint8_t id1,
+ * uint16_t id2,
+ * ExtAddr_t id3
+ * } CS_PersistentDataOffsets_t ;
+ * csPersistentMemTable =
+ * {
+ * address1, __field_offset(CS_PersistentDataOffsets_t, id1),
+ * address2, __field_offset(CS_PersistentDataOffsets_t, id2),
+ * address3, __field_offset(CS_PersistentDataOffsets_t, id3),
+ * };
+ *
+ * Please pay attention: records in csPersistentMemTable must be in the same order and under
+ * the same features as defined in CS_PersistentDataOffsets_t offsets structure.
+ */
+
+/* CS_PersistentDataOffsets_t structure used to automatically calculate
+ * offsets for csPersistentMemTable.
+ * Variables of this structure never instantiated. */
+#ifdef _COMMISSIONING_
+BEGIN_PACK
+typedef struct PACK
+{
+ ExtAddr_t CS_UID_ID;
+ int8_t CS_RF_TX_POWER_ID;
+#ifndef _MAC2_
+ ExtPanId_t CS_EXT_PANID_ID;
+ uint32_t CS_CHANNEL_MASK_ID;
+ uint8_t CS_CHANNEL_PAGE_ID;
+ DeviceType_t CS_DEVICE_TYPE_ID;
+ bool CS_RX_ON_WHEN_IDLE_ID;
+ bool CS_COMPLEX_DESCRIPTOR_AVAILABLE_ID;
+ bool CS_USER_DESCRIPTOR_AVAILABLE_ID;
+ UserDescriptor_t CS_ZDP_USER_DESCRIPTOR_ID;
+ PanId_t CS_NWK_PANID_ID;
+ bool CS_NWK_PREDEFINED_PANID_ID;
+ ShortAddr_t CS_NWK_ADDR_ID;
+ bool CS_NWK_UNIQUE_ADDR_ID;
+ bool CS_DTR_WAKEUP_ID;
+#if defined(_POWER_FAILURE_)
+ ShortAddr_t CS_NWK_PARENT_ADDR_ID;
+ uint8_t CS_NWK_DEPTH_ID;
+ ExtPanId_t CS_NWK_EXT_PANID_ID;
+ uint8_t CS_NWK_LOGICAL_CHANNEL_ID;
+ uint8_t CS_POWER_FAILURE_ID;
+#endif /* _POWER_FAILURE_ */
+#if defined(_SECURITY_)
+ ExtAddr_t CS_APS_TRUST_CENTER_ADDRESS_ID;
+ uint8_t CS_ZDO_SECURITY_STATUS_ID;
+#endif /* _SECURITY_ */
+#if defined(_POWER_FAILURE_)
+ uint8_t CS_NEIB_TABLE_ID[CS_NEIB_TABLE_SIZE * sizeof(Neib_t)];
+ #if defined(_BINDING_) && (CS_APS_BINDING_TABLE_SIZE > 0)
+ ApsBindingEntry_t CS_APS_BINDING_TABLE_ID[CS_APS_BINDING_TABLE_SIZE];
+ #endif /* _BINDING_ */
+ #if defined(_SECURITY_)
+ NWK_SecurityIB_t CS_NWK_SECURITY_IB_ID;
+ NWK_SecurityKey_t CS_NWK_SECURITY_KEYS_ID[CS_NWK_SECURITY_KEYS_AMOUNT];
+ #endif /* _SECURITY_ */
+#endif /* _POWER_FAILURE_ */
+#if defined (_GROUP_TABLE_)
+ uint8_t CS_GROUP_TABLE_ID[(CS_GROUP_TABLE_SIZE * sizeof(NWK_GroupTableEntry_t))];
+#endif /* _GROUP_TABLE_ */
+#if defined(_SECURITY_)
+ #if defined(_TC_PERMISSION_TABLE_) && CS_MAX_TC_ALLOWED_DEVICES_AMOUNT > 0
+ uint8_t CS_TC_PERMISSION_TABLE_ID[sizeof(ExtAddr_t) * CS_MAX_TC_ALLOWED_DEVICES_AMOUNT];
+ #endif
+ #if defined _LINK_SECURITY_ && CS_APS_KEY_PAIR_DESCRIPTORS_AMOUNT > 0
+
+ uint8_t CS_APS_KEY_PAIR_DESCRIPTORS_ID[(CS_APS_KEY_PAIR_DESCRIPTORS_AMOUNT * sizeof(ApsKeyPairDescriptor_t))];
+ #endif
+#endif /* _SECURITY_ */
+#endif /* _MAC2_ */
+} CS_PersistentDataOffsets_t;
+END_PACK
+/******************************************************************************
+ External variables section
+******************************************************************************/
+extern SIB_t csSIB;
+extern NIB_t csNIB;
+extern ZIB_t csZIB;
+extern PIB_t csPIB;
+extern CS_StackBuffers_t stackBuffers;
+#ifdef _LINK_SECURITY_
+extern CS_ReadOnlyItems_t PROGMEM_DECLARE(csReadOnlyItems);
+#endif
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+/* Table of Configuration Server persistent parameters, stored in FLASH.
+ * This table is used by Persist Data Server, which performs parameters storing
+ * and backuping from persistent memory.
+ * */
+PROGMEM_DECLARE(const CS_PersistantData_t csPersistentMemTable[]) =
+{
+ PERSISTREC(CS_UID_ID, &csPIB.macAttr.extAddr),
+ PERSISTREC(CS_RF_TX_POWER_ID, &csSIB.csRfTxPower),
+#ifndef _MAC2_
+ PERSISTREC(CS_EXT_PANID_ID, &csSIB.csExtPANID),
+ PERSISTREC(CS_CHANNEL_MASK_ID, &csZIB.channelMask),
+ PERSISTREC(CS_CHANNEL_PAGE_ID, &csNIB.channelPage),
+ PERSISTREC(CS_DEVICE_TYPE_ID, &csNIB.deviceType),
+ PERSISTREC(CS_RX_ON_WHEN_IDLE_ID, &csSIB.csRxOnWhenIdle),
+ PERSISTREC(CS_COMPLEX_DESCRIPTOR_AVAILABLE_ID, &csSIB.csComplexDescriptorAvailable),
+ PERSISTREC(CS_USER_DESCRIPTOR_AVAILABLE_ID, &csSIB.csUserDescriptorAvailable),
+ PERSISTREC(CS_ZDP_USER_DESCRIPTOR_ID, &csSIB.csUserDescriptor),
+ PERSISTREC(CS_NWK_PANID_ID, &csSIB.csNwkPanid),
+ PERSISTREC(CS_NWK_PREDEFINED_PANID_ID, &csSIB.csNwkPredefinedPanid),
+ PERSISTREC(CS_NWK_ADDR_ID, &csNIB.networkAddress),
+ PERSISTREC(CS_NWK_UNIQUE_ADDR_ID, &csNIB.uniqueAddr),
+ PERSISTREC(CS_DTR_WAKEUP_ID, &csSIB.csDtrWakeup),
+#if defined(_POWER_FAILURE_)
+ PERSISTREC(CS_NWK_PARENT_ADDR_ID, &csNIB.parentNetworkAddress),
+ PERSISTREC(CS_NWK_DEPTH_ID, &csNIB.depth),
+ PERSISTREC(CS_NWK_EXT_PANID_ID, &csNIB.extendedPanId),
+ PERSISTREC(CS_NWK_LOGICAL_CHANNEL_ID, &csSIB.csNwkLogicalChannel),
+ PERSISTREC(CS_POWER_FAILURE_ID, &csSIB.csPowerFailure),
+#endif /* _POWER_FAILURE_ */
+#if defined(_SECURITY_)
+ PERSISTREC(CS_APS_TRUST_CENTER_ADDRESS_ID, &csAIB.trustCenterAddress),
+ PERSISTREC(CS_ZDO_SECURITY_STATUS_ID, &csSIB.csZdoSecurityStatus),
+#endif /* _SECURITY_ */
+
+#if defined(_POWER_FAILURE_)
+ PERSISTREC(CS_NEIB_TABLE_ID, &stackBuffers.csNeibTable),
+ #if defined(_BINDING_) && (CS_APS_BINDING_TABLE_SIZE > 0)
+ PERSISTREC(CS_APS_BINDING_TABLE_ID, &stackBuffers.csApsBindingTable),
+ #endif /* _BINDING_ */
+ #if defined(_SECURITY_)
+ PERSISTREC(CS_NWK_SECURITY_IB_ID, &csNIB.securityIB),
+ PERSISTREC(CS_NWK_SECURITY_KEYS_ID, &stackBuffers.csNwkSecKeys),
+ #endif /* _SECURITY_ */
+#endif /* _POWER_FAILURE_ */
+#if defined (_GROUP_TABLE_)
+ PERSISTREC(CS_GROUP_TABLE_ID, &stackBuffers.csGroupTable),
+#endif /* _GROUP_TABLE_ */
+#if defined(_SECURITY_)
+ #if defined(_TC_PERMISSION_TABLE_) && CS_MAX_TC_ALLOWED_DEVICES_AMOUNT > 0
+ PERSISTREC(CS_TC_PERMISSION_TABLE_ID, &stackBuffers.csTcDevicePermissionTable),
+ #endif /* _TC_PERMISSION_TABLE_ */
+ #if defined _LINK_SECURITY_ && CS_APS_KEY_PAIR_DESCRIPTORS_AMOUNT > 0
+
+ PERSISTREC(CS_APS_KEY_PAIR_DESCRIPTORS_ID, &stackBuffers.csApsKeyPairDescriptors),
+ #endif /* _LINK_SECURITY_ */
+
+#endif /* _SECURITY_ */
+#endif /* _MAC2_ */
+};
+#endif /* _COMMISSIONING_ */
+
+/* Number of records in csPersistentMemTable*/
+const uint8_t csPersistentItemsAmount = PERSISTENT_ITEMS_AMOUNT;
+
+/* Total size of memory occupied by persistent parameters */
+const uint16_t csPersistentMemorySize = PERSISTENT_MEMORY_SIZE + SYSTEM_BASE_EEPROM_ADDRESS;
+
+/* eof csPersistentMem.c */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/Configuration b/digital/zigbit/bitcloud/stack/Components/HAL/Configuration
new file mode 100644
index 00000000..699bc97c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/Configuration
@@ -0,0 +1,103 @@
+#-------------------------------------------------------------------------------
+# \file Configuration
+#
+# \brief Declares build options for the HAL.
+#
+# \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).
+#
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+# Build configuration:
+# For "DEBUG" configuration system asserts, logging and debug info are switched on.
+# For "RELEASE" configuration system asserts, logging and debug info are switched off.
+#-------------------------------------------------------------------------------
+BUILD_CONFIGURATION = RELEASE
+#BUILD_CONFIGURATION = DEBUG
+
+#-------------------------------------------------------------------------------
+# Build configuration:
+# If QUIET is TRUE then short build message format is used, otherwise - normal.
+#-------------------------------------------------------------------------------
+QUIET = TRUE
+#QUIET = FALSE
+
+#-------------------------------------------------------------------------------
+# Compiler type:
+#-------------------------------------------------------------------------------
+COMPILER_TYPE = GCC
+#COMPILER_TYPE = IAR
+
+#-------------------------------------------------------------------------------
+# Platforms selection:
+#-------------------------------------------------------------------------------
+PLATFORM = PLATFORM_ZIGBIT
+#PLATFORM = PLATFORM_RCB
+
+#-------------------------------------------------------------------------------
+# ZIGBIT platform specific options:
+#-------------------------------------------------------------------------------
+ifeq ($(PLATFORM), PLATFORM_ZIGBIT)
+ # Microcontroller's type declaration. The following variants are possible:
+ HAL = ATMEGA1281
+
+ # Controller reference frequency.
+ #HAL_FREQUENCY = HAL_4MHz
+ HAL_FREQUENCY = HAL_8MHz
+
+ # Device to read UID from: TinyA13 MCU or DS2411.
+ #HAL_TINY_UID = TRUE
+ HAL_TINY_UID = FALSE
+
+ # Defines whether HAL controls amplifier or not.
+ #HAL_USE_AMPLIFIER = FALSE
+ HAL_USE_AMPLIFIER = TRUE
+
+endif # PLATFORM_ZIGBIT
+
+#-------------------------------------------------------------------------------
+# PLATFORM_RCB platform specific options:
+#-------------------------------------------------------------------------------
+ifeq ($(PLATFORM), PLATFORM_RCB)
+ # Platform revisions
+ #PLATFORM_REV = RCB230_V31
+ #PLATFORM_REV = RCB230_V32
+ PLATFORM_REV = RCB230_V331
+ #PLATFORM_REV = RCB231_V402
+ #PLATFORM_REV = RCB231_V411
+ #PLATFORM_REV = RCB212_V532
+
+ # Controller reference frequency.
+ #HAL_FREQUENCY = HAL_4MHz
+ HAL_FREQUENCY = HAL_8MHz
+endif # PLATFORM_RCB
+
+#-------------------------------------------------------------------------------
+# OS selection. Parameters is only for ARM:
+#-------------------------------------------------------------------------------
+OS = NONE_OS
+#OS = FREE_RTOS
+
+# Gives a possibility to enable USART error callbacks.
+HAL_USE_USART_ERROR_EVENT = FALSE
+#HAL_USE_USART_ERROR_EVENT = TRUE
+
+#RF_RX_TX_INDICATOR
+HAL_RF_RX_TX_INDICATOR = TRUE
+#HAL_RF_RX_TX_INDICATOR = FALSE
+
+#Selected automatically to FALSE for ZIGBIT platform.
+ifeq ($(PLATFORM), PLATFORM_ZIGBIT)
+ HAL_RF_RX_TX_INDICATOR = FALSE
+endif # PLATFORM_ZIGBIT
+
+# Antenna diversity feature
+HAL_ANT_DIVERSITY = FALSE
+#HAL_ANT_DIVERSITY = TRUE
+
+# eof Configuration
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/Makefile b/digital/zigbit/bitcloud/stack/Components/HAL/Makefile
new file mode 100644
index 00000000..0207ac35
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/Makefile
@@ -0,0 +1,103 @@
+#-------------------------------------------------------------------------------------
+# Paths.
+HAL_PATH = .
+
+#-------------------------------------------------------------------------------------
+# Includes.
+include $(HAL_PATH)/Makerules
+
+ifeq ($(HAL), ATMEGA1281)
+ TARGET=AVR
+endif
+
+ifeq ($(HAL), ATMEGA2561)
+ TARGET=AVR
+endif
+
+ifeq ($(HAL), ATMEGA1284)
+ TARGET=AVR
+endif
+
+ifeq ($(HAL), AT90USB1287)
+ TARGET=AVR
+endif
+
+ifeq ($(HAL), ATMEGA128RFA1)
+ TARGET=AVR
+endif
+
+ifeq ($(HAL), ATXMEGA128A1)
+ TARGET=XMEGA
+endif
+
+ifeq ($(HAL), ATXMEGA256A3)
+ TARGET=XMEGA
+endif
+
+ifeq ($(HAL), ATXMEGA256D3)
+ TARGET=XMEGA
+endif
+
+ifeq ($(HAL), AT91SAM7X256)
+ TARGET=ARM7
+endif
+
+ifeq ($(HAL), AT91SAM3S4C)
+ TARGET=CORTEX
+endif
+
+ifeq ($(HAL), AT32UC3A0512)
+ TARGET=AVR32
+endif
+
+ifeq ($(HAL), SIMULATOR)
+ TARGET=SIMULATOR
+endif
+
+ifeq ($(TARGET), AVR)
+all:
+ make all -C $(COMPONENTS_PATH)/HAL/avr
+
+clean:
+ make clean -C $(COMPONENTS_PATH)/HAL/avr
+endif
+
+ifeq ($(TARGET), XMEGA)
+all:
+ make all -C $(COMPONENTS_PATH)/HAL/xmega
+
+clean:
+ make clean -C $(COMPONENTS_PATH)/HAL/xmega
+endif
+
+ifeq ($(TARGET), ARM7)
+all:
+ make all -C $(COMPONENTS_PATH)/HAL/arm7tdmi
+
+clean:
+ make clean -C $(COMPONENTS_PATH)/HAL/arm7tdmi
+endif
+
+ifeq ($(TARGET), CORTEX)
+all:
+ make all -C $(COMPONENTS_PATH)/HAL/cortexm3
+
+clean:
+ make clean -C $(COMPONENTS_PATH)/HAL/cortexm3
+endif
+
+ifeq ($(TARGET), AVR32)
+all:
+ make all -C $(COMPONENTS_PATH)/HAL/avr32
+
+clean:
+ make clean -C $(COMPONENTS_PATH)/HAL/avr32
+endif
+
+ifeq ($(TARGET), SIMULATOR)
+all:
+ make all -C $(COMPONENTS_PATH)/HAL/simulator
+
+clean:
+ make clean -C $(COMPONENTS_PATH)/HAL/simulator
+endif
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/Makerules b/digital/zigbit/bitcloud/stack/Components/HAL/Makerules
new file mode 100644
index 00000000..8f133d44
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/Makerules
@@ -0,0 +1,807 @@
+COMPONENTS_PATH = $(HAL_PATH)/..
+STACK_PATH = $(COMPONENTS_PATH)/..
+STACK_LIB_PATH = $(STACK_PATH)/lib
+LIST_PATH = ./list
+
+include $(COMPONENTS_PATH)/HAL/Configuration
+
+#-------------------------------------------------------------------------------
+# Platform specific compiler flags definition and settins checking:
+#-------------------------------------------------------------------------------
+ifndef PLATFORM
+ $(error ERROR in file Makerules: $(PLATFORM) Unknown type of platform)
+endif
+ifeq ($(PLATFORM), PLATFORM_ZIGBIT) ######### ZigBit platform #####
+ ifeq (, $(findstring $(HAL_FREQUENCY), HAL_8MHz HAL_4MHz))
+ $(error ERROR in file Makerules: $(HAL_FREQUENCY) Unknown type of HAL frequency for $(PLATFORM) platform)
+ endif
+
+ ifeq (, $(findstring $(HAL), ATMEGA1281 ATMEGA2561))
+ $(error ERROR in file Makerules: $(HAL) Unknown type of HAL for $(PLATFORM) platform)
+ endif
+ # For platform with 32.768 kHz only.
+ SYSTEM_TIME_ON = SLEEP_TIMER
+endif # ZIGBIT
+
+ifeq ($(PLATFORM), PLATFORM_RAVEN) ######### Raven platform #####
+ # Checking parameters which were set by user.
+ ifeq (, $(findstring $(HAL_FREQUENCY), HAL_8MHz HAL_4MHz))
+ $(error ERROR in file Makerules: $(HAL_FREQUENCY) Unknown type of HAL frequency for $(PLATFORM) platform)
+ endif
+ # Setting platform parameters which can not be changed by user.
+ HAL = ATMEGA1284
+ # For platform with 32.768 kHz only.
+ SYSTEM_TIME_ON = SLEEP_TIMER
+endif # RAVEN
+
+ifeq ($(PLATFORM), PLATFORM_ATML_USB_DONGLE) ######### ATML_USB_DONGLE platform #####
+ # Setting platform parameters which can not be changed by user.
+ HAL = AT90USB1287
+ HAL_FREQUENCY = HAL_8MHz
+endif # ATML_USB_DONGLE
+
+ifeq ($(PLATFORM), PLATFORM_STK600) ####### ATML_STK600 platform ####
+ RF_EXTENDER = REB231
+
+ ifneq (, $(findstring $(HAL), ATXMEGA128A1 ATXMEGA256A3 ATXMEGA256D3))
+ ifeq (, $(findstring $(HAL_CLOCK_SOURCE), CRYSTAL_16MHz RC_INTERNAL_32MHz RC_INTERNAL_2MHz))
+ $(error ERROR in file Makerules: $(HAL_CLOCK_SOURCE) Unknown type of clock source for $(PLATFORM) platform)
+ endif
+
+ ifeq (, $(findstring $(HAL_ASYNC_CLOCK_SOURCE), RC_ULP RC_32K CRYSTAL_32K))
+ $(error ERROR in file Makerules: $(HAL_ASYNC_CLOCK_SOURCE) Unknown type of asynchronous clock source for $(PLATFORM) platform)
+ endif
+
+ # Set asynchronous clock as system time for platform with 32.768 kHz (RC or crystal).
+ ifneq (, $(findstring $(HAL_ASYNC_CLOCK_SOURCE), RC_32K CRYSTAL_32K))
+ SYSTEM_TIME_ON = SLEEP_TIMER
+ endif
+
+ ifeq (, $(findstring $(HAL_FREQUENCY), HAL_4MHz HAL_8MHz HAL_12MHz HAL_16MHz HAL_32MHz))
+ $(error ERROR in file Makerules: $(HAL_FREQUENCY) Unknown type of HAL frequency for $(PLATFORM) platform)
+ endif
+
+ else ifneq (, $(findstring $(HAL), ATMEGA128RFA1 ATMEGA256RFR2))
+ ifeq (, $(findstring $(HAL_FREQUENCY), HAL_16MHz HAL_8MHz HAL_4MHz))
+ $(error ERROR in file Makerules: $(HAL_FREQUENCY) Unknown type of HAL frequency for $(PLATFORM) platform)
+ endif
+
+ # For platform with 32.768 kHz only.
+ SYSTEM_TIME_ON = SLEEP_TIMER
+
+ else
+ $(error ERROR in file Makerules: $(HAL) Unknown type of HAL for $(PLATFORM) platform)
+ endif
+endif # PLATFORM_STK600
+
+ifeq ($(PLATFORM), PLATFORM_STK500_RF2XX) ####### ATML_STK500 + RF2XX radio platform ####
+ # Checking parameters.
+ ifeq (, $(findstring $(HAL_FREQUENCY), HAL_8MHz HAL_4MHz))
+ $(error ERROR in file Makerules: $(HAL_FREQUENCY) Unknown type of HAL frequency for $(PLATFORM) platform)
+ endif
+
+ ifeq (, $(findstring $(RF_EXTENDER), REB230 REB231 REB212))
+ $(error ERROR in file Makerules: $(RF_EXTENDER) Unknown type of the radio extension board for $(PLATFORM) platform)
+ endif
+
+ ifeq (, $(findstring $(HAL), ATMEGA1281 ATMEGA2561))
+ $(error ERROR in file Makerules: $(HAL) Unknown type of HAL for $(PLATFORM) platform)
+ endif
+
+ # For platform with 32.768 kHz only.
+ SYSTEM_TIME_ON = SLEEP_TIMER
+endif # PLATFORM_STK500_RF2XX
+
+
+ifeq ($(PLATFORM), PLATFORM_ZIGBIT_TURBO) #### ZIGBIT_TURBO platform ####
+ # Setting platform parameters which can not be changed by user.
+ HAL = AT91SAM7X256
+ HAL_FREQUENCY = HAL_48MHz
+
+ # Checking parameters which were set by user.
+ ifeq (, $(findstring $(HAL_CLOCK_SOURCE), CRYSTAL_18d432MHz RF))
+ $(error ERROR in file Makerules: $(HAL_CLOCK_SOURCE) Unknown clock HAL source for $(PLATFORM) platform)
+ endif
+endif # PLATFORM_ZIGBIT_TURBO
+
+
+ifeq ($(PLATFORM), PLATFORM_ZIGBIT_LAN) ###### ZIGBIT_LAN platform ####
+ # Setting platform parameters which can not be changed by user.
+ HAL = AT91SAM7X256
+ HAL_FREQUENCY = HAL_48MHz
+
+ # Checking parameters which were set by user.
+ ifeq (, $(findstring $(HAL_CLOCK_SOURCE), CRYSTAL_18d432MHz RF))
+ $(error ERROR in file Makerules: $(HAL_CLOCK_SOURCE) Unknown clock HAL source for $(PLATFORM) platform)
+ endif
+endif # PLATFORM_ZIGBIT_LAN
+
+
+ifeq ($(PLATFORM), PLATFORM_SAM7X_EK_RF2XX) ##### PLATFORM_SAM7X_EK_RF2XX platform ####
+ HAL = AT91SAM7X256
+ HAL_CLOCK_SOURCE = CRYSTAL_18d432MHz
+ HAL_FREQUENCY = HAL_48MHz
+endif # PLATFORM_SAM7X_EK_RF2XX
+
+
+ifeq ($(PLATFORM), PLATFORM_CUSTOM_1) ########### PLATFORM_CUSTOM_1 platform ####
+ HAL = AT91SAM7X256
+ HAL_CLOCK_SOURCE = CRYSTAL_8MHz
+ HAL_FREQUENCY = HAL_48MHz
+endif # PLATFORM_CUSTOM_1
+
+ifeq ($(PLATFORM), PLATFORM_CUSTOM_2) #### PLATFORM_CUSTOM_2 platform ####
+ HAL = AT91SAM7X256
+ HAL_CLOCK_SOURCE = CRYSTAL_8MHz
+ HAL_FREQUENCY = HAL_48MHz
+endif # PLATFORM_CUSTOM_2
+
+ifeq ($(PLATFORM), PLATFORM_RF231USBRD) ##### PLATFORM_RF231USBRD platform ####
+ HAL = AT91SAM3S4C
+ HAL_CLOCK_SOURCE = CRYSTAL_18d432MHz
+ HAL_ASYNC_CLOCK_SOURCE = RC_ASYNC
+ HAL_FREQUENCY = HAL_64MHz
+endif # PLATFORM_RF231USBRD
+
+ifeq ($(PLATFORM), PLATFORM_SAM3S_EK_RF2XX) ##### PLATFORM_SAM3S_EK_RF2XX platform ####
+ HAL = AT91SAM3S4C
+ # For platform with 32.768 kHz only.
+ SYSTEM_TIME_ON = SLEEP_TIMER
+endif # PLATFORM_SAM3S_EK_RF2XX
+
+ifeq ($(PLATFORM), PLATFORM_SAM3S_PIRRD) ##### PLATFORM_SAM3S_PIRRD platform ####
+ HAL = AT91SAM3S4C
+endif # PLATFORM_SAM3S_PIRRD
+
+ifeq ($(PLATFORM), PLATFORM_CUSTOM_3)
+ # AT91SAM3S4B in fact, but changes are negligible
+ HAL = AT91SAM3S4C
+ HAL_FREQUENCY = HAL_64MHz
+ HAL_CLOCK_SOURCE = CRYSTAL_16MHz
+ HAL_ASYNC_CLOCK_SOURCE = RC_ASYNC
+endif # PLATFORM_CUSTOM_3
+
+ifeq ($(PLATFORM), PLATFORM_RCB) ######### RCB platform #####
+ ifeq (, $(findstring $(PLATFORM_REV), RCB_ATMEGA128RFA1 RCB_ATMEGA256RFR2 RCB230_V31 RCB230_V32 RCB230_V331 RCB231_V402 RCB231_V411 RCB212_V532))
+ $(error ERROR in file Makerules: $(PLATFORM_REV) Unknown platform revision for PLATFORM_RCB)
+ endif
+
+ ifeq ($(PLATFORM_REV), RCB_ATMEGA128RFA1)
+ HAL = ATMEGA128RFA1
+ else ifeq ($(PLATFORM_REV), RCB_ATMEGA256RFR2)
+ HAL = ATMEGA256RFR2
+ else
+ HAL = ATMEGA1281
+ endif # PLATFORM_REV
+
+ ifeq (, $(findstring $(HAL_FREQUENCY), HAL_16MHz HAL_8MHz HAL_4MHz))
+ $(error ERROR in file Makerules: $(HAL_FREQUENCY) Unknown type of HAL frequency for $(PLATFORM) platform)
+ endif
+
+ # For platform with 32.768 kHz only.
+ SYSTEM_TIME_ON = SLEEP_TIMER
+endif # PLATFORM_RCB
+
+ifeq ($(PLATFORM), PLATFORM_AVR32_EVK1105) ##### PLATFORM_AVR32_EVK1105 platform ####
+ HAL = AT32UC3A0512
+ HAL_FREQUENCY = HAL_48MHz
+endif # PLATFORM_AVR32_EVK1105
+
+ifeq ($(PLATFORM), PLATFORM_XPLAIN) ####### XPLAIN platform ####
+ HAL = ATXMEGA128A1
+
+ # Checking parameters.
+ ifeq (, $(findstring $(HAL_CLOCK_SOURCE), CRYSTAL_16MHz RC_INTERNAL_32MHz RC_INTERNAL_2MHz))
+ $(error ERROR in file Makerules: $(HAL_CLOCK_SOURCE) Unknown type of clock source for $(PLATFORM) platform)
+ endif
+
+ # Checking parameters.
+ ifeq (, $(findstring $(HAL_ASYNC_CLOCK_SOURCE), RC_ULP RC_32K CRYSTAL_32K))
+ $(error ERROR in file Makerules: $(HAL_ASYNC_CLOCK_SOURCE) Unknown type of asynchronous clock source for $(PLATFORM) platform)
+ endif
+
+ # Set asynchronous clock as system time for platform with 32.768 kHz (RC or crystal).
+ ifneq (, $(findstring $(HAL_ASYNC_CLOCK_SOURCE), RC_32K CRYSTAL_32K))
+ SYSTEM_TIME_ON = SLEEP_TIMER
+ endif
+
+ ifeq (, $(findstring $(HAL_FREQUENCY), HAL_4MHz HAL_8MHz HAL_12MHz HAL_16MHz HAL_32MHz))
+ $(error ERROR in file Makerules: $(HAL_FREQUENCY) Unknown type of HAL frequency for $(PLATFORM) platform)
+ endif
+endif # PLATFORM_XPLAIN
+
+ifeq ($(PLATFORM), PLATFORM_REB_CBB) ####### REB CBB platform ####
+ HAL = ATXMEGA256A3
+
+ # Checking parameters.
+ ifeq (, $(findstring $(RF_EXTENDER), REB230 REB231 REB212))
+ $(error ERROR in file Makerules: $(HAL_CLOCK_SOURCE) Unknown type of the radio extension board for $(PLATFORM) platform)
+ endif
+
+ # Checking parameters.
+ ifeq (, $(findstring $(HAL_CLOCK_SOURCE), RC_INTERNAL_32MHz RC_INTERNAL_2MHz))
+ $(error ERROR in file Makerules: $(HAL_CLOCK_SOURCE) Unknown type of clock source for $(PLATFORM) platform)
+ endif
+
+ # Checking parameters.
+ ifeq (, $(findstring $(HAL_ASYNC_CLOCK_SOURCE), RC_ULP RC_32K CRYSTAL_32K))
+ $(error ERROR in file Makerules: $(HAL_ASYNC_CLOCK_SOURCE) Unknown type of asynchronous clock source for $(PLATFORM) platform)
+ endif
+
+ # Set asynchronous clock as system time for platform with 32.768 kHz (RC or crystal).
+ ifneq (, $(findstring $(HAL_ASYNC_CLOCK_SOURCE), RC_32K CRYSTAL_32K))
+ SYSTEM_TIME_ON = SLEEP_TIMER
+ endif
+
+ ifeq (, $(findstring $(HAL_FREQUENCY), HAL_4MHz HAL_8MHz HAL_12MHz HAL_16MHz HAL_32MHz))
+ $(error ERROR in file Makerules: $(HAL_FREQUENCY) Unknown type of HAL frequency for $(PLATFORM) platform)
+ endif
+endif # PLATFORM_REB_CBB
+
+ifeq ($(PLATFORM), PLATFORM_SIMULATOR) ######### Simulator platform #####
+ HAL = SIMULATOR
+ HAL_FREQUENCY = HAL_0MHz
+endif # PLATFORM_SIMULATOR
+
+#-------------------------------------------------------------------------------
+# CPU selection:
+#-------------------------------------------------------------------------------
+ifeq ($(HAL), ATMEGA1281)
+ ifeq ($(COMPILER_TYPE), GCC)
+ CPU = atmega1281
+ endif
+ ifeq ($(COMPILER_TYPE), IAR)
+ CPU = m1281
+ endif
+endif
+ifeq ($(HAL), ATMEGA2561)
+ ifeq ($(COMPILER_TYPE), GCC)
+ CPU = atmega2561
+ endif
+ ifeq ($(COMPILER_TYPE), IAR)
+ CPU = m2561
+ endif
+endif
+ifeq ($(HAL), ATMEGA1284)
+ ifeq ($(COMPILER_TYPE), GCC)
+ CPU = atmega1284p
+ endif
+ ifeq ($(COMPILER_TYPE), IAR)
+ CPU = m1284p
+ endif
+endif
+ifeq ($(HAL), AT90USB1287)
+ ifeq ($(COMPILER_TYPE), GCC)
+ CPU = at90usb1287
+ endif
+ ifeq ($(COMPILER_TYPE), IAR)
+ CPU = m1287
+ endif
+endif
+ifeq ($(HAL), ATXMEGA128A1)
+ ifeq ($(COMPILER_TYPE), GCC)
+ CPU = atxmega128a1
+ endif
+ ifeq ($(COMPILER_TYPE), IAR)
+ CPU = xm128a1
+ endif
+endif
+ifeq ($(HAL), ATXMEGA256A3)
+ ifeq ($(COMPILER_TYPE), GCC)
+ CPU = atxmega256a3
+ endif
+ ifeq ($(COMPILER_TYPE), IAR)
+ CPU = xm256a3
+ endif
+endif
+ifeq ($(HAL), ATXMEGA256D3)
+ ifeq ($(COMPILER_TYPE), GCC)
+ CPU = atxmega256d3
+ endif
+ ifeq ($(COMPILER_TYPE), IAR)
+ CPU = xm256d3
+ endif
+endif
+ifeq ($(HAL), AT91SAM7X256)
+ CPU = arm7tdmi
+endif
+ifeq ($(HAL), AT91SAM3S4C)
+ CPU = cortex-m3
+endif
+ifeq ($(HAL), ATMEGA128RFA1)
+ ifeq ($(COMPILER_TYPE), GCC)
+ CPU = atmega128rfa1
+ endif
+ ifeq ($(COMPILER_TYPE), IAR)
+ CPU = m128rfa1
+ endif
+endif
+ifeq ($(HAL), ATMEGA256RFR2)
+ ifeq ($(COMPILER_TYPE), GCC)
+ CPU = atmega256rfr2
+ endif
+ ifeq ($(COMPILER_TYPE), IAR)
+ CPU = m256rfr2
+ endif
+endif
+ifeq ($(HAL), AT32UC3A0512)
+ ifeq ($(COMPILER_TYPE), GCC)
+ CPU = ???
+ endif
+ ifeq ($(COMPILER_TYPE), IAR)
+ CPU = at32uc3a0512
+ endif
+endif
+ifeq ($(HAL), SIMULATOR)
+ CPU = simulator
+endif
+ifndef HAL
+ $(error ERROR in file Makerules: $(CPU) Unknown type of CPU)
+endif
+
+
+#-------------------------------------------------------------------------------
+# Cross-platform compiler type declaration:
+#-------------------------------------------------------------------------------
+ifndef COMPILER_TYPE
+ $(error ERROR in file Makerules: $(COMPILER_TYPE) - unknow type of compiler)
+endif
+ifneq (, $(findstring $(HAL), AT91SAM7X256 AT91SAM3S4C))
+ ifeq ($(COMPILER_TYPE), IAR)
+ CROSS_COMPILER = arm
+ endif
+ ifeq ($(COMPILER_TYPE), GCC)
+ CROSS_COMPILER = arm-none-eabi
+ endif
+endif
+ifneq (, $(findstring $(HAL), ATMEGA1281 ATMEGA2561 ATMEGA1284 AT90USB1287 ATXMEGA128A1 ATXMEGA256A3 ATXMEGA256D3 ATMEGA128RFA1 ATMEGA256RFR2))
+ CROSS_COMPILER = avr
+endif
+ifeq ($(HAL), AT32UC3A0512)
+ CROSS_COMPILER = avr32
+endif
+ifndef CROSS_COMPILER
+ #$(error ERROR in file Makerules: Cross-platform compiler type is not detected)
+endif
+
+#-------------------------------------------------------------------------------
+# Output options definitions:
+#-------------------------------------------------------------------------------
+ifeq ($(QUIET), TRUE)
+ Q = @
+ SILENT = -s
+
+ AS_MSG = @echo "$(AS)" $?
+ LD_MSG = @echo "$(LD)" $@
+ CC_MSG = @echo "$(CC)" $?
+ CPP_MSG = @echo "$(CPP)" $?
+ AR_MSG = @echo "$(AR)" $@
+ NM_MSG = @echo "$(NM)" $@
+ STRIP_MSG = @echo "$(STRIP)" $@
+ OBJCOPY_MSG = @echo "$(OBJCOPY)" $@
+ OBJDUMP_MSG = @echo "$(OBJDUMP)" $@
+ SHOW_SIZE = @echo
+else
+ SHOW_SIZE = $(SIZE)
+endif
+
+
+#-------------------------------------------------------------------------------
+# Components paths. In each component COMPONENTS_PATH should be defined:
+#-------------------------------------------------------------------------------
+ifeq ($(PLATFORM), PLATFORM_ZIGBIT_TURBO)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/arm7tdmi/at91sam7x256/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/arm7tdmi/at91sam7x256/zigBitArm
+endif
+ifeq ($(PLATFORM), PLATFORM_ZIGBIT_LAN)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/arm7tdmi/at91sam7x256/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/arm7tdmi/at91sam7x256/zigBitArm
+endif
+ifeq ($(PLATFORM), PLATFORM_SAM7X_EK_RF2XX)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/arm7tdmi/at91sam7x256/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/arm7tdmi/at91sam7x256/atmlEvalKit
+endif
+ifeq ($(PLATFORM), PLATFORM_CUSTOM_1)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/arm7tdmi/at91sam7x256/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/arm7tdmi/at91sam7x256/custom1
+endif
+ifeq ($(PLATFORM), PLATFORM_CUSTOM_2)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/arm7tdmi/at91sam7x256/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/arm7tdmi/at91sam7x256/custom2
+endif
+ifeq ($(PLATFORM), PLATFORM_SAM3S_EK_RF2XX)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/cortexm3/at91sam3s4c/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/cortexm3/at91sam3s4c/sam3sEK
+endif
+ifeq ($(PLATFORM), PLATFORM_RF231USBRD)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/cortexm3/at91sam3s4c/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/cortexm3/at91sam3s4c/Rf231UsbRd
+endif
+ifeq ($(PLATFORM), PLATFORM_SAM3S_PIRRD)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/cortexm3/at91sam3s4c/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/cortexm3/at91sam3s4c/sam3sPIRRD
+endif
+ifeq ($(PLATFORM), PLATFORM_CUSTOM_3)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/cortexm3/at91sam3s4c/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/cortexm3/at91sam3s4c/custom3
+endif
+ifeq ($(PLATFORM), PLATFORM_ZIGBIT)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/avr/atmega1281/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/avr/atmega1281/zigBit
+endif
+ifeq ($(PLATFORM), PLATFORM_RAVEN)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/avr/atmega1284/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/avr/atmega1284/raven
+endif
+ifeq ($(PLATFORM), PLATFORM_STK600)
+ ifeq ($(HAL), ATMEGA128RFA1)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/avr/atmega128rfa1/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/avr/atmega128rfa1/common
+ endif
+ ifeq ($(HAL), ATMEGA256RFR2)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/avr/atmega128rfa1/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/avr/atmega128rfa1/common
+ endif
+ ifeq ($(HAL), ATXMEGA128A1)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/xmega/atxmega128a1/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/xmega/atxmega128a1/stk600
+ endif # ATXMEGA128A1
+ ifeq ($(HAL), ATXMEGA256A3)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/xmega/atxmega256a3/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/xmega/atxmega256a3/stk600
+ endif # ATXMEGA256A3
+ ifeq ($(HAL), ATXMEGA256D3)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/xmega/atxmega256d3/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/xmega/atxmega256d3/stk600
+ endif # ATXMEGA256D3
+endif # PLATFORM_STK600
+ifeq ($(PLATFORM), PLATFORM_STK500_RF2XX)
+ ifneq (, $(findstring $(RF_EXTENDER), REB230))
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/avr/atmega1281/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/avr/atmega1281/rcb230
+ endif
+ ifneq (, $(findstring $(RF_EXTENDER), REB231 REB212))
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/avr/atmega1281/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/avr/atmega1281/rcb231_212
+ endif
+endif
+ifeq ($(PLATFORM), PLATFORM_ATML_USB_DONGLE)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/avr/at90usb1287/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/avr/at90usb1287/usbDongle
+endif
+ifeq ($(PLATFORM), PLATFORM_RCB)
+ ifneq (, $(findstring $(PLATFORM_REV), RCB_ATMEGA128RFA1 RCB_ATMEGA256RFR2))
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/avr/atmega128rfa1/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/avr/atmega128rfa1/common
+ endif
+ ifneq (, $(findstring $(PLATFORM_REV), RCB230_V31 RCB230_V32 RCB230_V331))
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/avr/atmega1281/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/avr/atmega1281/rcb230
+ endif
+ ifneq (, $(findstring $(PLATFORM_REV), RCB231_V402 RCB231_V411 RCB212_V532))
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/avr/atmega1281/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/avr/atmega1281/rcb231_212
+ endif
+endif
+ifeq ($(PLATFORM), PLATFORM_AVR32_EVK1105)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/avr32/uc32a0512/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/avr32/uc32a0512/evk1105
+endif
+ifeq ($(PLATFORM), PLATFORM_XPLAIN)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/xmega/atxmega128a1/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/xmega/atxmega128a1/xplain
+endif # PLATFORM_XPLAIN
+ifeq ($(PLATFORM), PLATFORM_REB_CBB)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/xmega/atxmega256a3/common
+ HAL_MAC_API_PATH = $(HAL_PATH)/xmega/atxmega256a3/stk600
+endif # PLATFORM_REB_CBB
+ifeq ($(PLATFORM), PLATFORM_SIMULATOR)
+ HAL_HWD_COMMON_PATH = $(HAL_PATH)/simulator
+ HAL_MAC_API_PATH = $(HAL_PATH)/simulator
+endif
+ifndef HAL_HWD_COMMON_PATH
+ $(error ERROR in file Makerules: unknown or unsupported platform)
+endif
+ifndef HAL_MAC_API_PATH
+ $(error ERROR in file Makerules: unknown or unsupported platform)
+endif
+
+#-------------------------------------------------------------------------------------
+# Stack library name definition.
+#-------------------------------------------------------------------------------------
+ifeq ($(COMPILER_TYPE), IAR)
+ LIB_NAME_COMPILER = _Iar
+endif
+ifeq ($(COMPILER_TYPE), GCC)
+ LIB_NAME_COMPILER = _Gcc
+endif
+
+ifeq ($(HAL_FREQUENCY), HAL_0MHz)
+ LIB_NAME_HAL_FREQ = _0Mhz
+else ifeq ($(HAL_FREQUENCY), HAL_4MHz)
+ LIB_NAME_HAL_FREQ = _4Mhz
+else ifeq ($(HAL_FREQUENCY), HAL_8MHz)
+ LIB_NAME_HAL_FREQ = _8Mhz
+else ifeq ($(HAL_FREQUENCY), HAL_12MHz)
+ LIB_NAME_HAL_FREQ = _12Mhz
+else ifeq ($(HAL_FREQUENCY), HAL_16MHz)
+ LIB_NAME_HAL_FREQ = _16Mhz
+else ifeq ($(HAL_FREQUENCY), HAL_18d432MHz)
+ LIB_NAME_HAL_FREQ = _18_432MHz
+else ifeq ($(HAL_FREQUENCY), HAL_32MHz)
+ LIB_NAME_HAL_FREQ = _32Mhz
+else ifeq ($(HAL_FREQUENCY), HAL_48MHz)
+ LIB_NAME_HAL_FREQ = _48Mhz
+else ifeq ($(HAL_FREQUENCY), HAL_64MHz)
+ LIB_NAME_HAL_FREQ = _64Mhz
+endif
+
+
+ifeq ($(PLATFORM), PLATFORM_ZIGBIT)
+ HAL_LIB_NAME_PLATFORM = _ZigBit
+endif
+ifeq ($(PLATFORM), PLATFORM_RAVEN)
+ HAL_LIB_NAME_PLATFORM = _Raven
+endif
+ifeq ($(PLATFORM), PLATFORM_ATML_USB_DONGLE)
+ HAL_LIB_NAME_PLATFORM = _AtmlUsbDongle
+endif
+ifeq ($(PLATFORM), PLATFORM_STK600)
+ HAL_LIB_NAME_PLATFORM = _AtmlStk600
+endif
+ifeq ($(PLATFORM), PLATFORM_STK500_RF2XX)
+ HAL_LIB_NAME_PLATFORM = _AtmlStk500Rf2xx
+endif
+ifeq ($(PLATFORM), PLATFORM_ZIGBIT_TURBO)
+ HAL_LIB_NAME_PLATFORM = _ZigBitTurbo
+endif
+ifeq ($(PLATFORM), PLATFORM_ZIGBIT_LAN)
+ HAL_LIB_NAME_PLATFORM = _ZigBitLan
+endif
+ifeq ($(PLATFORM), PLATFORM_SAM7X_EK_RF2XX)
+ HAL_LIB_NAME_PLATFORM = _Sam7xEkRf2xx
+endif
+ifeq ($(PLATFORM), PLATFORM_CUSTOM_1)
+ HAL_LIB_NAME_PLATFORM = _Custom1
+endif
+ifeq ($(PLATFORM), PLATFORM_CUSTOM_2)
+ HAL_LIB_NAME_PLATFORM = _Custom2
+endif
+ifeq ($(PLATFORM), PLATFORM_SAM3S_EK_RF2XX)
+ HAL_LIB_NAME_PLATFORM = _Sam3sEkRf2xx
+endif
+ifeq ($(PLATFORM), PLATFORM_RF231USBRD)
+ HAL_LIB_NAME_PLATFORM = _Rf231UsbRd
+endif
+ifeq ($(PLATFORM), PLATFORM_SAM3S_PIRRD)
+ HAL_LIB_NAME_PLATFORM = _Sam3sPirrd
+endif
+ifeq ($(PLATFORM), PLATFORM_CUSTOM_3)
+ HAL_LIB_NAME_PLATFORM = _Custom3
+endif
+ifeq ($(PLATFORM), PLATFORM_RCB)
+ ifeq ($(PLATFORM_REV), RCB_ATMEGA128RFA1)
+ HAL_LIB_NAME_PLATFORM = _RcbAtm128rfa1
+ else ifeq ($(PLATFORM_REV), RCB_ATMEGA256RFR2)
+ HAL_LIB_NAME_PLATFORM = _RcbAtm256rfr2
+ else
+ ifneq (, $(findstring $(PLATFORM_REV), RCB230_V31 RCB230_V32 RCB230_V331))
+ HAL_LIB_NAME_PLATFORM = _Rcb230
+ endif
+ ifneq (, $(findstring $(PLATFORM_REV), RCB231_V402 RCB231_V411 RCB212_V532))
+ HAL_LIB_NAME_PLATFORM = _Rcb231_212
+ endif
+ endif # PLATFORM_REV
+endif
+ifeq ($(PLATFORM), PLATFORM_AVR32_EVK1105)
+ HAL_LIB_NAME_PLATFORM = _Avr32Evk1105
+endif
+ifeq ($(PLATFORM), PLATFORM_XPLAIN)
+ HAL_LIB_NAME_PLATFORM = _Xplain
+endif
+ifeq ($(PLATFORM), PLATFORM_REB_CBB)
+ ifneq (, $(findstring $(RF_EXTENDER), REB230))
+ HAL_LIB_NAME_PLATFORM = _RebCbb230
+ endif
+ ifneq (, $(findstring $(RF_EXTENDER), REB231 REB212))
+ HAL_LIB_NAME_PLATFORM = _RebCbb231_212
+ endif
+endif
+ifeq ($(PLATFORM), PLATFORM_SIMULATOR)
+ HAL_LIB_NAME_PLATFORM = _Sim
+endif
+
+ifeq ($(HAL), ATMEGA1281)
+ LIB_NAME_MICRO = _Atmega1281
+endif
+ifeq ($(HAL), ATMEGA2561)
+ LIB_NAME_MICRO = _Atmega2561
+endif
+ifeq ($(HAL), ATMEGA1284)
+ LIB_NAME_MICRO = _Atmega1284
+endif
+ifeq ($(HAL), AT90USB1287)
+ LIB_NAME_MICRO = _At90usb1287
+endif
+ifeq ($(HAL), ATXMEGA128A1)
+ LIB_NAME_MICRO = _Atxmega128a1
+endif
+ifeq ($(HAL), ATXMEGA256A3)
+ LIB_NAME_MICRO = _Atxmega256a3
+endif
+ifeq ($(HAL), ATXMEGA256D3)
+ LIB_NAME_MICRO = _Atxmega256d3
+endif
+ifeq ($(HAL), ATMEGA128RFA1)
+ LIB_NAME_MICRO = _Atmega128rfa1
+endif
+ifeq ($(HAL), ATMEGA256RFR2)
+ LIB_NAME_MICRO = _Atmega256rfr2
+endif
+ifeq ($(HAL), AT91SAM7X256)
+ LIB_NAME_MICRO = _At91sam7x256
+endif
+ifeq ($(HAL), AT91SAM3S4C)
+ LIB_NAME_MICRO = _At91sam3s4c
+endif
+ifeq ($(HAL), AT32UC3A0512)
+ LIB_NAME_MICRO = _At32uc3a0512
+endif
+ifeq ($(HAL), SIMULATOR)
+ LIB_NAME_MICRO = _Sim
+endif
+
+ifeq ($(HAL_USE_AMPLIFIER), TRUE)
+ LIB_NAME_AMP = _Amp
+endif
+
+
+STACK_LIB = $(LIB_NAME_MICRO)$(LIB_NAME_COMPILER)
+
+ifndef STACK_LIB
+ $(error ERROR: Build target is not defined)
+endif
+
+include $(STACK_LIB_PATH)/Makerules$(STACK_LIB)
+
+HAL_LIB = HAL$(HAL_LIB_NAME_PLATFORM)$(LIB_NAME_MICRO)$(LIB_NAME_HAL_FREQ)$(LIB_NAME_COMPILER)$(LIB_NAME_AMP)
+
+#-------------------------------------------------------------------------------
+# Compiler flags:
+#-------------------------------------------------------------------------------
+CFLAGS += -D$(HAL)
+CFLAGS += -D$(PLATFORM)
+CFLAGS += -D$(OS)
+ifdef HAL_FREQUENCY
+ CFLAGS += -D$(HAL_FREQUENCY)
+endif
+ifdef HAL_CLOCK_SOURCE ####### For platforms with different main clock sources ####
+ CFLAGS += -D$(HAL_CLOCK_SOURCE)
+endif
+ifdef HAL_ASYNC_CLOCK_SOURCE ####### For platforms with different asyncronous clock sources ####
+ CFLAGS += -D$(HAL_ASYNC_CLOCK_SOURCE)
+endif
+ifeq ($(PLATFORM), PLATFORM_RCB) ####### RCB platform ####
+ CFLAGS += -D$(PLATFORM_REV)
+endif
+ifdef RF_EXTENDER ####### RF extension boards type for REB CBB & STK600 ####
+ CFLAGS += -D$(RF_EXTENDER)
+endif
+ifeq ($(HAL_USE_AMPLIFIER), TRUE) #### enable amplifier for zigbit platform ####
+ CFLAGS += -D_HAL_USE_AMPLIFIER_
+endif
+ifeq ($(HAL_USE_USART_ERROR_EVENT), TRUE) #### enable usart error handler ####
+ CFLAGS += -D_USE_USART_ERROR_EVENT_
+endif
+ifeq ($(HAL_RF_RX_TX_INDICATOR), TRUE) #### enable RF_RX_TX_INDICATOR ####
+ CFLAGS += -D_HAL_RF_RX_TX_INDICATOR_
+endif
+ifeq ($(HAL_ANT_DIVERSITY), TRUE) #### enable Antenna diversity ####
+ CFLAGS += -D_HAL_ANT_DIVERSITY_
+endif
+ifeq ($(HAL_USE_PIRRD_SPECIAL_SLEEP), TRUE) #### Special sleep mode for WPIRDemo application
+ CFLAGS += -D_HAL_USE_PIRRD_SPECIAL_SLEEP_
+endif
+
+#-------------------------------------------------------------------------------
+# UART HW support compiler flags.
+# AVR platforms support only UART channel 1 hardware control.
+# ARM platforms support both UART channels hardware control.
+#-------------------------------------------------------------------------------
+ifeq ($(PLATFORM), PLATFORM_ZIGBIT_LAN)
+ CFLAGS += -D_UART_0_HW_CONTROL_
+endif
+ifeq ($(PLATFORM), PLATFORM_SAM7X_EK_RF2XX)
+ CFLAGS += -D_UART_0_HW_CONTROL_
+endif
+ifeq ($(PLATFORM), PLATFORM_ZIGBIT_TURBO)
+ CFLAGS += -D_UART_0_HW_CONTROL_
+endif
+
+#-------------------------------------------------------------------------------
+# Compiler flags for debug info:
+#-------------------------------------------------------------------------------
+ifeq ($(BUILD_CONFIGURATION), DEBUG)
+ ifeq ($(COMPILER_TYPE), IAR)
+ CFLAGS += --debug
+ endif
+ ifeq ($(COMPILER_TYPE), GCC)
+ CFLAGS += -g
+ endif
+endif # DEBUG
+
+#-------------------------------------------------------------------------------
+# Check compiler version:
+#-------------------------------------------------------------------------------
+ifeq ($(COMPILER_TYPE), GCC)
+ COMPILER_VERSION = $(strip $(shell $(CC) -v 2>&1 | grep 'gcc version'))
+endif
+ifeq ($(COMPILER_TYPE), IAR)
+ COMPILER_VERSION = $(strip $(shell $(CC) | grep 'C/C++ Compiler V'))
+endif
+
+ifeq ($(COMPILER_AND_MICRO_TYPE), GCC_AVR)
+ EXP_VERSION = gcc version 4.3.3 (WinAVR 20100110)
+else ifeq ($(COMPILER_AND_MICRO_TYPE), IAR_AVR)
+ EXP_VERSION = IAR C/C++ Compiler V5.51.5.50367/W32 for Atmel AVR
+else ifeq ($(COMPILER_AND_MICRO_TYPE), GCC_ARM)
+ EXP_VERSION = gcc version 4.5.1 (GCC)
+else ifeq ($(COMPILER_AND_MICRO_TYPE), IAR_ARM)
+ EXP_VERSION = IAR ANSI C/C++ Compiler V6.21.1.52794/W32 for ARM
+else ifeq ($(COMPILER_AND_MICRO_TYPE), IAR_AVR32)
+ EXP_VERSION = IAR C/C++ Compiler V3.30.1.40051/W32 for Atmel AVR32
+else ifeq ($(COMPILER_AND_MICRO_TYPE), GCC_X86)
+ UNAME := $(shell uname)
+ ifeq ($(UNAME), Linux)
+ EXP_VERSION = gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
+ else
+ EXP_VERSION = gcc version 4.5.2 (GCC)
+ endif
+else
+ $(error unsupported COMPILER_AND_MICRO_TYPE)
+endif
+
+ifeq ($(COMPILER_TYPE), IAR)
+ COMPILER_TYPE_LOWER_CASE = _Iar
+else
+ COMPILER_TYPE_LOWER_CASE = _Gcc
+endif # COMPILER_TYPE
+
+ifeq ($(HAL), ATMEGA1281)
+ WDT_INIT_OBJ=WdtInitatmega1281$(COMPILER_TYPE_LOWER_CASE).o
+endif
+ifeq ($(HAL), ATMEGA2561)
+ WDT_INIT_OBJ=WdtInitatmega2561$(COMPILER_TYPE_LOWER_CASE).o
+endif
+ifeq ($(HAL), ATMEGA1284)
+ WDT_INIT_OBJ=WdtInitatmega1284$(COMPILER_TYPE_LOWER_CASE).o
+endif
+ifeq ($(HAL), AT90USB1287)
+ WDT_INIT_OBJ=WdtInitat90usb1287$(COMPILER_TYPE_LOWER_CASE).o
+endif
+ifeq ($(HAL), ATMEGA128RFA1)
+ WDT_INIT_OBJ=WdtInitatmega128rfa1$(COMPILER_TYPE_LOWER_CASE).o
+endif
+ifeq ($(HAL), ATMEGA256RFR2)
+ WDT_INIT_OBJ=WdtInitatmega256rfr2$(COMPILER_TYPE_LOWER_CASE).o
+endif
+ifeq ($(HAL), AT91SAM7X256)
+ ifeq ($(OS), FREE_RTOS)
+ FREE_RTOS_LIB=FreeRTOSat91sam7x256
+ endif
+ ifeq ($(COMPILER_TYPE), GCC)
+ ifeq ($(OS), FREE_RTOS)
+ BOOT_OBJ = $(LIBDIR)/FreertosBoot$(COMPILER_TYPE_LOWER_CASE).o
+ endif
+ ifeq ($(OS), NONE_OS)
+ BOOT_OBJ = $(LIBDIR)/FirmwareBoot$(COMPILER_TYPE_LOWER_CASE).o
+ endif
+ endif
+ ifeq ($(COMPILER_TYPE), IAR)
+ ifeq ($(OS), FREE_RTOS)
+ endif
+ ifeq ($(OS), NONE_OS)
+ BOOT_OBJ = $(LIBDIR)/FirmwareBoot$(COMPILER_TYPE_LOWER_CASE).o
+ endif
+ endif
+endif \ No newline at end of file
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/Makefile b/digital/zigbit/bitcloud/stack/Components/HAL/avr/Makefile
new file mode 100644
index 00000000..450e054d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/Makefile
@@ -0,0 +1,274 @@
+HAL_PATH = ..
+include $(HAL_PATH)/Makerules
+
+######
+LIBDIR = $(STACK_LIB_PATH)
+LIB = $(LIBDIR)/lib$(HAL_LIB).a
+
+ifeq ($(HAL), ATMEGA1281)
+ BUILDDIR = $(HAL_PATH)/avr/atmega1281
+endif
+
+ifeq ($(HAL), ATMEGA2561)
+ BUILDDIR = $(HAL_PATH)/avr/atmega1281
+endif
+
+ifeq ($(HAL), ATMEGA1284)
+ BUILDDIR = $(HAL_PATH)/avr/atmega1284
+endif
+
+ifeq ($(HAL), AT90USB1287)
+ BUILDDIR = $(HAL_PATH)/avr/at90usb1287
+endif
+
+ifeq ($(HAL), ATMEGA128RFA1)
+ BUILDDIR = $(HAL_PATH)/avr/atmega128rfa1
+endif
+
+#### DEFINES FLAGS #######
+CFLAGS += -DHAL_USE_ADC
+CFLAGS += -DHAL_USE_EE_READY
+# CFLAGS += -DHAL_USE_TWI
+CFLAGS += -DHAL_USE_TIMER4_COMPA
+CFLAGS += -DHAL_USE_EXT_HANDLER
+ifneq ($(HAL), AT90USB1287)
+ CFLAGS += -DHAL_USE_SLEEP
+ CFLAGS += -DHAL_USE_TIMER2_COMPA
+ CFLAGS += -DHAL_USE_WAKEUP
+endif
+ifneq ($(HAL), ATMEGA1284)
+ CFLAGS += -DHAL_USE_PWM
+endif #ATMEGA1284
+ifeq ($(HAL), AT90USB1287)
+ CFLAGS += -DHAL_USE_USB
+endif
+ifeq ($(HAL), ATMEGA128RFA1)
+ CFLAGS += -D_HAL_HW_AES_
+ CFLAGS += -DHAL_USE_SPI
+endif
+CFLAGS += -DSLEEP_PRESCALER_1024
+ifeq ($(HAL), ATMEGA1281)
+ ifeq ($(HAL_TINY_UID), TRUE)
+ CFLAGS += -D_HAL_TINY_UID_
+ endif
+endif
+
+
+##### DECLARES USART CHANNELS TO BE USED ##########
+CFLAGS += -DHAL_USE_USART
+ifneq ($(HAL), AT90USB1287)
+ CFLAGS += -DNUM_USART_CHANNELS=2
+else
+ CFLAGS += -DNUM_USART_CHANNELS=1
+endif # AT90USB1287
+
+ifneq ($(HAL), AT90USB1287)
+ CFLAGS += -DHAL_USE_USART_CHANNEL_0
+endif # AT90USB1287
+
+CFLAGS += -DHAL_USE_USART_CHANNEL_1
+
+# Defines which USART uses hardware control pins - only one port at
+# the same time can be hardware controlled. If the macros is not declared -
+# hw control is not used.
+ifeq (, $(findstring $(HAL), ATMEGA1284 AT90USB1287 ATMEGA128RFA1))
+ #CFLAGS += -DHARDWARE_CONTROL_PINS_PORT_ASSIGNMENT=USART_CHANNEL_0
+ CFLAGS += -DHW_CONTROL_PINS_PORT_ASSIGNMENT=USART_CHANNEL_1
+endif
+
+ifeq ($(SYSTEM_TIME_ON), SLEEP_TIMER)
+ CFLAGS += -D_SYSTEM_TIME_ON_SLEEP_TIMER_
+endif
+
+##### PATHS FLAGS OF INCLUDES #########
+CFLAGS += -I$(HAL_HWD_COMMON_PATH)/include
+CFLAGS += -I$(HAL_MAC_API_PATH)/include
+CFLAGS += -I$(BUILDDIR)/../../include
+CFLAGS += -I$(SE_PATH)/include
+
+#### ASM DEFINES FLAGS #######
+ASMFLAGS = -I$(HAL_HWD_COMMON_PATH)/include
+ifeq ($(COMPILER_TYPE), GCC)
+ ASMFLAGS += -mmcu=$(CPU)
+ ASM_FILE_EXT = s
+endif
+ifeq ($(COMPILER_TYPE), IAR)
+ ASMFLAGS += -s+ # Enables case sensitivity.
+ ASMFLAGS += -w+ # Enables warnings.
+ ASMFLAGS += -D$(HAL_FREQUENCY)
+ ASMFLAGS += -M'<>'# Change asm.macro argument quote chars.
+ ASMFLAGS += -L$(HAL_PATH)/avr/list # Generate a list on: <path> /<source> <.lst>
+ ASMFLAGS += -t8 # Set tab spacing.
+ ASMFLAGS += -u_enhancedCore
+ ASMFLAGS += -D__HAS_ENHANCED_CORE__=1
+ ASMFLAGS += -D__HAS_MUL__=1
+ ASMFLAGS += -D__MEMORY_MODEL__=2
+ ifneq (, $(findstring $(HAL), ATMEGA1281 ATMEGA1284 AT90USB1287 ATMEGA128RFA1))
+ ASMFLAGS += -v3 # Select processor option: Relative jumps do not wrap.
+ ifeq ($(HAL), ATMEGA1281)
+ ASMFLAGS += -D__ATmega1281__=1
+ endif
+ endif
+ ifneq (, $(findstring $(HAL), ATMEGA2561))
+ ASMFLAGS += -v5 # Select processor option: Relative jumps do not wrap.
+ ASMFLAGS += -D__ATmega2561__=1
+ endif
+ ASMFLAGS += -D__HAS_ELPM__=1
+ ASMFLAGS += -S
+ ASM_FILE_EXT = s90
+endif
+
+# Main clock of CPU in Hz.
+ifeq ($(HAL_FREQUENCY), HAL_4MHz)
+ F_CPU=4000000
+endif
+ifeq ($(HAL_FREQUENCY), HAL_8MHz)
+ F_CPU=8000000
+endif
+
+###### LIB ##########
+LIBS = $(LIB) $(LIBDIR)/$(WDT_INIT_OBJ)
+
+ifneq ($(HAL), ATMEGA1284)
+ common_hwd += halPwm
+endif
+ifneq ($(HAL), AT90USB1287)
+ common_hwd += halSleepTimerClock
+endif
+ifeq ($(HAL), AT90USB1287)
+ common_hwd += halUsb
+endif
+ifeq ($(HAL), ATMEGA128RFA1)
+ common_hwd += halSecurityModule
+ common_hwd += halDelay
+endif
+common_hwd += halAppClock
+common_hwd += halClkCtrl
+common_hwd += halUsart
+common_hwd += halIrq
+# common_hwd += i2c
+common_hwd += halEeprom
+common_hwd += wdt
+common_hwd += halSleep
+common_hwd += halAdc
+common_hwd += halSpi
+common_hwd += calibration
+common_hwd += halInit
+
+ifneq ($(HAL), ATMEGA128RFA1)
+ personal_hwd += halRfSpi
+endif
+
+personal_hwd += halRfCtrl
+personal_hwd += halUid
+personal_hwd += halMacIsr
+
+ifeq ($(HAL), ATMEGA1281)
+ ifeq ($(HAL_TINY_UID), TRUE)
+ personal_hwd += halAtmelUid
+ endif
+endif
+
+asm_hwd += halW1
+asm_hwd += halCalibration
+ifeq ($(COMPILER_TYPE), IAR)
+ asm_hwd += cstartup
+endif
+
+ifneq ($(HAL), ATMEGA1284)
+ hwi += pwm
+endif
+ifneq ($(HAL), AT90USB1287)
+ hwi += sleepTimer
+endif
+ifeq ($(HAL), AT90USB1287)
+ hwi += usb
+endif
+hwi += appTimer
+hwi += halTaskManager
+hwi += usart
+hwi += w1
+hwi += irq
+hwi += resetReason
+# hwi += i2cPacket
+hwi += eeprom
+hwi += timer
+hwi += adc
+hwi += spi
+hwi += sleep
+
+objects_hwd = $(addsuffix .o,$(addprefix $(HAL_HWD_COMMON_PATH)/objs/,$(common_hwd)))
+objects_hwd += $(addsuffix .o,$(addprefix $(HAL_MAC_API_PATH)/objs/,$(personal_hwd)))
+sources_hwd = $(addsuffix .c,$(addprefix $(HAL_HWD_COMMON_PATH)/src/,$(common_hwd)))
+sources_hwd += $(addsuffix .c,$(addprefix $(HAL_MAC_API_PATH)/src/,$(personal_hwd)))
+objects_asm_hwd = $(addsuffix .o,$(addprefix $(HAL_HWD_COMMON_PATH)/objs/,$(asm_hwd)))
+sources_asm_hwd = $(addsuffix .$(ASM_FILE_EXT),$(addprefix $(HAL_HWD_COMMON_PATH)/src/,$(asm_hwd)))
+objects_hwi = $(addsuffix .o,$(addprefix $(BUILDDIR)/../common/objs/,$(hwi)))
+sources_hwi = $(addsuffix .c,$(addprefix $(BUILDDIR)/../common/src/,$(hwi)))
+
+###### TARGETS ################
+all: component_label WdtInit $(LIB)
+
+component_label:
+ @echo
+ @echo ----------------------------------------------------
+ @echo HAL library creation.
+ @echo ----------------------------------------------------
+
+################ common part ##############################
+$(HAL_HWD_COMMON_PATH)/objs/%.o: $(HAL_HWD_COMMON_PATH)/src/%.c
+ $(CC_MSG)
+ $(Q)$(CC) $(CFLAGS) $^ -o $@
+################ common part ##############################
+
+################ personal part ##############################
+$(HAL_MAC_API_PATH)/objs/%.o: $(HAL_MAC_API_PATH)/src/%.c
+ $(CC_MSG)
+ $(Q)$(CC) $(CFLAGS) $^ -o $@
+################ personal part ##############################
+
+################ common assembler part ######################
+$(HAL_HWD_COMMON_PATH)/objs/%.o: $(HAL_HWD_COMMON_PATH)/src/%.$(ASM_FILE_EXT)
+ $(AS_MSG)
+ $(Q)$(AS) $(ASMFLAGS) -o $@ $^
+
+ifeq ($(COMPILER_TYPE), IAR)
+gen_fcpu_header:
+ @echo "FCPU EQU $(F_CPU)" > $(HAL_HWD_COMMON_PATH)/include/halIarD.h
+endif
+
+ifeq ($(COMPILER_TYPE), GCC)
+gen_fcpu_header:
+ @echo ".equ FCPU, $(F_CPU)" > $(HAL_HWD_COMMON_PATH)/include/halGccD.h
+endif
+################ common assembler part ######################
+
+################ hwi part ###################################
+$(BUILDDIR)/../common/objs/%.o: $(BUILDDIR)/../common/src/%.c
+ $(CC_MSG)
+ $(Q)$(CC) $(CFLAGS) $^ -o $@
+################ hwi part ###################################
+
+################
+WdtInit: $(HAL_HWD_COMMON_PATH)/src/halWdtInit.c
+ $(CC_MSG)
+ $(Q)$(CC) $(CFLAGS) $(HAL_HWD_COMMON_PATH)/src/halWdtInit.c -o $(LIBDIR)/$(WDT_INIT_OBJ)
+################
+$(LIB): $(objects_hwd) gen_fcpu_header $(objects_asm_hwd) $(objects_hwi)
+ $(AR_MSG)
+ $(Q)$(AR) $(AR_KEYS) $(LIB) $(objects_hwd) $(objects_asm_hwd) $(objects_hwi)
+ $(SIZE_MSG)
+ $(Q)$(SHOW_SIZE) -td $(LIBDIR)/$(WDT_INIT_OBJ)
+ $(SIZE_MSG)
+ $(Q)$(SHOW_SIZE) -td $(LIB)
+
+# $(foreach lib_iter,$(wildcard $(LIBDIR)/lib*$(STACK_LIB)*.a), $(shell $(AR) $(AR_KEYS) $(lib_iter) $(objects_hwd) $(objects_asm_hwd) $(objects_hwi)))
+################
+clean:
+ @echo
+ @echo ----------------------------------------------------
+ @echo HAL component cleaning.
+ $(Q)rm -f $(objects_hwd) $(objects_hwi) $(LIBS) $(objects_asm_hwd)
+ $(Q)rm -f $(HAL_PATH)/lib/*.a $(HAL_PATH)/lib/*.o $(HAL_PATH)/avr/list/*.*
+ @echo HAL cleaning done!
+ @echo ----------------------------------------------------
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/gpio.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/gpio.h
new file mode 100644
index 00000000..421cc4d6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/gpio.h
@@ -0,0 +1,147 @@
+/***************************************************************************//**
+ \file gpio.h
+
+ \brief Implementation of gpio defines.
+
+ \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:
+ 4/12/08 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _GPIO_H
+#define _GPIO_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+// \cond
+#include <types.h>
+// \endcond
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+/******************************************************************************
+* void gpioX_set() sets GPIOX pin to logical 1 level.
+* void gpioX_clr() clears GPIOX pin to logical 0 level.
+* void gpioX_make_in makes GPIOX pin as input.
+* void gpioX_make_in makes GPIOX pin as output.
+* uint8_t gpioX_read() returns logical level GPIOX pin.
+* uint8_t gpioX_state() returns configuration of GPIOX port.
+*******************************************************************************/
+#define HAL_ASSIGN_PIN(name, port, bit) \
+INLINE void GPIO_##name##_set() {PORT##port |= (1 << bit);} \
+INLINE void GPIO_##name##_clr() {PORT##port &= ~(1 << bit);} \
+INLINE uint8_t GPIO_##name##_read() {return (PIN##port & (1 << bit)) != 0;} \
+INLINE uint8_t GPIO_##name##_state() {return (DDR##port & (1 << bit)) != 0;} \
+INLINE void GPIO_##name##_make_out() {DDR##port |= (1 << bit);} \
+INLINE void GPIO_##name##_make_in() {DDR##port &= ~(1 << bit); PORT##port &= ~(1 << bit);} \
+INLINE void GPIO_##name##_make_pullup() {PORT##port |= (1 << bit);}\
+INLINE void GPIO_##name##_toggle() {PORT##port ^= (1 << bit);}
+
+/******************************************************************************
+ Inline static functions section
+******************************************************************************/
+// the macros for the manipulation by GPIO0
+HAL_ASSIGN_PIN(0, B, 5);
+// the macros for the manipulation by GPIO1
+HAL_ASSIGN_PIN(1, B, 6);
+// the macros for the manipulation by GPIO2
+HAL_ASSIGN_PIN(2, B, 7);
+// the macros for the manipulation by GPIO3
+HAL_ASSIGN_PIN(3, G, 0);
+// the macros for the manipulation by GPIO4
+HAL_ASSIGN_PIN(4, G, 1);
+// the macros for the manipulation by GPIO5
+HAL_ASSIGN_PIN(5, G, 2);
+// the macros for the manipulation by GPIO6
+HAL_ASSIGN_PIN(6, D, 6);
+// the macros for the manipulation by GPIO7
+HAL_ASSIGN_PIN(7, D, 7);
+// the macros for the manipulation by GPIO8
+HAL_ASSIGN_PIN(8, E, 3);
+
+// macroses only for STK500
+// the macros for the manipulation by GPIO9
+HAL_ASSIGN_PIN(9, C, 0);
+// the macros for the manipulation by GPIO10
+HAL_ASSIGN_PIN(10, C, 1);
+// the macros for the manipulation by GPIO11
+HAL_ASSIGN_PIN(11, C, 2);
+// the macros for the manipulation by GPIO12
+HAL_ASSIGN_PIN(12, C, 3);
+// the macros for the manipulation by GPIO13
+HAL_ASSIGN_PIN(13, C, 4);
+// the macros for the manipulation by GPIO14
+HAL_ASSIGN_PIN(14, C, 5);
+// the macros for the manipulation by GPIO15
+HAL_ASSIGN_PIN(15, C, 6);
+// the macros for the manipulation by GPIO16
+HAL_ASSIGN_PIN(16, C, 7);
+// macroses only for STK500
+
+// macroses only for Rcb
+// the macros for the manipulation by GPIOE2
+HAL_ASSIGN_PIN(E2, E, 2);
+// the macros for the manipulation by GPIOE3
+HAL_ASSIGN_PIN(E3, E, 3);
+// the macros for the manipulation by GPIOE4
+HAL_ASSIGN_PIN(E4, E, 4);
+// the macros for the manipulation by GPIOE5
+HAL_ASSIGN_PIN(E5, E, 5);
+// macroses only for Rcb
+
+// the macros for the manipulation by GPIO_I2C_CLK
+HAL_ASSIGN_PIN(I2C_CLK, D, 0);
+// the macros for the manipulation by GPIO_I2C_DATA
+HAL_ASSIGN_PIN(I2C_DATA, D, 1);
+// the macros for the manipulation by GPIO_USART1_TXD
+HAL_ASSIGN_PIN(USART1_TXD, D, 2);
+// the macros for the manipulation by GPIO_USART1_RXD
+HAL_ASSIGN_PIN(USART1_RXD, D, 3);
+// the macros for the manipulation by GPIO_USART1_EXTCLK
+HAL_ASSIGN_PIN(USART1_EXTCLK, D, 5);
+// the macros for the manipulation by GPIO_USART_RTS
+HAL_ASSIGN_PIN(USART_RTS, D, 4);
+// the macros for the manipulation by GPIO_USART_CTS
+HAL_ASSIGN_PIN(USART_CTS, D, 5);
+// the macros for the manipulation by GPIO_ADC_INPUT_3
+HAL_ASSIGN_PIN(ADC_INPUT_3, F, 3);
+// the macros for the manipulation by GPIO_ADC_INPUT_2
+HAL_ASSIGN_PIN(ADC_INPUT_2, F, 2);
+// the macros for the manipulation by GPIO_ADC_INPUT_1
+HAL_ASSIGN_PIN(ADC_INPUT_1, F, 1);
+// the macros for the manipulation by GPIO_BAT
+HAL_ASSIGN_PIN(BAT, F, 0);
+// the macros for the manipulation by GPIO_1WR
+HAL_ASSIGN_PIN(1WR, G, 5);
+// the macros for the manipulation by GPIO_USART_DTR
+HAL_ASSIGN_PIN(USART_DTR, E, 4);
+// the macros for the manipulation by GPIO_USART0_TXD
+HAL_ASSIGN_PIN(USART0_TXD, E, 0);
+// the macros for the manipulation by GPIO_USART0_RXD
+HAL_ASSIGN_PIN(USART0_RXD, E, 1);
+// the macros for the manipulation by GPIO_USART0_EXTCLK
+HAL_ASSIGN_PIN(USART0_EXTCLK, E, 2);
+// the macros for the manipulation by GPIO_IRQ_7
+HAL_ASSIGN_PIN(IRQ_7, E, 7);
+// the macros for the manipulation by GPIO_IRQ_6
+HAL_ASSIGN_PIN(IRQ_6, E, 6);
+
+#ifdef _HAL_USE_AMPLIFIER_
+ // the macros for the manipulation sleep power amplifier
+ HAL_ASSIGN_PIN(POW_AMPLF_SLP, C, 1);
+#endif
+
+#endif /* _GPIO_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halAdc.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halAdc.h
new file mode 100644
index 00000000..d64f6bd2
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halAdc.h
@@ -0,0 +1,68 @@
+/**************************************************************************//**
+ \file halAdc.h
+
+ \brief Declaration of hardware depended ADC interface.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALADC_H
+#define _HALADC_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <halTaskManager.h>
+#include <halFCPU.h>
+#include <adc.h>
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Initializations the ADC.
+\param[in]
+ param - pointer to parameter structure
+******************************************************************************/
+void halOpenAdc(HAL_AdcParams_t *param);
+
+/**************************************************************************//**
+\brief starts convertion on the ADC channel.
+\param[in]
+ channel - channel number.
+******************************************************************************/
+void halStartAdc(uint8_t channel);
+
+/**************************************************************************//**
+\brief Closes the ADC.
+******************************************************************************/
+void halCloseAdc(void);
+
+/******************************************************************************
+ Inline static functions section
+******************************************************************************/
+/**************************************************************************//**
+\brief SIG_ADC interrupt handler signal implementation
+******************************************************************************/
+INLINE void halSigAdcInterrupt(void)
+{
+ halPostTask3(HAL_ADC);
+}
+
+#endif /* _HALADC_H */
+
+// eof halSdc.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halAppClock.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halAppClock.h
new file mode 100644
index 00000000..47a90fac
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halAppClock.h
@@ -0,0 +1,101 @@
+/**************************************************************************//**
+ \file halAppClock.h
+
+ \brief Declarations of appTimer hardware-dependent module.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALAPPCLOCK_H
+#define _HALAPPCLOCK_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halClkCtrl.h>
+#include <halTaskManager.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+/** \brief system timer interval in ms */
+#define HAL_APPTIMERINTERVAL 10ul
+/** \brief frequency prescaler for system timer */
+#define TIMER_FREQUENCY_PRESCALER 8
+/** \brief timer counter top value */
+#define TOP_TIMER_COUNTER_VALUE ((F_CPU/1000ul) / TIMER_FREQUENCY_PRESCALER) * HAL_APPTIMERINTERVAL
+/** \brief cpu clk / 8 */
+#define HAL_CLOCK_SELECTION_MASK (1 << CS11)
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Initialization appTimer clock.
+******************************************************************************/
+void halInitAppClock(void);
+
+/**************************************************************************//**
+\brief Synchronization system time which based on application timer.
+******************************************************************************/
+void halAppSystemTimeSynchronize(void);
+
+/**************************************************************************//**
+\brief Return time of sleep timer.
+
+\return
+ time in ms.
+******************************************************************************/
+uint32_t halGetTimeOfAppTimer(void);
+
+/**************************************************************************//**
+\brief Return system time in us
+
+\param[out]
+ mem - memory for system time
+******************************************************************************/
+void halGetSystemTimeUs(uint64_t *mem);
+
+/**************************************************************************//**
+\brief Takes account of the sleep interval.
+
+\param[in]
+ interval - time of sleep
+******************************************************************************/
+void halAdjustSleepInterval(uint32_t interval);
+
+/******************************************************************************
+ Inline static functions prototypes section.
+******************************************************************************/
+/**************************************************************************//**
+\brief Enables appTimer clock.
+******************************************************************************/
+INLINE void halStartAppClock(void)
+{
+ TCCR4B |= HAL_CLOCK_SELECTION_MASK;
+}
+
+/**************************************************************************//**
+\brief Disables appTimer clock.
+******************************************************************************/
+INLINE void halStopAppClock(void)
+{
+ TCCR4B &= ~HAL_CLOCK_SELECTION_MASK; // stop the timer
+}
+
+#endif /*_HALAPPCLOCK_H*/
+
+// eof halAppClock.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halAssert.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halAssert.h
new file mode 100644
index 00000000..92e0497f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halAssert.h
@@ -0,0 +1,108 @@
+/**************************************************************************//**
+ \file halAssert.h
+
+ \brief Implementation of avr assert algorithm.
+
+ \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:
+ 18/08/08 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALASSERT_H
+#define _HALASSERT_H
+
+#ifdef __IAR_SYSTEMS_ICC__
+#ifndef _SYSTEM_BUILD
+#pragma system_include
+#endif
+#endif
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halClkCtrl.h>
+#include <wdtCtrl.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define DELAY_VALUE 0x000000ul
+
+#ifdef _SYS_ASSERT_ON_
+
+#if defined(_HAL_ASSERT_INTERFACE_UART0_)
+ #define UBRRNH UBRR0H
+ #define UBRRNL UBRR0L
+ #define UCSRNA UCSR0A
+ #define UCSRNB UCSR0B
+ #define UCSRNC UCSR0C
+ #define UDRN UDR0
+#elif defined(_HAL_ASSERT_INTERFACE_UART1_)
+ #define UBRRNH UBRR1H
+ #define UBRRNL UBRR1L
+ #define UCSRNA UCSR1A
+ #define UCSRNB UCSR1B
+ #define UCSRNC UCSR1C
+ #define UDRN UDR1
+#else
+ #error " Unknown assert interface "
+#endif
+
+/******************************************************************************
+ Inline static functions section
+******************************************************************************/
+INLINE void halAssert(uint8_t condition, uint16_t dbgCode)
+{
+ if (!condition)
+ {
+ uint32_t delay;
+
+ HAL_StopWdt();
+ asm("cli");
+ DDRB |= 0xE0;
+ /* Init UART */
+ UBRRNH = 0;
+ if (4000000ul == HAL_ReadFreq())
+ UBRRNL = 12;
+ else
+ UBRRNL = 25;
+ UCSRNA = (1 << U2X1);
+ UCSRNB = (1 << TXEN1);
+ UCSRNC = (3 << UCSZ10);
+ while(1)
+ {
+ PORTB &= ~0xE0;
+ /* Send high byte of message to UART */
+ while (!(UCSRNA & (1 << UDRE1)));
+ UDRN = (dbgCode >> 8);
+ /* Send low byte of message to UART */
+ while (!(UCSRNA & (1 << UDRE1)));
+ UDRN = dbgCode;
+ delay = DELAY_VALUE;
+ while (delay--);
+
+ PORTB |= 0xE0;
+ delay = (DELAY_VALUE / 2);
+ while(delay--);
+ }
+ }
+}
+
+#else /* _SYS_ASSERT_ON_ */
+ #define halAssert(condition, dbgCode)
+#endif /* _SYS_ASSERT_ON_ */
+
+#endif /* _HALASSERT_H */
+
+// eof halAssert.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halAtomic.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halAtomic.h
new file mode 100644
index 00000000..245abf6f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halAtomic.h
@@ -0,0 +1,57 @@
+/**************************************************************************//**
+ \file halAtomic.h
+
+ \brief Implementation of atomic sections.
+
+ \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:
+ 29/05/07 E. Ivanov - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALATOMIC_H
+#define _HALATOMIC_H
+
+#include <types.h>
+
+typedef uint8_t atomic_t;
+
+/******************************************************************************
+Saves global interrupt bit. Disables global interrupt.
+Parameters:
+ none.
+Returns:
+ none.
+******************************************************************************/
+INLINE atomic_t halStartAtomic(void)
+{
+ atomic_t result = SREG;
+ cli();
+ return result;
+}
+
+/******************************************************************************
+Restores global interrupt.
+Parameters:
+ none.
+Returns:
+ none.
+******************************************************************************/
+INLINE void halEndAtomic(atomic_t sreg)
+{
+ SREG = sreg;
+}
+
+#endif /* _HALATOMIC_H */
+// eof atomic.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halClkCtrl.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halClkCtrl.h
new file mode 100644
index 00000000..6bc7a11d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halClkCtrl.h
@@ -0,0 +1,70 @@
+/**************************************************************************//**
+ \file halClkCtrl.h
+
+ \brief Declarations of clock control hardware-dependent module.
+
+ \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:
+ 29/05/07 E. Ivanov - Created
+ 16/04/09 A. Khromykh - Refactored
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALCLKCTRL_H
+#define _HALCLKCTRL_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <halFCPU.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/**************************************************************************//**
+\brief Possible clock source
+******************************************************************************/
+typedef enum
+{
+ INTERNAL_RC,
+ OTHER_SOURCE
+} ClkSource_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Initialization system clock.
+******************************************************************************/
+void halInitFreq(void);
+
+/**************************************************************************//**
+\brief Return clock source
+
+\return
+ clock source.
+******************************************************************************/
+ClkSource_t halGetClockSource(void);
+
+/**************************************************************************//**
+\brief System clock.
+
+\return
+ system clock in Hz.
+******************************************************************************/
+uint32_t HAL_ReadFreq(void);
+
+#endif /* _HALCLKCTRL_H */
+
+// eof halClkCtrl.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halDbg.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halDbg.h
new file mode 100644
index 00000000..def330ba
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halDbg.h
@@ -0,0 +1,95 @@
+/***************************************************************************//**
+ \file halDbg.h
+
+ \brief Declarations of hal , bsb mistake interface.
+
+ \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:
+ 09/11/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALDBG_H
+#define _HALDBG_H
+
+#include <dbg.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+enum
+{
+ APPTIMER_MISTAKE = 0x2000,
+ INCORRECT_EEPROM_ADDRESS = 0x2001,
+ MEMORY_CANNOT_WRITE = 0x2002,
+ USARTC_HALUSARTRXBUFFERFILLER_0 = 0x2003,
+ USARTC_HALSIGUSARTTRANSMISSIONCOMPLETE_0 = 0x2004,
+ USARTC_HALSIGUSARTRECEPTIONCOMPLETE_0 = 0x2005,
+ HALUSARTH_HALCLOSEUSART_0 = 0X2006,
+ HALUSARTH_HALENABLEUSARTDREMINTERRUPT_0 = 0X2007,
+ HALUSARTH_HALDISABLEUSARTDREMINTERRUPT_0 = 0X2008,
+ HALUSARTH_HALENABLEUSARTTXCINTERRUPT_0 = 0X2009,
+ HALUSARTH_HALDISABLEUSARTTXCINTERRUPT_0 = 0X200A,
+ HALUSARTH_HALENABLEUSARTRXCINTERRUPT_0 = 0X200B,
+ HALUSARTH_HALDISABLEUSARTRXCINTERRUPT_0 = 0X200C,
+ HALUSARTH_HALSENDUSARTBYTE_0 = 0X200D,
+ USARTC_HALUSARTSAVEERRORREASON = 0x200E,
+ USARTC_HALSIGUSARTERROROCCURED_0 = 0x200F,
+ USARTC_HALUNKNOWNERRORREASON_0 = 0x2010,
+
+ HAL_USART_TX_EMPTY_LIMIT = 0x2FDB,
+ HAL_USART_TRANS_COMPLETE_LIMIT = 0x2FDC,
+ HAL_USART_HW_CONTROLLER_LIMIT = 0x2FDD,
+ HAL_SLEEP_TIMER_SYNCHRONIZE_LIMIT = 0x2FDE,
+ HAL_GET_SLEEP_TIME_LIMIT = 0x2FDF,
+ HALISR_EEPROM_WRITE_TIME_LIMIT = 0x2FE0,
+ HAL_APP_TIMER_SYNCHRONIZE_LIMIT = 0x2FE1,
+ HALISR_INT5_VECT_TIME_LIMIT = 0x2FE2,
+ HALISR_ADC_TIME_LIMIT = 0x2FE3,
+ HALISR_TIMER4_COMPA_TIME_LIMIT = 0x2FE4,
+ HALATOM_SETLOWFUSES_TIME_LIMIT = 0x2FE5,
+ HALATOM_INITFREQ_TIME_LIMIT = 0x2FE6,
+ HALISR_EEPROM_READY_TIME_LIMIT = 0x2FE7,
+ HALISR_INT6_VECT_TIME_LIMIT = 0x2FE8,
+ HALISR_INT7_VECT_TIME_LIMIT = 0x2FE9,
+ HALISR_TIMER2_COMPA_TIME_LIMIT = 0x2FEA,
+ HALISR_TIMER2_OVF_TIME_LIMIT = 0x2FEB,
+ HALISR_USART0_UDR_TIME_LIMIT = 0x2FEC,
+ HALISR_USART0_TX_TIME_LIMIT = 0x2FED,
+ HALISR_USART0_RX_TIME_LIMIT = 0x2FEE,
+ HALISR_USART1_UDRE_TIME_LIMIT = 0x2FEF,
+ HALISR_USART1_TX_TIME_LIMIT = 0x2FF0,
+ HALISR_USART1_RX_TIME_LIMIT = 0x2FF1,
+ HALISR_INT4_TIME_LIMIT = 0x2FF2,
+ HALISR_TWI_TIME_LIMIT = 0x2FF3,
+ HALATOM_STARTWDT_TIME_LIMIT = 0x2FF4,
+ HALISR_WDT_TIME_LIMIT = 0x2FF5,
+ HALATOM_WRITEBYTE_RFSPI_TIME_LIMIT = 0x2FF6,
+ HALISR_TIMER3_COMPA_TIME_LIMIT = 0x2FF7,
+ HALISR_PHYDISPATCH_RFINT_TIME_LIMIT = 0x2FF8,
+ HALATOM_GETTIME_OF_APPTIMER_1_TIME_LIMIT = 0x2FF9,
+ HALATOM_GETTIME_OF_APPTIMER_2_TIME_LIMIT = 0x2FFA,
+ HALATOM_GETTIME_OF_APPTIMER_3_TIME_LIMIT = 0x2FFB,
+ HALATOM_WRITE_USART_TIME_LIMIT = 0x2FFC,
+ HALATOM_READ_USART_TIME_LIMIT = 0x2FFD,
+ HALATOM_USART_RX_COMPLETE_TIME_LIMIT = 0x2FFE,
+ HALATOM_CLEAR_TIME_CONTROL_TIME_LIMIT = 0x2FFF
+};
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+#endif /* _HALDBG_H */
+
+// eof halDbg.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halDiagnostic.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halDiagnostic.h
new file mode 100644
index 00000000..53fb0302
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halDiagnostic.h
@@ -0,0 +1,51 @@
+/**************************************************************************//**
+ \file halDiagnostic.h
+
+ \brief Implementation of diagnostics defines.
+
+ \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:
+ 20/05/09 D. Kasyanov - Created
+ ******************************************************************************/
+
+#ifndef _HALDIAGNOSTIC_H
+#define _HALDIAGNOSTIC_H
+
+#include <halFCPU.h>
+#include <halDbg.h>
+
+#if defined (MEASURE)
+ #define TCNT5_ACCESS_TIME 8
+ #define DEFALUT_TIME_LIMIT 100
+ #define TIMER3_COMPA_TIME_LIMIT 150
+ #define PHYDISPATCH_RFINT_TIME_LIMIT 210
+
+ #define BEGIN_MEASURE { \
+ uint16_t timeLimit = DEFALUT_TIME_LIMIT; \
+ uint16_t start = TCNT5; uint16_t offset;
+
+ #define END_MEASURE(code) offset = (TCNT5 - start - TCNT5_ACCESS_TIME) / (F_CPU/1000000ul); \
+ if (HALISR_TIMER3_COMPA_TIME_LIMIT == code) timeLimit = TIMER3_COMPA_TIME_LIMIT; \
+ if (HALISR_PHYDISPATCH_RFINT_TIME_LIMIT == code) timeLimit = PHYDISPATCH_RFINT_TIME_LIMIT; \
+ if (timeLimit != 0) { \
+ if (offset > timeLimit) { \
+ TCCR5B = 0; TCNT5 = offset; assert(0,code); \
+ } \
+ } \
+ }
+
+#else
+ #define BEGIN_MEASURE
+ #define END_MEASURE(code)
+#endif
+
+
+#endif /* _HALDIAGNOSTIC_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halEeprom.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halEeprom.h
new file mode 100644
index 00000000..0ca06bfb
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halEeprom.h
@@ -0,0 +1,87 @@
+/**************************************************************************//**
+ \file halEeprom.h
+
+ \brief Provides interface for the access to hardware dependent
+ EEPROM module.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALEEPROM_H
+#define _HALEEPROM_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halTaskManager.h>
+#include <eeprom.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+/** \brief the mask to rise interrupt when operation on EEPROM was completed */
+#define HAL_EEPROM_WRITE_MASK_INT (1 << EEMPE | 1 << EERIE)
+#define HAL_EEPROM_WRITE_MASK (1 << EEMPE)
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Writes a byte to EEPROM.
+\param[in]
+ EECRMask - mask that define capability of interrupt after byte writing.
+\param[in]
+ address - address of byte
+\param[in]
+ data - data.
+******************************************************************************/
+void halEepromWrite(uint8_t EECRMask, uint16_t address, uint8_t data);
+
+/******************************************************************************
+ Inline static functions section
+******************************************************************************/
+/**************************************************************************//**
+\brief Waits completion of previous operation.
+******************************************************************************/
+INLINE void halWaitEepromReady(void)
+{
+ while (EECR & (1 << EEPE)); // wait for completion of previous write
+}
+
+/**************************************************************************//**
+\brief Reads byte from EEPROM.
+\param[in]
+ address -address of byte.
+\return
+ a read byte.
+******************************************************************************/
+INLINE uint8_t halReadEeprom(uint16_t address)
+{
+ EEAR = address;
+ EECR |= (1 << EERE);
+ return EEDR;
+}
+
+/**************************************************************************//**
+\brief Posts the task to taskhandler that "EEPROM ready"
+ interrupt has occured.
+******************************************************************************/
+INLINE void halSigEepromReadyInterrupt(void)
+{
+ halPostTask3(HAL_EE_READY);
+}
+#endif /*_HALEEPROM_H*/
+//eof halEeprom.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halFCPU.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halFCPU.h
new file mode 100644
index 00000000..fe961e60
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halFCPU.h
@@ -0,0 +1,36 @@
+/**************************************************************************//**
+ \file halFCPU.h
+
+ \brief Declaration F_CPU for C code.
+
+ \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:
+ 6/10/08 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+/* Main clock of CPU in Hz. */
+#if defined(HAL_3d6864MHz)
+ #define F_CPU 3686400
+#elif defined(HAL_4MHz)
+ #define F_CPU 4000000
+#elif defined(HAL_7d3728MHz)
+ #define F_CPU 7372800
+#elif defined(HAL_8MHz)
+ #define F_CPU 8000000
+#endif
+
+// eof halFCPU.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halInit.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halInit.h
new file mode 100644
index 00000000..b68aac65
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halInit.h
@@ -0,0 +1,31 @@
+/**************************************************************************//**
+ \file halInit.h
+
+ \brief HAL start up module interface.
+
+ \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:
+ 29/06/07 E. Ivanov - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALINIT_H
+#define _HALINIT_H
+/******************************************************************************
+ Performs start up HAL initialization.
+******************************************************************************/
+void HAL_Init(void);
+
+#endif /* _HALINIT_H */
+
+// eof halInit.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halInterrupt.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halInterrupt.h
new file mode 100644
index 00000000..03300064
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halInterrupt.h
@@ -0,0 +1,36 @@
+/**************************************************************************//**
+ \file halInterrupt.h
+
+ \brief Macroses to manipulate global interrupts.
+
+ \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:
+ 29/05/07 E. Ivanov - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALINTERRUPT_H
+#define _HALINTERRUPT_H
+
+/******************************************************************************
+Enables global interrupt.
+******************************************************************************/
+#define HAL_EnableInterrupts() sei()
+
+/******************************************************************************
+Disables global interrupt.
+******************************************************************************/
+#define HAL_DisableInterrupts() cli()
+
+#endif /* _HALINTERRUPT_H */
+// eof halInterrupt.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halIrq.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halIrq.h
new file mode 100644
index 00000000..687447a3
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halIrq.h
@@ -0,0 +1,99 @@
+/***************************************************************************//**
+ \file halIrq.h
+
+ \brief Declaration of HWD IRQ interface.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALIRQ_H
+#define _HALIRQ_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <halTaskManager.h>
+#include <irq.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#if defined(PLATFORM_ZIGBIT)
+ #define MAX_NUM_LINES 2
+ #define MIN_VALID_IRQ_NUMBER IRQ_6
+#else
+ #define MAX_NUM_LINES 3
+ #define MIN_VALID_IRQ_NUMBER IRQ_5
+#endif
+/** \brief number valid interrupt. */
+#define HAL_NUM_IRQ_LINES MAX_NUM_LINES
+/** \brief first valid interrupt. */
+#define HAL_FIRST_VALID_IRQ MIN_VALID_IRQ_NUMBER
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** \brief user's callback type. */
+typedef void (* IrqCallback_t)(void);
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Sets configuration of pins and the registers.
+\param[in]
+ irqNumber - number of interrupt.
+\param[in]
+ irqMode - mode of interrupt.
+******************************************************************************/
+void halSetIrqConfig(uint8_t irqNumber, uint8_t irqMode);
+
+/**************************************************************************//**
+\brief Clears configuration of pins and the registers.
+\param[in]
+ irqNumber - number of interrupt.
+******************************************************************************/
+void halClrIrqConfig(uint8_t irqNumber);
+
+/******************************************************************************
+ Inline static functions section
+******************************************************************************/
+/**************************************************************************//**
+\brief Enables external interrupt
+\param[in]
+ irqNumber - number of external interrupt.
+******************************************************************************/
+INLINE void halEnableIrqInterrupt(uint8_t irqNumber)
+{
+ // Enable external interrupt request
+ EIMSK |= (1 << irqNumber);
+}
+
+/**************************************************************************//**
+\brief Disables external interrupt
+\param[in]
+ irqNumber - number of external interrupt.
+******************************************************************************/
+INLINE void halDisableIrqInterrupt(uint8_t irqNumber)
+{
+ // Disable external interrupt request
+ EIMSK &= ~(1 << irqNumber);
+}
+
+#endif /* _HALIRQ_H */
+//eof halirq.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halPwm.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halPwm.h
new file mode 100644
index 00000000..6c026ce0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halPwm.h
@@ -0,0 +1,199 @@
+/**************************************************************************//**
+ \file halPwm.h
+
+ \brief Declaration of hardware depended PWM interface.
+
+ \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:
+ 10/11/08 A. Taradov - Created
+ 5/04/11 A.Razinkov - Refactored
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALPWM_H
+#define _HALPWM_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <gpio.h>
+#include <pwm.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+/* Waveform Generation Mode bits position. PWM module independent. */
+#define WGMn0 0
+#define WGMn1 1
+#define WGMn2 3
+#define WGMn3 4
+
+/* Force Output Compare bits position. PWM module independent. */
+#define FOCnA 7
+#define FOCnB 6
+#define FOCnC 5
+
+/* Clock Select bits position. PWM module independent. */
+#define CSn0 0
+#define CSn1 1
+#define CSn2 2
+
+/* Compare Output Mode bits position. PWM module independent. */
+#define COMnA0 6
+#define COMnA1 7
+#define COMnB0 4
+#define COMnB1 5
+#define COMnC0 2
+#define COMnC1 3
+
+/* PWN unit base channel pins position. PWM module dependent. */
+#define PWM_UNIT_1_BASE_CHANNEL_PIN PB5
+#define PWM_UNIT_3_BASE_CHANNEL_PIN PE3
+
+/* Force Output Compare base bit. PWM module independent. */
+#define FOCNX_BASE_BIT FOCnA
+/* Compare Output Mode base bit number. PWM module independent. */
+#define COMNX0_BASE_BIT COMnA0
+/* Compare Output Mode bitfield size. PWM module and channel independent. */
+#define COMNX_BITFIELD_SIZE 2
+/* Compare Output Mode low bit number. PWM module independent. */
+#define COMnx0(descriptor) ((descriptor)->service.COMnx0)
+/* Compare Output Mode high bit number. PWM module independent. */
+#define COMnx1(descriptor) ((descriptor)->service.COMnx0 + 1)
+/* Output Compare Register. PWM module and channel dependent. */
+#define OCRnx(descriptor) (*((descriptor)->service.OCRnx))
+/* Data Direction Rregister. PWM module dependent. */
+#define DDRn(descriptor) (*((descriptor)->service.DDRn))
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Initializes the PWM.
+
+\param [in] pwmUnit - PWM unit number.
+ Equal to ID of Timer/Counter witch serves PWM module.
+******************************************************************************/
+void halOpenPwm(HAL_PwmUnit_t pwmUnit);
+
+/**************************************************************************//**
+\brief Starts PWM on specified channel.
+
+\param [in] descriptor - PWM channel descriptor.
+******************************************************************************/
+void halStartPwm(HAL_PwmDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Stops PWM on specified channel.
+
+\param [in] descriptor - PWM channel descriptor.
+******************************************************************************/
+void halStopPwm(HAL_PwmDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Sets base frequency of module. Common for all module channels.
+
+\param [in] pwmUnit - PWM unit number. Equal to corresponding Timer/Counter ID.
+\param [in] top - value for the TOP register.
+\param [in] prescaler - clock prescaler.
+******************************************************************************/
+void halSetPwmFrequency(HAL_PwmUnit_t pwmUnit, uint16_t top, HAL_PwmPrescaler_t prescaler);
+
+/**************************************************************************//**
+\brief Sets compare value for the PWM channel.
+
+\param [in] descriptor - PWM channel descriptor.
+******************************************************************************/
+void halSetPwmCompareValue(HAL_PwmDescriptor_t *descriptor, uint16_t cmpValue);
+
+/**************************************************************************//**
+\brief Closes the PWM.
+
+\param [in] pwmUnit - PWM unit number.
+ Equal to ID of Timer/Counter witch serves PWM module.
+******************************************************************************/
+void halClosePwm(HAL_PwmUnit_t pwmUnit);
+
+/**************************************************************************//**
+\brief Prepare PWM channel access. Determine control registers, ports, pins etc.
+
+\param [in] descriptor - PWM channel descriptor.
+******************************************************************************/
+void halPreparePwmChannelAccess(HAL_PwmDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Configure corresponding pin as PWM out.
+
+\param [in] descriptor - PWM channel descriptor.
+******************************************************************************/
+static inline void halMakeOutPwmPin(HAL_PwmDescriptor_t *descriptor)
+{
+ DDRn(descriptor) |=
+ (1 << (descriptor->service.pwmBaseChannelPin + descriptor->channel));
+}
+
+/**************************************************************************//**
+\brief Configure corresponding PWM output pin as in.
+
+\param [in] descriptor - PWM channel descriptor.
+******************************************************************************/
+static inline void halMakeInPwmPin(HAL_PwmDescriptor_t *descriptor)
+{
+ DDRn(descriptor) &=
+ ~(1 << (descriptor->service.pwmBaseChannelPin + descriptor->channel));
+}
+
+/**************************************************************************//**
+\brief Perform two-step writing to 16-bit registers with special access rule:
+ TCNTn, OCRnA/B/C, ICRn.
+
+\param [in] reg - register address.
+\param [in] word - word to move.
+******************************************************************************/
+static inline void halMoveWordToRegister(volatile uint16_t *reg, uint16_t word)
+{
+ATOMIC_SECTION_ENTER
+ /* High byte writing */
+ *((volatile uint8_t*)(reg) + 1) = (uint8_t)(word >> 8);
+ /* Low byte writing */
+ *(volatile uint8_t*)(reg) = (uint8_t)(word);
+ATOMIC_SECTION_LEAVE
+}
+
+/**************************************************************************//**
+\brief Perform two-step reading of 16-bit registers with special access rule:
+ TCNTn, OCRnA/B/C, ICRn.
+
+\param [in] reg - register address.
+
+\return register value
+******************************************************************************/
+static inline uint16_t halReadWordFromRegister(volatile uint16_t *reg)
+{
+ uint16_t word;
+ATOMIC_SECTION_ENTER
+ /* Low byte reading */
+ word = *(volatile uint8_t*)(reg);
+ /* High byte reading */
+ word |= ((uint16_t)(*((volatile uint8_t*)(reg) + 1)) << 8);
+ATOMIC_SECTION_LEAVE
+ return word;
+}
+
+#endif /* _HALPWM_H */
+
+// eof halPwm.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halSleep.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halSleep.h
new file mode 100644
index 00000000..c82c1a09
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halSleep.h
@@ -0,0 +1,73 @@
+/**************************************************************************//**
+ \file halSleep.h
+
+ \brief Interface to control sleep mode.
+
+ \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:
+ 1/12/09 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALSLEEP_H
+#define _HALSLEEP_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <sleep.h>
+#include <sleepTimer.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+#define HAL_ACTIVE_MODE 0
+#define HAL_SLEEP_MODE 1
+#define HAL_SLEEP_TIMER_IS_STOPPED 0
+#define HAL_SLEEP_TIMER_IS_STARTED 1
+#define HAL_SLEEP_TIMER_IS_WAKEUP_SOURCE 0
+#define HAL_EXT_IRQ_IS_WAKEUP_SOURCE 1
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef struct
+{
+ HAL_WakeUpCallback_t callback;
+ HAL_SleepTimer_t sleepTimer;
+ uint8_t wakeupStation : 1;
+ uint8_t wakeupSource : 1;
+ uint8_t sleepTimerState : 1;
+} HalSleepControl_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Switch on system power.
+
+\param[in]
+ wakeupSource - wake up source
+******************************************************************************/
+void halPowerOn(const uint8_t wakeupSource);
+
+/*******************************************************************************
+ Shutdown system.
+ NOTES:
+ the application should be sure the poweroff will not be
+ interrupted after the execution of the sleep().
+*******************************************************************************/
+void halPowerOff(void);
+
+#endif /* _HALSLEEP_H */
+// eof halSleep.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halSleepTimerClock.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halSleepTimerClock.h
new file mode 100644
index 00000000..36ab9849
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halSleepTimerClock.h
@@ -0,0 +1,146 @@
+/**************************************************************************//**
+ \file halSleepTimerClock.h
+
+ \brief Definition for count out requested sleep interval.
+
+ \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:
+ 29/06/07 E. Ivanov - Created
+ 7/04/09 A. Khromykh - Refactored
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALSLEEPTIMERCLOCK_H
+#define _HALSLEEPTIMERCLOCK_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <halTaskManager.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define SLEEPTIMER_CLOCK 32768lu
+
+#if defined(SLEEP_PRESCALER_1)
+ #define SLEEPTIMER_DIVIDER 1ul
+ #define SLEEPTIMER_PRESCALER (1u << CS20) // No prescaling
+#elif defined(SLEEP_PRESCALER_8)
+ #define SLEEPTIMER_DIVIDER 8ul
+ #define SLEEPTIMER_PRESCALER (1u << CS21) // clk/8
+#elif defined(SLEEP_PRESCALER_32)
+ #define SLEEPTIMER_DIVIDER 32ul
+ #define SLEEPTIMER_PRESCALER ((1u << CS20) | (1u << CS21)) // clk/32
+#elif defined(SLEEP_PRESCALER_64)
+ #define SLEEPTIMER_DIVIDER 64ul
+ #define SLEEPTIMER_PRESCALER (1u << CS22) // clk/64
+#elif defined(SLEEP_PRESCALER_128)
+ #define SLEEPTIMER_DIVIDER 128ul
+ #define SLEEPTIMER_PRESCALER ((1u << CS20) | (1u << CS22)) // clk/128
+#elif defined(SLEEP_PRESCALER_256)
+ #define SLEEPTIMER_DIVIDER 256ul
+ #define SLEEPTIMER_PRESCALER ((1u << CS21) | (1u << CS22)) // clk/256
+#elif defined(SLEEP_PRESCALER_1024)
+ #define SLEEPTIMER_DIVIDER 1024ul
+ #define SLEEPTIMER_PRESCALER ((1u << CS20) | (1u << CS21) | (1u << CS22)) // clk/1024
+#endif
+
+#define HAL_ASSR_FLAGS ((1 << TCN2UB) | (1 << OCR2AUB) | (1 << OCR2BUB) | (1 << TCR2AUB) | (1 << TCR2BUB))
+// to write some value for correct work of the asynchronous timer
+#define SOME_VALUE_FOR_SYNCHRONIZATION 0x44
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+Starts the sleep timer clock.
+******************************************************************************/
+void halStartSleepTimerClock(void);
+
+/******************************************************************************
+Stops the sleep timer clock.
+******************************************************************************/
+void halStopSleepTimerClock(void);
+
+/******************************************************************************
+Sets interval.
+Parameters:
+ value - contains number of ticks which the timer must count out.
+Returns:
+ none.
+******************************************************************************/
+void halSetSleepTimerInterval(uint32_t value);
+
+/******************************************************************************
+Returns the sleep timer frequency in Hz.
+Parameters:
+ none.
+Returns:
+ the sleep timer frequency in Hz.
+******************************************************************************/
+uint32_t halSleepTimerFrequency(void);
+
+/**************************************************************************//**
+\brief Clear timer control structure
+******************************************************************************/
+void halClearTimeControl(void);
+
+/**************************************************************************//**
+\brief Wake up procedure for all external interrupts
+******************************************************************************/
+void halWakeupFromIrq(void);
+
+/**************************************************************************//**
+\brief Get time of sleep timer.
+
+\return
+ time in ms.
+******************************************************************************/
+uint32_t halGetTimeOfSleepTimer(void);
+
+/******************************************************************************
+ Inline static functions section
+******************************************************************************/
+/******************************************************************************
+Disables the sleep timer interrupt.
+Parameters:
+ none.
+Returns:
+ none.
+******************************************************************************/
+INLINE void halDisableSleepTimerInt(void)
+{
+ // Disables 8-bit Timer/Counter2 compare channel A and overflow interrupt
+ TIMSK2 &= (~(1 << OCIE2A) & ~(1 << TOIE2));
+}
+
+/******************************************************************************
+ Interrupt handler signal implementation
+******************************************************************************/
+INLINE void halInterruptSleepClock(void)
+{
+ halPostTask0(HAL_ASYNC_TIMER);
+}
+
+/******************************************************************************
+ Interrupt handler signal implementation
+******************************************************************************/
+INLINE void halSynchronizeSleepTime(void)
+{
+ halPostTask0(HAL_SYNC_SLEEP_TIME);
+}
+
+#endif /* _HALSLEEPTIMERCLOCK_H */
+// eof halSleepTimerClock.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halSpi.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halSpi.h
new file mode 100644
index 00000000..59ab72c8
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halSpi.h
@@ -0,0 +1,180 @@
+/*****************************************************************************//**
+\file halSpi.h
+
+\brief Declarations of USART SPI mode.
+
+\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:
+ 29/06/07 E. Ivanov - Created
+**********************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+#ifndef _HALSPI_H
+#define _HALSPI_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <usart.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define SPI_CHANNEL_0 USART_CHANNEL_0 // USART0 AtMega1281/2561 start addresss
+#define SPI_CHANNEL_1 USART_CHANNEL_1 // USART1 AtMega1281/2561 start addresss
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+// spi channel
+typedef UsartChannel_t SpiChannel_t;
+
+// types of the clock mode
+typedef enum
+{
+ // leading edge sample RX bit (rising), trailing edge setup TX bit (falling).
+ SPI_CLOCK_MODE0,
+ // leading edge setup TX bit (rising), trailing edge sample RX bit (falling).
+ SPI_CLOCK_MODE1,
+ // leading edge sample RX bit (falling), trailing edge setup TX bit (rising).
+ SPI_CLOCK_MODE2,
+ // leading edge setup TX bit (falling), trailing edge sample RX bit (rising).
+ SPI_CLOCK_MODE3
+} SpiClockMode_t;
+
+// clock rate
+typedef enum
+{
+ SPI_CLOCK_RATE_62 = ((F_CPU / (2 * 62500ul)) - 1),
+ SPI_CLOCK_RATE_125 = ((F_CPU / (2 * 125000ul)) - 1),
+ SPI_CLOCK_RATE_250 = ((F_CPU / (2 * 250000ul)) - 1),
+ SPI_CLOCK_RATE_500 = ((F_CPU / (2 * 500000ul)) - 1),
+ SPI_CLOCK_RATE_1000 = ((F_CPU / (2 * 1000000ul)) - 1),
+ SPI_CLOCK_RATE_2000 = ((F_CPU / (2 * 2000000ul)) - 1)
+} SpiBaudRate_t;
+
+// Data order
+typedef enum
+{
+ SPI_DATA_MSB_FIRST, // data with MSB first
+ SPI_DATA_LSB_FIRST // data with LSB first
+} SpiDataOrder_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+Disables USART channel.
+Parameters:
+ tty - spi channel.
+******************************************************************************/
+void halClearUsartSpi(SpiChannel_t tty);
+
+/******************************************************************************
+Write a length bytes to the SPI.
+Parameters:
+ tty - spi channel
+ buffer - pointer to application data buffer;
+ length - number bytes for transfer;
+Returns:
+ number of written bytes
+******************************************************************************/
+uint16_t halSyncUsartSpiWriteData(SpiChannel_t tty, uint8_t *buffer, uint16_t length);
+
+/******************************************************************************
+Write & read a length bytes to & from the SPI.
+Parameters:
+ tty - spi channel
+ buffer - pointer to application data buffer;
+ length - number bytes for transfer;
+Returns:
+ number of written & read bytes
+******************************************************************************/
+uint16_t halSyncUsartSpiReadData(SpiChannel_t tty, uint8_t *buffer, uint16_t length);
+
+/******************************************************************************
+ Inline static functions section
+******************************************************************************/
+/******************************************************************************
+Enables data register empty interrupt.
+Parameters:
+ tty - spi channel.
+Returns:
+ none.
+******************************************************************************/
+INLINE void halEnableUsartSpiDremInterrupt(SpiChannel_t tty)
+{
+ UCSRnB(tty) |= (1 << UDRIE0);
+}
+
+/******************************************************************************
+Disables data register empty interrupt.
+Parameters:
+ tty - spi channel.
+Returns:
+ none.
+******************************************************************************/
+INLINE void halDisableUsartSpiDremInterrupt(SpiChannel_t tty)
+{
+ UCSRnB(tty) &= ~(1 << UDRIE0);
+}
+
+/******************************************************************************
+Enables transmit complete interrupt.
+Parameters:
+ tty - spi channel.
+Returns:
+ none.
+******************************************************************************/
+INLINE void halEnableUsartSpiTxcInterrupt(SpiChannel_t tty)
+{
+ UCSRnB(tty) |= (1 << TXCIE0);
+}
+
+/******************************************************************************
+Disables transmit complete interrupt.
+Parameters:
+ tty - spi channel.
+Returns:
+ none.
+******************************************************************************/
+INLINE void halDisableUsartSpiTxcInterrupt(SpiChannel_t tty)
+{
+ UCSRnB(tty) &= ~(1 << TXCIE0);
+}
+
+/*****************************************************************************
+Enables receive complete interrupt.
+Parameters:
+ tty - spi channel.
+Returns:
+ none.
+******************************************************************************/
+INLINE void halEnableUsartSpiRxcInterrupt(SpiChannel_t tty)
+{
+ UCSRnB(tty) |= (1 << RXCIE0);
+}
+
+/*****************************************************************************
+Disables receive complete interrupt.
+Parameters:
+ tty - spi channel.
+Returns:
+ none.
+******************************************************************************/
+INLINE void halDisableUsartSpiRxcInterrupt(SpiChannel_t tty)
+{
+ UCSRnB(tty) &= ~(1 << RXCIE0);
+}
+#endif
+//eof halSpi.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halUsart.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halUsart.h
new file mode 100644
index 00000000..ccdd5e8f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halUsart.h
@@ -0,0 +1,327 @@
+/*****************************************************************************//**
+\file halUsart.h
+
+\brief Declarations of usart hardware-dependent module.
+
+\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:
+ 29/05/07 E. Ivanov - Created
+**********************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HAL_USART_H
+#define _HAL_USART_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halDbg.h>
+#include <halClkCtrl.h>
+#include <halTaskManager.h>
+#include <gpio.h>
+#include <mnUtils.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+/* if USART_DOUBLE_SPEED is 1 the USART uses U2Xn bit (Double speed the usart transmition).
+ if USART_DOUBLE_SPEED is 0 then U2Xn bit is not been used.
+ */
+#ifndef USART_DOUBLE_SPEED
+ #define USART_DOUBLE_SPEED 1ul
+#endif
+
+#define USART_CHANNEL_0 0xC0 // USART0 AtMega1281/2561 start address
+#define USART_CHANNEL_1 0xC8 // USART1 AtMega1281/2561 start address
+
+#if NUM_USART_CHANNELS == 2
+ #define HAL_GET_INDEX_BY_CHANNEL(channel) ((channel - USART_CHANNEL_0) >> 3)
+#else
+ #define HAL_GET_INDEX_BY_CHANNEL(channel) (channel - channel)
+#endif
+
+#define UCSRnA(tty) MMIO_BYTE(tty + 0)
+#define UCSRnB(tty) MMIO_BYTE(tty + 1)
+#define UCSRnC(tty) MMIO_BYTE(tty + 2)
+#define UBRRnL(tty) MMIO_BYTE(tty + 4)
+#define UBRRnH(tty) MMIO_BYTE(tty + 5)
+#define UBRRn(tty) MMIO_WORD(tty + 4)
+#define UDRn(tty) MMIO_BYTE(tty + 6)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+// usart channel
+typedef uint8_t UsartChannel_t;
+
+// clock rate of usart
+typedef enum
+{
+ USART_BAUDRATE_1200 = (unsigned)((F_CPU * (USART_DOUBLE_SPEED + 1ul)) / (16ul * 1200ul) - 1ul), // 1200 baud rate
+ USART_BAUDRATE_2400 = (unsigned)((F_CPU * (USART_DOUBLE_SPEED + 1ul)) / (16ul * 2400ul) - 1ul), // 2400 baud rate
+ USART_BAUDRATE_4800 = (unsigned)((F_CPU * (USART_DOUBLE_SPEED + 1ul)) / (16ul * 4800ul) - 1ul), // 4800 baud rate
+ USART_BAUDRATE_9600 = (unsigned)((F_CPU * (USART_DOUBLE_SPEED + 1ul)) / (16ul * 9600ul) - 1ul), // 9600 baud rate
+ USART_BAUDRATE_19200 = (unsigned)((F_CPU * (USART_DOUBLE_SPEED + 1ul)) / (16ul * 19200ul) - 1ul), // 19200 baud rate
+ USART_BAUDRATE_38400 = (unsigned)((F_CPU * (USART_DOUBLE_SPEED + 1ul)) / (16ul * 38400ul) - 1ul), // 38400 baud rate
+ USART_BAUDRATE_115200 = (unsigned)((F_CPU * (USART_DOUBLE_SPEED + 1ul)) / (16ul * 115200ul)), // 115200 baud rate
+ USART_SYNC_BAUDRATE_1200 = (uint16_t)((F_CPU / (2ul * 1200ul)) - 1ul),
+ USART_SYNC_BAUDRATE_2400 = (uint16_t)((F_CPU / (2ul * 2400ul)) - 1ul),
+ USART_SYNC_BAUDRATE_4800 = (uint16_t)((F_CPU / (2ul * 4800ul)) - 1ul),
+ USART_SYNC_BAUDRATE_9600 = (uint16_t)((F_CPU / (2ul * 9600ul)) - 1ul),
+ USART_SYNC_BAUDRATE_38400 = (uint16_t)((F_CPU / (2ul * 38400ul)) - 1ul),
+ USART_SYNC_BAUDRATE_57600 = (uint16_t)((F_CPU / (2ul * 57600ul)) - 1ul),
+ USART_SYNC_BAUDRATE_115200 = (uint16_t)((F_CPU / (2ul * 115200ul)) - 1ul)
+} UsartBaudRate_t;
+
+// usart data length
+typedef enum
+{
+ USART_DATA5 = (0 << UCSZ12) | (0 << UCSZ11) | (0 << UCSZ10), // 5 bits data length
+ USART_DATA6 = (0 << UCSZ12) | (0 << UCSZ11) | (1 << UCSZ10), // 6 bits data length
+ USART_DATA7 = (0 << UCSZ12) | (1 << UCSZ11) | (0 << UCSZ10), // 7 bits data length
+ USART_DATA8 = (0 << UCSZ12) | (1 << UCSZ11) | (1 << UCSZ10), // 8 bits data length
+} UsartData_t;
+
+// parity mode
+typedef enum
+{
+ USART_PARITY_NONE = (0 << UPM11) | (0 << UPM10), // Non parity mode
+ USART_PARITY_EVEN = (1 << UPM11) | (0 << UPM10), // Even parity mode
+ USART_PARITY_ODD = (1 << UPM11) | (1 << UPM10) // Odd parity mode
+} UsartParity_t;
+
+// number of stop bits
+typedef enum
+{
+ USART_STOPBIT_1 = (0 << USBS1), // 1 stop bits mode
+ USART_STOPBIT_2 = (1 << USBS1) // 2 stop bits mode
+} UsartStopBits_t;
+
+// USART task IDs.
+typedef enum
+{
+ #if defined(HAL_USE_USART_CHANNEL_0)
+ HAL_USART_TASK_USART0_DRE,
+ HAL_USART_TASK_USART0_TXC,
+ HAL_USART_TASK_USART0_RXC,
+ #if defined(_USE_USART_ERROR_EVENT_)
+ HAL_USART_TASK_USART0_ERR,
+ #endif
+ #endif
+
+ #if defined(HAL_USE_USART_CHANNEL_1)
+ HAL_USART_TASK_USART1_DRE,
+ HAL_USART_TASK_USART1_TXC,
+ HAL_USART_TASK_USART1_RXC,
+ #if defined(_USE_USART_ERROR_EVENT_)
+ HAL_USART_TASK_USART1_ERR,
+ #endif
+ #endif
+
+ HAL_USART_TASKS_NUMBER
+} HalUsartTaskId_t;
+
+// Defines edge of clock to sample data.
+/*
+------------------------------------------------------------------------------------
+| | Transmitted Data Changed (Output | Received Data Sampled (Input on |
+| | of TxDn Pin) | RxDn Pin) |
+|------------|-----------------------------------|----------------------------------
+|FALLING_EDGE| Rising XCKn Edge | Falling XCKn Edge |
+|RISING_EDGE | Falling XCKn Edge | Rising XCKn Edge |
+------------------------------------------------------------------------------------
+*/
+typedef enum
+{
+ USART_EDGE_MODE_FALLING = 0,
+ USART_EDGE_MODE_RISING = 1
+} UsartEdgeMode_t;
+
+// USART synchronization mode.
+typedef enum
+{
+ USART_MODE_ASYNC = ((0 << UMSEL01) | (0 << UMSEL00)),
+ USART_MODE_SYNC = ((0 << UMSEL01) | (1 << UMSEL00))
+} UsartMode_t;
+
+// clck is output in master mode else input
+typedef enum
+{
+ USART_CLK_MODE_MASTER = 0,
+ USART_CLK_MODE_SLAVE = 1
+} UsartClkMode_t;
+
+#if defined(_USE_USART_ERROR_EVENT_)
+ // usart receiver error reason
+ typedef enum
+ {
+ FRAME_ERROR,
+ DATA_OVERRUN,
+ PARITY_ERROR
+ } UsartErrorReason_t;
+#endif
+
+// usart control
+typedef struct
+{
+ volatile uint16_t txPointOfRead;
+ volatile uint16_t txPointOfWrite;
+ volatile uint16_t rxPointOfRead;
+ volatile uint16_t rxPointOfWrite;
+ volatile uint16_t rxBytesInBuffer;
+ uint8_t usartShiftRegisterEmpty;
+#if defined(_USE_USART_ERROR_EVENT_)
+ uint8_t errorReason;
+#endif
+} HalUsartService_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Puts the byte received to the cyclic buffer.
+
+\param[in]
+ tty - channel number.
+\param[in]
+ data - data to put.
+******************************************************************************/
+void halUsartRxBufferFiller(UsartChannel_t tty, uint8_t data);
+
+/**************************************************************************//**
+\brief Checks the channel number.
+
+\param[in]
+ channel - channel to be verified.
+
+\return
+ true if channel is possible, \n
+ false otherwise.
+******************************************************************************/
+bool halIsUsartChannelCorrect(UsartChannel_t channel);
+
+#if defined(_USE_USART_ERROR_EVENT_)
+/**************************************************************************//**
+\brief Save status register for analyzing of the error reason.
+
+\param[in]
+ tty - channel number.
+\param[in]
+ status - usart status register.
+******************************************************************************/
+void halUsartSaveErrorReason(UsartChannel_t tty, uint8_t status);
+#endif
+
+/******************************************************************************
+ Inline static functions section
+******************************************************************************/
+/**************************************************************************//**
+ \brief Disables USART channel
+
+ \param tty - number of USART channel.
+ \return none.
+******************************************************************************/
+INLINE void halCloseUsart(UsartChannel_t tty)
+{
+ assert((USART_CHANNEL_0 == tty) || (USART_CHANNEL_1 == tty), HALUSARTH_HALCLOSEUSART_0);
+ UCSRnB(tty) = 0x00;
+}
+
+/**************************************************************************//**
+ \brief Enables data register empty interrupt
+
+ \param tty - number of USART channel.
+ \return none.
+******************************************************************************/
+INLINE void halEnableUsartDremInterrupt(UsartChannel_t tty)
+{
+ assert((USART_CHANNEL_0 == tty) || (USART_CHANNEL_1 == tty), HALUSARTH_HALENABLEUSARTDREMINTERRUPT_0);
+ UCSRnB(tty) |= (1 << UDRIE1);
+}
+
+/**************************************************************************//**
+ \brief Disables data register empty interrupt
+
+ \param tty - number of USART channel.
+ \return none.
+******************************************************************************/
+INLINE void halDisableUsartDremInterrupt(UsartChannel_t tty)
+{
+ assert((USART_CHANNEL_0 == tty) || (USART_CHANNEL_1 == tty), HALUSARTH_HALDISABLEUSARTDREMINTERRUPT_0);
+ UCSRnB(tty) &= ~(1 << UDRIE1);
+}
+
+/**************************************************************************//**
+ \brief Enables transmit complete interrupt
+
+ \param tty - number of USART channel.
+ \return none.
+******************************************************************************/
+INLINE void halEnableUsartTxcInterrupt(UsartChannel_t tty)
+{
+ assert((USART_CHANNEL_0 == tty) || (USART_CHANNEL_1 == tty), HALUSARTH_HALENABLEUSARTTXCINTERRUPT_0);
+ UCSRnB(tty) |= (1 << TXCIE1);
+}
+
+/**************************************************************************//**
+ \brief Disables transmit complete interrupt
+
+ \param tty - number of USART channel.
+ return none.
+******************************************************************************/
+INLINE void halDisableUsartTxcInterrupt(UsartChannel_t tty)
+{
+ assert((USART_CHANNEL_0 == tty) || (USART_CHANNEL_1 == tty), HALUSARTH_HALDISABLEUSARTTXCINTERRUPT_0);
+ UCSRnB(tty) &= ~(1 << TXCIE1);
+}
+
+/**************************************************************************//**
+ \brief Enables receive complete interrupt
+
+ \param tty - number of USART channel.
+ \return none.
+******************************************************************************/
+INLINE void halEnableUsartRxcInterrupt(UsartChannel_t tty)
+{
+ assert((USART_CHANNEL_0 == tty) || (USART_CHANNEL_1 == tty), HALUSARTH_HALENABLEUSARTRXCINTERRUPT_0);
+ UCSRnB(tty) |= (1 << RXCIE0);
+}
+
+/**************************************************************************//**
+ \brief Disables receive complete interrupt
+
+ \param tty - number of USART channel.
+ \return none.
+******************************************************************************/
+INLINE void halDisableUsartRxcInterrupt(UsartChannel_t tty)
+{
+ assert((USART_CHANNEL_0 == tty) || (USART_CHANNEL_1 == tty), HALUSARTH_HALDISABLEUSARTRXCINTERRUPT_0);
+ UCSRnB(tty) &= ~(1 << RXCIE0);
+}
+
+/**************************************************************************//**
+ \brief Puts byte to data register of USART
+
+ \param tty - number of USART channel.
+ data - byte to send.
+ \return none.
+******************************************************************************/
+INLINE void halSendUsartByte(UsartChannel_t tty, uint8_t data)
+{
+ assert((USART_CHANNEL_0 == tty) || (USART_CHANNEL_1 == tty), HALUSARTH_HALSENDUSARTBYTE_0);
+ UCSRnA(tty) |= (1 << TXC1); // clear transmite complete flag
+ UDRn(tty) = data;
+}
+
+#endif /* _HAL_USART_H */
+//eof halUsart.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halW1.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halW1.h
new file mode 100644
index 00000000..46c66fd7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halW1.h
@@ -0,0 +1,93 @@
+/***************************************************************************//**
+ \file halW1.h
+
+ \brief Declarations of 1-wire hardware-dependent module.
+
+ \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:
+ 10/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALW1_H
+#define _HALW1_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <inttypes.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** \brief i2c 1-wire status */
+typedef enum
+{
+ /** \brief There is no device on the bus */
+ W1_NO_DEVICE_STATUS,
+ /** \brief At least one device is on the bus */
+ W1_SUCCESS_STATUS,
+ /** \brief Invalid CRC was read during the device search operation */
+ W1_INVALID_CRC
+} W1Status_t;
+
+/***************************************************************************//**
+\brief Reads byte from the bus.
+
+\return
+ byte read from the bus.
+*******************************************************************************/
+uint8_t halReadW1(void);
+
+/***************************************************************************//**
+\brief Reads bit from the bus.
+
+\return
+ Read bit is placed to position of last significant bit.
+*******************************************************************************/
+uint8_t halReadW1Bit(void);
+
+/***************************************************************************//**
+\brief Writes bit to the bus.
+
+\param[in]
+ value - to write. The bit is placed to position of last significant bit.
+*******************************************************************************/
+void halWriteW1bit(uint8_t value);
+
+/***************************************************************************//**
+\brief Writes byte to the bus
+
+\param[in]
+ value - byte to write.
+*******************************************************************************/
+void halWriteW1(uint8_t value);
+
+/***************************************************************************//**
+\brief Resets all devices connected to the bus.
+
+\return
+ 0 - there are some devices at the bus. \n
+ 1 - there are not any devices at the bus.
+*******************************************************************************/
+uint8_t halResetW1(void);
+
+/**************************************************************************//**
+\brief Performs delay in microseconds
+
+\param[in]
+ delay - number of microseconds to be delay
+******************************************************************************/
+void __delay_us(uint8_t delay);
+
+#endif /* _HALW1_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halWdt.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halWdt.h
new file mode 100644
index 00000000..bdf3ee27
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/halWdt.h
@@ -0,0 +1,53 @@
+/**************************************************************************//**
+ \file halWdt.h
+
+ \brief Declarations of wdt hardware-dependent module.
+
+ \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:
+ 1/10/08 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALWDT_H
+#define _HALWDT_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halClkCtrl.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#if defined(__ICCAVR__)
+
+/** Enable the watch dog timer with a specific timeout value */
+#define wdt_enable(timeout) do { \
+ uint8_t volatile sreg_temp = SREG; \
+ cli(); \
+ __watchdog_reset(); \
+ WDTCSR |= (1 << WDCE) | (1 << WDE); \
+ WDTCSR = (1 << WDE) | timeout; \
+ SREG = sreg_temp; \
+} while (0)
+
+#define wdt_disable() MCUSR = 0; \
+ WDTCSR |= (1 << WDCE) | (1 << WDE); \
+ WDTCSR = 0x00;
+
+#endif
+
+#endif /* _HALWDT_H */
+
+//eof halWdt.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/i2c.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/i2c.h
new file mode 100644
index 00000000..79e6b2e6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/i2c.h
@@ -0,0 +1,185 @@
+/***************************************************************************//**
+ \file i2c.h
+
+ \brief Declarations of i2c interface.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _I2C_H
+#define _I2C_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <i2cPacket.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+/** \brief TWI status codes. */
+enum
+{
+ TWS_BUSERROR = 0x00,
+ TWS_START = 0x08,
+ TWS_RSTART = 0x10,
+ TWS_MT_SLA_ACK = 0x18,
+ TWS_MT_SLA_NACK = 0x20,
+ TWS_MT_DATA_ACK = 0x28,
+ TWS_MT_DATA_NACK = 0x30,
+ TWS_M_ARB_LOST = 0x38,
+ TWS_MR_SLA_ACK = 0x40,
+ TWS_MR_SLA_NACK = 0x48,
+ TWS_MR_DATA_ACK = 0x50,
+ TWS_MR_DATA_NACK = 0x58
+};
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Inits TWI module. Setup the speed of TWI.
+\param[in]
+ i2cMode - the speed of TWI.
+******************************************************************************/
+void halInitI2c(HAL_i2cMode_t *i2cMode);
+
+/**************************************************************************//**
+\brief Notification about the start condition was sent.
+******************************************************************************/
+void halSendStartDoneI2c(void);
+
+/**************************************************************************//**
+\brief Notification that byte was written to the TWI.
+\param[in]
+ result - contains result of previous operation.
+******************************************************************************/
+void halWriteDoneI2c(void);
+
+/**************************************************************************//**
+\brief Notification that byte was read from the TWI.
+\param[in]
+ data - contains byte that was read.
+******************************************************************************/
+void halReadDoneI2c(uint8_t data);
+
+/**************************************************************************//**
+\brief Notification that last byte was read from the TWI. Needs send STOP condition
+on bus.
+\param[in]
+ data - contains byte that was read.
+******************************************************************************/
+void halReadLastByteDoneI2c(uint8_t data);
+
+/**************************************************************************//**
+\brief Notification that address byte was written to the TWI and was read ACK.
+Starts reading data.
+******************************************************************************/
+void halMasterReadWriteAddressAckI2c(void);
+
+/**************************************************************************//**
+\brief Resets TWI bus and i2c HAL.
+******************************************************************************/
+void halI2cBusReset(void);
+
+/******************************************************************************
+ Inline static functions section
+******************************************************************************/
+/**************************************************************************//**
+\brief Loop for waiting for end of stop condition on bus.
+******************************************************************************/
+INLINE void halWaitEndOfStopStation(void)
+{
+ loop_until_bit_is_clear(TWCR, TWSTO);
+}
+
+/**************************************************************************//**
+\brief Enables interrupt on TWI.
+******************************************************************************/
+INLINE void halInterruptEnableI2c(void)
+{
+ TWCR |= (1 << TWIE);
+}
+
+/**************************************************************************//**
+\brief Disables interrupt on TWI.
+******************************************************************************/
+INLINE void halInterruptDisableI2c(void)
+{
+ TWCR &= (~(1 << TWIE));
+}
+
+/*************************************************************************//**
+\brief Returns byte that was read from the TWI.
+******************************************************************************/
+INLINE uint8_t halReadByteI2c(void)
+{
+ return TWDR;
+}
+
+/*************************************************************************//**
+\brief Resets the TWI.
+******************************************************************************/
+INLINE void halResetI2c(void)
+{
+ TWCR = ((1 << TWSTO) | (1 << TWINT)); // Reset TWI
+}
+
+/**************************************************************************//**
+\brief Begins writing an byte to TWI.
+\param[in]
+ data - an byte for sending.
+******************************************************************************/
+INLINE void halWriteI2c(uint8_t data)
+{
+ TWDR = data;
+ TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWIE);
+}
+
+/**************************************************************************//**
+\brief Begins read an byte from TWI.
+\param[in]
+ ack - defines the need to send ACK after an byte was recieved.
+******************************************************************************/
+INLINE void halReadI2c(bool ack)
+{
+ if (ack)
+ TWCR |= (1 << TWEA);
+ else
+ TWCR &= ~(1 << TWEA);
+
+ TWCR |= ((1 << TWINT) | (1 << TWIE) | (1 << TWEN)); // Trigger the TWI
+}
+
+/**************************************************************************//**
+\brief Directs TWI to send stop condition.
+******************************************************************************/
+INLINE void halSendStopI2c(void)
+{
+ TWCR = ((1 << TWSTO) | (1 << TWINT) | (1 << TWEN));
+}
+
+/**************************************************************************//**
+\brief Directs the TWI to send start condition.
+******************************************************************************/
+INLINE void halSendStartI2c(void)
+{
+ TWCR = ((1 << TWSTA) | (1 <<TWINT) | (1 << TWEN) | (1 << TWIE));
+}
+
+#endif /* _I2C_H*/
+
+// eof i2c.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/macros.m90 b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/macros.m90
new file mode 100644
index 00000000..57ce6f92
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/include/macros.m90
@@ -0,0 +1,152 @@
+;----------------------------------------------------------------------------
+;
+; MACROS.M90
+;
+; This module contains the A90/AVR C macros
+; used by cstartup.s90 and other assemble source.
+;
+; File version: $Revision: 1.8 $
+;
+;
+;----------------------------------------------------------------------------
+
+#if (((__TID__ >> 8) & 0x7F) != 90)
+#error This file should only be assembled by aa90 or aavr
+#endif
+
+#define A90_PROC_OPTION ((__TID__ >> 4) & 0x0F)
+
+/* Long or relative jumps and calls */
+#if (A90_PROC_OPTION == 0) || (A90_PROC_OPTION == 1)
+#define XCALL RCALL
+#define XJMP RJMP
+#else
+#define XCALL CALL
+#define XJMP JMP
+#endif
+
+/* Length of pointer registers (X/Y/Z) */
+#if (A90_PROC_OPTION == 0) || (A90_PROC_OPTION == 2)
+#define A90_POINTER_REG_SIZE 1
+#define A90_TINY_INDEX
+#else /*!(A90_PROC_OPTION == 0) || (A90_PROC_OPTION == 2)*/
+#if (A90_PROC_OPTION == 1) || (A90_PROC_OPTION == 3) || (A90_PROC_OPTION ==5)
+#define A90_POINTER_REG_SIZE 2
+#else /*!(A90_PROC_OPTION == 1) || (A90_PROC_OPTION == 3) || (A90_PROC_OPTION ==5)*/
+#if (A90_PROC_OPTION == 4) || (A90_PROC_OPTION == 6)
+#define A90_POINTER_REG_SIZE 3
+#define A90_EXTENDED_DATA
+#else /*!(A90_PROC_OPTION == 4) || (A90_PROC_OPTION == 6)*/
+#error Unknown processor option!!
+#endif /*!(A90_PROC_OPTION == 4) || (A90_PROC_OPTION == 6)*/
+#endif /*!(A90_PROC_OPTION == 1) || (A90_PROC_OPTION == 3) || (A90_PROC_OPTION ==5)*/
+#endif /*!(A90_PROC_OPTION == 0) || (A90_PROC_OPTION == 2)*/
+
+#if (A90_PROC_OPTION > 4)
+#define A90_LARGE_CODE
+#endif
+
+#if (A90_PROC_OPTION > 1)
+#define A90_HAS_POSSIBLE_ELPM
+#endif
+
+#ifdef A90_HAS_POSSIBLE_ELPM
+#ifdef __HAS_ELPM__
+#define A90_HAS_ELPM
+#else
+#ifndef SMALL_FLASH
+#define A90_HAS_ELPM
+#endif
+#endif
+#endif
+
+#if A90_PROC_OPTION > 1
+#define A90_24BIT_GENERIC
+#endif
+
+#if A90_PROC_OPTION < 2
+#define A90_16BIT_GENERIC
+#endif
+
+#ifdef __MEMORY_MODEL__
+
+#define TINY_MEMORY_MODEL 0
+#define SMALL_MEMORY_MODEL 1
+#define LARGE_MEMORY_MODEL 2
+
+#if __MEMORY_MODEL__ == 1
+#undef MEMORY_MODEL
+#define MEMORY_MODEL TINY_MEMORY_MODEL
+#endif
+
+#if __MEMORY_MODEL__ == 2
+#undef MEMORY_MODEL
+#define MEMORY_MODEL SMALL_MEMORY_MODEL
+#endif
+
+#if __MEMORY_MODEL__ == 3
+#undef MEMORY_MODEL
+#define MEMORY_MODEL LARGE_MEMORY_MODEL
+#endif
+
+#else
+
+#ifdef MEMORY_MODEL
+#define t 0
+#define s 1
+#define l 2
+
+#define TINY_MEMORY_MODEL 0
+#define SMALL_MEMORY_MODEL 1
+#define LARGE_MEMORY_MODEL 2
+
+#if MEMORY_MODEL == t
+#undef MEMORY_MODEL
+#define MEMORY_MODEL TINY_MEMORY_MODEL
+#endif
+
+#if MEMORY_MODEL == s
+#undef MEMORY_MODEL
+#define MEMORY_MODEL SMALL_MEMORY_MODEL
+#endif
+
+#if MEMORY_MODEL == l
+#undef MEMORY_MODEL
+#define MEMORY_MODEL LARGE_MEMORY_MODEL
+#endif
+
+#undef t
+#undef s
+#undef l
+#endif
+#endif
+
+/* Register nicknames */
+#define T0 R0
+#define T1 R1
+#define T2 R2
+#define T3 R3
+#define P0 R16
+#define P1 R17
+#define P2 R18
+#define P3 R19
+#define Q0 R20
+#define Q1 R21
+#define Q2 R22
+#define Q3 R23
+#define X0 R26
+#define X1 R27
+#define X2 R25
+#define Y0 R28
+#define Y1 R29
+#define Z0 R30
+#define Z1 R31
+#define Z2 R19
+
+/* I/O-Space Register nicknames */
+#define RAMPD 0x38
+#define RAMPX 0x39
+#define RAMPY 0x3A
+#define RAMPZ 0x3B
+#define EIND 0x3C
+#define SREG 0x3F
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/calibration.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/calibration.c
new file mode 100644
index 00000000..7d59a5e0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/calibration.c
@@ -0,0 +1,141 @@
+/**************************************************************************//**
+ \file calibration.c
+
+ \brief the calibration of the internal RC generator.
+
+ \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:
+ 29/06/07 E. Ivanov - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halClkCtrl.h>
+#include <calibration.h>
+#include <atomic.h>
+#include <halW1.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+#define INTERNAL_CLOCK F_CPU
+
+// low frequency oscillator clock for 1 cycle measurement
+#define EXTERNAL_TICKS 1
+// mcu clocks number of one procedure measurement
+#define CYCLE_LENGTH 7
+// stability crystal oscillator frequency
+#define REFERENCE_CLOCK (32768/1024)
+// Etalon mcu clock number for 1 ticks of 32 Hz asynchronous timer
+#define REFERENCE_COUNT (INTERNAL_CLOCK * EXTERNAL_TICKS) / (REFERENCE_CLOCK * CYCLE_LENGTH)
+// up direction
+#define UP_DIRECT 2
+// down direction
+#define DOWN_DIRECT 1
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+Calculates number of cycles during EXTERNAL_TICKS period.
+Parameters:
+ none
+Returns:
+ number of the cycles.
+******************************************************************************/
+uint16_t halMeasurement(void);
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+Performs calibration of the internal RC generator.
+Parameters:
+ none.
+Returns:
+ none.
+******************************************************************************/
+void halCalibrateInternalRc(void)
+{
+ uint16_t count;
+ uint8_t cycles = 0x80;
+ uint16_t counterGate = REFERENCE_COUNT;
+ uint8_t direct = 0;
+
+ do
+ {
+ // perform clock measurement
+ count = halMeasurement();
+ if (count > REFERENCE_COUNT)
+ {
+ if ((counterGate < (count - REFERENCE_COUNT)) && (UP_DIRECT == direct))
+ { // previous measurement was more correct
+ OSCCAL--;
+ NOP;
+ break;
+ }
+ OSCCAL--;
+ NOP;
+ counterGate = count - REFERENCE_COUNT;
+ direct = DOWN_DIRECT;
+ }
+
+ if (count < REFERENCE_COUNT)
+ {
+ if ((counterGate < (REFERENCE_COUNT - count)) && (DOWN_DIRECT == direct))
+ { // previous measurement was more exactly
+ OSCCAL++;
+ NOP;
+ break;
+ }
+ OSCCAL++;
+ NOP;
+ counterGate = REFERENCE_COUNT - count;
+ direct = UP_DIRECT;
+ }
+
+ if (REFERENCE_COUNT == count)
+ break;
+
+ } while (--cycles);
+}
+
+/******************************************************************************
+Performs calibration of the main clock generator.
+Parameters:
+ none.
+Returns:
+ none.
+******************************************************************************/
+void HAL_CalibrateMainClock(void)
+{
+ if (INTERNAL_RC == halGetClockSource())
+ halCalibrateInternalRc();
+}
+
+/******************************************************************************
+Starts calibration after program starting or waking up from power down.
+******************************************************************************/
+void halStartingCalibrate(void)
+{
+ uint16_t i;
+
+ for (i = 0; i < 5000; i++)
+ { /* wait for 1 second start up low frequency generator*/
+ __delay_us(200); // 200 us
+ }
+ HAL_CalibrateMainClock();
+}
+// eof calibration.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/cstartup.s90 b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/cstartup.s90
new file mode 100644
index 00000000..ce20e615
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/cstartup.s90
@@ -0,0 +1,250 @@
+;----------------------------------------------------------------------------
+;
+; This module contains the AVR C and EC++ startup
+; routine and must usually be tailored to suit
+; customer's hardware.
+;
+; File version: $Revision: 1.13 $
+;
+;----------------------------------------------------------------------------
+#include <macros.m90>
+
+;----------------------------------------------------------------------------
+; Set up the INTVEC segment with a reset vector
+;----------------------------------------------------------------------------
+ MODULE ?RESET
+
+ COMMON INTVEC:CODE:ROOT(1) ; Align at an even address
+
+ EXTERN ?BC_STARTUP
+ PUBLIC __bitcloud_start
+ PUBLIC ?RESET
+
+ ORG $0
+__bitcloud_start:
+?RESET:
+ XJMP ?BC_STARTUP
+
+ ENDMOD
+
+;----------------------------------------------------------------------------
+; Forward declarations of segments used in initialization
+;----------------------------------------------------------------------------
+ RSEG CSTACK:DATA:NOROOT(0)
+ RSEG RSTACK:DATA:NOROOT(0)
+
+;----------------------------------------------------------------------------
+; Perform C initialization
+;----------------------------------------------------------------------------
+ MODULE ?BC_STARTUP
+
+ EXTERN __low_level_init
+ EXTERN __segment_init
+#ifdef _ECLIB_ECPP
+ EXTERN __call_ctors
+#endif /* _ECLIB_ECPP */
+ EXTERN main
+ EXTERN exit
+ EXTERN _exit
+ ; jump NULL handler
+ EXTERN halWdtInit
+
+;----------------------------------------------------------------------------
+; If the return address stack is located in external SRAM, make sure that
+; you have uncommented the correct code in __low_level_init!!!
+;----------------------------------------------------------------------------
+ RSEG CODE:CODE:NOROOT(1)
+ PUBLIC ?BC_STARTUP
+ PUBLIC __RESTART
+ EXTERN ?RESET
+
+__RESTART:
+?BC_STARTUP:
+ XCALL halWdtInit ; call stop wdt, read reset reason and jump NULL handler
+
+#if A90_POINTER_REG_SIZE > 2
+ PUBLIC ?zero_reg_initialization
+
+?zero_reg_initialization:
+ CLR R15
+ OUT RAMPD,R15
+#endif
+
+ REQUIRE ?SETUP_STACK
+ REQUIRE ?RESET
+
+ RSEG CODE:CODE:NOROOT(1)
+ PUBLIC __RSTACK_in_external_ram
+
+__RSTACK_in_external_ram:
+ LDI R16,0xC0
+ OUT 0x35,R16 ;Enable the external SRAM with a wait state
+
+ RSEG CODE:CODE:NOROOT(1)
+ PUBLIC __RSTACK_in_external_ram_new_way
+ EXTERN __?XMCRA
+
+__RSTACK_in_external_ram_new_way:
+ LDI R16,0x8C ;SRE=1,SRL2=0,SRL1=0,SRL0=0,SRW11=1,SRW10=1,SRW01=0,SRW00=0
+ STS __?XMCRA,R16 ;Enable the external SRAM with maximum wait state.
+
+;----------------------------------------------------------------------------
+; Set up the CSTACK and RSTACK pointers.
+;----------------------------------------------------------------------------
+ RSEG CODE:CODE:NOROOT(1)
+ ;; Fill up stacks with repeated pattern 0xCD (same pattern is used by IAR stack gauge)
+?FILL_RSTACK:
+ LDI R16, 0xCD
+ LDI X0, LOW(SFB(RSTACK))
+ LDI Y0, LOW(SFE(RSTACK))
+#if A90_POINTER_REG_SIZE > 1
+ LDI X1, HIGH(SFB(RSTACK))
+ LDI Y1, HIGH(SFE(RSTACK))
+#else
+ LDI X1, 0
+ LDI Y1, 0
+#endif
+?FILL_RSTACK_LOOP:
+ ST X+, R16
+ CP X0, Y0
+ CPC X1, Y1
+ BRNE ?FILL_RSTACK_LOOP
+
+?FILL_CSTACK:
+ LDI X0, LOW(SFB(CSTACK))
+ LDI Y0, LOW(SFE(CSTACK))
+#if A90_POINTER_REG_SIZE > 1
+ LDI X1, HIGH(SFB(CSTACK))
+ LDI Y1, HIGH(SFE(CSTACK))
+#else
+ LDI X1, 0
+ LDI Y1, 0
+#endif
+?FILL_CSTACK_LOOP:
+ ST X+, R16
+ CP X0, Y0
+ CPC X1, Y1
+ BRNE ?FILL_CSTACK_LOOP
+
+?SETUP_STACK:
+ ;; Return address stack (RSTACK)
+ LDI R16,LOW(SFE(RSTACK)-1)
+ OUT 0x3D,R16
+#if A90_POINTER_REG_SIZE > 1
+ LDI R16,HIGH(SFE(RSTACK)-1)
+ OUT 0x3E,R16
+#endif
+
+ ;; Data stack (CSTACK)
+ LDI Y0,LOW(SFE(CSTACK))
+#if A90_POINTER_REG_SIZE > 1
+#if MEMORY_MODEL == TINY_MEMORY_MODEL
+ LDI Y1,0
+#else
+ LDI Y1,HIGH(SFE(CSTACK))
+#endif
+#if A90_POINTER_REG_SIZE > 2
+ LDI Z0,HWRD(SFB(CSTACK))
+ OUT RAMPY,Z0
+#endif
+#endif
+
+#if A90_POINTER_REG_SIZE > 2
+; Nothing here, the things previously here has been done earlier.
+#else
+ REQUIRE ?call_low_level_init
+
+;----------------------------------------------------------------------------
+; Clear R15 so that it can be used as zero register by the code generator.
+; The compiler will emit a "REQUIRE ?zero_reg_initialization" statement if
+; this optimization has been enabled.
+;----------------------------------------------------------------------------
+ RSEG CODE:CODE:NOROOT(1)
+ PUBLIC ?zero_reg_initialization
+
+?zero_reg_initialization:
+ CLR R15
+
+;----------------------------------------------------------------------------
+; Call __low_level_init to do low level initializatons. Modify the supplied
+; __low_level_init module to add your own initialization code or to
+; remove segment initialization (by returning 0).
+;----------------------------------------------------------------------------
+ RSEG CODE:CODE:NOROOT(1)
+#endif
+ PUBLIC ?call_low_level_init
+
+?call_low_level_init:
+ XCALL __low_level_init
+
+ REQUIRE ?cstartup_call_main
+
+;----------------------------------------------------------------------------
+; Call __segment_init to initialize segments.
+;----------------------------------------------------------------------------
+ RSEG CODE:CODE:NOROOT(1)
+ PUBLIC ?need_segment_init
+
+?need_segment_init:
+ TST P0
+ BREQ ?skip_segment_init
+ XCALL __segment_init
+?skip_segment_init:
+
+;----------------------------------------------------------------------------
+; Call the constructors of all global objects. This code will only
+; be used if any EC++ modules defines global objects that need to
+; have its constructor called before main.
+;----------------------------------------------------------------------------
+#ifdef _ECLIB_ECPP
+ RSEG DIFUNCT:CODE:NOROOT(0)
+ RSEG CODE:CODE:NOROOT(1)
+
+ PUBLIC ?call_ctors
+
+?call_ctors:
+#ifdef __HAS_ELPM__
+ LDI P0,LOW(SFB(DIFUNCT))
+ LDI P1,LOW(SFB(DIFUNCT) >> 8)
+ LDI P2,SFB(DIFUNCT) >> 16
+
+ LDI Q0,LOW(SFE(DIFUNCT))
+ LDI Q1,LOW(SFE(DIFUNCT) >> 8)
+ LDI Q2,SFE(DIFUNCT) >> 16
+#else
+ LDI P0,LOW(SFB(DIFUNCT))
+ LDI P1,SFB(DIFUNCT) >> 8
+
+ LDI P2,LOW(SFE(DIFUNCT))
+ LDI P3,SFE(DIFUNCT) >> 8
+#endif
+
+ XCALL __call_ctors
+#endif /* _ECLIB_ECPP */
+
+;----------------------------------------------------------------------------
+; Call main
+;----------------------------------------------------------------------------
+ RSEG CODE:CODE:NOROOT(1)
+
+ PUBLIC ?cstartup_call_main
+
+?cstartup_call_main:
+ XCALL main
+ XCALL exit
+ XJMP _exit
+
+ END
+
+;----------------------------------------------------------------------------
+; $Log: cstartup.s90 $
+; Revision 1.13 2005/02/09 16:34:50Z IPEO
+; Revision 1.12 2005/02/09 12:12:46Z IPEO
+; Revision 1.11 2005/02/09 11:32:04Z IPEO
+; Revision 1.10 2005/01/26 13:56:34Z IPEO
+; Revision 1.9 2005/01/17 15:24:14Z IPEO
+; Revision 1.8 2003/11/07 16:34:04Z IPEO
+; Revision 1.7 2003/09/04 13:48:25Z IPEO
+; Revision 1.6 2003/08/22 14:09:09Z IPEO
+; Revision 1.5 2003/08/22 08:54:09Z IPEO
+; Revision 1.4 2003/08/20 08:38:55Z IPEO
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halAdc.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halAdc.c
new file mode 100644
index 00000000..b9e19a0b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halAdc.c
@@ -0,0 +1,163 @@
+/**************************************************************************//**
+ \file halAdc.c
+
+ \brief Implementation of hardware depended ADC interface.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halAdc.h>
+#include <halW1.h>
+#include <halDbg.h>
+#include <halDiagnostic.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+#define ALL_CHANNEL_MASK 0x1F
+#define CHANNEL_MASK_1 0x01
+#define CHANNEL_MASK_2 0x03
+#define CHANNEL_MASK_3 0x04
+#define CHANNEL_MASK_4 0x0C
+#define DELAY_FOR_STABILIZE 125
+
+/******************************************************************************
+ Constants section
+******************************************************************************/
+#if F_CPU == 4000000
+ PROGMEM_DECLARE(const uint8_t halAdcDivider[5]) = {2, 3, 4, 5, 6};
+#elif F_CPU == 8000000
+ PROGMEM_DECLARE(const uint8_t halAdcDivider[5]) = {3, 4, 5, 6, 7};
+#endif
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+static volatile uint8_t halAdcResolution = RESOLUTION_8_BIT;
+static volatile void *halAdcDataPointer = NULL;
+static volatile uint16_t halAdcCurCount = 0;
+static volatile uint16_t halAdcMaxCount = 0;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+Initializations the ADC.
+Parameters:
+ param - pointer to parameter structure
+Returns:
+ none.
+******************************************************************************/
+void halOpenAdc(HAL_AdcParams_t *param)
+{
+ halAdcMaxCount = param->selectionsAmount;
+ halAdcResolution = param->resolution;
+ halAdcDataPointer = param->bufferPointer;
+
+ /* sets voltage reference */
+ ADMUX = param->voltageReference;
+ /* Enable left adjust result */
+ if (RESOLUTION_8_BIT == halAdcResolution)
+ ADMUX |= (1 << ADLAR);
+
+ uint8_t tmp;
+ memcpy_P(&tmp, &(halAdcDivider[param->sampleRate]), 1);
+ ADCSRA = tmp | (1 << ADEN);
+}
+
+/******************************************************************************
+Starts convertion on the ADC channel.
+Parameters:
+ channel - channel number.
+Returns:
+ none.
+******************************************************************************/
+void halStartAdc(uint8_t channel)
+{
+ halAdcCurCount = 0;
+ /* disable digital buffers */
+ if (HAL_ADC_CHANNEL3 >= channel)
+ {
+ DIDR0 = (1 << channel);
+ }
+ else
+ {
+ if ((HAL_ADC_DIFF_CHANNEL0 == channel) || (HAL_ADC_DIFF_CHANNEL2 == channel))
+ DIDR0 = CHANNEL_MASK_1;
+ else if ((HAL_ADC_DIFF_CHANNEL1 == channel) || (HAL_ADC_DIFF_CHANNEL3 == channel))
+ DIDR0 = CHANNEL_MASK_2;
+ else if ((HAL_ADC_DIFF_CHANNEL4 == channel) || (HAL_ADC_DIFF_CHANNEL6 == channel))
+ DIDR0 = CHANNEL_MASK_3;
+ else if ((HAL_ADC_DIFF_CHANNEL5 == channel) || (HAL_ADC_DIFF_CHANNEL7 == channel))
+ DIDR0 = CHANNEL_MASK_4;
+ }
+
+ uint8_t tmp = ADMUX & ALL_CHANNEL_MASK;
+
+ /* clear previous channel number */
+ ADMUX &= ~ALL_CHANNEL_MASK;
+ /* set current channel number */
+ ADMUX |= channel;
+
+ /* if new differential channel is settled then must make 125 us delay for gain stabilize. */
+ if ((tmp != channel) && (HAL_ADC_CHANNEL3 < channel))
+ __delay_us(DELAY_FOR_STABILIZE);
+
+ if (halAdcMaxCount > 1)
+ ADCSRA |= ((1 << ADIE) | (1 << ADATE) | (1 << ADSC)); // Starts running mode
+ else
+ ADCSRA |= ((1 << ADIE) | (1 << ADSC)); // Starts one conversion
+}
+
+/******************************************************************************
+Closes the ADC.
+Parameters:
+ none
+Returns:
+ none
+******************************************************************************/
+void halCloseAdc(void)
+{
+ ADMUX = 0;
+ ADCSRA = 0;
+ // Digital input enable
+ DIDR0 = 0;
+}
+
+/******************************************************************************
+ADC conversion complete interrupt handler.
+******************************************************************************/
+ISR(ADC_vect)
+{
+ BEGIN_MEASURE
+ // Read ADC conversion result
+ if (RESOLUTION_8_BIT == halAdcResolution)
+ ((uint8_t *)halAdcDataPointer)[halAdcCurCount++] = ADCH;
+ else
+ ((uint16_t *)halAdcDataPointer)[halAdcCurCount++] = ADC;
+
+ if (halAdcCurCount == halAdcMaxCount)
+ {
+ // Disable ADC Interrupt
+ ADCSRA &= ~(1 << ADIE);
+ halSigAdcInterrupt();
+ }
+ END_MEASURE(HALISR_ADC_TIME_LIMIT)
+}
+// eof halAdc.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halAppClock.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halAppClock.c
new file mode 100644
index 00000000..c462b896
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halAppClock.c
@@ -0,0 +1,124 @@
+/**************************************************************************//**
+ \file halAppClock.c
+
+ \brief Implementation of appTimer hardware-dependent module.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halAppClock.h>
+#include <halDbg.h>
+#include <halDiagnostic.h>
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+static uint32_t halAppTime = 0ul; // time of application timer
+uint8_t halAppTimeOvfw = 0;
+static volatile uint8_t halAppIrqCount = 0;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+Initialization appTimer clock.
+******************************************************************************/
+void halInitAppClock(void)
+{
+ OCR4A = TOP_TIMER_COUNTER_VALUE; // 1 millisecond timer interrupt interval.
+ TCCR4B = (1 << WGM12); // CTC mode
+ halStartAppClock(); // clock source is cpu divided by 8
+ TIMSK4 |= (1 << OCIE4A); // Enable TC4 interrupt
+}
+
+/******************************************************************************
+Return time of sleep timer.
+
+Returns:
+ time in ms.
+******************************************************************************/
+uint32_t halGetTimeOfAppTimer(void)
+{
+ halAppSystemTimeSynchronize();
+ return halAppTime;
+}
+
+/******************************************************************************
+Return system time in us
+
+Parameters:
+ mem - memory for system time
+Returns:
+ none.
+******************************************************************************/
+void halGetSystemTimeUs(uint64_t *mem)
+{
+#if (F_CPU == 4000000ul)
+ *mem = 1000ul * halAppTime + (TCNT4 << 1);
+#endif
+#if (F_CPU == 8000000ul)
+ *mem = 1000ul * halAppTime + TCNT4;
+#endif
+}
+
+/**************************************************************************//**
+\brief Takes account of the sleep interval.
+
+\param[in]
+ interval - time of sleep
+******************************************************************************/
+void halAdjustSleepInterval(uint32_t interval)
+{
+ halAppTime += interval;
+ halPostTask4(HAL_TIMER4_COMPA);
+}
+
+/**************************************************************************//**
+Synchronization system time which based on application timer.
+******************************************************************************/
+void halAppSystemTimeSynchronize(void)
+{
+ uint8_t tmpCounter;
+ uint32_t tmpValue;
+
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ tmpCounter = halAppIrqCount;
+ halAppIrqCount = 0;
+ END_MEASURE(HAL_APP_TIMER_SYNCHRONIZE_LIMIT)
+ ATOMIC_SECTION_LEAVE
+
+ tmpValue = tmpCounter * HAL_APPTIMERINTERVAL;
+ halAppTime += tmpValue;
+ if (halAppTime < tmpValue)
+ halAppTimeOvfw++;
+}
+
+/******************************************************************************
+Interrupt handler
+******************************************************************************/
+ISR(TIMER4_COMPA_vect)
+{
+ BEGIN_MEASURE
+ halAppIrqCount++;
+ halPostTask4(HAL_TIMER4_COMPA);
+ // infinity loop spy
+ SYS_InfinityLoopMonitoring();
+ END_MEASURE(HALISR_TIMER4_COMPA_TIME_LIMIT)
+}
+// eof halAppClock.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halCalibration.s b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halCalibration.s
new file mode 100644
index 00000000..a6332b7d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halCalibration.s
@@ -0,0 +1,79 @@
+/**************************************************************************//**
+ \file halCalibration.s
+
+ \brief Implementation of measurement of mcu clock.
+
+ \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:
+ 1/10/08 A. Khromykh - Created
+*******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+Calculates number of cycles during EXTERNAL_TICKS period.
+Parameters:
+ none
+Returns:
+ number of the cycles (r25:r24).
+******************************************************************************/
+.global halMeasurement
+.type halMeasurement,@function
+halMeasurement:
+ push r21
+
+ ; Store SREG
+ push r23
+ in r23, 0x3F
+ ; Disable interrupts
+ cli
+
+ ; local copy cnt
+ push r28
+ push r29
+ ldi r28, 0 ; cnt = 0
+ ldi r29, 0 ; cnt = 0
+
+ ; r21 = TCNT2
+ push r23 ; save SREG to stack, to clear r23
+ lds r21, 0x00B2
+ ; while(TCNT2 == r21);
+ __l0:
+ lds r23, 0x00B2
+ cp r23, r21
+ breq __l0
+
+ ; r23++
+ inc r23
+
+ ; measurement
+ __l1:
+ adiw r28, 0x01 ; cnt ++ (2 cycle)
+ lds r21, 0x00B2 ; read TCNT2
+ cp r21, r23 ; if (TCNT2 == TCNT2old)
+ brne __l1 ;
+
+ pop r23 ; load SREG from stack
+
+ ; return cnt
+ movw r24, r28
+
+ pop r29
+ pop r28
+
+ ; Restore SREG
+ out 0x3F, r23
+ pop r23
+ pop r21
+ ret
+
+; eof halCalibration.s
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halCalibration.s90 b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halCalibration.s90
new file mode 100644
index 00000000..cbdb8d13
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halCalibration.s90
@@ -0,0 +1,80 @@
+/**************************************************************************//**
+ \file halCalibration.s90
+
+ \brief Implementation of measurement of mcu clock.
+
+ \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:
+ 1/10/08 A. Khromykh - Created
+*******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/*=============================================================
+Calculates number of cycles during EXTERNAL_TICKS period.
+Parameters:
+ none
+Returns:
+ number of the cycles (r17:r16).
+===============================================================*/
+PUBLIC halMeasurement
+RSEG CODE
+halMeasurement:
+ push r21
+
+ ; Store SREG
+ push r23
+ in r23, 0x3F
+ ; Disable interrupts
+ cli
+
+ ; local copy cnt
+ push r28
+ push r29
+ ldi r28, 0 ; cnt = 0
+ ldi r29, 0 ; cnt = 0
+
+ ; r21 = TCNT2
+ push r23 ; save SREG to stack, to clear r23
+ lds r21, 0x00B2
+ ; while(TCNT2 == r21);
+ __l0:
+ lds r23, 0x00B2
+ cp r23, r21
+ breq __l0
+
+ ; r23++
+ inc r23
+
+ ; measurement
+ __l1:
+ adiw r28, 0x01 ; cnt ++ (2 cycle)
+ lds r21, 0x00B2 ; read TCNT2
+ cp r21, r23 ; if (TCNT2 == TCNT2old)
+ brne __l1 ;
+
+ pop r23 ; load SREG from stack
+
+ ; return cnt
+ movw r16, r28
+
+ pop r29
+ pop r28
+
+ ; Restore SREG
+ out 0x3F, r23
+ pop r23
+ pop r21
+ ret
+
+; eof halCalibration.s90
+END
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halClkCtrl.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halClkCtrl.c
new file mode 100644
index 00000000..e6f968d1
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halClkCtrl.c
@@ -0,0 +1,122 @@
+/**************************************************************************//**
+ \file halClkCtrl.c
+
+ \brief Implementation of clock control module.
+
+ \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:
+ 29/05/07 E. Ivanov - Created
+ 16/04/09 A. Khromykh - Refactored
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halClkCtrl.h>
+#include <halRfCtrl.h>
+#include <atomic.h>
+#include <halDbg.h>
+#include <halDiagnostic.h>
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+// defines fuse mask for RC oscillator
+#define HAL_RC_OSCILLATOR_CLOCK 0x02
+// mask for CKSEL bits
+#define HAL_CKSEL_MASK 0x0F
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+void halStartingCalibrate(void);
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+static volatile ClkSource_t clkClockSource;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Initialization system clock.
+******************************************************************************/
+void halInitFreq(void)
+{
+ uint8_t lowFuseByte;
+
+ // wait for end of eeprom writing
+ while (EECR & (1 << EEPE));
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ lowFuseByte = SF_GET_LOW_FUSES();
+ END_MEASURE(HALATOM_SETLOWFUSES_TIME_LIMIT)
+ ATOMIC_SECTION_LEAVE
+
+ if (HAL_RC_OSCILLATOR_CLOCK == (lowFuseByte & HAL_CKSEL_MASK))
+ clkClockSource = INTERNAL_RC;
+ else
+ clkClockSource = OTHER_SOURCE;
+
+ if (INTERNAL_RC == clkClockSource)
+ {
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ ASM (
+ "push r21 \n\t"
+
+ "ldi r21, 0x80 \n\t" /* CLKPR = 1 << CLKPCE */
+ "sts 0x0061, r21 \n\t" /* CLKPR = 1 << CLKPCE */
+
+#if (F_CPU == 4000000ul)
+ "ldi r21, 0x01 \n\t" /* CLKPR = 1 << CLKPS0 (1 cycle) */
+ "sts 0x0061, r21 \n\t" /* CLKPR = 1 << CLKPS0 (2 cycle) */
+#endif
+#if (F_CPU == 8000000ul)
+ "ldi r21, 0x00 \n\t" /* CLKPR = 0 (1 cycle) */
+ "sts 0x0061, r21 \n\t" /* CLKPR = 0 (2 cycle) */
+#endif
+
+ "pop r21 \n\t"
+ );
+
+ END_MEASURE(HALATOM_INITFREQ_TIME_LIMIT)
+ ATOMIC_SECTION_LEAVE
+ halStartingCalibrate();
+ }
+}
+
+/**************************************************************************//**
+\brief Return clock source
+
+\return
+ clock source.
+******************************************************************************/
+ClkSource_t halGetClockSource(void)
+{
+ return clkClockSource;
+}
+
+/**************************************************************************//**
+\brief System clock.
+
+\return
+ system clock in Hz.
+******************************************************************************/
+uint32_t HAL_ReadFreq(void)
+{
+ return (uint32_t)F_CPU;
+}
+
+// eof halClkCtrl.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halEeprom.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halEeprom.c
new file mode 100644
index 00000000..0dfda94e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halEeprom.c
@@ -0,0 +1,66 @@
+/**************************************************************************//**
+ \file halEeprom.c
+
+ \brief Implementation of the hardware dependent the EEPROM module.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <atomic.h>
+#include <halEeprom.h>
+#include <halDbg.h>
+#include <halDiagnostic.h>
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+Writes a byte to EEPROM.
+Parameters:
+ EECRMask - mask that define capability of interrupt after byte writing.
+ address - address of byte
+ data - data.
+Returns:
+ none.
+******************************************************************************/
+void halEepromWrite(uint8_t EECRMask, uint16_t address, uint8_t data)
+{
+ while (EECR & (1 << EEPE)); // wait for completion of previous eeprom write
+ while (SPMCSR & (1 << SPMEN)); // wait for completion of previous program memory write
+ EEAR = address;
+ EEDR = data;
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ EECR = EECRMask;
+ EECR |= (1 << EEPE);
+ END_MEASURE(HALISR_EEPROM_WRITE_TIME_LIMIT)
+ ATOMIC_SECTION_LEAVE
+}
+
+/******************************************************************************
+Interrupt handler.
+******************************************************************************/
+ISR(EE_READY_vect)
+{
+ BEGIN_MEASURE
+ EECR &= ~(1 << EERIE); //disable interrupt
+ halSigEepromReadyInterrupt();
+ END_MEASURE(HALISR_EEPROM_READY_TIME_LIMIT)
+}
+
+// eof helEeprom.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halInit.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halInit.c
new file mode 100644
index 00000000..593e6257
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halInit.c
@@ -0,0 +1,71 @@
+/**************************************************************************//**
+ \file halInit.c
+
+ \brief HAL start up module.
+
+ \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:
+ 29/06/07 E. Ivanov - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halAppClock.h>
+#include <halSleepTimerClock.h>
+#include <halRfSpi.h>
+#include <halIrq.h>
+#include <halInterrupt.h>
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ Reads uid from external devices.
+******************************************************************************/
+void halReadUid(void);
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+Performs start up HAL initialization.
+Parameters:
+ none.
+Returns:
+ none.
+******************************************************************************/
+void HAL_Init(void)
+{
+ /* Init first diagnostic timer */
+#ifdef MEASURE
+ TCCR5B = (1 << CS50);
+#endif
+
+ HAL_InitRfSpi();
+ /* start sleep time */
+ halStartSleepTimerClock();
+ /* initialization work frequency &
+ * start calibration */
+ halInitFreq();
+ /* Reads unique ID */
+ halReadUid();
+ /* initialization and start application timer */
+ halInitAppClock();
+ /* initialization dtr interrupt */
+ halSetIrqConfig(IRQ_4, IRQ_LOW_LEVEL);
+ /* global enable interrupt*/
+ HAL_EnableInterrupts();
+}
+// eof halInit.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halIrq.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halIrq.c
new file mode 100644
index 00000000..b119fe4d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halIrq.c
@@ -0,0 +1,119 @@
+/**************************************************************************//**
+ \file halIrq.c
+
+ \brief Implementation of HWD IRQ interface.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halIrq.h>
+#include <sleep.h>
+#include <halSleepTimerClock.h>
+#include <halAppClock.h>
+#include <halDbg.h>
+#include <halDiagnostic.h>
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+#if defined(PLATFORM_ZIGBIT)
+ IrqCallback_t IrqCallbackList[HAL_NUM_IRQ_LINES] = {NULL, NULL};
+#else
+ IrqCallback_t IrqCallbackList[HAL_NUM_IRQ_LINES] = {NULL, NULL, NULL};
+#endif
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+Sets configuration of pins and the registers.
+Parameters:
+ irqNumber - number of interrupt.
+ irqMode - mode of interrupt
+Returns:
+ none.
+******************************************************************************/
+void halSetIrqConfig(uint8_t irqNumber, uint8_t irqMode)
+{
+ uint8_t ui8ShiftCount = (irqNumber - IRQ_4) << 1;
+ // IRQ pin is input
+ DDRE &= ~(1 << irqNumber);
+ PORTE |= (1 << irqNumber);
+ // Clear previous settings of corresponding interrupt sense control
+ EICRB &= ~(3 << ui8ShiftCount);
+ // Setup corresponding interrupt sence control
+ EICRB |= (irqMode & 0x03) << ui8ShiftCount;
+ // Clear the INTn interrupt flag
+ EIFR |= (1 << irqNumber);
+}
+
+/**************************************************************************//**
+\brief Clears configuration of pins and the registers.
+\param[in]
+ irqNumber - number of interrupt.
+******************************************************************************/
+void halClrIrqConfig(uint8_t irqNumber)
+{
+ uint8_t ui8ShiftCount = (irqNumber - IRQ_4) << 1;
+ DDRE &= ~(1 << irqNumber);// IRQ pin is input
+ PORTE &= ~(1 << irqNumber); // pullup off
+ EICRB &= ~(3 << ui8ShiftCount);
+}
+
+#if !defined(PLATFORM_ZIGBIT)
+/******************************************************************************
+ External interrupt 5 handler
+******************************************************************************/
+ISR(INT5_vect)
+{
+ BEGIN_MEASURE
+ halWakeupFromIrq();
+ /* user's callback */
+ if (NULL != IrqCallbackList[IRQ_5 - HAL_FIRST_VALID_IRQ])
+ IrqCallbackList[IRQ_5 - HAL_FIRST_VALID_IRQ]();
+ END_MEASURE(HALISR_INT5_VECT_TIME_LIMIT)
+}
+#endif
+
+/******************************************************************************
+ External interrupt 6 handler
+******************************************************************************/
+ISR(INT6_vect)
+{
+ BEGIN_MEASURE
+ halWakeupFromIrq();
+ /* user's callback */
+ if (NULL != IrqCallbackList[IRQ_6 - HAL_FIRST_VALID_IRQ])
+ IrqCallbackList[IRQ_6 - HAL_FIRST_VALID_IRQ]();
+ END_MEASURE(HALISR_INT6_VECT_TIME_LIMIT)
+}
+
+/******************************************************************************
+ External interrupt 7 handler
+******************************************************************************/
+ISR(INT7_vect)
+{
+ BEGIN_MEASURE
+ halWakeupFromIrq();
+ /* user's callback */
+ if (NULL != IrqCallbackList[IRQ_7 - HAL_FIRST_VALID_IRQ])
+ IrqCallbackList[IRQ_7 - HAL_FIRST_VALID_IRQ]();
+ END_MEASURE(HALISR_INT7_VECT_TIME_LIMIT)
+}
+// eof irq.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halPwm.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halPwm.c
new file mode 100644
index 00000000..d5cd8a74
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halPwm.c
@@ -0,0 +1,161 @@
+/**************************************************************************//**
+ \file halPwm.c
+
+ \brief Implementation of hardware depended PWM interface.
+
+ \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:
+ 10/11/08 A. Taradov - Created
+ 5/04/11 A.Razinkov - Refactored
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <halPwm.h>
+#include <atomic.h>
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Prepare PWM channel access. Determine control registers, ports, pins etc.
+
+\param [in] descriptor - PWM channel descriptor.
+******************************************************************************/
+void halPreparePwmChannelAccess(HAL_PwmDescriptor_t *descriptor)
+{
+ /* PWM output port and pin determination */
+ switch (descriptor->unit)
+ {
+ case PWM_UNIT_1:
+ descriptor->service.DDRn = &DDRB;
+ descriptor->service.pwmBaseChannelPin = PWM_UNIT_1_BASE_CHANNEL_PIN;
+ break;
+
+ case PWM_UNIT_3:
+ descriptor->service.DDRn = &DDRE;
+ descriptor->service.pwmBaseChannelPin = PWM_UNIT_3_BASE_CHANNEL_PIN;
+ break;
+
+ /* Invalid PWM unit identifier */
+ default:
+ break;
+ }
+ /* PWM control registers determination */
+ descriptor->service.COMnx0 = COMNX0_BASE_BIT - (descriptor->channel * COMNX_BITFIELD_SIZE);
+ descriptor->service.OCRnx = (&OCRnA(descriptor->unit) + (descriptor->channel));
+}
+
+/**************************************************************************//**
+\brief Initializes the PWM.
+
+\param [in] pwmUnit - PWM unit number.
+ Equal to ID of Timer/Counter witch serves PWM module.
+******************************************************************************/
+void halOpenPwm(HAL_PwmUnit_t pwmUnit)
+{
+ /* Clear Timer/Counter */
+ halMoveWordToRegister(&TCNTn(pwmUnit), 0x0000);
+ /* Clear Timer/Counter Input Capture register */
+ halMoveWordToRegister(&ICRn(pwmUnit), 0x0000);
+ /* Configure port for normal operation */
+ TCCRnA(pwmUnit) = 0x00;
+ /* Configure PWM mode: phase and frequency correct, TOP = ICRn */
+ TCCRnB(pwmUnit) = (1 << WGMn3);
+}
+
+/**************************************************************************//**
+\brief Starts PWM on specified channel.
+
+\param [in] descriptor - PWM channel descriptor.
+******************************************************************************/
+void halStartPwm(HAL_PwmDescriptor_t *descriptor)
+{
+ /* Force compare on channel to clear output */
+ TCCRnC(descriptor->unit) |= (1 << (FOCNX_BASE_BIT - descriptor->channel));
+ /* Configure PWM pin as output */
+ halMakeOutPwmPin(descriptor);
+ /* Configure Compare Output Mode for PWM channel */
+ TCCRnA(descriptor->unit) |=
+ ((1 << COMnx1(descriptor)) | (1 << COMnx0(descriptor)));
+ if (PWM_POLARITY_INVERTED == descriptor->polarity)
+ TCCRnA(descriptor->unit) &= ~(1 << COMnx0(descriptor));
+}
+
+/**************************************************************************//**
+\brief Stops PWM on specified channel.
+
+\param [in] descriptor - PWM channel descriptor.
+******************************************************************************/
+void halStopPwm(HAL_PwmDescriptor_t *descriptor)
+{
+ /* Clean compare register and stop Timer/Counter */
+ halMoveWordToRegister(&OCRnx(descriptor), 0x0000);
+ TCCRnA(descriptor->unit) &= ~((1 << COMnx1(descriptor)) | (1 << COMnx0(descriptor)));
+ /* Configure PWM pin as intput */
+ halMakeInPwmPin(descriptor);
+}
+
+/**************************************************************************//**
+\brief Sets base frequency of module. Common for all module channels.
+
+\param [in] pwmUnit - PWM unit number. Equal to corresponding Timer/Counter ID.
+\param [in] top - value for the TOP register.
+\param [in] prescaler - clock prescaler.
+******************************************************************************/
+void halSetPwmFrequency(HAL_PwmUnit_t pwmUnit, uint16_t top, HAL_PwmPrescaler_t prescaler)
+{
+ /* Stop Timer/Counter */
+ TCCRnB(pwmUnit) &= ~((1 << CSn2) | (1 << CSn1) | (1 << CSn0));
+ /* Set new TOP register (ICRn in our case) */
+ halMoveWordToRegister(&ICRn(pwmUnit), top);
+ /* Initialize Timer/Counter with new TOP value */
+ halMoveWordToRegister(&TCNTn(pwmUnit), top);
+ /* Clear all PWM outputs */
+ halMoveWordToRegister(&OCRnA(pwmUnit), 0x0000);
+ halMoveWordToRegister(&OCRnB(pwmUnit), 0x0000);
+ halMoveWordToRegister(&OCRnC(pwmUnit), 0x0000);
+
+ /* Run Timer/Counter */
+ TCCRnB(pwmUnit) |= prescaler;
+}
+
+/**************************************************************************//**
+\brief Sets compare value for the PWM channel.
+
+\param [in] descriptor - PWM channel descriptor.
+******************************************************************************/
+void halSetPwmCompareValue(HAL_PwmDescriptor_t *descriptor, uint16_t cmpValue)
+{
+ halMoveWordToRegister(&OCRnx(descriptor), cmpValue);
+}
+
+/**************************************************************************//**
+\brief Closes the PWM.
+
+\param [in] pwmUnit - PWM unit number.
+ Equal to ID of Timer/Counter witch serves PWM module.
+******************************************************************************/
+void halClosePwm(HAL_PwmUnit_t pwmUnit)
+{
+ /* Configure port for normal operation */
+ TCCRnA(pwmUnit) = 0x00;
+ /* Disable PWM and stop timer */
+ TCCRnB(pwmUnit) = 0x00;
+}
+
+// eof halPwm.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halSleep.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halSleep.c
new file mode 100644
index 00000000..305dfd39
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halSleep.c
@@ -0,0 +1,297 @@
+/**************************************************************************//**
+ \file halSleep.c
+
+ \brief Implementation of sleep modes.
+
+ \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:
+ 1/12/09 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <sleepTimer.h>
+#include <halSleepTimerClock.h>
+#include <halRfPio.h>
+#include <halRfCtrl.h>
+#include <halSleep.h>
+#include <halIrq.h>
+#include <halDbg.h>
+#include <halAppClock.h>
+#include <halEeprom.h>
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Performs calibration of the main clock generator.
+******************************************************************************/
+void halStartingCalibrate(void);
+
+#ifdef _HAL_RF_RX_TX_INDICATOR_
+/**************************************************************************//**
+\brief Turn on pin 1 (DIG3) and pin 2 (DIG4) to indicate the transmit state of
+the radio transceiver.
+******************************************************************************/
+void phyRxTxSwitcherOn(void);
+
+/**************************************************************************//**
+\brief Turn off pin 1 (DIG3) and pin 2 (DIG4) to indicate the transmit state of
+the radio transceiver.
+******************************************************************************/
+void phyRxTxSwitcherOff(void);
+
+#endif
+
+#ifdef _HAL_ANT_DIVERSITY_
+/**************************************************************************//**
+\brief Turn on pin 9 (DIG1) and pin 10 (DIG2) to enable antenna select.
+******************************************************************************/
+void phyAntennaSwitcherOn(void);
+
+/**************************************************************************//**
+\brief Turn off pin 9 (DIG1) and pin 10 (DIG2) to disable antenna select.
+******************************************************************************/
+void phyAntennaSwitcherOff(void);
+
+#endif // _HAL_ANT_DIVERSITY_
+
+/******************************************************************************
+ External global variables section
+******************************************************************************/
+extern volatile bool halEnableDtrWakeUp;
+extern HalSleepControl_t halSleepControl;
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+static uint32_t halTimeStartOfSleep = 0ul;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Switch on system power.
+
+\param[in]
+ wakeupSource - wake up source
+******************************************************************************/
+void halPowerOn(const uint8_t wakeupSource)
+{
+ halSleepControl.wakeupStation = HAL_ACTIVE_MODE;
+ halSleepControl.wakeupSource = wakeupSource;
+
+ if (INTERNAL_RC == halGetClockSource())
+ {
+ GPIO_RF_SLP_TR_clr();
+ }
+ else
+ {
+ GPIO_RF_SLP_TR_make_in();
+ TCCR2A &= ~((1 << COM2A1) | (1 << COM2A0)); // no compare
+ while (ASSR & HAL_ASSR_FLAGS);
+ }
+ GPIO_RF_SLP_TR_make_out();
+
+ #ifdef _HAL_USE_AMPLIFIER_
+ // set one on pin. Enable power amplifier.
+ GPIO_POW_AMPLF_SLP_set();
+ #endif
+
+ halPostTask4(HAL_WAKEUP);
+}
+
+/******************************************************************************
+Shutdowns system.
+ NOTES:
+ the application should be sure the poweroff will not be
+ interrupted after the execution of the sleep().
+******************************************************************************/
+void halPowerOff(void)
+{
+ if (HAL_ACTIVE_MODE == halSleepControl.wakeupStation)
+ return; // it is a too late to sleep.
+
+ // stop application timer clock
+ halStopAppClock(); // will be shutdown
+ if (0ul == halTimeStartOfSleep)
+ { // start of sleep procedure
+ // save time of stopping of the application timer
+ halTimeStartOfSleep = halGetTimeOfSleepTimer();
+ }
+
+ #ifdef _HAL_USE_AMPLIFIER_
+ // set zero on pin. Disable power amplifier.
+ GPIO_POW_AMPLF_SLP_clr();
+ #endif
+
+ #ifdef _HAL_RF_RX_TX_INDICATOR_
+
+ // disable front end driver if that is supported
+ phyRxTxSwitcherOff();
+
+ #endif
+
+ #ifdef _HAL_ANT_DIVERSITY_
+
+ // disable antenna diversity switcher
+ phyAntennaSwitcherOff();
+
+ #endif
+
+ if (halEnableDtrWakeUp)
+ { /* enable DTR (irq 4) wake up */
+ halEnableIrqInterrupt(IRQ_4);
+ } /* enable DTR (irq 4) wake up */
+
+ // wait for end of eeprom writing
+ halWaitEepromReady();
+
+ if (INTERNAL_RC == halGetClockSource())
+ {
+ GPIO_RF_SLP_TR_set();
+ GPIO_RF_SLP_TR_make_out();
+
+ if (HAL_SLEEP_TIMER_IS_STARTED == halSleepControl.sleepTimerState)
+ { // sleep timer is started
+ SMCR = (1 << SM1) | (1 << SM0) | (1 << SE); // power-save
+ __SLEEP;
+ SMCR = 0;
+ }
+ else
+ {
+ halStopSleepTimerClock();
+ SMCR = (1 << SM1) | (1 << SE); // power-down
+ __SLEEP;
+ SMCR = 0;
+ halStartSleepTimerClock();
+ halStartingCalibrate();
+ }
+ }
+ else
+ {
+ uint8_t timsk4 = TIMSK4;
+ uint8_t twcr = TWCR;
+ uint8_t adcsra = ADCSRA;
+ TIMSK4 = 0;
+ TWCR = 0;
+ ADCSRA = 0;
+ GPIO_RF_SLP_TR_make_out();
+ SMCR = (1 << SM1) | (1 << SM0) | (1 << SE); // power-save
+ __SLEEP;
+ SMCR = 0;
+ TIMSK4 = timsk4;
+ TWCR = twcr;
+ ADCSRA = adcsra;
+ }
+
+ // wait for time about 1 TOSC1 cycle for correct re-entering from power save mode to power save mode
+ // wait for time about 1 TOSC1 cycle for correct reading TCNT2 after wake up to
+ OCR2B = SOME_VALUE_FOR_SYNCHRONIZATION;
+ while (ASSR & HAL_ASSR_FLAGS);
+}
+
+/******************************************************************************
+ Prepares system for power-save, power-down.
+ Power-down the mode is possible only when internal RC is used
+ Parameters:
+ none.
+ Returns:
+ -1 there is no possibility to power-down system.
+******************************************************************************/
+int HAL_Sleep(void)
+{
+ if (INTERNAL_RC != halGetClockSource())
+ {
+ if (HAL_SLEEP_TIMER_IS_STOPPED == halSleepControl.sleepTimerState)
+ { // sleep timer isn't started
+ return -1;
+ }
+ GPIO_RF_SLP_TR_make_in();
+
+ while (ASSR & HAL_ASSR_FLAGS);
+ if (!(TIMSK2 & (1 << OCIE2A)))
+ { // compare interrupt is disabled
+ OCR2A = 0xFF;
+ while (ASSR & HAL_ASSR_FLAGS);
+ }
+
+ TCCR2A |= ((1 << COM2A1) | (1 << COM2A0)); // set OC2A on compare
+ while (ASSR & HAL_ASSR_FLAGS);
+ TCCR2B |= (1 << FOC2A); // force output to set OC2A
+ while (ASSR & HAL_ASSR_FLAGS);
+ TCCR2A &= ~((1 << COM2A1) | (1 << COM2A0)); // no compare
+ while (ASSR & HAL_ASSR_FLAGS);
+ TCCR2A |= (1 << COM2A1); // clear OC2A on compare
+ while (ASSR & HAL_ASSR_FLAGS);
+ }
+
+ halSleepControl.wakeupStation = HAL_SLEEP_MODE; // the reset of sign of entry to the sleep mode.
+ while (ASSR & HAL_ASSR_FLAGS);
+ halPostTask4(HAL_SLEEP);
+ return 0;
+}
+
+/******************************************************************************
+ Handler for task manager. It is executed when system has waked up.
+******************************************************************************/
+void halWakeupHandler(void)
+{
+ uint32_t timeEndOfSleep;
+
+ // save time of stopping of the application timer
+ timeEndOfSleep = halGetTimeOfSleepTimer();
+
+ timeEndOfSleep -= halTimeStartOfSleep; // time of sleep
+ halTimeStartOfSleep = 0ul;
+ // adjust application timer interval
+ halAdjustSleepInterval(timeEndOfSleep);
+ // start application timer clock
+ halStartAppClock();
+ // Wait for when radio will be waked up.
+ halWaitRadio();
+
+ #ifdef _HAL_ANT_DIVERSITY_
+
+ // enable antenna diversity switcher
+ phyAntennaSwitcherOn();
+
+ #endif
+
+ #ifdef _HAL_RF_RX_TX_INDICATOR_
+
+ // enable front end driver if that is supported
+ phyRxTxSwitcherOn();
+
+ #endif
+
+ if (HAL_SLEEP_TIMER_IS_WAKEUP_SOURCE == halSleepControl.wakeupSource)
+ {
+ if (halSleepControl.callback)
+ halSleepControl.callback();
+ }
+}
+
+/*******************************************************************************
+ Makes MCU enter Idle mode.
+*******************************************************************************/
+void HAL_IdleMode(void)
+{
+ SMCR = 0x1;
+ __SLEEP;
+ SMCR = 0;
+}
+
+// eof sleep.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halSleepTimerClock.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halSleepTimerClock.c
new file mode 100644
index 00000000..70038e7f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halSleepTimerClock.c
@@ -0,0 +1,304 @@
+/**************************************************************************//**
+ \file halSleepTimer.c
+
+ \brief Module for count out requested sleep interval.
+
+ \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:
+ 29/06/07 E. Ivanov - Created
+ 7/04/09 A. Khromykh - Refactored
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <sleepTimer.h>
+#include <halSleepTimerClock.h>
+#include <halSleep.h>
+#include <halDbg.h>
+#include <halDiagnostic.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define LSB_IN_DWORD(A) ((uint32_t)A & 0x000000FF)
+#define MULTIPLY_ON_31d25(A) (((uint32_t)A << 5) - (uint32_t)A + ((uint32_t)A >> 2))
+#define MAX_TIMER_VALUE 0xFF
+#define SLEEP_TIMER_ITERATOR (1000ul * 256ul * SLEEPTIMER_DIVIDER / SLEEPTIMER_CLOCK)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef struct
+{
+ volatile uint16_t interval; // Contains number of timer full interval before will load reminder.
+ volatile uint8_t remainder; // Contains number of ticks that passed before timer firing
+} TimerControl_t;
+
+/******************************************************************************
+ External global variables section
+******************************************************************************/
+extern HalSleepControl_t halSleepControl;
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+static volatile TimerControl_t halTimerControl;
+// time of sleep timer in ms.
+static uint32_t halSleepTime = 0ul;
+// upper byte of sleep time
+uint8_t halSleepTimerOvfw = 0;
+// interrupt counter
+static volatile uint8_t halIrqOvfwCount = 0;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Clear timer control structure
+******************************************************************************/
+void halClearTimeControl(void)
+{
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ // clear timer control structure
+ halTimerControl.remainder = 0;
+ halTimerControl.interval = 0;
+ END_MEASURE(HALATOM_CLEAR_TIME_CONTROL_TIME_LIMIT)
+ ATOMIC_SECTION_LEAVE
+}
+
+/**************************************************************************//**
+\brief Wake up procedure for all external interrupts
+******************************************************************************/
+void halWakeupFromIrq(void)
+{
+ if (HAL_SLEEP_MODE == halSleepControl.wakeupStation)
+ {
+ halPowerOn(HAL_EXT_IRQ_IS_WAKEUP_SOURCE);
+ // disable compare match interrupt
+ TIMSK2 &= ~(1 << OCIE2A);
+ // clear timer control structure
+ halClearTimeControl();
+ // stop high sleep timer logic
+ halSleepControl.sleepTimerState = HAL_SLEEP_TIMER_IS_STOPPED;
+ }
+}
+
+/******************************************************************************
+Starts the sleep timer clock.
+******************************************************************************/
+void halStartSleepTimerClock(void)
+{
+ //1. Disable the Timer/Counter2 interrupts by clearing OCIE2x and TOIE2.
+ halDisableSleepTimerInt();
+ //2. Select clock source by setting AS2 as appropriate.
+ ASSR |= (1 << AS2); // clock source is TOSC1 pin
+ //3. Write new values to TCNT2, OCR2x, and TCCR2x.
+ TCNT2 = 0;
+ TCCR2A = 0x00; // normal operation, OC2A&OC2B disconnected
+ TCCR2B = 0x00;
+ OCR2A = 0x00;
+ //4. To switch to asynchronous operation: Wait for TCN2UB, OCR2xUB, and TCR2xUB.
+ while (ASSR & HAL_ASSR_FLAGS);
+ //5. Clear the Timer/Counter2 Interrupt Flags.
+ TIFR2 = (1 << OCF2A) | (1 << TOV2);
+ //6. Enable interrupts, if needed.
+ TCCR2B = SLEEPTIMER_PRESCALER; // start timer
+ TIMSK2 |= (1 << TOIE2); // enable overflow interrupt
+}
+
+/******************************************************************************
+Stops the sleep timer clock.
+******************************************************************************/
+void halStopSleepTimerClock(void)
+{
+ while (ASSR & HAL_ASSR_FLAGS);
+ //1. Disable the Timer/Counter2 interrupts by clearing OCIE2x and TOIE2.
+ halDisableSleepTimerInt();
+ TCCR2B &= ~SLEEPTIMER_PRESCALER; // Stops the timer
+ GTCCR |= (1 << PSRASY); // Reset prescaler
+ while (ASSR & HAL_ASSR_FLAGS);
+ // switch of oscillator
+ ASSR &= ~(1 << AS2);
+}
+
+/******************************************************************************
+Sets interval.
+Parameters:
+ value - contains number of ticks which the timer must count out.
+Returns:
+ none.
+******************************************************************************/
+void halSetSleepTimerInterval(uint32_t value)
+{
+ uint8_t currCounter = TCNT2;
+ uint32_t tempValue = LSB_IN_DWORD(~currCounter);
+
+ if (value > tempValue)
+ {
+ value -= tempValue;
+ // halTimerControl.interval = value / 255
+ halTimerControl.interval = value >> 8;
+ halTimerControl.remainder = value & 0xFF;
+ }
+ else
+ { // enough timer reminder before overflow
+ currCounter += (uint8_t)value;
+ // wait for end of synchronization
+ while (ASSR & HAL_ASSR_FLAGS);
+ // load compared value
+ OCR2A = currCounter;
+ // clear compare interrupt flag
+ TIFR2 = 1 << OCF2A;
+ // enable compare match interrupt
+ TIMSK2 |= (1 << OCIE2A);
+ }
+}
+
+/******************************************************************************
+Return time of sleep timer.
+
+Returns:
+ time in ms.
+******************************************************************************/
+uint32_t halGetTimeOfSleepTimer(void)
+{
+ uint32_t tempValue;
+ uint8_t tmpCounter;
+
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ // read interrupt counter
+ tmpCounter = halIrqOvfwCount;
+ // read asynchronous counter
+ tempValue = TCNT2;
+ // wait for setup asynchronous registers
+ OCR2B = SOME_VALUE_FOR_SYNCHRONIZATION;
+ while (ASSR & HAL_ASSR_FLAGS);
+ if (TIFR2 & (1 << TOV2))
+ { // there is issued interrupt
+ tempValue = TCNT2;
+ tempValue += MAX_TIMER_VALUE;
+ }
+ END_MEASURE(HAL_GET_SLEEP_TIME_LIMIT)
+ ATOMIC_SECTION_LEAVE
+
+ tempValue += tmpCounter * MAX_TIMER_VALUE;
+
+ #if defined(SLEEP_PRESCALER_1024)
+ // one tick time 31.25 ms.
+ return (halSleepTime + MULTIPLY_ON_31d25(tempValue));
+ #else
+ #warning 'to do counting sleep timer for that prescaler'
+ return (halSleepTime + tempValue * (1000 * SLEEPTIMER_DIVIDER / SLEEPTIMER_CLOCK));
+ #endif
+}
+
+/******************************************************************************
+Returns the sleep timer frequency in Hz.
+Parameters:
+ none.
+Returns:
+ frequency.
+******************************************************************************/
+uint32_t halSleepTimerFrequency(void)
+{
+ return (SLEEPTIMER_CLOCK / SLEEPTIMER_DIVIDER);
+}
+
+/**************************************************************************//**
+Synchronization system time which based on sleep timer.
+******************************************************************************/
+void halSleepSystemTimeSynchronize(void)
+{
+ uint8_t tmpCounter;
+ uint32_t tmpValue;
+
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ tmpCounter = halIrqOvfwCount;
+ halIrqOvfwCount = 0;
+ END_MEASURE(HAL_SLEEP_TIMER_SYNCHRONIZE_LIMIT)
+ ATOMIC_SECTION_LEAVE
+
+ tmpValue = tmpCounter * SLEEP_TIMER_ITERATOR;
+ halSleepTime += tmpValue;
+ if (halSleepTime < tmpValue)
+ halSleepTimerOvfw++;
+}
+
+/******************************************************************************
+Compare interrupt handler.
+******************************************************************************/
+ISR(TIMER2_COMPA_vect)
+{
+ BEGIN_MEASURE
+ // disable compare match interrupt
+ TIMSK2 &= ~(1 << OCIE2A);
+ // nulling for adjusting
+ halTimerControl.remainder = 0;
+ if (HAL_SLEEP_MODE == halSleepControl.wakeupStation)
+ halPowerOn(HAL_SLEEP_TIMER_IS_WAKEUP_SOURCE);
+ // post task for task manager
+ if (HAL_SLEEP_TIMER_IS_STARTED == halSleepControl.sleepTimerState)
+ halInterruptSleepClock();
+ END_MEASURE(HALISR_TIMER2_COMPA_TIME_LIMIT)
+}
+
+/******************************************************************************
+Overflow interrupt handler.
+******************************************************************************/
+ISR(TIMER2_OVF_vect)
+{
+ BEGIN_MEASURE
+ if (0 == halTimerControl.interval)
+ {
+ if (0 == halTimerControl.remainder)
+ {
+ if (HAL_SLEEP_MODE == halSleepControl.wakeupStation)
+ halPowerOn(HAL_SLEEP_TIMER_IS_WAKEUP_SOURCE);
+ // post task for task manager
+ if (HAL_SLEEP_TIMER_IS_STARTED == halSleepControl.sleepTimerState)
+ halInterruptSleepClock();
+ }
+ else
+ {
+ // wait for end of synchronization
+ while (ASSR & HAL_ASSR_FLAGS);
+ // load compared value
+ OCR2A = halTimerControl.remainder;
+ // clear compare interrupt flag
+ TIFR2 = 1 << OCF2A;
+ // enable compare match interrupt
+ TIMSK2 |= (1 << OCIE2A);
+ if (HAL_SLEEP_MODE == halSleepControl.wakeupStation)
+ HAL_Sleep();
+ }
+ }
+ else
+ {
+ halTimerControl.interval--;
+ if (HAL_SLEEP_MODE == halSleepControl.wakeupStation)
+ HAL_Sleep();
+ }
+
+ halIrqOvfwCount++;
+ halSynchronizeSleepTime();
+
+ END_MEASURE(HALISR_TIMER2_OVF_TIME_LIMIT)
+}
+
+//eof halSleepTimerClock.c
+
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halSpi.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halSpi.c
new file mode 100644
index 00000000..b0c8bf0a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halSpi.c
@@ -0,0 +1,142 @@
+/**************************************************************************//**
+\file halSpi.c
+
+\brief Implementation of USART SPI mode.
+
+\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:
+ 29/06/07 E. Ivanov - Created
+******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <spi.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define UDORD0 2
+#define UCPHA0 1
+#define UCPOL0 0
+#define SPI_CLOCK_MODE_AMOUNT 4
+#define SPI_DATA_ORDER_AMOUNT 2
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+Set the parameters of USART to work at SPI mode.
+Parameters:
+ descriptor - pointer to the spi descriptor.
+Returns:
+ none.
+******************************************************************************/
+void halSetUsartSpiConfig(HAL_SpiDescriptor_t *descriptor)
+{
+ uint8_t clockMode[SPI_CLOCK_MODE_AMOUNT] = {((0 << UCPOL0) | (0 << UCPHA0)),
+ ((0 << UCPOL0) | (1 << UCPHA0)),
+ ((1 << UCPOL0) | (0 << UCPHA0)),
+ ((1 << UCPOL0) | (1 << UCPHA0))};
+ uint8_t dataOrder[SPI_DATA_ORDER_AMOUNT] = {(0 << UDORD0),
+ (1 << UDORD0)};
+
+ // setting of the spi gpio direct
+ if (SPI_CHANNEL_0 == descriptor->tty)
+ GPIO_USART0_EXTCLK_make_out();
+ else
+ GPIO_USART1_EXTCLK_make_out();
+
+ UBRRn(descriptor->tty) = 0;
+ // Set MSPI mode
+ UCSRnC(descriptor->tty) = (1 << UMSEL01) | (1 << UMSEL00);
+ // Set clock mode and data order
+ UCSRnC(descriptor->tty) |= (dataOrder[descriptor->dataOrder] | clockMode[descriptor->clockMode]);
+ // Enable receiver and transmitter
+ UCSRnB(descriptor->tty) = (1 << RXEN0) | (1 << TXEN0);
+ // Set baud rate
+ UBRRn(descriptor->tty) = descriptor->baudRate;
+}
+
+/******************************************************************************
+Disables USART channel.
+Parameters:
+ tty - spi channel.
+******************************************************************************/
+void halClearUsartSpi(SpiChannel_t tty)
+{
+ if (SPI_CHANNEL_0 == tty)
+ GPIO_USART0_EXTCLK_make_in();
+ else
+ GPIO_USART1_EXTCLK_make_in();
+
+ UCSRnB(tty) = 0x00; // disable
+}
+
+/******************************************************************************
+Write a length bytes to the SPI.
+Parameters:
+ tty - spi channel
+ buffer - pointer to application data buffer;
+ length - number bytes for transfer;
+Returns:
+ number of written bytes
+******************************************************************************/
+uint16_t halSyncUsartSpiWriteData(SpiChannel_t tty, uint8_t *buffer, uint16_t length)
+{
+ uint16_t i;
+ uint8_t temp;
+
+ for (i = 0; i < length; i++)
+ {
+ // Wait for empty transmit buffer
+ while (!(UCSRnA(tty) & (1 << UDRE0)));
+ // Send data
+ UDRn(tty) = *(buffer + i);
+ // Wait for data to be received
+ while (!(UCSRnA(tty) & (1 << RXC0)));
+ // receives data to clear received usart buffer
+ temp = UDRn(tty);
+ (void)temp;
+ }
+ return i;
+}
+
+/******************************************************************************
+Write & read a length bytes to & from the SPI.
+Parameters:
+ tty - spi channel
+ buffer - pointer to application data buffer;
+ length - number bytes for transfer;
+Returns:
+ number of written & read bytes
+******************************************************************************/
+uint16_t halSyncUsartSpiReadData(SpiChannel_t tty, uint8_t *buffer, uint16_t length)
+{
+ uint16_t i;
+
+ for (i = 0; i < length; i++)
+ {
+ // Wait for empty transmit buffer
+ while (!(UCSRnA(tty) & (1 << UDRE0)));
+ // Send data
+ UDRn(tty) = *(buffer + i);
+ // Wait for data to be received
+ while (!(UCSRnA(tty) & (1 << RXC0)));
+ // Receive data
+ *(buffer + i) = UDRn(tty);
+ }
+ return i;
+}
+
+//end of halSpi.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halUsart.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halUsart.c
new file mode 100644
index 00000000..90388ed0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halUsart.c
@@ -0,0 +1,190 @@
+/**************************************************************************//**
+\file halUsart.c
+
+\brief Implementation of usart hardware-dependent module.
+
+\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:
+ 29/05/07 E. Ivanov - Created
+*******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <sleep.h>
+#include <usart.h>
+#include <halSleepTimerClock.h>
+#include <halAppClock.h>
+#include <halIrq.h>
+#include <halDiagnostic.h>
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+void halPostUsartTask(HalUsartTaskId_t taskId);
+
+/******************************************************************************
+ External global variables section
+******************************************************************************/
+extern volatile bool halEnableDtrWakeUp;
+extern void (* dtrWakeUpCallback)(void);
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+ \brief Sets USART module parameters.
+ \param
+ usartmode - pointer to HAL_UsartDescriptor_t
+ \return
+ none.
+******************************************************************************/
+void halSetUsartConfig(HAL_UsartDescriptor_t *usartMode)
+{
+ UCSRnB(usartMode->tty) = 0x00; // disable usart
+ UBRRn(usartMode->tty) = usartMode->baudrate; // usart speed
+
+ if (USART_MODE_ASYNC == usartMode->mode)
+ {
+ UCSRnA(usartMode->tty) = (uint8_t)USART_DOUBLE_SPEED << U2X0; // Double the USART Transmition Speed
+ UCSRnC(usartMode->tty) = 0x00;
+ }
+ else
+ {
+ UCSRnA(usartMode->tty) = 0;
+ UCSRnC(usartMode->tty) = usartMode->edge; // edge select
+ }
+
+ UCSRnC(usartMode->tty) |= usartMode->mode;
+ UCSRnC(usartMode->tty) |= usartMode->dataLength; // character size
+ UCSRnC(usartMode->tty) |= usartMode->parity; // parity mode
+ UCSRnC(usartMode->tty) |= usartMode->stopbits; // stop bit select
+ UCSRnA(usartMode->tty) |= (1 << RXC0); // clear receive interrupt
+ UCSRnB(usartMode->tty) |= (1 << RXEN1) | (1 << TXEN1); // usart enable
+ UCSRnB(usartMode->tty) |= (1 << RXCIE0) ; // receive interrupt enable
+}
+
+/**************************************************************************//**
+ \brief The interrupt handler of USART0 - data register is empty.
+******************************************************************************/
+ISR(USART0_UDRE_vect)
+{
+ BEGIN_MEASURE
+ // We must disable the interrupt because we must "break" context.
+ halDisableUsartDremInterrupt(USART_CHANNEL_0);
+ halPostUsartTask(HAL_USART_TASK_USART0_DRE);
+ END_MEASURE(HALISR_USART0_UDR_TIME_LIMIT)
+}
+
+/**************************************************************************//**
+ \brief The interrupt handler of USART0 - transmission is completed.
+******************************************************************************/
+ISR(USART0_TX_vect)
+{
+ BEGIN_MEASURE
+ halDisableUsartTxcInterrupt(USART_CHANNEL_0);
+ halPostUsartTask(HAL_USART_TASK_USART0_TXC);
+ END_MEASURE(HALISR_USART0_TX_TIME_LIMIT)
+}
+
+/**************************************************************************//**
+ \brief The interrupt handler of USART0 - reception is completed.
+******************************************************************************/
+ISR(USART0_RX_vect)
+{
+ BEGIN_MEASURE
+ uint8_t status = UCSR0A;
+ uint8_t data = UDR0;
+
+ if (!(status & ((1 << FE0) | (1 << DOR0) | (1 << UPE0))))
+ {
+ halUsartRxBufferFiller(USART_CHANNEL_0, data);
+ halPostUsartTask(HAL_USART_TASK_USART0_RXC);
+ }
+ #if defined(_USE_USART_ERROR_EVENT_)
+ else // There is an error in the received byte.
+ {
+ halUsartSaveErrorReason(USART_CHANNEL_0, status);
+ halPostUsartTask(HAL_USART_TASK_USART0_ERR);
+ }
+ #endif
+
+ END_MEASURE(HALISR_USART0_RX_TIME_LIMIT)
+}
+
+/**************************************************************************//**
+ \brief The interrupt handler of USART1 - data register is empty.
+******************************************************************************/
+ISR(USART1_UDRE_vect)
+{
+ BEGIN_MEASURE
+ // We must disable the interrupt because we must "break" context.
+ halDisableUsartDremInterrupt(USART_CHANNEL_1);
+ halPostUsartTask(HAL_USART_TASK_USART1_DRE);
+ END_MEASURE(HALISR_USART1_UDRE_TIME_LIMIT)
+}
+
+/**************************************************************************//**
+ \brief The interrupt handler of USART1 - transmission is completed.
+******************************************************************************/
+ISR(USART1_TX_vect)
+{
+ BEGIN_MEASURE
+ halDisableUsartTxcInterrupt(USART_CHANNEL_1);
+ halPostUsartTask(HAL_USART_TASK_USART1_TXC);
+ END_MEASURE(HALISR_USART1_TX_TIME_LIMIT)
+}
+
+/**************************************************************************//**
+ \brief The interrupt handler of USART1 - reception is completed.
+******************************************************************************/
+ISR(USART1_RX_vect)
+{
+ BEGIN_MEASURE
+ uint8_t status = UCSR1A;
+ uint8_t data = UDR1;
+
+ if (!(status & ((1 << FE1) | (1 << DOR1) | (1 << UPE1))))
+ {
+ halUsartRxBufferFiller(USART_CHANNEL_1, data);
+ halPostUsartTask(HAL_USART_TASK_USART1_RXC);
+ }
+ #if defined(_USE_USART_ERROR_EVENT_)
+ else // There is an error in the received byte.
+ {
+ halUsartSaveErrorReason(USART_CHANNEL_1, status);
+ halPostUsartTask(HAL_USART_TASK_USART1_ERR);
+ }
+ #endif
+ END_MEASURE(HALISR_USART1_RX_TIME_LIMIT)
+}
+
+/**************************************************************************//**
+/brief External interrupt 4 (DTR) handler
+******************************************************************************/
+ISR(INT4_vect)
+{
+ BEGIN_MEASURE
+ halWakeupFromIrq();
+
+ if (halEnableDtrWakeUp)
+ { /* enable DTR (irq 4) wake up */
+ halDisableIrqInterrupt(IRQ_4);
+ } /* enable DTR (irq 4) wake up */
+
+ if (NULL != dtrWakeUpCallback)
+ dtrWakeUpCallback();
+ END_MEASURE(HALISR_INT4_TIME_LIMIT)
+}
+// eof halUsart.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halW1.s b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halW1.s
new file mode 100644
index 00000000..1c76747f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halW1.s
@@ -0,0 +1,210 @@
+/**************************************************************************//**
+ \file halW1.s
+
+ \brief Implementation of 1-wire hardware-dependent module.
+
+ \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:
+ 29/05/07 E. Ivanov - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+.include "halGccD.h"
+.set __w1_port, 0x14 ; PORTG
+.set __w1_bit, 5 ; PORTG5
+.set __w1_ddr, 0x13 ; DDRG
+.set __w1_pin, 0x12 ; PING
+
+/*=============================================================
+ Resets all devices connected to the bus. Function asserts on
+ the bus reset pulse and detects presence pulse. The result is
+ contained in r24.
+ Parameters:
+ Returns:
+ W1_SUCCESS_STATUS - If device(s) was(were) detected.
+ W1_NO_DEVICE_STATUS - If device(s) was(were) not detected.
+===============================================================*/
+.global halResetW1
+.type halResetW1,@function
+halResetW1:
+ ; Store SREG
+ push r23
+ in r23, 0x3F
+ ; Disable interrupts
+ cli
+ ; Pull down
+ sbi __w1_ddr, __w1_bit
+ cbi __w1_port, __w1_bit
+ ; Reset Low Time (500 us)
+ ldi r24, 250
+ call __delay_us
+ ldi r24, 250
+ call __delay_us
+ ; Tri-state (external pullup)
+ cbi __w1_ddr, __w1_bit
+ ; Presence-Detect Sample Time (70 us)
+ ldi r24, 70
+ call __delay_us
+ ; Precense-Detect
+ ldi r24, 0x01
+ sbic __w1_pin, __w1_bit
+ ldi r24, 0x00
+ push r24
+ ; Tail of Reset High Time
+ ldi r24, 240
+ call __delay_us
+ pop r24
+ ; Restore SREG
+ out 0x3F, r23
+ pop r23
+ ret
+
+/*=============================================================
+ Reads bit from the bus
+ Returns:
+ bit read from the bus in r24
+===============================================================*/
+.global halReadW1Bit
+.type halReadW1Bit,@function
+halReadW1Bit:
+ ; Store SREG
+ push r23
+ in r23, 0x3F
+ ; Disable interrupts
+ cli
+ ; Pull down
+ sbi __w1_ddr, __w1_bit
+ cbi __w1_port, __w1_bit
+ ; Read Low Time (6 us)
+ ldi r24, 6
+ call __delay_us
+ ; Tri-state (external pullup)
+ cbi __w1_ddr, __w1_bit
+ ; Tail of Read Sample Time (10 us)
+ ldi r24, 10
+ call __delay_us
+ ; Read Sample
+ clc
+ sbic __w1_pin, __w1_bit
+ sec
+ rol r24
+ ; Tail of Timeslot Duration
+ push r24
+ ldi r24, 100
+ call __delay_us
+ pop r24
+ ; Restore SREG
+ out 0x3F, r23
+ pop r23
+ ret
+
+/*=============================================================
+ Reads byte from the bus
+ Returns:
+ byte read from the bus in r24
+===============================================================*/
+.global halReadW1
+.type halReadW1,@function
+halReadW1:
+ push r25
+ push r23
+ ldi r25, 8
+__read_bit_again:
+ call halReadW1Bit
+ ror r24
+ ror r23
+ dec r25
+ tst r25
+ brne __read_bit_again
+ mov r24, r23
+ pop r23
+ pop r25
+ ret
+
+/*=============================================================
+ Writes bit to the bus
+ Parameters:
+ value - bit that should be written to the bus.
+===============================================================*/
+.global halWriteW1bit
+.type halWriteW1bit,@function
+halWriteW1bit:
+ ; Store SREG
+ push r23
+ in r23, 0x3F
+ ; Disable interrupts
+ cli
+ ; Pull down
+ cbi __w1_port, __w1_bit
+ sbi __w1_ddr, __w1_bit
+ ; Write-1 Low Time
+ push r24
+ ldi r24, 6
+ call __delay_us
+ pop r24
+ ; Write bit
+ ror r24
+ brcc __w1_write_zero
+ ; Write-One -> tri-state (external pullup)
+ cbi __w1_ddr, __w1_bit
+__w1_write_zero:
+ ; Tail of Timeslot Duration
+ push r24
+ ldi r24, 100
+ call __delay_us
+ pop r24
+ ; Tri-state (external pullup)
+ cbi __w1_ddr, __w1_bit
+ ; Restore SREG
+ out 0x3F, r23
+ pop r23
+ ret
+
+/*=============================================================
+ Writes byte to the bus
+ Parameters:
+ value - byte that should be written to the bus.
+===============================================================*/
+.global halWriteW1
+.type halWriteW1,@function
+halWriteW1:
+ push r25
+ ldi r25, 8
+__write_bit_again:
+ call halWriteW1bit
+ dec r25
+ tst r25
+ brne __write_bit_again
+ pop r25
+ ret
+
+/*=============================================================
+ Delay in microseconds.
+ Parameters:
+ us - delay time in microseconds
+===============================================================*/
+.global __delay_us
+.type __delay_us,@function
+__delay_us:
+__w0:
+.if FCPU==8000000
+ nop
+ nop
+ nop
+ nop
+.endif
+ dec r24
+ tst r24
+ brne __w0
+ ret
+; eof halW1.s
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halW1.s90 b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halW1.s90
new file mode 100644
index 00000000..a12f063d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halW1.s90
@@ -0,0 +1,211 @@
+/**************************************************************************//**
+ \file halW1.s90
+
+ \brief Implementation of 1-wire hardware-dependent module.
+
+ \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:
+ 29/05/07 E. Ivanov - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#include <halIarD.h>
+__w1_port VAR 0x14 ; PORTG
+__w1_bit VAR 5 ; PORTG5
+__w1_ddr VAR 0x13 ; DDRG
+__w1_pin VAR 0x12 ; PING
+
+/*=============================================================
+ Resets all devices connected to the bus. Function asserts on
+ the bus reset pulse and detects presence pulse. The result is
+ contained in r16.
+ Parameters:
+ Returns:
+ W1_SUCCESS_STATUS - If device(s) was(were) detected.
+ W1_NO_DEVICE_STATUS - If device(s) was(were) not detected.
+===============================================================*/
+PUBLIC halResetW1
+RSEG CODE
+halResetW1:
+ ; Store SREG
+ push r23
+ in r23, 0x3F
+ ; Disable interrupts
+ cli
+ ; Pull down
+ sbi __w1_ddr, __w1_bit
+ cbi __w1_port, __w1_bit
+ ; Reset Low Time (500 us)
+ ldi r16, 250
+ call __delay_us
+ ldi r16, 250
+ call __delay_us
+ ; Tri-state (external pullup)
+ cbi __w1_ddr, __w1_bit
+ ; Presence-Detect Sample Time (70 us)
+ ldi r16, 70
+ call __delay_us
+ ; Precense-Detect
+ ldi r16, 0x01
+ sbic __w1_pin, __w1_bit
+ ldi r16, 0x00
+ push r16
+ ; Tail of Reset High Time
+ ldi r16, 240
+ call __delay_us
+ pop r16
+ ; Restore SREG
+ out 0x3F, r23
+ pop r23
+ ret
+
+/*=============================================================
+ Reads bit from the bus
+ Returns:
+ bit read from the bus in r16
+===============================================================*/
+PUBLIC halReadW1Bit
+RSEG CODE
+halReadW1Bit:
+ ; Store SREG
+ push r23
+ in r23, 0x3F
+ ; Disable interrupts
+ cli
+ ; Pull down
+ sbi __w1_ddr, __w1_bit
+ cbi __w1_port, __w1_bit
+ ; Read Low Time (6 us)
+ ldi r16, 6
+ call __delay_us
+ ; Tri-state (external pullup)
+ cbi __w1_ddr, __w1_bit
+ ; Tail of Read Sample Time (10 us)
+ ldi r16, 10
+ call __delay_us
+ ; Read Sample
+ clc
+ sbic __w1_pin, __w1_bit
+ sec
+ rol r16
+ ; Tail of Timeslot Duration
+ push r16
+ ldi r16, 100
+ call __delay_us
+ pop r16
+ ; Restore SREG
+ out 0x3F, r23
+ pop r23
+ ret
+
+/*=============================================================
+ Reads byte from the bus
+ Returns:
+ byte read from the bus in r16
+===============================================================*/
+PUBLIC halReadW1
+RSEG CODE
+halReadW1:
+ push r25
+ push r23
+ ldi r25, 8
+__read_bit_again:
+ call halReadW1Bit
+ ror r16
+ ror r23
+ dec r25
+ tst r25
+ brne __read_bit_again
+ mov r16, r23
+ pop r23
+ pop r25
+ ret
+
+/*=============================================================
+ Writes bit to the bus
+ Parameters:
+ value - bit that should be written to the bus.
+===============================================================*/
+PUBLIC halWriteW1bit
+RSEG CODE
+halWriteW1bit:
+ ; Store SREG
+ push r23
+ in r23, 0x3F
+ ; Disable interrupts
+ cli
+ ; Pull down
+ cbi __w1_port, __w1_bit
+ sbi __w1_ddr, __w1_bit
+ ; Write-1 Low Time
+ push r16
+ ldi r16, 6
+ call __delay_us
+ pop r16
+ ; Write bit
+ ror r16
+ brcc __w1_write_zero
+ ; Write-One -> tri-state (external pullup)
+ cbi __w1_ddr, __w1_bit
+__w1_write_zero:
+ ; Tail of Timeslot Duration
+ push r16
+ ldi r16, 100
+ call __delay_us
+ pop r16
+ ; Tri-state (external pullup)
+ cbi __w1_ddr, __w1_bit
+ ; Restore SREG
+ out 0x3F, r23
+ pop r23
+ ret
+
+/*=============================================================
+ Writes byte to the bus
+ Parameters:
+ value - byte that should be written to the bus.
+===============================================================*/
+PUBLIC halWriteW1
+RSEG CODE
+halWriteW1:
+ push r25
+ ldi r25, 8
+__write_bit_again:
+ call halWriteW1bit
+ dec r25
+ tst r25
+ brne __write_bit_again
+ pop r25
+ ret
+
+/*=============================================================
+ Delay in microseconds.
+ Parameters:
+ us - delay time in microseconds
+===============================================================*/
+PUBLIC __delay_us
+RSEG CODE
+__delay_us:
+__w0:
+#if FCPU==8000000
+ nop
+ nop
+ nop
+ nop
+#endif
+ dec r16
+ tst r16
+ brne __w0
+ ret
+; eof halW1.s
+END
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halWdtInit.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halWdtInit.c
new file mode 100644
index 00000000..eb2a9dff
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/halWdtInit.c
@@ -0,0 +1,175 @@
+/**************************************************************************//**
+ \file halWdtInit.c
+
+ \brief Implementation of WDT start up procedure.
+
+ \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:
+ 29/05/07 E. Ivanov - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <resetReason.h>
+#include <halAppClock.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+#define PIN_OUT 62500
+#define MEANING_BITS 0x1F
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+#ifdef _SYS_ASSERT_ON_
+ INLINE void halJumpNullHandler(void);
+#endif
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+#if defined(__GNUC__)
+ uint8_t halResetReason __attribute__ ((section (".noinit")));
+#elif defined(__ICCAVR__)
+ __no_init uint8_t halResetReason;
+#endif
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+Resets and stops wdt. Saves the reason of reset.
+Parameters:
+ none.
+Returns:
+ none.
+******************************************************************************/
+#if defined(__GNUC__)
+
+ void halWdtInit(void) __attribute__ ((naked)) \
+ __attribute__ ((section (".init0")));
+
+ void halWdtInit(void)
+ {
+ ASM("clr r1");
+#elif defined(__ICCAVR__)
+
+ __task void halWdtInit(void)
+ {
+ ASM("clr r15");
+#else
+ #error 'Compiler not supported.'
+#endif
+
+ if (TEMP_WARM_RESET != halResetReason)
+ {
+ halResetReason = MCUSR & MEANING_BITS;
+
+ if (halResetReason & POWER_ON_RESET)
+ halResetReason = POWER_ON_RESET;
+ }
+ else
+ {
+ halResetReason = WARM_RESET;
+ }
+ MCUSR = 0;
+ WDTCSR |= (1 << WDCE) | (1 << WDE);
+ WDTCSR = 0x00;
+
+ #ifdef _SYS_ASSERT_ON_
+ halJumpNullHandler();
+ #endif
+ }
+
+#ifdef _SYS_ASSERT_ON_
+/******************************************************************************
+Jump to NULL handler.
+Parameters:
+ none.
+Returns:
+ none.
+******************************************************************************/
+void halJumpNullHandler(void)
+{
+ if (0 == halResetReason) // was jump on NULL
+ {
+ register volatile uint16_t tmp;
+ tmp = SP;
+
+ ASM ("cli");
+ DDRB |= 0xE0;
+ /* Init UART*/
+ UBRR1H = 0;
+ #if (F_CPU == 4000000ul)
+ UBRR1L = 12;
+ #elif (F_CPU == 8000000ul)
+ UBRR1L = 25;
+ #endif
+ UCSR1A = (1 << U2X1);
+ UCSR1B = (1 << TXEN1);
+ UCSR1C = (3 << UCSZ10); // 8-bit data
+
+ /* Init timer counter 4.*/
+ OCR4A = 0;
+ /* Disable TC4 interrupt */
+ TIMSK4 &= ~(1 << OCIE4A);
+ /* main clk / 8 */
+ TCCR4B = (1 << WGM12) | (1 << CS11);
+
+ while (1)
+ {
+ do
+ { /* Send byte to UART */
+ while (!(UCSR1A & (1 << UDRE1)));
+ UDR1 = *((uint8_t *)SP);
+ SP++;
+ } while (RAMEND >= SP);
+ SP = tmp;
+
+ PORTB |= 0x80;
+ TCNT4 = 0;
+ while(TCNT4 < PIN_OUT);
+ PORTB &= ~0x80;
+ PORTB |= 0x40;
+ TCNT4 = 0;
+ while(TCNT4 < PIN_OUT);
+ PORTB &= ~0x40;
+ PORTB |= 0x20;
+ TCNT4 = 0;
+ while(TCNT4 < PIN_OUT);
+ PORTB &= ~0x20;
+ }
+ }
+}
+#endif
+
+#if defined(__GNUC__) && defined(_REPORT_STATS_)
+void halFillStack(void) __attribute__ ((naked, section (".init1")));
+/**************************************************************************//**
+\brief Fill cstack with repeated pattern 0xCD
+******************************************************************************/
+void halFillStack(void)
+{
+ extern uint16_t __stack_start;
+ extern uint16_t __stack;
+
+ for (uint8_t *start = (uint8_t *)&__stack_start; start <= (uint8_t *)&__stack; start++)
+ *start = 0xCD;
+}
+#endif
+
+// eof halWdtInit.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/i2c.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/i2c.c
new file mode 100644
index 00000000..f118194e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/i2c.c
@@ -0,0 +1,90 @@
+/**************************************************************************//**
+ \file i2c.c
+
+ \brief Provides the functionality of TWI.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <i2c.h>
+#include <halTaskManager.h>
+#include <halDbg.h>
+#include <halDiagnostic.h>
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+Inits TWI module. Setup teh speed of TWI.
+Parameters:
+ i2cMode - the speed of TWI.
+Returns:
+ none.
+******************************************************************************/
+void halInitI2c(HAL_i2cMode_t *i2cMode)
+{
+ TWCR = 0x00;
+ TWSR = HAL_I2C_PRESCALER; // prescaler
+ // Set bit rate
+ TWBR = i2cMode->clockrate;
+}
+
+/******************************************************************************
+Interrupt handler.
+******************************************************************************/
+ISR(TWI_vect)
+{
+ BEGIN_MEASURE
+ switch (TWSR & 0xF8)
+ {
+ case TWS_START:
+ case TWS_RSTART:
+ halSendStartDoneI2c();
+ break;
+
+ case TWS_MT_SLA_ACK:
+ case TWS_MT_DATA_ACK:
+ halWriteDoneI2c();
+ break;
+
+ case TWS_BUSERROR:
+ case TWS_MT_SLA_NACK:
+ case TWS_MT_DATA_NACK:
+ case TWS_MR_SLA_NACK:
+ halI2cBusReset();
+ break;
+
+ case TWS_MR_SLA_ACK:
+ halMasterReadWriteAddressAckI2c();
+ break;
+
+ case TWS_MR_DATA_ACK:
+ halReadDoneI2c(halReadByteI2c());
+ break;
+
+ case TWS_MR_DATA_NACK:
+ halReadLastByteDoneI2c(halReadByteI2c());
+ break;
+
+ default:
+ break;
+ }
+ END_MEASURE(HALISR_TWI_TIME_LIMIT)
+}
+// eof i2c.c
+
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/wdt.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/wdt.c
new file mode 100644
index 00000000..d9c5a859
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/common/src/wdt.c
@@ -0,0 +1,79 @@
+/**************************************************************************//**
+ \file wdt.c
+
+ \brief Implementation of WDT interrupt handler.
+
+ \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:
+ 29/05/07 E. Ivanov - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#include <wdtCtrl.h>
+#include <atomic.h>
+#include <halDbg.h>
+#include <halDiagnostic.h>
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+void (*halWdtCallback)(void) = NULL;
+
+/*******************************************************************************
+Registers WDT fired callback.
+Parameters:
+ wdtCallback - callback.
+Returns:
+ none.
+*******************************************************************************/
+void HAL_RegisterWdtCallback(void (*wdtCallback)(void))
+{
+ halWdtCallback = wdtCallback;
+}
+
+/*******************************************************************************
+Starts WDT with interval.
+Parameters:
+ interval - interval.
+Returns:
+ none.
+*******************************************************************************/
+void HAL_StartWdt(HAL_WdtInterval_t interval)
+{
+ uint8_t i = 0;
+
+ if (halWdtCallback)
+ i = (1<<WDE) | (1 << WDIE) | interval;
+ else
+ i = (1<<WDE) | interval;
+
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ wdt_reset();
+ WDTCSR |= (1<<WDCE) | (1<<WDE);
+ WDTCSR = i;
+ END_MEASURE(HALATOM_STARTWDT_TIME_LIMIT)
+ ATOMIC_SECTION_LEAVE
+}
+
+/*******************************************************************************
+Interrupt handler.
+*******************************************************************************/
+ISR(WDT_vect)
+{
+ if (NULL != halWdtCallback)
+ halWdtCallback();
+ wdt_enable(0);
+ for (;;);
+}
+//eof wdt.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/include/halMacIsr.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/include/halMacIsr.h
new file mode 100644
index 00000000..127af1ee
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/include/halMacIsr.h
@@ -0,0 +1,77 @@
+/**************************************************************************//**
+ \file halMacIsr.h
+
+ \brief Declaration mac timer interface.
+
+ \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:
+ 14/01/08 A. Mandychev - Created.
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALMACISR_H
+#define _HALMACISR_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <halAppClock.h>
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+typedef enum
+{
+ HAL_RTIMER_REPEAT_MODE = 0,
+ HAL_RTIMER_ONE_SHOT_MODE = 1,
+ HAL_RTIMER_STOPPED_MODE = 2,
+} HAL_RTimerMode_t;
+
+typedef struct // Timer description.
+{
+ volatile HAL_RTimerMode_t mode; // Mode.
+ volatile uint16_t period; // Period of the timer.
+ volatile uint16_t nextEvent; // Counter of periods.
+} RTimerDescr_t;
+
+/******************************************************************************
+ External variables.
+******************************************************************************/
+// Do not use it in other files.
+extern RTimerDescr_t __rtimer;
+
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+/******************************************************************************
+ Initializes Rtimer and RF ext. interrupts.
+******************************************************************************/
+void HAL_InitMacIsr(void);
+
+/******************************************************************************
+ Starts RTimer. Function should be invoked in critical section.
+ Parameters:
+ source - source of invocation.
+ mode - RTimer mode.
+ period - RTimer period.
+******************************************************************************/
+bool HAL_StartRtimer(HAL_RTimerMode_t mode, uint16_t period);
+
+/******************************************************************************
+ Stops RTimer. Function should be invoked in critical section.
+******************************************************************************/
+void HAL_StopRtimer(void);
+
+#endif /* _HALMACISR_H */
+
+// eof halMacIsr.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/include/halRfCtrl.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/include/halRfCtrl.h
new file mode 100644
index 00000000..7b6534d2
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/include/halRfCtrl.h
@@ -0,0 +1,127 @@
+/**************************************************************************//**
+ \file halRfCtrl.h
+
+ \brief Types and constants declaration for IEEE802.15.4 PHY implementation.
+
+ \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:
+ 28/05/07 ALuzhetsky - Created.
+ 06/08/07 A. Mandychev, E. Ivanov - Modified.
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALRFCTRL_H
+#define _HALRFCTRL_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum
+{
+ HAL_FREQ_NOCLK,
+ HAL_FREQ_1MHZ,
+ HAL_FREQ_2MHZ,
+ HAL_FREQ_4MHZ,
+ HAL_FREQ_8MHZ,
+ HAL_FREQ_16MHZ
+} HalSysFreq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ Delay in us
+******************************************************************************/
+void HAL_Delay(uint8_t us);
+
+/******************************************************************************
+ Clears the irq.
+******************************************************************************/
+void HAL_ClearRfIrqFlag(void);
+
+/******************************************************************************
+ Enables the irq.
+******************************************************************************/
+void HAL_EnableRfIrq(void);
+
+/******************************************************************************
+ Disables the irq.
+******************************************************************************/
+uint8_t HAL_DisableRfIrq(void);
+
+/******************************************************************************
+ Sets SLP_TR pin to 1.
+******************************************************************************/
+void HAL_SetRfSlpTr(void);
+
+/******************************************************************************
+ Clears SLP_TR pin to 0.
+******************************************************************************/
+void HAL_ClearRfSlpTr(void);
+
+/******************************************************************************
+ Makes SLP_TR pin as input.
+******************************************************************************/
+void HAL_MakeInRfSlpTr(void);
+
+/******************************************************************************
+ Makes SLP_TR pin as input.
+******************************************************************************/
+void HAL_MakeOutRfSlpTr(void);
+
+/******************************************************************************
+ Sets RST_TR pin to 1.
+******************************************************************************/
+void HAL_SetRfRst(void);
+
+/******************************************************************************
+ Clears RST_TR pin to 1.
+******************************************************************************/
+void HAL_ClearRfRst(void);
+
+/******************************************************************************
+ Init pins that controls RF chip.
+******************************************************************************/
+void HAL_InitRfPins(void);
+
+/******************************************************************************
+ Inits Atmega IRQ pin.
+******************************************************************************/
+void HAL_InitRfIrq(void);
+
+/******************************************************************************
+ Returns current frequency code.
+******************************************************************************/
+HalSysFreq_t HAL_GetRfFreq(void);
+
+/**************************************************************************//**
+ \brief Wait for when radio will be waked up.
+
+ \param none.
+ \return none.
+******************************************************************************/
+void halWaitRadio(void);
+
+/**************************************************************************//**
+ \brief Enables RX TX indicator for radio if that is supported.
+******************************************************************************/
+void HAL_EnableRxTxSwitcher(void);
+
+#endif /* _HALRFCTRL_H */
+
+// eof halRfCtrl.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/include/halRfPio.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/include/halRfPio.h
new file mode 100644
index 00000000..87ac6c88
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/include/halRfPio.h
@@ -0,0 +1,43 @@
+/**************************************************************************//**
+ \file halRfPio.h
+
+ \brief AT86RF230 control pins declarations.
+
+ \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:
+ 29/05/07 A. Luzhetsky - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALRFPIO_H
+#define _HALRFPIO_H
+
+#include <gpio.h>
+
+// Macros for the RF_SLP_TR pin manipulation.
+HAL_ASSIGN_PIN(RF_SLP_TR, B, 4);
+// Macros for the RF_RST pin manipulation.
+HAL_ASSIGN_PIN(RF_RST, B, 5);
+// Macros for the RF_IRQ pin manipulation.
+HAL_ASSIGN_PIN(RF_IRQ, D, 4);
+// Macros for the SPI_CS pin manipulation.
+HAL_ASSIGN_PIN(SPI_CS, B, 0);
+// Macros for the SPI_SCK pin manipulation.
+HAL_ASSIGN_PIN(SPI_SCK, B, 1);
+// Macros for the SPI_MOSI pin manipulation.
+HAL_ASSIGN_PIN(SPI_MOSI, B, 2);
+// Macros for the SPI_MISO pin manipulation.
+HAL_ASSIGN_PIN(SPI_MISO, B, 3);
+// Macros for the RF_TST pin manipulation.
+HAL_ASSIGN_PIN(RF_TST, B, 6);
+#endif /* _HALRFPIO_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/include/halRfSpi.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/include/halRfSpi.h
new file mode 100644
index 00000000..663ae50b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/include/halRfSpi.h
@@ -0,0 +1,80 @@
+/***************************************************************************//**
+ \file halRfSpi.h
+
+ \brief SPI interface routines header.
+
+ \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:
+ 29/05/07 A. Luzhetsky - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALRFSPI_H
+#define _HALRFSPI_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <atomic.h>
+#include <halDbg.h>
+#include <halDiagnostic.h>
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ Performs initialization of SPI interface.
+******************************************************************************/
+void HAL_InitRfSpi(void);
+
+/******************************************************************************
+ Writes/reads byte to/from SPI.
+ parameters: value - byte to write.
+ Returns: the byte which was read.
+******************************************************************************/
+uint8_t HAL_WriteByteRfSpi(uint8_t value);
+
+/******************************************************************************
+ Deselects a slave device.
+******************************************************************************/
+void HAL_DeselectRfSpi(void);
+
+/******************************************************************************
+ Selects a slave device.
+******************************************************************************/
+void HAL_SelectRfSpi(void);
+
+/******************************************************************************
+ Inline function (to use in critical sections)
+ Writes/reads byte to/from SPI.
+ parameters: value - byte to write.
+ Returns: the byte which was read.
+******************************************************************************/
+INLINE uint8_t HAL_WriteByteInlineRfSpi(uint8_t value)
+{
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ SPDR = value; // Write data.
+ asm("nop"); // This "nop" tunes up the "while" to reduce time for SPIF flag
+ // detecting.
+ while (!(SPSR&(1 << SPIF)));
+ END_MEASURE(HALATOM_WRITEBYTE_RFSPI_TIME_LIMIT)
+ ATOMIC_SECTION_LEAVE
+ return SPDR;
+}
+
+
+#endif /* _HALRFSPI_H */
+
+//eof halRfSpi.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/src/halMacIsr.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/src/halMacIsr.c
new file mode 100644
index 00000000..e622372d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/src/halMacIsr.c
@@ -0,0 +1,152 @@
+/**************************************************************************//**
+ \file halMacIsr.c
+
+ \brief mac interrupts implementation.
+
+ \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:
+ 14/01/08 A. Mandychev - Created.
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <halMacIsr.h>
+#include <halRfCtrl.h>
+#include <atomic.h>
+#include <halDiagnostic.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#if defined(HAL_3d6864MHz)
+ #define HAL_RTIMER_INTERVAL_CALCULATE(period) (period >> 1)
+#elif defined(HAL_4MHz)
+ #define HAL_RTIMER_INTERVAL_CALCULATE(period) (period >> 1)
+#elif defined(HAL_7d3728MHz)
+ #define HAL_RTIMER_INTERVAL_CALCULATE(period) (period)
+#elif defined(HAL_8MHz)
+ #define HAL_RTIMER_INTERVAL_CALCULATE(period) (period)
+#endif
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+RTimerDescr_t __rtimer;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ Initializes Rtimer.
+******************************************************************************/
+void HAL_InitMacIsr(void);
+
+/******************************************************************************
+ Redirect interrupt event depending on the TrxState.
+ Parameters: none.
+ Returns: none.
+******************************************************************************/
+void phyDispatcheRTimerEvent(void);
+
+/******************************************************************************
+ Redirect interrupt event depending on the TrxState.
+ Parameters: none.
+ Returns: none.
+******************************************************************************/
+void phyDispatcheRfInterrupt(void);
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+ Initializes Rtimer.
+******************************************************************************/
+void HAL_InitMacIsr(void)
+{
+ __rtimer.mode = HAL_RTIMER_STOPPED_MODE;
+ HAL_InitRfIrq();
+}
+
+/******************************************************************************
+ Starts RTimer. Function should be invoked in critical section.
+ Parameters:
+ source - source of invocation.
+ mode - RTimer mode.
+ period - RTimer period.
+******************************************************************************/
+bool HAL_StartRtimer(HAL_RTimerMode_t mode, uint16_t period)
+{
+ if (HAL_RTIMER_STOPPED_MODE != __rtimer.mode)
+ return false;
+
+ __rtimer.period = HAL_RTIMER_INTERVAL_CALCULATE(period);
+ __rtimer.mode = mode;
+ __rtimer.nextEvent = TCNT4 + __rtimer.period;
+ if (__rtimer.nextEvent > TOP_TIMER_COUNTER_VALUE)
+ __rtimer.nextEvent -= TOP_TIMER_COUNTER_VALUE;
+ OCR4B = __rtimer.nextEvent;
+ // clear possible interrupt by setting logical one.
+ TIFR4 = (1 << OCF4B);
+ // enable interrupt
+ TIMSK4 |= (1 << OCIE4B);
+ return true;
+}
+
+/******************************************************************************
+ Stops RTimer. Function should be invoked in critical section.
+******************************************************************************/
+void HAL_StopRtimer(void)
+{
+ // clear possible interrupt
+ TIFR4 &= ~(1 << OCF4B);
+ // disable interrupt
+ TIMSK4 &= ~(1 << OCIE4B);
+ __rtimer.mode = HAL_RTIMER_STOPPED_MODE;
+}
+
+/******************************************************************************
+ Output compare unit (channel B) interrupt handler.
+******************************************************************************/
+ISR(TIMER4_COMPB_vect)
+{
+ BEGIN_MEASURE
+ if (HAL_RTIMER_ONE_SHOT_MODE == __rtimer.mode)
+ {
+ TIMSK4 &= ~(1 << OCIE4B);
+ __rtimer.mode = HAL_RTIMER_STOPPED_MODE;
+ }
+ else
+ {
+ __rtimer.nextEvent += __rtimer.period;
+ if (__rtimer.nextEvent > TOP_TIMER_COUNTER_VALUE)
+ __rtimer.nextEvent -= TOP_TIMER_COUNTER_VALUE;
+ OCR4B = __rtimer.nextEvent;
+ }
+ phyDispatcheRTimerEvent();
+ END_MEASURE(HALISR_TIMER3_COMPA_TIME_LIMIT)
+}
+
+/****************************************************************
+ Interrupt service routine.
+ Do not move this ISR! It could be omitted in your project.
+****************************************************************/
+ISR(TIMER1_CAPT_vect)
+{
+ BEGIN_MEASURE
+ phyDispatcheRfInterrupt();
+ END_MEASURE(HALISR_PHYDISPATCH_RFINT_TIME_LIMIT)
+}
+
+// eof halMacIsr.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/src/halRfCtrl.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/src/halRfCtrl.c
new file mode 100644
index 00000000..ffbd38b5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/src/halRfCtrl.c
@@ -0,0 +1,214 @@
+/**************************************************************************//**
+ \file halRfCtrl.c
+
+ \brief mac pin interface implementation.
+
+ \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:
+ 28/05/07 ALuzhetsky - Created.
+ 06/08/07 A. Mandychev, E. Ivanov - Modified.
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <halClkCtrl.h>
+#include <halW1.h>
+#include <halRfPio.h>
+#include <halRfSpi.h>
+#include <halRfCtrl.h>
+#include <halClkCtrl.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define RF_REGISTER_READ_ACCESS_MODE 0x80
+#define RF_REGISTER_TRX_STATUS_ADDRESS 0x01
+#define RF_TRX_OFF_STATE 0x08
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+#ifdef _HAL_RF_RX_TX_INDICATOR_
+/**************************************************************************//**
+\brief Turn on pin 1 (DIG3) and pin 2 (DIG4) to indicate the transmit state of
+the radio transceiver.
+******************************************************************************/
+void phyRxTxSwitcherOn(void);
+
+#endif //_HAL_RF_RX_TX_INDICATOR_
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+ Delay in us
+******************************************************************************/
+void HAL_Delay(uint8_t us)
+{
+ __delay_us(us);
+}
+
+/******************************************************************************
+ Clears the irq.
+******************************************************************************/
+void HAL_ClearRfIrqFlag(void)
+{
+ TIFR1 = 1 << ICF1;
+}
+
+/******************************************************************************
+ Enables the irq.
+******************************************************************************/
+void HAL_EnableRfIrq(void)
+{
+ TIMSK1 |= 1 << ICIE1;
+}
+
+/******************************************************************************
+ Disables the irq.
+******************************************************************************/
+uint8_t HAL_DisableRfIrq(void)
+{
+ uint8_t tmp;
+
+ tmp = TIMSK1 & (1 << ICIE1);
+ TIMSK1 &= ~(1 << ICIE1);
+ return tmp;
+}
+
+/******************************************************************************
+ Sets SLP_TR pin to 1.
+******************************************************************************/
+void HAL_SetRfSlpTr(void)
+{
+ GPIO_RF_SLP_TR_set();
+}
+
+/******************************************************************************
+ Clears SLP_TR pin to 0.
+******************************************************************************/
+void HAL_ClearRfSlpTr(void)
+{
+ GPIO_RF_SLP_TR_clr();
+}
+
+/******************************************************************************
+ Makes SLP_TR pin as input.
+******************************************************************************/
+void HAL_MakeInRfSlpTr(void)
+{
+ GPIO_RF_SLP_TR_make_in();
+}
+
+/******************************************************************************
+ Makes SLP_TR pin as input.
+******************************************************************************/
+void HAL_MakeOutRfSlpTr(void)
+{
+ GPIO_RF_SLP_TR_make_out();
+}
+
+/******************************************************************************
+ Sets RST_TR pin to 1.
+******************************************************************************/
+void HAL_SetRfRst(void)
+{
+ GPIO_RF_RST_set();
+}
+
+/******************************************************************************
+ Clears RST_TR pin to 1.
+******************************************************************************/
+void HAL_ClearRfRst(void)
+{
+ GPIO_RF_RST_clr();
+}
+
+/******************************************************************************
+ Init pins that controls RF chip.
+******************************************************************************/
+void HAL_InitRfPins(void)
+{
+ GPIO_RF_TST_make_out();
+ GPIO_RF_TST_clr();
+
+ GPIO_RF_SLP_TR_clr();
+ GPIO_RF_SLP_TR_make_out();
+
+ GPIO_RF_RST_set();
+ GPIO_RF_RST_make_out();
+
+ GPIO_RF_IRQ_make_in();
+}
+
+/******************************************************************************
+ Inits Atmega IRQ pin.
+******************************************************************************/
+void HAL_InitRfIrq(void)
+{
+ OCR1A = 0;
+ TCCR1B = (1 << WGM12) | (1 << CS10); // CTC mode, clock source is not prescaled
+ TCCR1B |= (1 << ICNC1) | (1 << ICES1); // input noise canceler and rising edge are enabled
+}
+
+/******************************************************************************
+ Returns current frequency code.
+******************************************************************************/
+HalSysFreq_t HAL_GetRfFreq(void)
+{
+/* if (INTERNAL_RC == halGetClockSource())
+ {
+ return HAL_FREQ_NOCLK;
+ }
+ else*/
+ {
+ #if (F_CPU == 4000000ul)
+ return HAL_FREQ_4MHZ;
+ #endif
+ #if (F_CPU == 8000000ul)
+ return HAL_FREQ_8MHZ;
+ #endif
+ }
+}
+
+/**************************************************************************//**
+ \brief Wait for when radio will be waked up.
+
+ \param none.
+ \return none.
+******************************************************************************/
+void halWaitRadio(void)
+{
+ uint8_t tempValue = 0;
+
+ do {
+ HAL_SelectRfSpi();
+ HAL_WriteByteRfSpi(RF_REGISTER_READ_ACCESS_MODE | RF_REGISTER_TRX_STATUS_ADDRESS);
+ tempValue = HAL_WriteByteRfSpi(tempValue);
+ HAL_DeselectRfSpi();
+ } while(RF_TRX_OFF_STATE != tempValue);
+}
+
+/**************************************************************************//**
+ \brief Enables RX TX indicator for radio if that is supported.
+******************************************************************************/
+void HAL_EnableRxTxSwitcher(void)
+{
+ #ifdef _HAL_RF_RX_TX_INDICATOR_
+ phyRxTxSwitcherOn();
+ #endif //_HAL_RF_RX_TX_INDICATOR_
+}
+
+//eof halRfCtrl.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/src/halRfSpi.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/src/halRfSpi.c
new file mode 100644
index 00000000..053ba68a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/src/halRfSpi.c
@@ -0,0 +1,90 @@
+/**************************************************************************//**
+ \file halrfSpi.c
+
+ \brief SPI interface routines.
+
+ \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:
+ 29/05/07 A. Luzhetsky - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#include <halRfSpi.h>
+#include <halRfPio.h>
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+ Performs initialization of SPI interface.
+******************************************************************************/
+void HAL_InitRfSpi(void)
+{
+ GPIO_SPI_CS_set();
+ GPIO_SPI_MISO_make_in();
+ GPIO_SPI_MOSI_make_out();
+ GPIO_SPI_SCK_make_out();
+ GPIO_SPI_CS_make_out();
+ SPCR = ((1 << SPE) | (1 << MSTR)); // SPI enable, master mode.
+ SPSR = (1 << SPI2X); // rate = fosc/2
+}
+
+/******************************************************************************
+ Writes/reads byte to/from SPI. CPU clock critical function (4 MHz only).
+ parameters: value - byte to write.
+ Returns: the byte which was read.
+******************************************************************************/
+uint8_t HAL_WriteByteRfSpi(uint8_t value)
+{
+ uint8_t tmp8;
+
+ SPDR = value; // Write data.
+ asm("nop"); // 1
+ asm("nop"); // 2
+ asm("nop"); // 3
+ asm("nop"); // 4
+ asm("nop"); // 5
+ asm("nop"); // 5
+ asm("nop"); // 7
+ asm("nop"); // 8
+ asm("nop"); // 9
+ asm("nop"); // 10
+ asm("nop"); // 11
+ asm("nop"); // 12
+ asm("nop"); // 13
+ asm("nop"); // 14
+ asm("nop"); // 15
+ asm("nop"); // 16
+ asm("nop"); // 17
+ tmp8 = SPSR;
+ (void)tmp8;
+ return SPDR;
+}
+
+/******************************************************************************
+ Deselects a slave device.
+******************************************************************************/
+void HAL_DeselectRfSpi(void)
+{
+ GPIO_SPI_CS_set();
+}
+
+/******************************************************************************
+ Selects a slave device.
+******************************************************************************/
+void HAL_SelectRfSpi(void)
+{
+ GPIO_SPI_CS_clr();
+}
+
+// eof halrfSpi.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/src/halUid.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/src/halUid.c
new file mode 100644
index 00000000..21976ce9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb230/src/halUid.c
@@ -0,0 +1,87 @@
+/**************************************************************************//**
+ \file halUid.c
+
+ \brief Implementation of UID interface.
+
+ \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:
+ 7/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halRfPio.h>
+#include <halRfSpi.h>
+#include <uid.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** \brief uid type. */
+typedef union
+{
+ uint64_t uid;
+ uint8_t array[sizeof(uint64_t)];
+} HalUid_t;
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+static HalUid_t halUid = {.uid = 0ull};
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+ Reads uid from external spi eeprom at25010a.
+******************************************************************************/
+void halReadUid(void)
+{
+ uint8_t command = 0x03;
+ uint8_t address = 0;
+ uint8_t itr;
+
+ GPIO_RF_RST_make_out();
+ GPIO_RF_RST_clr();
+ GPIO_SPI_CS_clr();
+
+ HAL_WriteByteRfSpi(command);
+ HAL_WriteByteRfSpi(address);
+ for (itr=0; itr<sizeof(uint64_t); itr++)
+ {
+ halUid.array[itr] = HAL_WriteByteRfSpi(address);
+ }
+
+ GPIO_SPI_CS_set();
+}
+
+/******************************************************************************
+ Returns number which was read from external eeprom.
+ Parameters:
+ id - UID buffer pointer.
+ Returns:
+ 0 - if unique ID has been found without error;
+ -1 - if there are some erros during UID discovery.
+******************************************************************************/
+int HAL_ReadUid(uint64_t *id)
+{
+ if (!id)
+ return -1;
+
+ *id = halUid.uid;
+ return 0;
+}
+
+// eof uid.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/include/halMacIsr.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/include/halMacIsr.h
new file mode 100644
index 00000000..127af1ee
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/include/halMacIsr.h
@@ -0,0 +1,77 @@
+/**************************************************************************//**
+ \file halMacIsr.h
+
+ \brief Declaration mac timer interface.
+
+ \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:
+ 14/01/08 A. Mandychev - Created.
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALMACISR_H
+#define _HALMACISR_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <halAppClock.h>
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+typedef enum
+{
+ HAL_RTIMER_REPEAT_MODE = 0,
+ HAL_RTIMER_ONE_SHOT_MODE = 1,
+ HAL_RTIMER_STOPPED_MODE = 2,
+} HAL_RTimerMode_t;
+
+typedef struct // Timer description.
+{
+ volatile HAL_RTimerMode_t mode; // Mode.
+ volatile uint16_t period; // Period of the timer.
+ volatile uint16_t nextEvent; // Counter of periods.
+} RTimerDescr_t;
+
+/******************************************************************************
+ External variables.
+******************************************************************************/
+// Do not use it in other files.
+extern RTimerDescr_t __rtimer;
+
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+/******************************************************************************
+ Initializes Rtimer and RF ext. interrupts.
+******************************************************************************/
+void HAL_InitMacIsr(void);
+
+/******************************************************************************
+ Starts RTimer. Function should be invoked in critical section.
+ Parameters:
+ source - source of invocation.
+ mode - RTimer mode.
+ period - RTimer period.
+******************************************************************************/
+bool HAL_StartRtimer(HAL_RTimerMode_t mode, uint16_t period);
+
+/******************************************************************************
+ Stops RTimer. Function should be invoked in critical section.
+******************************************************************************/
+void HAL_StopRtimer(void);
+
+#endif /* _HALMACISR_H */
+
+// eof halMacIsr.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/include/halRfCtrl.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/include/halRfCtrl.h
new file mode 100644
index 00000000..846b101c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/include/halRfCtrl.h
@@ -0,0 +1,142 @@
+/**************************************************************************//**
+ \file halRfCtrl.h
+
+ \brief Types and constants declaration for IEEE802.15.4 PHY implementation.
+
+ \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:
+ 28/05/07 ALuzhetsky - Created.
+ 06/08/07 A. Mandychev, E. Ivanov - Modified.
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALRFCTRL_H
+#define _HALRFCTRL_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum
+{
+ HAL_FREQ_NOCLK,
+ HAL_FREQ_1MHZ,
+ HAL_FREQ_2MHZ,
+ HAL_FREQ_4MHZ,
+ HAL_FREQ_8MHZ,
+ HAL_FREQ_16MHZ
+} HalSysFreq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ Delay in us
+******************************************************************************/
+void HAL_Delay(uint8_t us);
+
+/******************************************************************************
+ Clears the irq.
+******************************************************************************/
+void HAL_ClearRfIrqFlag(void);
+
+/******************************************************************************
+ Enables the irq.
+******************************************************************************/
+void HAL_EnableRfIrq(void);
+
+/******************************************************************************
+ Disables the irq.
+******************************************************************************/
+uint8_t HAL_DisableRfIrq(void);
+
+/******************************************************************************
+ Sets SLP_TR pin to 1.
+******************************************************************************/
+void HAL_SetRfSlpTr(void);
+
+/******************************************************************************
+ Clears SLP_TR pin to 0.
+******************************************************************************/
+void HAL_ClearRfSlpTr(void);
+
+/******************************************************************************
+ Makes SLP_TR pin as input.
+******************************************************************************/
+void HAL_MakeInRfSlpTr(void);
+
+/******************************************************************************
+ Makes SLP_TR pin as input.
+******************************************************************************/
+void HAL_MakeOutRfSlpTr(void);
+
+/******************************************************************************
+ Sets RST_TR pin to 1.
+******************************************************************************/
+void HAL_SetRfRst(void);
+
+/******************************************************************************
+ Clears RST_TR pin to 1.
+******************************************************************************/
+void HAL_ClearRfRst(void);
+
+/******************************************************************************
+ Init pins that controls RF chip.
+******************************************************************************/
+void HAL_InitRfPins(void);
+
+/******************************************************************************
+ Inits Atmega IRQ pin.
+******************************************************************************/
+void HAL_InitRfIrq(void);
+
+/******************************************************************************
+ Returns current frequency code.
+******************************************************************************/
+HalSysFreq_t HAL_GetRfFreq(void);
+
+/**************************************************************************//**
+ \brief Wait for when radio will be waked up.
+
+ \param none.
+ \return none.
+******************************************************************************/
+void halWaitRadio(void);
+
+/**************************************************************************//**
+ \brief Enables RX TX indicator for radio if that is supported.
+******************************************************************************/
+void HAL_EnableRxTxSwitcher(void);
+
+/**************************************************************************//**
+ \brief Enables Antenna diversity option for radio if that is supported.
+******************************************************************************/
+void HAL_InitAntennaDiversity(void);
+
+/**************************************************************************//**
+ \brief Enables Antenna diversity in RX mode for radio if that is supported.
+******************************************************************************/
+void HAL_EnableRxAntennaDiversity(void);
+
+/**************************************************************************//**
+ \brief Enables Antenna diversity in TX mode for radio if that is supported.
+******************************************************************************/
+void HAL_EnableTxAntennaDiversity(void);
+
+#endif /* _HALRFCTRL_H */
+
+// eof halRfCtrl.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/include/halRfPio.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/include/halRfPio.h
new file mode 100644
index 00000000..bbce93f4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/include/halRfPio.h
@@ -0,0 +1,41 @@
+/**************************************************************************//**
+ \file halRfPio.h
+
+ \brief AT86RF230 control pins declarations.
+
+ \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:
+ 29/05/07 A. Luzhetsky - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALRFPIO_H
+#define _HALRFPIO_H
+
+#include <gpio.h>
+
+// Macros for the RF_SLP_TR pin manipulation.
+HAL_ASSIGN_PIN(RF_SLP_TR, B, 4);
+// Macros for the RF_RST pin manipulation.
+HAL_ASSIGN_PIN(RF_RST, B, 5);
+// Macros for the RF_IRQ pin manipulation.
+HAL_ASSIGN_PIN(RF_IRQ, D, 0);
+// Macros for the SPI_CS pin manipulation.
+HAL_ASSIGN_PIN(SPI_CS, B, 0);
+// Macros for the SPI_SCK pin manipulation.
+HAL_ASSIGN_PIN(SPI_SCK, B, 1);
+// Macros for the SPI_MOSI pin manipulation.
+HAL_ASSIGN_PIN(SPI_MOSI, B, 2);
+// Macros for the SPI_MISO pin manipulation.
+HAL_ASSIGN_PIN(SPI_MISO, B, 3);
+#endif /* _HALRFPIO_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/include/halRfSpi.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/include/halRfSpi.h
new file mode 100644
index 00000000..fe3328a6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/include/halRfSpi.h
@@ -0,0 +1,79 @@
+/***************************************************************************//**
+ \file halRfSpi.h
+
+ \brief SPI interface routines header.
+
+ \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:
+ 29/05/07 A. Luzhetsky - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALRFSPI_H
+#define _HALRFSPI_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <atomic.h>
+#include <halDbg.h>
+#include <halDiagnostic.h>
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ Performs initialization of SPI interface.
+******************************************************************************/
+void HAL_InitRfSpi(void);
+
+/******************************************************************************
+ Writes/reads byte to/from SPI.
+ parameters: value - byte to write.
+ Returns: the byte which was read.
+******************************************************************************/
+uint8_t HAL_WriteByteRfSpi(uint8_t value);
+
+/******************************************************************************
+ Deselects a slave device.
+******************************************************************************/
+void HAL_DeselectRfSpi(void);
+
+/******************************************************************************
+ Selects a slave device.
+******************************************************************************/
+void HAL_SelectRfSpi(void);
+
+/******************************************************************************
+ Inline function (to use in critical sections)
+ Writes/reads byte to/from SPI.
+ parameters: value - byte to write.
+ Returns: the byte which was read.
+******************************************************************************/
+INLINE uint8_t HAL_WriteByteInlineRfSpi(uint8_t value)
+{
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ SPDR = value; // Write data.
+ asm("nop"); // This "nop" tunes up the "while" to reduce time for SPIF flag
+ // detecting.
+ while (!(SPSR&(1 << SPIF)));
+ END_MEASURE(HALATOM_WRITEBYTE_RFSPI_TIME_LIMIT)
+ ATOMIC_SECTION_LEAVE
+ return SPDR;
+}
+
+#endif /* _HALRFSPI_H */
+
+//eof halRfSpi.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/src/halMacIsr.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/src/halMacIsr.c
new file mode 100644
index 00000000..b468cbdf
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/src/halMacIsr.c
@@ -0,0 +1,152 @@
+/**************************************************************************//**
+ \file halMacIsr.c
+
+ \brief mac interrupts implementation.
+
+ \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:
+ 14/01/08 A. Mandychev - Created.
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <halMacIsr.h>
+#include <halRfCtrl.h>
+#include <atomic.h>
+#include <halDiagnostic.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#if defined(HAL_3d6864MHz)
+ #define HAL_RTIMER_INTERVAL_CALCULATE(period) (period >> 1)
+#elif defined(HAL_4MHz)
+ #define HAL_RTIMER_INTERVAL_CALCULATE(period) (period >> 1)
+#elif defined(HAL_7d3728MHz)
+ #define HAL_RTIMER_INTERVAL_CALCULATE(period) (period)
+#elif defined(HAL_8MHz)
+ #define HAL_RTIMER_INTERVAL_CALCULATE(period) (period)
+#endif
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+RTimerDescr_t __rtimer;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ Initializes Rtimer.
+******************************************************************************/
+void HAL_InitMacIsr(void);
+
+/******************************************************************************
+ Redirect interrupt event depending on the TrxState.
+ Parameters: none.
+ Returns: none.
+******************************************************************************/
+void phyDispatcheRTimerEvent(void);
+
+/******************************************************************************
+ Redirect interrupt event depending on the TrxState.
+ Parameters: none.
+ Returns: none.
+******************************************************************************/
+void phyDispatcheRfInterrupt(void);
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+ Initializes Rtimer.
+******************************************************************************/
+void HAL_InitMacIsr(void)
+{
+ __rtimer.mode = HAL_RTIMER_STOPPED_MODE;
+ HAL_InitRfIrq();
+}
+
+/******************************************************************************
+ Starts RTimer. Function should be invoked in critical section.
+ Parameters:
+ source - source of invocation.
+ mode - RTimer mode.
+ period - RTimer period.
+******************************************************************************/
+bool HAL_StartRtimer(HAL_RTimerMode_t mode, uint16_t period)
+{
+ if (HAL_RTIMER_STOPPED_MODE != __rtimer.mode)
+ return false;
+
+ __rtimer.period = HAL_RTIMER_INTERVAL_CALCULATE(period);
+ __rtimer.mode = mode;
+ __rtimer.nextEvent = TCNT4 + __rtimer.period;
+ if (__rtimer.nextEvent > TOP_TIMER_COUNTER_VALUE)
+ __rtimer.nextEvent -= TOP_TIMER_COUNTER_VALUE;
+ OCR4B = __rtimer.nextEvent;
+ // clear possible interrupt by setting logical one.
+ TIFR4 = (1 << OCF4B);
+ // enable interrupt
+ TIMSK4 |= (1 << OCIE4B);
+ return true;
+}
+
+/******************************************************************************
+ Stops RTimer. Function should be invoked in critical section.
+******************************************************************************/
+void HAL_StopRtimer(void)
+{
+ // clear possible interrupt
+ TIFR4 &= ~(1 << OCF4B);
+ // disable interrupt
+ TIMSK4 &= ~(1 << OCIE4B);
+ __rtimer.mode = HAL_RTIMER_STOPPED_MODE;
+}
+
+/******************************************************************************
+ Output compare unit (channel B) interrupt handler.
+******************************************************************************/
+ISR(TIMER4_COMPB_vect)
+{
+ BEGIN_MEASURE
+ if (HAL_RTIMER_ONE_SHOT_MODE == __rtimer.mode)
+ {
+ TIMSK4 &= ~(1 << OCIE4B);
+ __rtimer.mode = HAL_RTIMER_STOPPED_MODE;
+ }
+ else
+ {
+ __rtimer.nextEvent += __rtimer.period;
+ if (__rtimer.nextEvent > TOP_TIMER_COUNTER_VALUE)
+ __rtimer.nextEvent -= TOP_TIMER_COUNTER_VALUE;
+ OCR4B = __rtimer.nextEvent;
+ }
+ phyDispatcheRTimerEvent();
+ END_MEASURE(HALISR_TIMER3_COMPA_TIME_LIMIT)
+}
+
+/****************************************************************
+ Interrupt service routine.
+ Do not move this ISR! It could be omitted in your project.
+****************************************************************/
+ISR(INT0_vect)
+{
+ BEGIN_MEASURE
+ phyDispatcheRfInterrupt();
+ END_MEASURE(HALISR_PHYDISPATCH_RFINT_TIME_LIMIT)
+}
+
+// eof halMacIsr.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/src/halRfCtrl.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/src/halRfCtrl.c
new file mode 100644
index 00000000..c21a9784
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/src/halRfCtrl.c
@@ -0,0 +1,257 @@
+/**************************************************************************//**
+ \file halRfCtrl.c
+
+ \brief mac pin interface implementation.
+
+ \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:
+ 28/05/07 ALuzhetsky - Created.
+ 06/08/07 A. Mandychev, E. Ivanov - Modified.
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <halClkCtrl.h>
+#include <halW1.h>
+#include <halRfPio.h>
+#include <halRfSpi.h>
+#include <halRfCtrl.h>
+#include <halClkCtrl.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define RF_REGISTER_READ_ACCESS_MODE 0x80
+#define RF_REGISTER_TRX_STATUS_ADDRESS 0x01
+#define RF_TRX_OFF_STATE 0x08
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+#ifdef _HAL_RF_RX_TX_INDICATOR_
+/**************************************************************************//**
+\brief Turn on pin 1 (DIG3) and pin 2 (DIG4) to indicate the transmit state of
+the radio transceiver.
+******************************************************************************/
+void phyRxTxSwitcherOn(void);
+
+#endif //_HAL_RF_RX_TX_INDICATOR_
+
+#ifdef _HAL_ANT_DIVERSITY_
+/**************************************************************************//**
+\brief Enable antenna diversity feature.
+******************************************************************************/
+void phyAntennaDiversityInit(void);
+
+/**************************************************************************//**
+\brief Enable antenna diversity in the receive state of the radio transceiver.
+******************************************************************************/
+void phyRxAntennaDiversity(void);
+
+/**************************************************************************//**
+\brief Enable antenna diversity in the transmit state of the radio transceiver.
+******************************************************************************/
+void phyTxAntennaDiversity(void);
+
+#endif //_HAL_ANT_DIVERSITY_
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+ Delay in us
+******************************************************************************/
+void HAL_Delay(uint8_t us)
+{
+ __delay_us(us);
+}
+
+/******************************************************************************
+ Clears the irq.
+******************************************************************************/
+void HAL_ClearRfIrqFlag(void)
+{
+ EIFR = 1 << INTF0;
+}
+
+/******************************************************************************
+ Enables the irq.
+******************************************************************************/
+void HAL_EnableRfIrq(void)
+{
+ EIMSK |= 1 << INT0;
+}
+
+/******************************************************************************
+ Disables the irq.
+******************************************************************************/
+uint8_t HAL_DisableRfIrq(void)
+{
+ uint8_t tmp;
+
+ tmp = EIMSK & (1 << INT0);
+ EIMSK &= ~(1 << INT0);
+ return tmp;
+}
+
+/******************************************************************************
+ Sets SLP_TR pin to 1.
+******************************************************************************/
+void HAL_SetRfSlpTr(void)
+{
+ GPIO_RF_SLP_TR_set();
+}
+
+/******************************************************************************
+ Clears SLP_TR pin to 0.
+******************************************************************************/
+void HAL_ClearRfSlpTr(void)
+{
+ GPIO_RF_SLP_TR_clr();
+}
+
+/******************************************************************************
+ Makes SLP_TR pin as input.
+******************************************************************************/
+void HAL_MakeInRfSlpTr(void)
+{
+ GPIO_RF_SLP_TR_make_in();
+}
+
+/******************************************************************************
+ Makes SLP_TR pin as input.
+******************************************************************************/
+void HAL_MakeOutRfSlpTr(void)
+{
+ GPIO_RF_SLP_TR_make_out();
+}
+
+/******************************************************************************
+ Sets RST_TR pin to 1.
+******************************************************************************/
+void HAL_SetRfRst(void)
+{
+ GPIO_RF_RST_set();
+}
+
+/******************************************************************************
+ Clears RST_TR pin to 1.
+******************************************************************************/
+void HAL_ClearRfRst(void)
+{
+ GPIO_RF_RST_clr();
+}
+
+/******************************************************************************
+ Init pins that controls RF chip.
+******************************************************************************/
+void HAL_InitRfPins(void)
+{
+ GPIO_RF_SLP_TR_clr();
+ GPIO_RF_SLP_TR_make_out();
+
+ GPIO_RF_RST_set();
+ GPIO_RF_RST_make_out();
+
+ GPIO_RF_IRQ_make_in();
+}
+
+/******************************************************************************
+ Inits Atmega IRQ pin.
+******************************************************************************/
+void HAL_InitRfIrq(void)
+{
+ EICRA |= (1 << ISC01) | (1 << ISC00); // rising edge
+}
+
+/******************************************************************************
+ Returns current frequency code.
+******************************************************************************/
+HalSysFreq_t HAL_GetRfFreq(void)
+{
+/* if (INTERNAL_RC == halGetClockSource())
+ {
+ return HAL_FREQ_NOCLK;
+ }
+ else*/
+ {
+ #if (F_CPU == 4000000ul)
+ return HAL_FREQ_4MHZ;
+ #endif
+ #if (F_CPU == 8000000ul)
+ return HAL_FREQ_8MHZ;
+ #endif
+ }
+}
+
+/**************************************************************************//**
+ \brief Wait for when radio will be waked up.
+
+ \param none.
+ \return none.
+******************************************************************************/
+void halWaitRadio(void)
+{
+ uint8_t tempValue = 0;
+
+ do {
+ HAL_SelectRfSpi();
+ HAL_WriteByteRfSpi(RF_REGISTER_READ_ACCESS_MODE | RF_REGISTER_TRX_STATUS_ADDRESS);
+ tempValue = HAL_WriteByteRfSpi(tempValue);
+ HAL_DeselectRfSpi();
+ } while(RF_TRX_OFF_STATE != tempValue);
+}
+
+/**************************************************************************//**
+ \brief Enables RX TX indicator for radio if that is supported.
+******************************************************************************/
+void HAL_EnableRxTxSwitcher(void)
+{
+ #ifdef _HAL_RF_RX_TX_INDICATOR_
+ phyRxTxSwitcherOn();
+ #endif //_HAL_RF_RX_TX_INDICATOR_
+}
+
+/**************************************************************************//**
+ \brief Enables Antenna diversity option for radio if that is supported.
+******************************************************************************/
+void HAL_InitAntennaDiversity(void)
+{
+ #ifdef _HAL_ANT_DIVERSITY_
+ phyAntennaDiversityInit();
+ #endif //_HAL_ANT_DIVERSITY_
+}
+
+/**************************************************************************//**
+ \brief Enables Antenna diversity in RX mode for radio if that is supported.
+******************************************************************************/
+void HAL_EnableRxAntennaDiversity(void)
+{
+ #ifdef _HAL_ANT_DIVERSITY_
+ phyRxAntennaDiversity();
+ #endif //_HAL_ANT_DIVERSITY_
+}
+
+/**************************************************************************//**
+ \brief Enables Antenna diversity in TX mode for radio if that is supported.
+******************************************************************************/
+void HAL_EnableTxAntennaDiversity(void)
+{
+ #ifdef _HAL_ANT_DIVERSITY_
+ phyTxAntennaDiversity();
+ #endif //_HAL_ANT_DIVERSITY_
+}
+
+//eof halRfCtrl.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/src/halRfSpi.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/src/halRfSpi.c
new file mode 100644
index 00000000..053ba68a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/src/halRfSpi.c
@@ -0,0 +1,90 @@
+/**************************************************************************//**
+ \file halrfSpi.c
+
+ \brief SPI interface routines.
+
+ \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:
+ 29/05/07 A. Luzhetsky - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#include <halRfSpi.h>
+#include <halRfPio.h>
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+ Performs initialization of SPI interface.
+******************************************************************************/
+void HAL_InitRfSpi(void)
+{
+ GPIO_SPI_CS_set();
+ GPIO_SPI_MISO_make_in();
+ GPIO_SPI_MOSI_make_out();
+ GPIO_SPI_SCK_make_out();
+ GPIO_SPI_CS_make_out();
+ SPCR = ((1 << SPE) | (1 << MSTR)); // SPI enable, master mode.
+ SPSR = (1 << SPI2X); // rate = fosc/2
+}
+
+/******************************************************************************
+ Writes/reads byte to/from SPI. CPU clock critical function (4 MHz only).
+ parameters: value - byte to write.
+ Returns: the byte which was read.
+******************************************************************************/
+uint8_t HAL_WriteByteRfSpi(uint8_t value)
+{
+ uint8_t tmp8;
+
+ SPDR = value; // Write data.
+ asm("nop"); // 1
+ asm("nop"); // 2
+ asm("nop"); // 3
+ asm("nop"); // 4
+ asm("nop"); // 5
+ asm("nop"); // 5
+ asm("nop"); // 7
+ asm("nop"); // 8
+ asm("nop"); // 9
+ asm("nop"); // 10
+ asm("nop"); // 11
+ asm("nop"); // 12
+ asm("nop"); // 13
+ asm("nop"); // 14
+ asm("nop"); // 15
+ asm("nop"); // 16
+ asm("nop"); // 17
+ tmp8 = SPSR;
+ (void)tmp8;
+ return SPDR;
+}
+
+/******************************************************************************
+ Deselects a slave device.
+******************************************************************************/
+void HAL_DeselectRfSpi(void)
+{
+ GPIO_SPI_CS_set();
+}
+
+/******************************************************************************
+ Selects a slave device.
+******************************************************************************/
+void HAL_SelectRfSpi(void)
+{
+ GPIO_SPI_CS_clr();
+}
+
+// eof halrfSpi.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/src/halUid.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/src/halUid.c
new file mode 100644
index 00000000..21976ce9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/rcb231_212/src/halUid.c
@@ -0,0 +1,87 @@
+/**************************************************************************//**
+ \file halUid.c
+
+ \brief Implementation of UID interface.
+
+ \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:
+ 7/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halRfPio.h>
+#include <halRfSpi.h>
+#include <uid.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** \brief uid type. */
+typedef union
+{
+ uint64_t uid;
+ uint8_t array[sizeof(uint64_t)];
+} HalUid_t;
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+static HalUid_t halUid = {.uid = 0ull};
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+ Reads uid from external spi eeprom at25010a.
+******************************************************************************/
+void halReadUid(void)
+{
+ uint8_t command = 0x03;
+ uint8_t address = 0;
+ uint8_t itr;
+
+ GPIO_RF_RST_make_out();
+ GPIO_RF_RST_clr();
+ GPIO_SPI_CS_clr();
+
+ HAL_WriteByteRfSpi(command);
+ HAL_WriteByteRfSpi(address);
+ for (itr=0; itr<sizeof(uint64_t); itr++)
+ {
+ halUid.array[itr] = HAL_WriteByteRfSpi(address);
+ }
+
+ GPIO_SPI_CS_set();
+}
+
+/******************************************************************************
+ Returns number which was read from external eeprom.
+ Parameters:
+ id - UID buffer pointer.
+ Returns:
+ 0 - if unique ID has been found without error;
+ -1 - if there are some erros during UID discovery.
+******************************************************************************/
+int HAL_ReadUid(uint64_t *id)
+{
+ if (!id)
+ return -1;
+
+ *id = halUid.uid;
+ return 0;
+}
+
+// eof uid.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halAtmelUid.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halAtmelUid.h
new file mode 100644
index 00000000..d3931966
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halAtmelUid.h
@@ -0,0 +1,68 @@
+/**************************************************************************//**
+ \file halAtmelUid.h
+
+ \brief The header file describes the UID interface for Atmel MeshBean.
+
+ \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:
+ 10/12/10 A. Malkin - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALATMELUID_H
+#define _HALATMELUID_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <gpio.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+#define SINGLE_WIRE_SUCCESS_STATUS 0
+#define SINGLE_WIRE_ERROR_STATUS -1
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** \brief uid type. */
+typedef union
+{
+ uint64_t uid;
+ uint8_t array[sizeof(uint64_t)];
+} HalUid_t;
+
+/******************************************************************************
+ Inline static functions prototypes section.
+******************************************************************************/
+HAL_ASSIGN_PIN(SINGLE_WIRE, G, 5); // Macros for the Single-wire pin actions.
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Reads Atmel MeshBean UID from ATTiny13A
+
+\param[in] uidBuffer - memory for unique ID.
+
+\return
+ SINGLE_WIRE_SUCCESS_STATUS - if UID read successfully;
+ SINGLE_WIRE_ERROR_STATUS - if error occured during UID read.
+******************************************************************************/
+int halReadAtmelMeshbeanUid(uint8_t *uidBuffer);
+
+#endif /* _HALATMELUID_H */
+
+// eof halAtmelUid.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halMacIsr.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halMacIsr.h
new file mode 100644
index 00000000..127af1ee
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halMacIsr.h
@@ -0,0 +1,77 @@
+/**************************************************************************//**
+ \file halMacIsr.h
+
+ \brief Declaration mac timer interface.
+
+ \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:
+ 14/01/08 A. Mandychev - Created.
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALMACISR_H
+#define _HALMACISR_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <halAppClock.h>
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+typedef enum
+{
+ HAL_RTIMER_REPEAT_MODE = 0,
+ HAL_RTIMER_ONE_SHOT_MODE = 1,
+ HAL_RTIMER_STOPPED_MODE = 2,
+} HAL_RTimerMode_t;
+
+typedef struct // Timer description.
+{
+ volatile HAL_RTimerMode_t mode; // Mode.
+ volatile uint16_t period; // Period of the timer.
+ volatile uint16_t nextEvent; // Counter of periods.
+} RTimerDescr_t;
+
+/******************************************************************************
+ External variables.
+******************************************************************************/
+// Do not use it in other files.
+extern RTimerDescr_t __rtimer;
+
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+/******************************************************************************
+ Initializes Rtimer and RF ext. interrupts.
+******************************************************************************/
+void HAL_InitMacIsr(void);
+
+/******************************************************************************
+ Starts RTimer. Function should be invoked in critical section.
+ Parameters:
+ source - source of invocation.
+ mode - RTimer mode.
+ period - RTimer period.
+******************************************************************************/
+bool HAL_StartRtimer(HAL_RTimerMode_t mode, uint16_t period);
+
+/******************************************************************************
+ Stops RTimer. Function should be invoked in critical section.
+******************************************************************************/
+void HAL_StopRtimer(void);
+
+#endif /* _HALMACISR_H */
+
+// eof halMacIsr.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfCtrl.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfCtrl.h
new file mode 100644
index 00000000..846b101c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfCtrl.h
@@ -0,0 +1,142 @@
+/**************************************************************************//**
+ \file halRfCtrl.h
+
+ \brief Types and constants declaration for IEEE802.15.4 PHY implementation.
+
+ \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:
+ 28/05/07 ALuzhetsky - Created.
+ 06/08/07 A. Mandychev, E. Ivanov - Modified.
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALRFCTRL_H
+#define _HALRFCTRL_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum
+{
+ HAL_FREQ_NOCLK,
+ HAL_FREQ_1MHZ,
+ HAL_FREQ_2MHZ,
+ HAL_FREQ_4MHZ,
+ HAL_FREQ_8MHZ,
+ HAL_FREQ_16MHZ
+} HalSysFreq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ Delay in us
+******************************************************************************/
+void HAL_Delay(uint8_t us);
+
+/******************************************************************************
+ Clears the irq.
+******************************************************************************/
+void HAL_ClearRfIrqFlag(void);
+
+/******************************************************************************
+ Enables the irq.
+******************************************************************************/
+void HAL_EnableRfIrq(void);
+
+/******************************************************************************
+ Disables the irq.
+******************************************************************************/
+uint8_t HAL_DisableRfIrq(void);
+
+/******************************************************************************
+ Sets SLP_TR pin to 1.
+******************************************************************************/
+void HAL_SetRfSlpTr(void);
+
+/******************************************************************************
+ Clears SLP_TR pin to 0.
+******************************************************************************/
+void HAL_ClearRfSlpTr(void);
+
+/******************************************************************************
+ Makes SLP_TR pin as input.
+******************************************************************************/
+void HAL_MakeInRfSlpTr(void);
+
+/******************************************************************************
+ Makes SLP_TR pin as input.
+******************************************************************************/
+void HAL_MakeOutRfSlpTr(void);
+
+/******************************************************************************
+ Sets RST_TR pin to 1.
+******************************************************************************/
+void HAL_SetRfRst(void);
+
+/******************************************************************************
+ Clears RST_TR pin to 1.
+******************************************************************************/
+void HAL_ClearRfRst(void);
+
+/******************************************************************************
+ Init pins that controls RF chip.
+******************************************************************************/
+void HAL_InitRfPins(void);
+
+/******************************************************************************
+ Inits Atmega IRQ pin.
+******************************************************************************/
+void HAL_InitRfIrq(void);
+
+/******************************************************************************
+ Returns current frequency code.
+******************************************************************************/
+HalSysFreq_t HAL_GetRfFreq(void);
+
+/**************************************************************************//**
+ \brief Wait for when radio will be waked up.
+
+ \param none.
+ \return none.
+******************************************************************************/
+void halWaitRadio(void);
+
+/**************************************************************************//**
+ \brief Enables RX TX indicator for radio if that is supported.
+******************************************************************************/
+void HAL_EnableRxTxSwitcher(void);
+
+/**************************************************************************//**
+ \brief Enables Antenna diversity option for radio if that is supported.
+******************************************************************************/
+void HAL_InitAntennaDiversity(void);
+
+/**************************************************************************//**
+ \brief Enables Antenna diversity in RX mode for radio if that is supported.
+******************************************************************************/
+void HAL_EnableRxAntennaDiversity(void);
+
+/**************************************************************************//**
+ \brief Enables Antenna diversity in TX mode for radio if that is supported.
+******************************************************************************/
+void HAL_EnableTxAntennaDiversity(void);
+
+#endif /* _HALRFCTRL_H */
+
+// eof halRfCtrl.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfPio.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfPio.h
new file mode 100644
index 00000000..05f3f296
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfPio.h
@@ -0,0 +1,41 @@
+/**************************************************************************//**
+ \file halRfPio.h
+
+ \brief AT86RF230 control pins declarations.
+
+ \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:
+ 29/05/07 A. Luzhetsky - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALRFPIO_H
+#define _HALRFPIO_H
+
+#include <gpio.h>
+
+// Macros for the RF_SLP_TR pin manipulation.
+HAL_ASSIGN_PIN(RF_SLP_TR, B, 4);
+// Macros for the RF_RST pin manipulation.
+HAL_ASSIGN_PIN(RF_RST, A, 7);
+// Macros for the RF_IRQ pin manipulation.
+HAL_ASSIGN_PIN(RF_IRQ, E, 5);
+// Macros for the SPI_CS pin manipulation.
+HAL_ASSIGN_PIN(SPI_CS, B, 0);
+// Macros for the SPI_SCK pin manipulation.
+HAL_ASSIGN_PIN(SPI_SCK, B, 1);
+// Macros for the SPI_MOSI pin manipulation.
+HAL_ASSIGN_PIN(SPI_MOSI, B, 2);
+// Macros for the SPI_MISO pin manipulation.
+HAL_ASSIGN_PIN(SPI_MISO, B, 3);
+#endif /* _HALRFPIO_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfSpi.h b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfSpi.h
new file mode 100644
index 00000000..fe3328a6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/include/halRfSpi.h
@@ -0,0 +1,79 @@
+/***************************************************************************//**
+ \file halRfSpi.h
+
+ \brief SPI interface routines header.
+
+ \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:
+ 29/05/07 A. Luzhetsky - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALRFSPI_H
+#define _HALRFSPI_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <atomic.h>
+#include <halDbg.h>
+#include <halDiagnostic.h>
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ Performs initialization of SPI interface.
+******************************************************************************/
+void HAL_InitRfSpi(void);
+
+/******************************************************************************
+ Writes/reads byte to/from SPI.
+ parameters: value - byte to write.
+ Returns: the byte which was read.
+******************************************************************************/
+uint8_t HAL_WriteByteRfSpi(uint8_t value);
+
+/******************************************************************************
+ Deselects a slave device.
+******************************************************************************/
+void HAL_DeselectRfSpi(void);
+
+/******************************************************************************
+ Selects a slave device.
+******************************************************************************/
+void HAL_SelectRfSpi(void);
+
+/******************************************************************************
+ Inline function (to use in critical sections)
+ Writes/reads byte to/from SPI.
+ parameters: value - byte to write.
+ Returns: the byte which was read.
+******************************************************************************/
+INLINE uint8_t HAL_WriteByteInlineRfSpi(uint8_t value)
+{
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ SPDR = value; // Write data.
+ asm("nop"); // This "nop" tunes up the "while" to reduce time for SPIF flag
+ // detecting.
+ while (!(SPSR&(1 << SPIF)));
+ END_MEASURE(HALATOM_WRITEBYTE_RFSPI_TIME_LIMIT)
+ ATOMIC_SECTION_LEAVE
+ return SPDR;
+}
+
+#endif /* _HALRFSPI_H */
+
+//eof halRfSpi.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halAtmelUid.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halAtmelUid.c
new file mode 100644
index 00000000..9c80dcbe
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halAtmelUid.c
@@ -0,0 +1,248 @@
+/**************************************************************************//**
+ \file halAtmelUid.c
+
+ \brief The header file describes the UID interface for Atmel MeshBean.
+
+ \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:
+ 10/12/10 A. Malkin - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halAtmelUid.h>
+#include <halW1.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define UID_LEN 0x08 // size of UID (bytes)
+
+#define SINGLE_WIRE_ZERO_BIT 0x00 // logical level zero
+#define SINGLE_WIRE_ONE_BIT 0x01 // logical level one
+
+#define BIT_DURATION 208 // bit duration - 208 us
+#define BIT_DURATION_HALF BIT_DURATION/2
+#define MAX_START_BIT_WAITING 10 // waiting time(in bit) of Start bit
+
+// Commands for Single-wire UART (Atmel MeshBean)
+#define CMD_SYNCH 0xAA // Synchronization
+#define CMD_READ_MAC64_0 0x60 // Read 64-bit MAC address
+#define NUM_OF_MAC64 0x00 // Number of MAC64 slot
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+static void halWriteSingleWireBit(uint8_t value);
+static void halWriteSingleWire(uint8_t value);
+static int halWaitSingleWireStartBit(void);
+static uint8_t halReadSingleWireBit(void);
+static int halReadSingleWire(uint8_t *data);
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/***************************************************************************//**
+\brief Writes bit to the bus
+
+\param[in]
+ value - byte to write. The bit is placed to position of LSB.
+*******************************************************************************/
+static void halWriteSingleWireBit(uint8_t value)
+{
+ if (value)
+ GPIO_SINGLE_WIRE_set();
+ else
+ GPIO_SINGLE_WIRE_clr();
+
+ __delay_us(BIT_DURATION);
+}
+
+/***************************************************************************//**
+\brief Writes byte to the bus
+
+\param[in]
+ value - byte to write.
+*******************************************************************************/
+static void halWriteSingleWire(uint8_t value)
+{
+ uint8_t i;
+
+ // write Start bit
+ halWriteSingleWireBit(SINGLE_WIRE_ZERO_BIT);
+
+ // write Data
+ for (i = 0; i < UID_LEN; i++)
+ {
+ halWriteSingleWireBit(value & 0x01);
+ value >>= 1;
+ }
+
+ // add 2 Stop bits
+ halWriteSingleWireBit(SINGLE_WIRE_ONE_BIT);
+ halWriteSingleWireBit(SINGLE_WIRE_ONE_BIT);
+}
+
+/***************************************************************************//**
+\brief Wait for Start bit from the bus.
+
+\return
+ SINGLE_WIRE_SUCCESS_STATUS - if Start bit has been found successfully; \n
+ SINGLE_WIRE_ERROR_STATUS - if Start bit has been not found.
+*******************************************************************************/
+static int halWaitSingleWireStartBit(void)
+{
+ uint16_t i;
+
+ for (i = BIT_DURATION * MAX_START_BIT_WAITING; i > 0; i--)
+ {
+ if (!GPIO_SINGLE_WIRE_read())
+ return SINGLE_WIRE_SUCCESS_STATUS;
+ __delay_us(1);
+ }
+
+ return SINGLE_WIRE_ERROR_STATUS;
+}
+
+/***************************************************************************//**
+\brief Reads bit from the bus.
+
+\return
+ Read bit is placed to position of last significant bit.
+*******************************************************************************/
+static uint8_t halReadSingleWireBit(void)
+{
+ uint8_t result;
+
+ // read pin level in half of bit period
+ if (GPIO_SINGLE_WIRE_read())
+ result = SINGLE_WIRE_ONE_BIT;
+ else
+ result = SINGLE_WIRE_ZERO_BIT;
+
+ // wait for bit period before next bit reading
+ __delay_us(BIT_DURATION);
+
+ return result;
+}
+
+/***************************************************************************//**
+\brief Reads byte from the Atmel Single-wire bus.
+
+\param[in]
+ data - byte read from the bus.
+
+\return
+ SINGLE_WIRE_SUCCESS_STATUS - if byte read without error;
+ SINGLE_WIRE_ERROR_STATUS - if there are some errors during byte read.
+*******************************************************************************/
+static int halReadSingleWire(uint8_t *data)
+{
+ uint8_t reg = 0;
+ uint8_t bit;
+ uint8_t i;
+ int result;
+
+ // wait for Start bit of response
+ result = halWaitSingleWireStartBit();
+
+ if (result)
+ return SINGLE_WIRE_ERROR_STATUS;
+
+ // wait for half of bit period before reading Start bit
+ __delay_us(BIT_DURATION_HALF);
+
+ // read Start bit
+ bit = halReadSingleWireBit();
+ if (SINGLE_WIRE_ZERO_BIT != bit)
+ return SINGLE_WIRE_ERROR_STATUS;
+
+ // read byte
+ for (i = 0; i < UID_LEN; i++)
+ {
+ if (SINGLE_WIRE_ONE_BIT == halReadSingleWireBit())
+ reg |= (1 << i);
+ }
+
+ // read and check 1'st Stop bit
+ bit = halReadSingleWireBit();
+ if (SINGLE_WIRE_ONE_BIT != bit)
+ return SINGLE_WIRE_ERROR_STATUS;
+
+ // wait for bit period after reading
+ __delay_us(BIT_DURATION_HALF);
+
+ *data = reg;
+
+ return SINGLE_WIRE_SUCCESS_STATUS;
+}
+
+/**************************************************************************//**
+\brief Reads Atmel MeshBean UID from ATTiny13A
+
+\param[in] uidBuffer - memory for unique ID.
+
+\return
+ SINGLE_WIRE_SUCCESS_STATUS - if UID read successfully;
+ SINGLE_WIRE_ERROR_STATUS - if error occured during UID read.
+******************************************************************************/
+int halReadAtmelMeshbeanUid(uint8_t *uidBuffer)
+{
+ uint8_t i;
+ uint8_t reg = 0;
+
+ // port sets as output.
+ GPIO_SINGLE_WIRE_make_out();
+
+ // send synchronization byte
+ halWriteSingleWire(CMD_SYNCH);
+
+ // write command
+ halWriteSingleWire(CMD_READ_MAC64_0);
+
+ // write UID location
+ halWriteSingleWire(NUM_OF_MAC64);
+
+ // Tri-state (external pullup)
+ GPIO_SINGLE_WIRE_make_in();
+
+ // wait for synchronization
+ if (halReadSingleWire(&reg))
+ return SINGLE_WIRE_ERROR_STATUS;
+
+ if (CMD_SYNCH != reg)
+ return SINGLE_WIRE_ERROR_STATUS;
+
+ // wait for response with same command ID
+ if (halReadSingleWire(&reg))
+ return SINGLE_WIRE_ERROR_STATUS;
+
+ if (CMD_READ_MAC64_0 == reg)
+ {
+ // wait for 8 bytes of UID
+ for (i = UID_LEN; i > 0; i--)
+ {
+ // fill array in reversionary order
+ if (halReadSingleWire(uidBuffer + i - 1))
+ return SINGLE_WIRE_ERROR_STATUS;
+ }
+ }
+ return SINGLE_WIRE_SUCCESS_STATUS;
+}
+
+// eof halAtmelUid.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halMacIsr.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halMacIsr.c
new file mode 100644
index 00000000..7f349660
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halMacIsr.c
@@ -0,0 +1,152 @@
+/**************************************************************************//**
+ \file halMacIsr.c
+
+ \brief mac interrupts implementation.
+
+ \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:
+ 14/01/08 A. Mandychev - Created.
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <halMacIsr.h>
+#include <halRfCtrl.h>
+#include <atomic.h>
+#include <halDiagnostic.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#if defined(HAL_3d6864MHz)
+ #define HAL_RTIMER_INTERVAL_CALCULATE(period) (period >> 1)
+#elif defined(HAL_4MHz)
+ #define HAL_RTIMER_INTERVAL_CALCULATE(period) (period >> 1)
+#elif defined(HAL_7d3728MHz)
+ #define HAL_RTIMER_INTERVAL_CALCULATE(period) (period)
+#elif defined(HAL_8MHz)
+ #define HAL_RTIMER_INTERVAL_CALCULATE(period) (period)
+#endif
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+RTimerDescr_t __rtimer;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ Initializes Rtimer.
+******************************************************************************/
+void HAL_InitMacIsr(void);
+
+/******************************************************************************
+ Redirect interrupt event depending on the TrxState.
+ Parameters: none.
+ Returns: none.
+******************************************************************************/
+void phyDispatcheRTimerEvent(void);
+
+/******************************************************************************
+ Redirect interrupt event depending on the TrxState.
+ Parameters: none.
+ Returns: none.
+******************************************************************************/
+void phyDispatcheRfInterrupt(void);
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+ Initializes Rtimer.
+******************************************************************************/
+void HAL_InitMacIsr(void)
+{
+ __rtimer.mode = HAL_RTIMER_STOPPED_MODE;
+ HAL_InitRfIrq();
+}
+
+/******************************************************************************
+ Starts RTimer. Function should be invoked in critical section.
+ Parameters:
+ source - source of invocation.
+ mode - RTimer mode.
+ period - RTimer period.
+******************************************************************************/
+bool HAL_StartRtimer(HAL_RTimerMode_t mode, uint16_t period)
+{
+ if (HAL_RTIMER_STOPPED_MODE != __rtimer.mode)
+ return false;
+
+ __rtimer.period = HAL_RTIMER_INTERVAL_CALCULATE(period);
+ __rtimer.mode = mode;
+ __rtimer.nextEvent = TCNT4 + __rtimer.period;
+ if (__rtimer.nextEvent > TOP_TIMER_COUNTER_VALUE)
+ __rtimer.nextEvent -= TOP_TIMER_COUNTER_VALUE;
+ OCR4B = __rtimer.nextEvent;
+ // clear possible interrupt by setting logical one.
+ TIFR4 = (1 << OCF4B);
+ // enable interrupt
+ TIMSK4 |= (1 << OCIE4B);
+ return true;
+}
+
+/******************************************************************************
+ Stops RTimer. Function should be invoked in critical section.
+******************************************************************************/
+void HAL_StopRtimer(void)
+{
+ // clear possible interrupt
+ TIFR4 &= ~(1 << OCF4B);
+ // disable interrupt
+ TIMSK4 &= ~(1 << OCIE4B);
+ __rtimer.mode = HAL_RTIMER_STOPPED_MODE;
+}
+
+/******************************************************************************
+ Output compare unit (channel B) interrupt handler.
+******************************************************************************/
+ISR(TIMER4_COMPB_vect)
+{
+ BEGIN_MEASURE
+ if (HAL_RTIMER_ONE_SHOT_MODE == __rtimer.mode)
+ {
+ TIMSK4 &= ~(1 << OCIE4B);
+ __rtimer.mode = HAL_RTIMER_STOPPED_MODE;
+ }
+ else
+ {
+ __rtimer.nextEvent += __rtimer.period;
+ if (__rtimer.nextEvent > TOP_TIMER_COUNTER_VALUE)
+ __rtimer.nextEvent -= TOP_TIMER_COUNTER_VALUE;
+ OCR4B = __rtimer.nextEvent;
+ }
+ phyDispatcheRTimerEvent();
+ END_MEASURE(HALISR_TIMER3_COMPA_TIME_LIMIT)
+}
+
+/****************************************************************
+ Interrupt service routine.
+ Do not move this ISR! It could be omitted in your project.
+****************************************************************/
+ISR(INT5_vect)
+{
+ BEGIN_MEASURE
+ phyDispatcheRfInterrupt();
+ END_MEASURE(HALISR_PHYDISPATCH_RFINT_TIME_LIMIT)
+}
+
+// eof halMacIsr.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halRfCtrl.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halRfCtrl.c
new file mode 100644
index 00000000..8e3232a7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halRfCtrl.c
@@ -0,0 +1,281 @@
+/**************************************************************************//**
+ \file halRfCtrl.c
+
+ \brief mac pin interface implementation.
+
+ \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:
+ 28/05/07 ALuzhetsky - Created.
+ 06/08/07 A. Mandychev, E. Ivanov - Modified.
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <halClkCtrl.h>
+#include <halW1.h>
+#include <halRfPio.h>
+#include <halRfCtrl.h>
+#include <halRfSpi.h>
+#include <halClkCtrl.h>
+//#include <phyRxTxIndicator.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define RF_REGISTER_READ_ACCESS_MODE 0x80
+#define RF_REGISTER_TRX_STATUS_ADDRESS 0x01
+#define RF_TRX_OFF_STATE 0x08
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+#ifdef _HAL_RF_RX_TX_INDICATOR_
+/**************************************************************************//**
+\brief Turn on pin 1 (DIG3) and pin 2 (DIG4) to indicate the transmit state of
+the radio transceiver.
+******************************************************************************/
+void phyRxTxSwitcherOn(void);
+
+#endif //_HAL_RF_RX_TX_INDICATOR_
+
+#ifdef _HAL_ANT_DIVERSITY_
+/**************************************************************************//**
+\brief Enable antenna diversity feature.
+******************************************************************************/
+void phyAntennaDiversityInit(void);
+
+/**************************************************************************//**
+\brief Enable antenna diversity in the receive state of the radio transceiver.
+******************************************************************************/
+void phyRxAntennaDiversity(void);
+
+/**************************************************************************//**
+\brief Enable antenna diversity in the transmit state of the radio transceiver.
+******************************************************************************/
+void phyTxAntennaDiversity(void);
+
+#endif //_HAL_ANT_DIVERSITY_
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+ Delay in us
+******************************************************************************/
+void HAL_Delay(uint8_t us)
+{
+ __delay_us(us);
+}
+
+/******************************************************************************
+ Clears the irq.
+******************************************************************************/
+void HAL_ClearRfIrqFlag(void)
+{
+ EIFR = 1 << INTF5;
+}
+
+/******************************************************************************
+ Enables the irq.
+******************************************************************************/
+void HAL_EnableRfIrq(void)
+{
+ EIMSK |= 1 << INT5;
+}
+
+/******************************************************************************
+ Disables the irq.
+******************************************************************************/
+uint8_t HAL_DisableRfIrq(void)
+{
+ uint8_t tmp;
+
+ tmp = EIMSK & (1 << INT5);
+ EIMSK &= ~(1 << INT5);
+ return tmp;
+}
+
+/******************************************************************************
+ Sets SLP_TR pin to 1.
+******************************************************************************/
+void HAL_SetRfSlpTr(void)
+{
+ GPIO_RF_SLP_TR_set();
+}
+
+/******************************************************************************
+ Clears SLP_TR pin to 0.
+******************************************************************************/
+void HAL_ClearRfSlpTr(void)
+{
+ GPIO_RF_SLP_TR_clr();
+}
+
+/******************************************************************************
+ Makes SLP_TR pin as input.
+******************************************************************************/
+void HAL_MakeInRfSlpTr(void)
+{
+ GPIO_RF_SLP_TR_make_in();
+}
+
+/******************************************************************************
+ Makes SLP_TR pin as input.
+******************************************************************************/
+void HAL_MakeOutRfSlpTr(void)
+{
+ GPIO_RF_SLP_TR_make_out();
+}
+
+/******************************************************************************
+ Sets RST_TR pin to 1.
+******************************************************************************/
+void HAL_SetRfRst(void)
+{
+ GPIO_RF_RST_set();
+}
+
+/******************************************************************************
+ Clears RST_TR pin to 1.
+******************************************************************************/
+void HAL_ClearRfRst(void)
+{
+ GPIO_RF_RST_clr();
+}
+
+/******************************************************************************
+ Init pins that controls RF chip.
+******************************************************************************/
+void HAL_InitRfPins(void)
+{
+ GPIO_RF_SLP_TR_clr();
+ GPIO_RF_SLP_TR_make_out();
+
+ GPIO_RF_RST_set();
+ GPIO_RF_RST_make_out();
+
+ GPIO_RF_IRQ_make_in();
+
+ #ifdef _HAL_USE_AMPLIFIER_
+ // enable power amplifier
+ // make port C pin 1 as output
+ GPIO_POW_AMPLF_SLP_make_out();
+ // set one on pin
+ GPIO_POW_AMPLF_SLP_set();
+ #endif
+}
+
+/******************************************************************************
+ Inits Atmega IRQ pin.
+******************************************************************************/
+void HAL_InitRfIrq(void)
+{
+ EICRB |= (1 << ISC51) | (1 << ISC50); // rising edge
+}
+
+/******************************************************************************
+ Returns current frequency code.
+******************************************************************************/
+HalSysFreq_t HAL_GetRfFreq(void)
+{
+/* if (INTERNAL_RC == halGetClockSource())
+ {
+ return HAL_FREQ_NOCLK;
+ }
+ else*/
+ {
+ #if (F_CPU == 4000000ul)
+ return HAL_FREQ_4MHZ;
+ #endif
+ #if (F_CPU == 8000000ul)
+ return HAL_FREQ_8MHZ;
+ #endif
+ }
+}
+
+/**************************************************************************//**
+ \brief Wait for when radio will be waked up.
+
+ \param none.
+ \return none.
+******************************************************************************/
+void halWaitRadio(void)
+{
+ uint8_t tempValue = 0;
+
+ do {
+ HAL_SelectRfSpi();
+ HAL_WriteByteRfSpi(RF_REGISTER_READ_ACCESS_MODE | RF_REGISTER_TRX_STATUS_ADDRESS);
+ tempValue = HAL_WriteByteRfSpi(tempValue);
+ HAL_DeselectRfSpi();
+ } while(RF_TRX_OFF_STATE != tempValue);
+}
+
+/**************************************************************************//**
+\brief Checks if amplifier is used.
+
+\return true - is used, \n
+ false - is not used.
+******************************************************************************/
+bool HAL_IsAmplifierUsed(void)
+{
+ #ifdef _HAL_USE_AMPLIFIER_
+ return true;
+ #else
+ return false;
+ #endif
+}
+
+/**************************************************************************//**
+ \brief Enables RX TX indicator for radio if that is supported.
+******************************************************************************/
+void HAL_EnableRxTxSwitcher(void)
+{
+ #ifdef _HAL_RF_RX_TX_INDICATOR_
+ phyRxTxSwitcherOn();
+ #endif //_HAL_RF_RX_TX_INDICATOR_
+}
+
+/**************************************************************************//**
+ \brief Enables Antenna diversity option for radio if that is supported.
+******************************************************************************/
+void HAL_InitAntennaDiversity(void)
+{
+ #ifdef _HAL_ANT_DIVERSITY_
+ phyAntennaDiversityInit();
+ #endif //_HAL_ANT_DIVERSITY_
+}
+
+/**************************************************************************//**
+ \brief Enables Antenna diversity in RX mode for radio if that is supported.
+******************************************************************************/
+void HAL_EnableRxAntennaDiversity(void)
+{
+ #ifdef _HAL_ANT_DIVERSITY_
+ phyRxAntennaDiversity();
+ #endif //_HAL_ANT_DIVERSITY_
+}
+
+/**************************************************************************//**
+ \brief Enables Antenna diversity in TX mode for radio if that is supported.
+******************************************************************************/
+void HAL_EnableTxAntennaDiversity(void)
+{
+ #ifdef _HAL_ANT_DIVERSITY_
+ phyTxAntennaDiversity();
+ #endif //_HAL_ANT_DIVERSITY_
+}
+
+//eof halRfCtrl.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halRfSpi.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halRfSpi.c
new file mode 100644
index 00000000..6edb9d7a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halRfSpi.c
@@ -0,0 +1,87 @@
+/**************************************************************************//**
+ \file halrfSpi.c
+
+ \brief SPI interface routines.
+
+ \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:
+ 29/05/07 A. Luzhetsky - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#include <halRfSpi.h>
+#include <halRfPio.h>
+
+/******************************************************************************
+ Performs initialization of SPI interface.
+******************************************************************************/
+void HAL_InitRfSpi(void)
+{
+ GPIO_SPI_CS_set();
+ GPIO_SPI_MISO_make_in();
+ GPIO_SPI_MOSI_make_out();
+ GPIO_SPI_SCK_make_out();
+ GPIO_SPI_CS_make_out();
+ SPCR = ((1 << SPE) | (1 << MSTR)); // SPI enable, master mode.
+ SPSR = (1 << SPI2X); // rate = fosc/2
+}
+
+/******************************************************************************
+ Writes/reads byte to/from SPI. CPU clock critical function (4 MHz only).
+ parameters: value - byte to write.
+ Returns: the byte which was read.
+******************************************************************************/
+uint8_t HAL_WriteByteRfSpi(uint8_t value)
+{
+ uint8_t tmp8;
+
+ SPDR = value; // Write data.
+ asm("nop"); // 1
+ asm("nop"); // 2
+ asm("nop"); // 3
+ asm("nop"); // 4
+ asm("nop"); // 5
+ asm("nop"); // 5
+ asm("nop"); // 7
+ asm("nop"); // 8
+ asm("nop"); // 9
+ asm("nop"); // 10
+ asm("nop"); // 11
+ asm("nop"); // 12
+ asm("nop"); // 13
+ asm("nop"); // 14
+ asm("nop"); // 15
+ asm("nop"); // 16
+ asm("nop"); // 17
+ tmp8 = SPSR;
+ (void)tmp8;
+ return SPDR;
+}
+
+/******************************************************************************
+ Deselects a slave device.
+******************************************************************************/
+void HAL_DeselectRfSpi(void)
+{
+ GPIO_SPI_CS_set();
+}
+
+/******************************************************************************
+ Selects a slave device.
+******************************************************************************/
+void HAL_SelectRfSpi(void)
+{
+ GPIO_SPI_CS_clr();
+}
+
+// eof halrfSpi.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halUid.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halUid.c
new file mode 100644
index 00000000..4f135528
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/atmega1281/zigBit/src/halUid.c
@@ -0,0 +1,72 @@
+/**************************************************************************//**
+ \file uid.c
+
+ \brief Implementation of UID interface.
+
+ \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:
+ 7/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <w1.h>
+#include <uid.h>
+#include <halAtmelUid.h>
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+static HalUid_t halUid = {.uid = 0ull};
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+ Reads uid from ds2411 (meshnetics meshbean) or ATTiny13A (atmel meshbean).
+******************************************************************************/
+void halReadUid(void)
+{
+#ifdef _HAL_TINY_UID_
+ // Atmel Single-Wire Software UART UID
+ halReadAtmelMeshbeanUid(halUid.array);
+#else
+ // 1-Wire UID
+ if (W1_SUCCESS_STATUS == HAL_SearchW1Device(W1_ANY_FAMILY, halUid.array, 1, NULL))
+ {
+ *(halUid.array + 7) = *(halUid.array + 0);
+ halUid.uid >>= 8;
+ }
+#endif
+}
+
+/******************************************************************************
+ UID discovery.
+ Parameters:
+ id - UID buffer pointer.
+ Returns:
+ 0 - if unique ID has been found without error;
+ -1 - if there are some errors during UID discovery.
+******************************************************************************/
+int HAL_ReadUid(uint64_t *id)
+{
+ if (!id)
+ return -1;
+
+ *id = halUid.uid;
+ return 0;
+}
+
+// eof uid.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/adc.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/adc.c
new file mode 100644
index 00000000..03598dcd
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/adc.c
@@ -0,0 +1,133 @@
+/**************************************************************************//**
+ \file adc.c
+
+ \brief Implementation of ADC interface.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <halAdc.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum
+{
+ IDLE, // idle
+ DATA, // performs request
+ BUSY // the module is ready to start conversion
+} AdcStates_t;
+
+typedef struct
+{
+ void (*callback)(void); // address of callback
+} HalAdcControl_t;
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+AdcStates_t halAdcState = IDLE; // Monitors current state
+HalAdcControl_t halAdcControl;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+Opens the ADC to make the measuring on a ADC channel.
+Parameters:
+ param - pointer to parameter structure
+Returns:
+ -1 - unsupported parameter or ADC is busy.
+ 0 - on success.
+******************************************************************************/
+int HAL_OpenAdc(HAL_AdcParams_t *param)
+{
+ if (IDLE != halAdcState)
+ return -1;
+ if (NULL == param)
+ return -1;
+ if (NULL == param->bufferPointer)
+ return -1;
+ if (param->resolution > RESOLUTION_10_BIT)
+ return -1;
+ /* unsupported voltage reference */
+ if (param->voltageReference & 0x3F)
+ return -1;
+ /* adc speed must be only 9600 or 4800 SPS for 10 bit resolution */
+ if ((RESOLUTION_10_BIT == param->resolution) && (param->sampleRate < ADC_9600SPS))
+ return -1;
+
+ halAdcState = BUSY;
+ halOpenAdc(param);
+ halAdcControl.callback = param->callback;
+ return 0;
+}
+
+/******************************************************************************
+Starts ADC with the parameters that were defined at HAL_OpenAdc.
+Parameters:
+ channel - number of channel
+Returns:
+ -1 - the ADC was not opened, unsupported channel number.
+ 0 - on success.
+******************************************************************************/
+int HAL_ReadAdc(HAL_AdcChannelNumber_t channel)
+{
+ if (BUSY != halAdcState)
+ return -1;
+ if (((channel > HAL_ADC_CHANNEL3) && (channel < HAL_ADC_DIFF_CHANNEL0)) || (channel > HAL_ADC_DIFF_CHANNEL7))
+ return -1;
+
+ halAdcState = DATA;
+ halStartAdc(channel);
+ return 0;
+}
+
+/******************************************************************************
+Closes the ADC.
+Parameters:
+ none.
+Returns:
+ -1 - the module was not opened to be used.
+ 0 - on success.
+******************************************************************************/
+int HAL_CloseAdc(void)
+{
+ if (IDLE == halAdcState)
+ return -1;
+
+ halAdcState = IDLE;
+ halCloseAdc();
+ return 0;
+}
+
+/******************************************************************************
+ ADC interrupt handler.
+******************************************************************************/
+void halSigAdcHandler(void)
+{
+ if (DATA == halAdcState)
+ {
+ halAdcState = BUSY;
+ if (NULL != halAdcControl.callback)
+ halAdcControl.callback();
+ }
+}
+// eof adc.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/appTimer.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/appTimer.c
new file mode 100644
index 00000000..45047822
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/appTimer.c
@@ -0,0 +1,169 @@
+/**************************************************************************//**
+ \file appTimer.c
+
+ \brief Implementation of appTimer.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <appTimer.h>
+#include <halAppClock.h>
+#include <halTaskManager.h>
+#include <atomic.h>
+#include <halDbg.h>
+#include <halDiagnostic.h>
+#if defined(_SYSTEM_TIME_ON_SLEEP_TIMER_)
+ #include <halSleepTimerClock.h>
+#endif
+
+/******************************************************************************
+ External global variables section
+******************************************************************************/
+extern uint8_t halSleepTimerOvfw;
+extern uint8_t halAppTimeOvfw;
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+static HAL_AppTimer_t *halAppTimerHead = NULL; // head of appTimer list
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+Interrupt handler of appTimer clock.
+******************************************************************************/
+void halAppTimerHandler(void)
+{
+ uint32_t sysTime;
+
+ // search for expired timers and call their callbacks
+ while ( halAppTimerHead
+ && ((sysTime = halGetTimeOfAppTimer()) - halAppTimerHead->service.sysTimeLabel) >= halAppTimerHead->interval)
+ {
+ HAL_AppTimer_t *p = halAppTimerHead;
+ halRemoveTimer(&halAppTimerHead, NULL, p);
+ if (TIMER_REPEAT_MODE == p->mode)
+ {
+ p->service.sysTimeLabel = sysTime;
+ halAddTimer(&halAppTimerHead, p, sysTime);
+ }
+ p->callback();
+ }
+}
+
+/******************************************************************************
+Check if timer is already started.
+Parameters:
+ appTimer - pointer to HAL_AppTimer_t.
+Returns:
+ true - timer specified already started and presents in the system timers queue
+ false - timer is't started yet
+******************************************************************************/
+static bool isTimerAlreadyStarted(HAL_AppTimer_t *appTimer)
+{
+ bool result = false;
+ Timer_t *p; // p is bottom of list
+ p = halAppTimerHead;
+
+ while (NULL != p)
+ {
+ if (p == appTimer)
+ {
+ result = true;
+ assert(false, APPTIMER_MISTAKE);
+ break;
+ }
+ p = (Timer_t *)p->service.next;
+ }
+ return result;
+}
+
+
+/******************************************************************************
+Starts to count an interval.
+Parameters:
+ appTimer - pointer to HAL_AppTimer_t.
+Returns:
+ -1 - pointer is NULL.
+ 0 - success
+******************************************************************************/
+int HAL_StartAppTimer(HAL_AppTimer_t *appTimer)
+{
+ uint32_t sysTime;
+
+ if (!appTimer)
+ return -1;
+
+ if (true == isTimerAlreadyStarted(appTimer))
+ return 0;
+
+ sysTime = halGetTimeOfAppTimer();
+ appTimer->service.next = NULL;
+ appTimer->service.sysTimeLabel = sysTime;
+ halAddTimer((Timer_t**)(&halAppTimerHead), (Timer_t*)appTimer, sysTime);
+ return 0;
+}
+
+/******************************************************************************
+Stops the timer.
+Parameters:
+ appTimer - pointer to HAL_AppTimer_t.
+Returns:
+ -1 there is not the appTimer.
+ 0 - success
+******************************************************************************/
+int HAL_StopAppTimer(HAL_AppTimer_t *appTimer)
+{
+ Timer_t *prev = 0;
+ Timer_t **t = &appTimer;
+
+ if (!appTimer)
+ return -1;
+ if (halAppTimerHead != *t)
+ {
+ if (!(prev = halFindPrevTimer((Timer_t**)(&halAppTimerHead), appTimer)))
+ return -1; // This timer is not in the list
+ }
+ halRemoveTimer((Timer_t**)(&halAppTimerHead), prev, appTimer);
+ return 0;
+}
+
+/**************************************************************************//**
+\brief Gets system time.
+
+\return
+ time since power up in milliseconds(8 bytes).
+******************************************************************************/
+BcTime_t HAL_GetSystemTime(void)
+{
+ BcTime_t sysTime = 0ull;
+
+ #if defined(_SYSTEM_TIME_ON_SLEEP_TIMER_)
+ sysTime = halGetTimeOfSleepTimer();
+ sysTime |= ((BcTime_t)halSleepTimerOvfw << 32);
+ #else
+ sysTime = halGetTimeOfAppTimer();
+ sysTime |= ((BcTime_t)halAppTimeOvfw << 32);
+ #endif
+
+ return sysTime;
+}
+
+// eof appTimer.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/eeprom.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/eeprom.c
new file mode 100644
index 00000000..8e17055b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/eeprom.c
@@ -0,0 +1,156 @@
+/**************************************************************************//**
+ \file eeprom.c
+
+ \brief Implementation of the EEPROM interface.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halEeprom.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum
+{
+ EEPROM_IDLE = 0,
+ EEPROM_BUSY
+} EepromState_t;
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+EepromState_t halEepromState = EEPROM_IDLE; // state
+HAL_EepromParams_t halEepromParams;
+void (*halEepromDone)();
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+Reads some number of bytes defined by HAL_EepromParams_t from the EEPROM.
+Parameters:
+ params - address of HAL_EepromParams_t defined by user.
+ readDone - callback method
+Returns:
+ 0 - success.
+ -1 - the EEPROM has request that was not completed,
+ number of byte to read too much.
+ -2 - eeprom is busy
+******************************************************************************/
+int HAL_ReadEeprom(HAL_EepromParams_t *params, void (*readDone)())
+{
+ uint16_t i;
+
+ if (EEPROM_IDLE != halEepromState)
+ return -2;
+ if (NULL == params)
+ return -1;
+ if ((uint16_t)(params->address + params->length) > EEPROM_DATA_MEMORY_SIZE)
+ return -1;
+
+ halEepromState = EEPROM_BUSY;
+ halEepromDone = readDone;
+ halEepromParams = *params;
+ halWaitEepromReady(); // wait for completion of previous operation
+ for (i = 0; i < halEepromParams.length; i++)
+ {
+ halEepromParams.data[i] = halReadEeprom(halEepromParams.address++);
+ }
+ halEepromParams.length = 0;
+ halPostTask3(HAL_EE_READY);
+
+ return 0;
+}
+
+/******************************************************************************
+Writes number of bytes defined by HAL_EepromParams_t to EEPROM.
+By writeDone parameter user can control if write operation will be asynchronous
+or synchronous.
+Parameters:
+ params - address of HAL_EepromParams_t defined by user.
+ writeDone - address of callback. if writeDone is NULL write operation will be
+ synchronous.
+Returns:
+ 0 - success.
+ -1 - the EEPROM has request that was not completed,
+ number of byte to write too much.
+ -2 - eeprom is busy
+******************************************************************************/
+int HAL_WriteEeprom(HAL_EepromParams_t *params, void (*writeDone)())
+{
+ uint16_t i;
+
+ if (EEPROM_IDLE != halEepromState)
+ return -2;
+ if (NULL == params)
+ return -1;
+ if ((uint16_t)(params->address + params->length) > EEPROM_DATA_MEMORY_SIZE)
+ return -1;
+
+ halEepromState = EEPROM_BUSY;
+ halEepromParams = *params;
+ halEepromDone = writeDone;
+ if (halEepromDone)
+ {// asynchronous operation
+ halEepromWrite(HAL_EEPROM_WRITE_MASK_INT, halEepromParams.address++, *halEepromParams.data++);
+ halEepromParams.length--;
+ return 0;
+ }
+ for (i = 0; i < halEepromParams.length; i++)
+ {
+ halEepromWrite(HAL_EEPROM_WRITE_MASK, halEepromParams.address++, *halEepromParams.data++);
+ }
+ halWaitEepromReady(); // wait for completion of previous write
+ halEepromState = EEPROM_IDLE;
+
+ return 0;
+}
+
+/******************************************************************************
+Checks the eeprom state.
+
+Returns:
+ true - eeprom is busy;
+ false - eeprom is free;
+******************************************************************************/
+bool HAL_IsEepromBusy(void)
+{
+ if (EEPROM_BUSY == halEepromState)
+ return true;
+ else
+ return false;
+}
+
+/******************************************************************************
+Interrupt handler about write completion to EEPROM.
+******************************************************************************/
+void halSigEepromReadyHandler(void)
+{
+ if (!halEepromParams.length)
+ {
+ halEepromState = EEPROM_IDLE;
+ if (NULL != halEepromDone)
+ halEepromDone();
+ return;
+ }
+ halEepromWrite(HAL_EEPROM_WRITE_MASK_INT, halEepromParams.address++, *halEepromParams.data++);
+ halEepromParams.length--;
+}
+//eof eeprom.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/halTaskManager.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/halTaskManager.c
new file mode 100644
index 00000000..2c647084
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/halTaskManager.c
@@ -0,0 +1,305 @@
+/**************************************************************************//**
+ \file halTaskManager.c
+
+ \brief Implemenattion of HAL task manager.
+
+ \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:
+ 10/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halTaskManager.h>
+#include <atomic.h>
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+void (* extHandler)(void);
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Interrupt handler of appTimer clock.
+******************************************************************************/
+void halAppTimerHandler(void);
+
+/**************************************************************************//**
+\brief HAL USART task. Exact ection depends on USART internal task.
+******************************************************************************/
+void halSigUsartHandler(void);
+
+/**************************************************************************//**
+\brief twi end of sending handler
+******************************************************************************/
+void halSig2WireSerialHandler(void);
+
+/**************************************************************************//**
+\brief Interrupt handler about write completion to EEPROM.
+******************************************************************************/
+void halSigEepromReadyHandler(void);
+
+/**************************************************************************//**
+\brief Interrupt handler about sleep interval was completed.
+******************************************************************************/
+void halAsyncTimerHandler(void);
+
+/***************************************************************************//**
+\brief Shutdown system. \n
+ NOTES: \n
+ the application should be sure the poweroff will not be \n
+ interrupted after the execution of the sleep().
+*******************************************************************************/
+void halPowerOff(void);
+
+/**************************************************************************//**
+\brief ADC interrupt handler.
+******************************************************************************/
+void halSigAdcHandler(void);
+
+/**************************************************************************//**
+\brief Endpoint interrupt handler.
+******************************************************************************/
+void halEndPointHandler(void);
+
+/**************************************************************************//**
+\brief usb suspend interrupt handler.
+******************************************************************************/
+void halSuspendHandler(void);
+
+/**************************************************************************//**
+\brief usb resume interrupt handler.
+******************************************************************************/
+void halResumeHandler(void);
+
+/**************************************************************************//**
+\brief usb bus reset interrupt handler.
+******************************************************************************/
+void halBusResetHandler(void);
+
+/**************************************************************************//**
+\brief Handler for task manager. It is executed when system has waked up.
+******************************************************************************/
+void halWakeupHandler(void);
+
+/**************************************************************************//**
+\brief Security Module request handler.
+******************************************************************************/
+void halSmRequestHandler(void);
+
+/**************************************************************************//**
+\brief Synchronization system time which based on sleep timer.
+******************************************************************************/
+void halSleepSystemTimeSynchronize(void);
+
+/**************************************************************************//**
+\brief Slave spi reception complete interrupt handler.
+******************************************************************************/
+void halSpiRxByteComplete(void);
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+volatile uint8_t halTaskFlags0 = 0;
+volatile uint8_t halTaskFlags1 = 0;
+volatile uint8_t halTaskFlags2 = 0;
+volatile uint8_t halTaskFlags3 = 0;
+volatile uint8_t halTaskFlags4 = 0;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+HAL task handler.
+******************************************************************************/
+void HAL_TaskHandler()
+{
+ if (0)
+ {
+ }
+#ifdef HAL_USE_TIMER2_COMPA
+ else if (halTaskFlags0 & HAL_ASYNC_TIMER)
+ {
+ ATOMIC_SECTION_ENTER
+ halTaskFlags0 &= (~HAL_ASYNC_TIMER);
+ ATOMIC_SECTION_LEAVE
+ halAsyncTimerHandler();
+ }
+#endif // HAL_USE_TIMER2_COMPA
+
+#ifdef HAL_USE_TIMER2_COMPA
+ else if (halTaskFlags0 & HAL_SYNC_SLEEP_TIME)
+ {
+ ATOMIC_SECTION_ENTER
+ halTaskFlags0 &= (~HAL_SYNC_SLEEP_TIME);
+ ATOMIC_SECTION_LEAVE
+ halSleepSystemTimeSynchronize();
+ }
+#endif // HAL_USE_TIMER2_COMPA
+
+#ifdef HAL_USE_SPI
+ else if (halTaskFlags2 & HAL_TASK_SPI)
+ {
+ ATOMIC_SECTION_ENTER
+ halTaskFlags2 &= (~HAL_TASK_SPI);
+ ATOMIC_SECTION_LEAVE
+ halSpiRxByteComplete();
+ }
+#endif // HAL_USE_SPI
+
+#ifdef HAL_USE_USART
+ else if (halTaskFlags2 & HAL_TASK_USART)
+ {
+ ATOMIC_SECTION_ENTER
+ halTaskFlags2 &= (~HAL_TASK_USART);
+ ATOMIC_SECTION_LEAVE
+ halSigUsartHandler();
+ }
+#endif // HAL_USE_USART
+
+#ifdef HAL_USE_ADC
+ else if (halTaskFlags3 & HAL_ADC)
+ {
+ ATOMIC_SECTION_ENTER
+ halTaskFlags3 &= (~HAL_ADC);
+ ATOMIC_SECTION_LEAVE
+ halSigAdcHandler();
+ }
+#endif // HAL_USE_ADC
+
+#ifdef HAL_USE_EE_READY
+ else if (halTaskFlags3 & HAL_EE_READY)
+ {
+ ATOMIC_SECTION_ENTER
+ halTaskFlags3 &= (~HAL_EE_READY);
+ ATOMIC_SECTION_LEAVE
+ halSigEepromReadyHandler();
+ }
+#endif // HAL_USE_EE_READY
+
+#ifdef HAL_USE_USB
+ else if (halTaskFlags3 & HAL_USB_ENDPOINTS)
+ {
+ ATOMIC_SECTION_ENTER
+ halTaskFlags3 &= (~HAL_USB_ENDPOINTS);
+ ATOMIC_SECTION_LEAVE
+ halEndPointHandler();
+ }
+#endif // HAL_USE_USB
+
+#ifdef HAL_USE_USB
+ else if (halTaskFlags3 & HAL_USB_SUSPEND)
+ {
+ ATOMIC_SECTION_ENTER
+ halTaskFlags3 &= (~HAL_USB_SUSPEND);
+ ATOMIC_SECTION_LEAVE
+ halSuspendHandler();
+ }
+#endif // HAL_USE_USB
+
+#ifdef HAL_USE_USB
+ else if (halTaskFlags3 & HAL_USB_RESUME)
+ {
+ ATOMIC_SECTION_ENTER
+ halTaskFlags3 &= (~HAL_USB_RESUME);
+ ATOMIC_SECTION_LEAVE
+ halResumeHandler();
+ }
+#endif // HAL_USE_USB
+
+#ifdef _HAL_HW_AES_
+ else if (halTaskFlags3 & HAL_SM_REQ)
+ {
+ ATOMIC_SECTION_ENTER
+ halTaskFlags3 &= (~HAL_SM_REQ);
+ ATOMIC_SECTION_LEAVE
+ halSmRequestHandler();
+ }
+#endif // _HAL_HW_AES_
+
+#ifdef HAL_USE_USB
+ else if (halTaskFlags3 & HAL_USB_BUS_RESET)
+ {
+ ATOMIC_SECTION_ENTER
+ halTaskFlags3 &= (~HAL_USB_BUS_RESET);
+ ATOMIC_SECTION_LEAVE
+ halBusResetHandler();
+ }
+#endif // HAL_USE_USB
+
+#ifdef HAL_USE_WAKEUP
+ else if (halTaskFlags4 & HAL_WAKEUP)
+ {
+ ATOMIC_SECTION_ENTER
+ halTaskFlags4 &= (~HAL_WAKEUP);
+ ATOMIC_SECTION_LEAVE
+ halWakeupHandler();
+ }
+#endif
+
+#ifdef HAL_USE_TWI
+ else if (halTaskFlags4 & HAL_TWI)
+ {
+ ATOMIC_SECTION_ENTER
+ halTaskFlags4 &= (~HAL_TWI);
+ ATOMIC_SECTION_LEAVE
+ halSig2WireSerialHandler();
+ }
+#endif // HAL_USE_TWI
+
+#ifdef HAL_USE_TIMER4_COMPA
+ else if (halTaskFlags4 & HAL_TIMER4_COMPA)
+ {
+ ATOMIC_SECTION_ENTER
+ halTaskFlags4 &= (~HAL_TIMER4_COMPA);
+ ATOMIC_SECTION_LEAVE
+ halAppTimerHandler();
+ }
+#endif // HAL_USE_TIMER4_COMPA
+
+#ifdef HAL_USE_SLEEP
+ else if (halTaskFlags4 & HAL_SLEEP)
+ {
+ ATOMIC_SECTION_ENTER
+ halTaskFlags4 &= (~HAL_SLEEP);
+ ATOMIC_SECTION_LEAVE
+ halPowerOff();
+ }
+#endif // HAL_USE_SLEEP
+
+#ifdef HAL_USE_EXT_HANDLER
+ else if (halTaskFlags4 & HAL_EXT_HANDLER)
+ {
+ ATOMIC_SECTION_ENTER
+ halTaskFlags4 &= (~HAL_EXT_HANDLER);
+ ATOMIC_SECTION_LEAVE
+ if (extHandler)
+ extHandler();
+ }
+#endif // HAL_USE_EXT_HANDLER
+
+ if (halTaskFlags0 ||
+ halTaskFlags1 ||
+ halTaskFlags2 ||
+ halTaskFlags3 ||
+ halTaskFlags4)
+ {
+ SYS_PostTask(HAL_TASK_ID);
+ }
+}
+
+// eof halTaskManager.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/i2cPacket.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/i2cPacket.c
new file mode 100644
index 00000000..340981e1
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/i2cPacket.c
@@ -0,0 +1,371 @@
+/**************************************************************************//**
+ \file i2cPacket.c
+
+ \brief Provides the functionality for the writing and the reading \n
+ of packets through the TWI.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <i2cPacket.h>
+#include <i2c.h>
+#include <halTaskManager.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+/* states of the i2c transaction */
+#define I2C_CLOSE 0
+#define I2C_IDLE 1
+#define I2C_WRITE_IADDR_WRITE_DATA 2
+#define I2C_WRITE_IADDR_READ_DATA 3
+#define I2C_WRITE_DATA 4
+#define I2C_READ_DATA 5
+#define I2C_TRANSAC_SUCCESS 6
+#define I2C_TRANSAC_FAIL 7
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef struct
+{
+ volatile uint8_t* data; // bytes to write to the i2c bus
+ volatile uint8_t length; // length in bytes of the request
+ volatile uint8_t index; // current index of read/write byte
+ volatile uint8_t addr; // destination address
+ volatile uint32_t intAddress; // internal address inner i2c device
+ void (*done)(bool result); // callback
+} HalI2cPacketControl_t;
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+// current state of the i2c request
+volatile uint8_t halI2cPacketState = I2C_CLOSE;
+HalI2cPacketControl_t halI2cPacketControl;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+Resets TWI bus and i2c HAL.
+******************************************************************************/
+void halI2cBusReset(void)
+{
+ halI2cPacketState = I2C_TRANSAC_FAIL;
+ halResetI2c();
+ halPostTask4(HAL_TWI);
+}
+
+/******************************************************************************
+Opens resource.
+Parameters:
+ i2cMode - pointer to clock rate structure.
+Returns:
+ Returns:
+ -1 - resource was opened or pointer is NULL
+ 0 - success.
+******************************************************************************/
+int HAL_OpenI2cPacket(HAL_i2cMode_t *i2cMode)
+{
+ if (NULL == i2cMode)
+ return -1;
+ if (I2C_CLOSE == halI2cPacketState)
+ {
+ halInitI2c(i2cMode);
+ halI2cPacketState = I2C_IDLE;
+ halI2cPacketControl.index = 0;
+ return 0;
+ }
+ return -1;
+}
+
+/******************************************************************************
+Closes resource.
+Returns:
+ -1 - resource was not opened.
+ 0 - success.
+******************************************************************************/
+int HAL_CloseI2cPacket(void)
+{
+ if (I2C_CLOSE != halI2cPacketState)
+ {
+ halI2cPacketControl.done = NULL;
+ halI2cPacketState = I2C_CLOSE;
+ return 0;
+ }
+ return -1;
+}
+
+/******************************************************************************
+Writes the series of bytes out to the TWI bus.
+Parameters:
+ param - pointer to HAL_I2cParams_t structure
+Returns:
+ 0 - the bus is free and the request is accepted.
+ -1 - other case.
+******************************************************************************/
+int HAL_WriteI2cPacket(HAL_I2cParams_t *param)
+{
+ if ((I2C_IDLE == halI2cPacketState) && param)
+ {
+ halI2cPacketControl.addr = param->id;
+ halI2cPacketControl.data = param->data;
+ halI2cPacketControl.index = param->lengthAddr;
+ halI2cPacketControl.length = param->length;
+ halI2cPacketControl.done = param->f;
+ halI2cPacketControl.intAddress = param->internalAddr;
+ }
+ else
+ {
+ return -1;
+ }
+
+ if (HAL_NO_INTERNAL_ADDRESS == halI2cPacketControl.index)
+ halI2cPacketState = I2C_WRITE_DATA;
+ else
+ halI2cPacketState = I2C_WRITE_IADDR_WRITE_DATA;
+ halSendStartI2c();
+ return 0;
+}
+
+/******************************************************************************
+Reads the series of bytes out to the TWI bus.
+Parameters:
+ param - pointer to HAL_I2cParams_t structure
+Returns:
+ 0 - the bus is free and the request is accepted.
+ -1 - other case.
+******************************************************************************/
+int HAL_ReadI2cPacket(HAL_I2cParams_t *param)
+{
+ if ((I2C_IDLE == halI2cPacketState) && param)
+ {
+ halI2cPacketControl.addr = param->id;
+ halI2cPacketControl.index = param->lengthAddr;
+ halI2cPacketControl.length = param->length;
+ halI2cPacketControl.data = param->data;
+ halI2cPacketControl.done = param->f;
+ halI2cPacketControl.intAddress = param->internalAddr;
+ }
+ else
+ {
+ return -1;
+ }
+
+ if (HAL_NO_INTERNAL_ADDRESS == halI2cPacketControl.index)
+ halI2cPacketState = I2C_READ_DATA;
+ else
+ halI2cPacketState = I2C_WRITE_IADDR_READ_DATA;
+ halSendStartI2c();
+ return 0;
+}
+
+/******************************************************************************
+Notification about the start condition was sent.
+Parameters:
+ none.
+Returns:
+ none.
+******************************************************************************/
+void halSendStartDoneI2c(void)
+{
+ if ((I2C_WRITE_IADDR_WRITE_DATA == halI2cPacketState) ||
+ (I2C_WRITE_IADDR_READ_DATA == halI2cPacketState) ||
+ (I2C_WRITE_DATA == halI2cPacketState))
+ {
+ halWriteI2c(((halI2cPacketControl.addr << 1) + 0));
+ }
+ else if (I2C_READ_DATA == halI2cPacketState)
+ {
+ halWriteI2c(((halI2cPacketControl.addr << 1) + 1));
+ }
+ else
+ { // abnormal
+ halI2cBusReset();
+ }
+}
+
+/******************************************************************************
+Sending data to i2c bus. If last byte then send stop condition and post task.
+Parameters:
+ none.
+Returns:
+ none.
+******************************************************************************/
+void halWriteData(void)
+{
+ if (halI2cPacketControl.index < halI2cPacketControl.length)
+ {
+ halWriteI2c(halI2cPacketControl.data[halI2cPacketControl.index++]);
+ }
+ else
+ {
+ halI2cPacketState = I2C_TRANSAC_SUCCESS;
+ halSendStopI2c();
+ halPostTask4(HAL_TWI);
+ }
+}
+
+/******************************************************************************
+Sending internal device address to i2c bus. If address is sent then switch i2c
+hal state.
+Parameters:
+ none.
+Returns:
+ none.
+******************************************************************************/
+void halWriteInternalAddress(void)
+{
+ uint8_t data;
+
+ data = (uint8_t)(halI2cPacketControl.intAddress >> --halI2cPacketControl.index * 8);
+ halWriteI2c(data);
+
+ if (0 == halI2cPacketControl.index)
+ {
+ if (I2C_WRITE_IADDR_WRITE_DATA == halI2cPacketState)
+ halI2cPacketState = I2C_WRITE_DATA;
+ else
+ halI2cPacketState = I2C_READ_DATA;
+ }
+}
+
+/******************************************************************************
+Notification that byte was written to the TWI.
+Parameters:
+ result - contains result of previous operation.
+Returns:
+ none.
+******************************************************************************/
+void halWriteDoneI2c(void)
+{
+ if (I2C_WRITE_DATA == halI2cPacketState)
+ {
+ halWriteData();
+ }
+ else if ((I2C_WRITE_IADDR_WRITE_DATA == halI2cPacketState) || (I2C_WRITE_IADDR_READ_DATA == halI2cPacketState))
+ {
+ halWriteInternalAddress();
+ }
+ else if (I2C_READ_DATA == halI2cPacketState)
+ {
+ halSendStartI2c();
+ }
+ else
+ { // abnormal
+ halI2cBusReset();
+ }
+}
+
+/******************************************************************************
+Notification that address byte was written to the TWI and was read ACK.
+Starts reading data.
+Parameters:
+ none.
+Returns:
+ none.
+******************************************************************************/
+void halMasterReadWriteAddressAckI2c(void)
+{
+ if (I2C_READ_DATA == halI2cPacketState)
+ {
+ if (1 == halI2cPacketControl.length)
+ halReadI2c(false); // send nack
+ else
+ halReadI2c(true); // send ack
+ }
+ else
+ { // abnormal
+ halI2cBusReset();
+ }
+}
+
+/******************************************************************************
+Notification that byte was read from the TWI.
+Parameters:
+ data - contains byte that was read.
+Returns:
+ none.
+******************************************************************************/
+void halReadDoneI2c(uint8_t data)
+{
+ if (I2C_READ_DATA == halI2cPacketState)
+ {
+ halI2cPacketControl.data[halI2cPacketControl.index++] = data;
+ if (halI2cPacketControl.index < (halI2cPacketControl.length - 1))
+ halReadI2c(true); // send ACK
+ else
+ halReadI2c(false); // send NACK
+ }
+ else
+ { // abnormal
+ halI2cBusReset();
+ }
+}
+
+/******************************************************************************
+Notification that last byte was read from the TWI. Needs send STOP condition
+on bus.
+Parameters:
+ data - contains byte that was read.
+Returns:
+ none.
+******************************************************************************/
+void halReadLastByteDoneI2c(uint8_t data)
+{
+ if (I2C_READ_DATA == halI2cPacketState)
+ {
+ halI2cPacketControl.data[halI2cPacketControl.index++] = data;
+ halI2cPacketState = I2C_TRANSAC_SUCCESS;
+ halSendStopI2c();
+ halPostTask4(HAL_TWI);
+ }
+ else
+ { // abnormal
+ halI2cBusReset();
+ }
+}
+
+/******************************************************************************
+Waits for end of sending and calls user's callback
+******************************************************************************/
+void halSig2WireSerialHandler(void)
+{
+ if (halI2cPacketControl.done)
+ {
+ if (I2C_TRANSAC_SUCCESS == halI2cPacketState)
+ {
+ halWaitEndOfStopStation();
+ halI2cPacketState = I2C_IDLE;
+ halI2cPacketControl.done(true);
+ }
+ else
+ {
+ halI2cPacketState = I2C_IDLE;
+ halI2cPacketControl.done(false);
+ }
+ }
+ else
+ {
+ halI2cPacketState = I2C_IDLE;
+ }
+}
+// eof i2cPacket.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/irq.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/irq.c
new file mode 100644
index 00000000..c681ba74
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/irq.c
@@ -0,0 +1,143 @@
+/**************************************************************************//**
+ \file irq.c
+
+ \brief Implementation of IRQ interface.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halIrq.h>
+
+/******************************************************************************
+ External global variables section
+******************************************************************************/
+extern IrqCallback_t IrqCallbackList[HAL_NUM_IRQ_LINES];
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+ Registers user's irqNumber interrupt
+ Parameters:
+ irqNumber - IRQ number
+ irqMode - Interrupt sence control
+ f - user's interrupt handler. Handler must be executed less than 100 us.
+ Returns:
+ -1 - if irqNumber is out of range, not valid irq mode, invalid interrupt handler
+ or such interrupt has been already registered.
+ 0 - otherwise.
+******************************************************************************/
+int HAL_RegisterIrq(HAL_IrqNumber_t irqNumber, HAL_IrqMode_t irqMode, void (*f)(void))
+{
+ uint8_t irqOffsetNumber = irqNumber - HAL_FIRST_VALID_IRQ;
+
+ // irqNumber is out of range
+ if (irqOffsetNumber >= HAL_NUM_IRQ_LINES)
+ return -1;
+ // Such interrupt has been already register
+ if (NULL != IrqCallbackList[irqOffsetNumber])
+ return -1;
+ // not valid irq mode
+ if (IRQ_HIGH_LEVEL == irqMode)
+ return -1;
+ // invalid interrupt handler
+ if (NULL == f)
+ return -1;
+
+ /* type HAL_IrqMode_t has not valid IRQ_HIGH_LEVEL state,
+ * because for saving to register all states need decrement after IRQ_LOW_LEVEL state. */
+ if (IRQ_LOW_LEVEL == irqMode)
+ halSetIrqConfig(irqNumber, irqMode);
+ else
+ halSetIrqConfig(irqNumber, irqMode - 1);
+
+ IrqCallbackList[irqOffsetNumber] = f;
+ return 0;
+}
+
+/******************************************************************************
+ Enables irqNumber interrupt
+ Parameters:
+ irqNumber - IRQ number
+ Returns:
+ -1 - if irqNumber is out of range or has not been
+ registered yet.
+ 0 - otherwise.
+******************************************************************************/
+int HAL_EnableIrq(HAL_IrqNumber_t irqNumber)
+{
+ uint8_t irqOffsetNumber = irqNumber - HAL_FIRST_VALID_IRQ;
+ // irqNumber is out of range
+ if (irqOffsetNumber >= HAL_NUM_IRQ_LINES)
+ return -1;
+ // Interrupt has not been opened yet
+ if (NULL == IrqCallbackList[irqOffsetNumber])
+ return -1;
+ halEnableIrqInterrupt(irqNumber);
+ return 0;
+}
+
+/******************************************************************************
+ Disables irqNumber interrupt
+ Parameters:
+ irqNumber - IRQ number
+ Returns:
+ -1 - if irqNumber is out of range or has not been
+ registered yet.
+ 0 - otherwise.
+******************************************************************************/
+int HAL_DisableIrq(HAL_IrqNumber_t irqNumber)
+{
+ uint8_t irqOffsetNumber = irqNumber - HAL_FIRST_VALID_IRQ;
+ // irqNumber is out of range
+ if (irqOffsetNumber >= HAL_NUM_IRQ_LINES)
+ return -1;
+ // Interrupt has not been opened yet
+ if (NULL == IrqCallbackList[irqOffsetNumber])
+ return -1;
+ halDisableIrqInterrupt(irqNumber);
+ return 0;
+}
+
+/******************************************************************************
+ Unregisters user's irqNumber interrupt
+ Parameters:
+ irqNumber - IRQ number
+ Returns:
+ -1 - if irqNumber is out of range or has not been
+ registered yet.
+ 0 - otherwise.
+******************************************************************************/
+int HAL_UnregisterIrq(HAL_IrqNumber_t irqNumber)
+{
+ uint8_t irqOffsetNumber = irqNumber - HAL_FIRST_VALID_IRQ;
+ // irqNumber is out of range
+ if (irqOffsetNumber >= HAL_NUM_IRQ_LINES)
+ return -1;
+ // Interrupt has not been opened yet
+ if (NULL == IrqCallbackList[irqOffsetNumber])
+ return -1;
+ // Disable external interrupt request
+ halDisableIrqInterrupt(irqNumber);
+ halClrIrqConfig(irqNumber);
+ IrqCallbackList[irqOffsetNumber] = NULL;
+ return 0;
+}
+
+// eof irq.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/pwm.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/pwm.c
new file mode 100644
index 00000000..ad7b18a2
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/pwm.c
@@ -0,0 +1,165 @@
+/**************************************************************************//**
+ \file pwm.c
+
+ \brief Implementation of PWM interface.
+
+ \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:
+ 10/11/08 A. Taradov - Created
+ 5/04/11 A.Razinkov - Refactored
+*******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halPwm.h>
+#include <pwm.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+
+/******************************************************************************
+ Constants section
+******************************************************************************/
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Initializes the PWM.
+
+\param [in] pwmUnit - PWM unit number.
+ Equal to ID of Timer/Counter witch serves PWM module.
+
+\return operation status
+******************************************************************************/
+int HAL_OpenPwm(HAL_PwmUnit_t pwmUnit)
+{
+ /* Check PWM unit */
+ if ((PWM_UNIT_1 == pwmUnit) || (PWM_UNIT_3 == pwmUnit))
+ halOpenPwm(pwmUnit);
+ else
+ return PWM_INVALID_UNIT_STATUS;
+
+ return PWM_SUCCESS_STATUS;
+}
+
+/**************************************************************************//**
+\brief Starts PWM on specified channel.
+
+\param [in] descriptor - PWM channel descriptor.
+
+\return operation status
+******************************************************************************/
+int HAL_StartPwm(HAL_PwmDescriptor_t *descriptor)
+{
+ /* Invalid PWM channel specified */
+ if (PWM_INVALID_CHANNEL <= descriptor->channel)
+ return PWM_INVALID_CHANNEL_STATUS;
+ /* Check PWM unit */
+ if ((PWM_UNIT_1 == descriptor->unit) || (PWM_UNIT_3 == descriptor->unit))
+ {
+ halPreparePwmChannelAccess(descriptor);
+ halStartPwm(descriptor);
+ }
+ else
+ return PWM_INVALID_UNIT_STATUS;
+
+ return PWM_SUCCESS_STATUS;
+}
+
+/**************************************************************************//**
+\brief Stops PWM on specified channel.
+
+\param [in] descriptor - PWM channel descriptor.
+
+\return operation status
+******************************************************************************/
+int HAL_StopPwm(HAL_PwmDescriptor_t *descriptor)
+{
+ /* Invalid PWM channel specified */
+ if (PWM_INVALID_CHANNEL <= descriptor->channel)
+ return PWM_INVALID_CHANNEL_STATUS;
+ else
+ halStopPwm(descriptor);
+
+ return PWM_SUCCESS_STATUS;
+}
+
+/**************************************************************************//**
+\brief Sets base frequency of module. Common for all module channels.
+
+\param [in] pwmUnit - PWM unit number. Equal to corresponding Timer/Counter ID.
+\param [in] top - value for the TOP register.
+\param [in] prescaler - clock prescaler.
+
+\return operation status
+******************************************************************************/
+int HAL_SetPwmFrequency(HAL_PwmUnit_t pwmUnit, uint16_t top, HAL_PwmPrescaler_t prescaler)
+{
+ /* Check prescaler value */
+ if (PWM_PRESCALER_INVALID <= prescaler)
+ return PWM_INVALID_PRESCALER_STATUS;
+ else halSetPwmFrequency(pwmUnit, top, prescaler);
+
+ return PWM_SUCCESS_STATUS;
+}
+
+/**************************************************************************//**
+\brief Sets compare value for the PWM channel.
+
+\param [in] descriptor - PWM channel descriptor.
+
+\return operation status
+******************************************************************************/
+int HAL_SetPwmCompareValue(HAL_PwmDescriptor_t *descriptor, uint16_t cmpValue)
+{
+ /* Invalid PWM channel specified */
+ if (PWM_INVALID_CHANNEL <= descriptor->channel)
+ return PWM_INVALID_CHANNEL_STATUS;
+ /* Check PWM unit */
+ if ((PWM_UNIT_1 == descriptor->unit) || (PWM_UNIT_3 == descriptor->unit))
+ halSetPwmCompareValue(descriptor, cmpValue);
+ else
+ return PWM_INVALID_UNIT_STATUS;
+
+ return PWM_SUCCESS_STATUS;
+}
+
+/**************************************************************************//**
+\brief Closes the PWM.
+
+\param [in] pwmUnit - PWM unit number.
+ Equal to ID of Timer/Counter witch serves PWM module.
+
+\return operation status
+******************************************************************************/
+int HAL_ClosePwm(HAL_PwmUnit_t pwmUnit)
+{
+ /* Check PWM unit */
+ if ((PWM_UNIT_1 == pwmUnit) || (PWM_UNIT_3 == pwmUnit))
+ halClosePwm(pwmUnit);
+ else
+ return PWM_INVALID_UNIT_STATUS;
+
+ return PWM_SUCCESS_STATUS;
+}
+
+// eof pwm.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/resetReason.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/resetReason.c
new file mode 100644
index 00000000..0fecaa11
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/resetReason.c
@@ -0,0 +1,59 @@
+/**************************************************************************//**
+ \file halWdtInit.c
+
+ \brief Implementation of the reset reason interface.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <resetReason.h>
+#include <types.h>
+#include <wdtCtrl.h>
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+extern uint8_t halResetReason; // contains the reset reason
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+Returns the reset reason.
+Parameters:
+ none.
+Returns:
+ The reason of reset.
+******************************************************************************/
+HAL_ResetReason_t HAL_ReadResetReason(void)
+{
+ return (HAL_ResetReason_t)halResetReason;
+}
+
+/******************************************************************************
+Software reset.
+******************************************************************************/
+void HAL_WarmReset(void)
+{
+
+ halResetReason = TEMP_WARM_RESET;
+ wdt_enable(0);
+ while(1);
+}
+//eof resetReason.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/sleep.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/sleep.c
new file mode 100644
index 00000000..1ad72df2
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/sleep.c
@@ -0,0 +1,79 @@
+/**************************************************************************//**
+ \file sleep.c
+
+ \brief The implementation of common sleep and wake up.
+
+ \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:
+ 1/12/09 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halSleep.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define HAL_NULL_POINTER -1
+#define HAL_SLEEP_TIMER_HAS_ALREADY_STARTED -3
+#define HAL_SLEEP_TIMER_IS_BUSY -2
+#define HAL_SLEEP_SYSTEM_HAS_ALREADY_STARTED -3
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+HalSleepControl_t halSleepControl =
+{
+ .wakeupStation = HAL_ACTIVE_MODE,
+ .sleepTimerState = HAL_SLEEP_TIMER_IS_STOPPED
+};
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Starts sleep timer and HAL sleep. When system is wake up send callback
+\param[in]
+ sleepParam - pointer to sleep structure.
+\return
+ -1 - bad pointer, \n
+ -2 - sleep timer is busy, \n
+ -3 - sleep system has been started.
+ 0 - success.
+******************************************************************************/
+int HAL_StartSystemSleep(HAL_Sleep_t *sleepParam)
+{
+ HAL_SleepTimer_t sleepTimer;
+ int sleepTimerStatus;
+
+ if (!sleepParam)
+ return HAL_NULL_POINTER;
+
+ halSleepControl.callback = sleepParam->callback;
+ sleepTimer.interval = sleepParam->sleepTime;
+ sleepTimer.mode = TIMER_ONE_SHOT_MODE;
+ sleepTimer.callback = NULL;
+
+ sleepTimerStatus = HAL_StartSleepTimer(&sleepTimer);
+ if ((HAL_NULL_POINTER == sleepTimerStatus) || (HAL_SLEEP_TIMER_HAS_ALREADY_STARTED == sleepTimerStatus))
+ return HAL_SLEEP_TIMER_IS_BUSY;
+
+ if (-1 == HAL_Sleep())
+ return HAL_SLEEP_SYSTEM_HAS_ALREADY_STARTED;
+
+ return 0;
+}
+
+//eof sleep.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/sleepTimer.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/sleepTimer.c
new file mode 100644
index 00000000..f83d2446
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/sleepTimer.c
@@ -0,0 +1,126 @@
+/**************************************************************************//**
+ \file sleepTimer.c
+
+ \brief The implementation of the sleep timer.
+
+ \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:
+ 29/05/07 E. Ivanov - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <sleepTimer.h>
+#include <halSleepTimerClock.h>
+#include <halSleep.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define HAL_NULL_POINTER -1
+#define HAL_TIME_CAN_NOT_BE_COUNTED -2
+#define HAL_SLEEP_TIMER_HAS_ALREADY_STARTED -3
+#define HAL_SLEEP_TIMER_HAS_ALREADY_STOPPED -1
+
+/******************************************************************************
+ External global variables section
+******************************************************************************/
+extern HalSleepControl_t halSleepControl;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+Starts sleep timer. Interval must be greater one tick time.
+ Parameters:
+ sleepTimer - address of the HAL_SleepTimer_t.
+ Returns:
+ -1 - NULL pointer, \n
+ -2 - interval can not be counted out, \n
+ -3 - sleep timer has already started. \n
+ 0 - otherwise.
+******************************************************************************/
+int HAL_StartSleepTimer(HAL_SleepTimer_t *sleepTimer)
+{
+ uint32_t tempValue;
+
+ if (!sleepTimer)
+ return HAL_NULL_POINTER;
+
+ // Convert millisecond interval to the sleep timer ticks.
+ tempValue = (halSleepTimerFrequency() * sleepTimer->interval) / 1000ul;
+ if (!tempValue)
+ return HAL_TIME_CAN_NOT_BE_COUNTED;// Can't count out interval
+
+ if (HAL_SLEEP_TIMER_IS_STARTED == halSleepControl.sleepTimerState) // there is active timer
+ return HAL_SLEEP_TIMER_HAS_ALREADY_STARTED;
+
+ halSleepControl.sleepTimerState = HAL_SLEEP_TIMER_IS_STARTED;
+ halSleepControl.sleepTimer = *sleepTimer;
+ // Start asynchronous timer2.
+ halSetSleepTimerInterval(tempValue);
+ return 0;
+}// end sleepTimer_start
+
+/******************************************************************************
+Removes timer.
+Parameters:
+ sleepTimer - is not used now. For capabilities for old version.
+Returns:
+ -1 - there is no active sleep timer.
+ 0 - otherwise.
+******************************************************************************/
+int HAL_StopSleepTimer(HAL_SleepTimer_t *sleepTimer)
+{
+ (void)sleepTimer;
+
+ // there is no active timer
+ if (HAL_SLEEP_TIMER_IS_STOPPED == halSleepControl.sleepTimerState)
+ return HAL_SLEEP_TIMER_HAS_ALREADY_STOPPED;
+ halClearTimeControl();
+ halSleepControl.sleepTimerState = HAL_SLEEP_TIMER_IS_STOPPED;
+
+ return 0;
+}
+
+/******************************************************************************
+Interrupt handler about sleep interval was completed.
+******************************************************************************/
+void halAsyncTimerHandler(void)
+{
+ // there isn't work timer
+ if (HAL_SLEEP_TIMER_IS_STOPPED == halSleepControl.sleepTimerState)
+ return;
+
+ if (TIMER_REPEAT_MODE == halSleepControl.sleepTimer.mode)
+ {
+ if (halSleepControl.sleepTimer.callback)
+ halSleepControl.sleepTimer.callback();
+
+ // user can stop timer in callback
+ if (HAL_SLEEP_TIMER_IS_STOPPED == halSleepControl.sleepTimerState)
+ return;
+
+ halSetSleepTimerInterval(halSleepControl.sleepTimer.interval);
+ }
+ else
+ {
+ halSleepControl.sleepTimerState = HAL_SLEEP_TIMER_IS_STOPPED;
+ if (halSleepControl.sleepTimer.callback)
+ halSleepControl.sleepTimer.callback();
+ }
+}
+
+//eof sleepTimer.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/spi.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/spi.c
new file mode 100644
index 00000000..cd4c55b0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/spi.c
@@ -0,0 +1,602 @@
+/**************************************************************************//**
+ \file spi.c
+
+ \brief Implementation of USART SPI mode, hardware-independent module.
+
+ \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:
+ 29/05/08 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <spi.h>
+
+/******************************************************************************
+ Global functions prototypes section
+******************************************************************************/
+void halSetUsartSpiConfig(HAL_SpiDescriptor_t *descriptor);
+void halSetSlaveSpiConfig(HAL_SpiDescriptor_t *descriptor);
+
+/******************************************************************************
+ External global variables section
+******************************************************************************/
+extern HAL_UsartDescriptor_t *halPointDescrip[NUM_USART_CHANNELS];
+#if defined(ATMEGA128RFA1)
+ extern HAL_SpiDescriptor_t *halRealSpiDescripPointer;
+ extern volatile uint8_t rxSlaveBuffer[HAL_SPI_RX_BUFFER_LENGTH];
+#endif
+
+/******************************************************************************
+ Static functions prototypes section
+******************************************************************************/
+static bool isClosedPd(void *pointer);
+static bool isOpenedPd(void *pointer);
+static int halCheckUsartDescriptor(HAL_SpiDescriptor_t *descriptor, bool(* predicate)(void *));
+static int halOpenUsartSpi(HAL_SpiDescriptor_t *descriptor);
+static int halCloseUsartSpi(HAL_SpiDescriptor_t *descriptor);
+static int halFillServiceInfo(HAL_SpiDescriptor_t *descriptor, uint8_t *buffer, uint16_t length, uint8_t transac);
+static int halWriteUsartSpi(HAL_SpiDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);
+static int halReadUsartSpi(HAL_SpiDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);
+#if defined(ATMEGA128RFA1)
+static int halCheckSpiDescriptor(HAL_SpiDescriptor_t *descriptor, bool(* predicate)(void *));
+static int halOpenRealSpi(HAL_SpiDescriptor_t *descriptor);
+static int halCloseRealSpi(HAL_SpiDescriptor_t *descriptor);
+static int halWriteRealSpi(HAL_SpiDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);
+static int halReadRealSpi(HAL_SpiDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);
+#endif
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Predicate for check of closed station.
+\param[in]
+ pointer - pointer to some descriptor.
+\return
+ true - interface is closed;
+ false - interface is not closed.
+******************************************************************************/
+static bool isClosedPd(void *pointer)
+{
+ return pointer ? false : true;
+}
+
+/**************************************************************************//**
+\brief Predicate for check of opened station.
+\param[in]
+ pointer - pointer to some descriptor.
+\return
+ true - interface is opened;
+ false - interface is not opened.
+******************************************************************************/
+static bool isOpenedPd(void *pointer)
+{
+ return pointer ? true : false;
+}
+
+/**************************************************************************//**
+\brief Check correctenss of the usart spi descriptor.
+\param[in]
+ descriptor - pointer to the usart spi descriptor.
+\param[in]
+ predicate - check station predicate.
+\return
+ interface index - interface is opened;
+ -1 - interface is not opened.
+******************************************************************************/
+static int halCheckUsartDescriptor(HAL_SpiDescriptor_t *descriptor, bool(* predicate)(void *))
+{
+ int i;
+
+ if (NULL == descriptor)
+ return -1;
+
+ if (false == halIsUsartChannelCorrect(descriptor->tty))
+ return -1;
+
+ i = HAL_GET_INDEX_BY_CHANNEL(descriptor->tty);
+ if (false == predicate((void *)halPointDescrip[i]))
+ return -1;
+
+ return i;
+}
+
+#if defined(ATMEGA128RFA1)
+/**************************************************************************//**
+\brief Check correctenss of the real spi descriptor.
+\param[in]
+ descriptor - pointer to the real spi descriptor.
+\param[in]
+ predicate - check station predicate.
+\return
+ 0 - interface is opened;
+ -1 - interface is not opened.
+******************************************************************************/
+static int halCheckSpiDescriptor(HAL_SpiDescriptor_t *descriptor, bool(* predicate)(void *))
+{
+ if (NULL == descriptor)
+ return -1;
+
+ if (SPI_CHANNEL_2 != descriptor->tty)
+ return -1;
+
+ if (false == predicate((void *)halRealSpiDescripPointer))
+ return -1;
+
+ return 0;
+}
+#endif
+
+/**************************************************************************//**
+\brief Configure usart in mspi mode.
+\param[in]
+ descriptor - pointer to the usart spi descriptor.
+\return
+ -1 - there not are free resources.
+ 0 - SPI channel is ready.
+******************************************************************************/
+static int halOpenUsartSpi(HAL_SpiDescriptor_t *descriptor)
+{
+ int i; // Descriptor index
+
+ i = halCheckUsartDescriptor(descriptor, isClosedPd);
+ if (-1 == i)
+ return -1;
+
+ if (NULL != descriptor->callback)
+ {
+ descriptor->spiDescriptor.txCallback = descriptor->callback;
+ descriptor->spiDescriptor.tty = descriptor->tty;
+ }
+
+ halPointDescrip[i] = &descriptor->spiDescriptor;
+ halSetUsartSpiConfig(descriptor);
+ return 0;
+}
+
+#if defined(ATMEGA128RFA1)
+/**************************************************************************//**
+\brief Configure spi.
+\param[in]
+ descriptor - pointer to the spi descriptor.
+\return
+ -1 - there are no free resources.
+ 0 - SPI channel is ready.
+******************************************************************************/
+static int halOpenRealSpi(HAL_SpiDescriptor_t *descriptor)
+{
+ if (-1 == halCheckSpiDescriptor(descriptor, isClosedPd))
+ return -1;
+
+ halRealSpiDescripPointer = descriptor;
+ halRealSpiDescripPointer->spiDescriptor.service.txPointOfRead = 0;
+ halRealSpiDescripPointer->spiDescriptor.service.txPointOfWrite = 0;
+ halRealSpiDescripPointer->spiDescriptor.service.rxPointOfRead = 0;
+ halRealSpiDescripPointer->spiDescriptor.service.rxPointOfWrite = 0;
+ halSetSlaveSpiConfig(descriptor);
+ return 0;
+}
+#endif
+
+/**************************************************************************//**
+\brief Open the SPI interface.
+\param[in]
+ descriptor - pointer to the spi descriptor.
+\return
+ -1 - there not are free resources.
+ 0 - SPI channel is ready.
+******************************************************************************/
+int HAL_OpenSpi(HAL_SpiDescriptor_t *descriptor)
+{
+#if defined(ATMEGA128RFA1)
+ if (SPI_CHANNEL_2 == descriptor->tty)
+ return halOpenRealSpi(descriptor);
+ else
+#endif
+ return halOpenUsartSpi(descriptor);
+}
+
+/**************************************************************************//**
+\brief Clear the usart channel and pins.
+\param[in]
+ descriptor - pointer to the spi descriptor.
+\return
+ 0 - success
+ -1 - channel was not opened.
+******************************************************************************/
+static int halCloseUsartSpi(HAL_SpiDescriptor_t *descriptor)
+{
+ int i;
+
+ i = halCheckUsartDescriptor(descriptor, isOpenedPd);
+ if (-1 == i)
+ return -1;
+
+ halPointDescrip[i] = NULL;
+ halClearUsartSpi(descriptor->tty);
+ return 0;
+}
+
+#if defined(ATMEGA128RFA1)
+/**************************************************************************//**
+\brief Clear the spi channel and pins.
+\param[in]
+ descriptor - pointer to the spi descriptor.
+\return
+ Returns 0 on success or -1 if channel was not opened.
+******************************************************************************/
+static int halCloseRealSpi(HAL_SpiDescriptor_t *descriptor)
+{
+ if (-1 == halCheckSpiDescriptor(descriptor, isClosedPd))
+ return -1;
+
+ halRealSpiDescripPointer = NULL;
+ halClearRealSpi();
+ return 0;
+}
+#endif
+
+/**************************************************************************//**
+\brief Close the SPI channel and pins.
+\param[in]
+ descriptor - pointer to the spi descriptor.
+\return
+ Returns 0 on success or -1 if channel was not opened.
+******************************************************************************/
+int HAL_CloseSpi(HAL_SpiDescriptor_t *descriptor)
+{
+#if defined(ATMEGA128RFA1)
+ if (SPI_CHANNEL_2 == descriptor->tty)
+ return halCloseRealSpi(descriptor);
+ else
+#endif
+ return halCloseUsartSpi(descriptor);
+}
+
+/**************************************************************************//**
+\brief Fill service structure for bus transaction.
+\param[in]
+ descriptor - pointer to the spi descriptor.
+\param[in]
+ buffer -pointer to data buffer.
+\param[in]
+ length - length of the data buffer.
+\param[in]
+ transac - bus transaction type.
+\return
+ -1 - interface is busy;
+ 0 - success.
+******************************************************************************/
+static int halFillServiceInfo(HAL_SpiDescriptor_t *descriptor, uint8_t *buffer, uint16_t length, uint8_t transac)
+{
+ HalUsartService_t *halBufferControl;
+
+ halBufferControl = &descriptor->spiDescriptor.service;
+ if (halBufferControl->txPointOfWrite != halBufferControl->txPointOfRead)
+ return -1; // there is unsent data
+
+ descriptor->spiDescriptor.txBuffer = buffer;
+ descriptor->spiDescriptor.txBufferLength = 0;
+ halBufferControl->txPointOfWrite = length;
+ halBufferControl->txPointOfRead = 0;
+ descriptor->spiDescriptor.rxBuffer = buffer;
+ descriptor->spiDescriptor.flowControl = transac;
+ return 0;
+}
+
+/**************************************************************************//**
+\brief Writes a length bytes to the usart. \n
+ Callback function will be used to notify about the finishing transmitting.
+\param[in]
+ descriptor - pointer to spi descriptor
+\param[in]
+ buffer - pointer to application data buffer;
+\param[in]
+ length - number bytes for transfer;
+\return
+ -1 - spi module was not opened, there is unsent data, pointer to the data or
+ the length are zero; \n
+ 0 - on success or a number; \n
+ Number of written bytes if the synchronous method is used(callback is NULL).
+******************************************************************************/
+static int halWriteUsartSpi(HAL_SpiDescriptor_t *descriptor, uint8_t *buffer, uint16_t length)
+{
+ int i;
+
+ if (!buffer || !length)
+ return -1;
+
+ i = halCheckUsartDescriptor(descriptor, isOpenedPd);
+ if (-1 == i)
+ return -1;
+
+ if (&descriptor->spiDescriptor != halPointDescrip[i])
+ return -1; // incorrect descriptor
+
+ if (NULL != descriptor->callback)
+ {
+ if (-1 == halFillServiceInfo(descriptor, buffer, length, USART_SPI_WRITE_MODE))
+ return -1;
+
+ halEnableUsartSpiRxcInterrupt(descriptor->tty);
+ halEnableUsartSpiDremInterrupt(descriptor->tty);
+ return 0;
+ }
+ else
+ {
+ return halSyncUsartSpiWriteData(descriptor->tty, buffer, length);
+ }
+}
+
+#if defined(ATMEGA128RFA1)
+/**************************************************************************//**
+\brief Writes a length bytes to the spi. \n
+\param[in]
+ descriptor - pointer to spi descriptor
+\param[in]
+ buffer - pointer to application data buffer;
+\param[in]
+ length - number bytes for transfer;
+\return
+ -1 - spi module was not opened, there is unsent data, pointer to the data or
+ the length are zero; \n
+ 0 - on success or a number; \n
+******************************************************************************/
+static int halWriteRealSpi(HAL_SpiDescriptor_t *descriptor, uint8_t *buffer, uint16_t length)
+{
+ if (!buffer || !length)
+ return -1;
+
+ if (-1 == halCheckSpiDescriptor(descriptor, isOpenedPd))
+ return -1;
+
+ if (descriptor != halRealSpiDescripPointer)
+ return -1; // incorrect descriptor
+
+ if (-1 == halFillServiceInfo(descriptor, buffer, length, USART_SPI_WRITE_MODE))
+ return -1;
+
+ halSendSpiByte(*buffer);
+ return 0;
+}
+#endif
+
+#if defined(ATMEGA128RFA1)
+/**************************************************************************//**
+\brief Put next byte to the spi.
+******************************************************************************/
+void halSpiTxByteComplete(void)
+{
+ HalUsartService_t *halBufferControl;
+
+ halBufferControl = &halRealSpiDescripPointer->spiDescriptor.service;
+
+ if (halBufferControl->txPointOfWrite != halBufferControl->txPointOfRead)
+ halSendSpiByte(halRealSpiDescripPointer->spiDescriptor.txBuffer[++halBufferControl->txPointOfRead]);
+}
+#endif
+
+/**************************************************************************//**
+\brief Writes a length bytes to the SPI. \n
+ Callback function will be used to notify about the finishing transmitting.
+ (only for master spi)
+\param[in]
+ descriptor - pointer to spi descriptor
+\param[in]
+ buffer - pointer to application data buffer;
+\param[in]
+ length - number bytes for transfer;
+\return
+ -1 - spi module was not opened, there is unsent data, pointer to the data or
+ the length are zero; \n
+ 0 - on success or a number; \n
+ Number of written bytes if the synchronous method is used(callback is NULL), \n
+ only for master spi.
+******************************************************************************/
+int HAL_WriteSpi(HAL_SpiDescriptor_t *descriptor, uint8_t *buffer, uint16_t length)
+{
+#if defined(ATMEGA128RFA1)
+ if (SPI_CHANNEL_2 == descriptor->tty)
+ return halWriteRealSpi(descriptor, buffer, length);
+ else
+#endif
+ return halWriteUsartSpi(descriptor, buffer, length);
+}
+
+/**************************************************************************//**
+\brief Reads a number of bytes from the usart.\n
+ Callback function will be used to notify when the activity is finished.\n
+ The read data is placed to the buffer.
+\param[in]
+ descriptor - pointer to HAL_SpiDescriptor_t structure
+\param[in]
+ buffer - pointer to the application data buffer
+\param[in]
+ length - number of bytes to transfer
+\return
+ -1 - spi module was not opened, or there is unsent data, or the pointer to
+ data or the length are NULL; \n
+ 0 - success; \n
+ Number of written bytes if the synchronous method is used(callback is NULL).
+******************************************************************************/
+static int halReadUsartSpi(HAL_SpiDescriptor_t *descriptor, uint8_t *buffer, uint16_t length)
+{
+ HAL_UsartDescriptor_t *spiDescrip;
+ int i;
+
+ if (!buffer || !length)
+ return -1;
+
+ i = halCheckUsartDescriptor(descriptor, isOpenedPd);
+ if (-1 == i)
+ return -1;
+
+ spiDescrip = &descriptor->spiDescriptor;
+ if (spiDescrip != halPointDescrip[i])
+ return -1; // incorrect descriptor
+
+ if (NULL != descriptor->callback)
+ {
+ if (-1 == halFillServiceInfo(descriptor, buffer, length, USART_SPI_READ_MODE))
+ return -1;
+
+ halEnableUsartSpiRxcInterrupt(descriptor->tty);
+ halEnableUsartSpiDremInterrupt(descriptor->tty);
+ return 0;
+ }
+ else
+ {
+ return halSyncUsartSpiReadData(descriptor->tty, buffer, length);
+ }
+}
+
+#if defined(ATMEGA128RFA1)
+/**************************************************************************//**
+\brief Reads a number of bytes from spi internal buffer and places them to the buffer.
+\param[in]
+ descriptor - pointer to HAL_SpiDescriptor_t structure
+\param[in]
+ buffer - pointer to the application data buffer
+\param[in]
+ length - number of bytes to transfer
+\return
+ -1 - spi module was not opened, or there is unsent data, or the pointer to
+ data or the length are NULL; \n
+ Number of read bytes from spi internal buffer.
+******************************************************************************/
+static int halReadRealSpi(HAL_SpiDescriptor_t *descriptor, uint8_t *buffer, uint16_t length)
+{
+ uint16_t wasRead = 0;
+ uint16_t poW;
+ uint16_t poR;
+ HalUsartService_t *halBufferControl;
+
+ if (!buffer || !length)
+ return -1;
+
+ if (-1 == halCheckSpiDescriptor(descriptor, isOpenedPd))
+ return -1;
+
+ if (descriptor != halRealSpiDescripPointer)
+ return -1; // incorrect descriptor
+
+ halBufferControl = &halRealSpiDescripPointer->spiDescriptor.service;
+ ATOMIC_SECTION_ENTER
+ poW = halBufferControl->rxPointOfWrite;
+ poR = halBufferControl->rxPointOfRead;
+ ATOMIC_SECTION_LEAVE
+
+ while ((poR != poW) && (wasRead < length))
+ {
+ buffer[wasRead] = rxSlaveBuffer[poR];
+ if (HAL_SPI_RX_BUFFER_LENGTH == ++poR)
+ poR = 0;
+ wasRead++;
+ }
+
+ ATOMIC_SECTION_ENTER
+ halBufferControl->rxPointOfRead = poR;
+ halBufferControl->rxBytesInBuffer -= wasRead;
+ ATOMIC_SECTION_LEAVE
+
+ return wasRead;
+}
+#endif
+
+/**************************************************************************//**
+\brief For master : writes a number of bytes to the spi.\n
+ Callback function will be used to notify when the activity is finished.\n
+ The read data is placed to the buffer. \n
+ For slave: reads a number of bytes from internal spi buffer and writes them \n
+ to application buffer.
+\param[in]
+ descriptor - pointer to HAL_SpiDescriptor_t structure
+\param[in]
+ buffer - pointer to the application data buffer
+\param[in]
+ length - number of bytes to transfer
+\return
+ -1 - spi module was not opened, or there is unsent data, or the pointer to
+ data or the length are NULL; \n
+ 0 - success for master; \n
+ Number of written bytes if the synchronous method is used(callback is NULL) for master \n
+ or number of read bytes from internal buffer to the application buffer for slave.
+******************************************************************************/
+int HAL_ReadSpi(HAL_SpiDescriptor_t *descriptor, uint8_t *buffer, uint16_t length)
+{
+#if defined(ATMEGA128RFA1)
+ if (SPI_CHANNEL_2 == descriptor->tty)
+ return halReadRealSpi(descriptor, buffer, length);
+ else
+#endif
+ return halReadUsartSpi(descriptor, buffer, length);
+}
+
+#if defined(ATMEGA128RFA1)
+/**************************************************************************//**
+\brief Puts the received byte to the cyclic buffer.
+
+\param[in]
+ data - data to put.
+******************************************************************************/
+void halSpiRxBufferFiller(uint8_t data)
+{
+ uint16_t old;
+ HalUsartService_t *halBufferControl;
+
+ if (NULL == halRealSpiDescripPointer)
+ {// abnormal
+ halClearRealSpi();
+ return;
+ }
+
+ halBufferControl = &halRealSpiDescripPointer->spiDescriptor.service;
+ old = halBufferControl->rxPointOfWrite;
+
+ if (HAL_SPI_RX_BUFFER_LENGTH == ++halBufferControl->rxPointOfWrite)
+ halBufferControl->rxPointOfWrite = 0;
+
+ if (halBufferControl->rxPointOfWrite == halBufferControl->rxPointOfRead)
+ { // Buffer full.
+ halBufferControl->rxPointOfWrite = old;
+ return;
+ } // Buffer full.
+
+ rxSlaveBuffer[old] = data;
+ halBufferControl->rxBytesInBuffer++;
+}
+#endif
+
+#if defined(ATMEGA128RFA1)
+/**************************************************************************//**
+\brief Slave spi reception complete interrupt handler.
+******************************************************************************/
+void halSpiRxByteComplete(void)
+{
+ uint16_t number;
+
+ ATOMIC_SECTION_ENTER
+ number = halRealSpiDescripPointer->spiDescriptor.service.rxBytesInBuffer;
+ ATOMIC_SECTION_LEAVE
+
+ if (number)
+ if (NULL != halRealSpiDescripPointer->slave_callback)
+ halRealSpiDescripPointer->slave_callback(number);
+}
+#endif
+
+// eof spi.c
+
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/timer.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/timer.c
new file mode 100644
index 00000000..ca36cca9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/timer.c
@@ -0,0 +1,114 @@
+/**************************************************************************//**
+ \file timer.c
+
+ \brief Functions to manipulate by timers list.
+
+ \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:
+ 7/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <bcTimer.h>
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+Adds timer to the timer's list.
+Parameters:
+ head - address of pointer to head of the timers list.
+ timer - address of timer that must be added to the list.
+ sysTime - current time.
+Returns:
+ none.
+******************************************************************************/
+void halAddTimer(Timer_t **head, Timer_t *new, uint32_t sysTime)
+{
+ if (!*head)
+ {
+ *head = new;
+ return;
+ }
+
+ Timer_t *it, *prev = NULL;
+ for (it = *head; it; it = it->service.next)
+ {
+ uint32_t remain = it->service.sysTimeLabel + it->interval - sysTime;
+ if ((remain < INT32_MAX) && (remain >= new->interval))
+ break;
+ prev = it;
+ }
+ if (it == *head)
+ {
+ new->service.next = *head;
+ *head = new;
+ }
+ else
+ {
+ prev->service.next = new;
+ new->service.next = it;
+ }
+}
+
+/******************************************************************************
+Removes timer from the timers list.
+Parameters:
+ head - address of pointer to head of the timers list.
+ prev - address of the timer before the timer that must be removed from the list.
+ p - address of timer that must be removed from the list.
+Returns:
+ pointer to next cell or pointer to head if deleting is head
+******************************************************************************/
+Timer_t* halRemoveTimer(Timer_t **head, Timer_t *prev, Timer_t *p)
+{
+ Timer_t *t;
+
+ if (p == *head)
+ {// removing first element of list
+ t = p->service.next;
+ p->service.next = 0;
+ *head = t;
+ return *head;
+ }
+ else
+ {
+ prev->service.next = p->service.next;
+ p->service.next = 0;
+ return prev->service.next;
+ }
+}
+
+/******************************************************************************
+The search of the timer in the timers list before one.
+Parameters:
+ head - address of pointer to head of the timers list.
+Returns:
+ pointer to saerching timer
+******************************************************************************/
+Timer_t *halFindPrevTimer(Timer_t **head, Timer_t *p)
+{
+ Timer_t *t = *head;
+
+ for (; t ;)
+ {
+ if (t->service.next == p)
+ return t;
+ t = t->service.next;
+ }
+ return NULL;
+}
+//eof timer.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/usart.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/usart.c
new file mode 100644
index 00000000..53a63927
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/usart.c
@@ -0,0 +1,1061 @@
+/**************************************************************************//**
+\file usart.c
+
+\brief USART implementation. Asynchronous mode.
+
+\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:
+ 29/05/07 E. Ivanov - Created
+ 18/02/09 A. Luzhetsky - Corretced.
+*******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halDbg.h>
+#include <usart.h>
+#include <appTimer.h>
+#include <halDiagnostic.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define HANDLERS_GET(A, I) memcpy_P(A, &halUsartHandlers[I], sizeof(HalUsartTask_t))
+/** \brief Amount of reserved bytes in received buffer. Some clients (PC Windows for example)
+ send few more bytes after CTS setting, so we need to reserve some space for them.
+ Reserved space = Buffer Size / 2^BUFFER_RESERV. */
+#define BUFFER_RESERV 1
+#define USART_HW_CONTROLLER_TIMER_PERIOD 10
+#if defined(_USE_USART_ERROR_EVENT_)
+ #define HAL_BM_FRAME_ERROR (1 << 4)
+ #define HAL_BM_DATA_OVERRUN (1 << 3)
+ #define HAL_BM_PARITY_ERROR (1 << 2)
+#endif
+#if NUM_USART_CHANNELS == 0
+ #error 'USART channels is not alowed.'
+#endif
+
+/******************************************************************************
+ Types definition section
+******************************************************************************/
+/**************************************************************************//**
+ \brief HAL USART tasks bit mask.
+******************************************************************************/
+typedef volatile uint8_t HalUsartTaskBitMask_t;
+
+/**************************************************************************//**
+ \brief HAL USART task type declaration.
+******************************************************************************/
+typedef void (* HalUsartTask_t)(void);
+
+/******************************************************************************
+ Global functions prototypes section
+******************************************************************************/
+void halSigUsartHandler(void);
+void halSetUsartConfig(HAL_UsartDescriptor_t *usartmode);
+void halPostUsartTask(HalUsartTaskId_t taskId);
+#ifdef HW_CONTROL_PINS_PORT_ASSIGNMENT
+ void hwControlPinsPollCallback(void);
+#endif // HW_CONTROL_PINS_PORT_ASSIGNMENT
+
+/******************************************************************************
+ Static function prototypes section
+******************************************************************************/
+#if defined(HAL_USE_USART_CHANNEL_0)
+ static void halUsartTaskUsart0Dre(void);
+ static void halUsartTaskUsart0Txc(void);
+ static void halUsartTaskUsart0Rxc(void);
+ #if defined(_USE_USART_ERROR_EVENT_)
+ static void halUsartTaskUsart0Err(void);
+ #endif
+#endif
+
+#if defined(HAL_USE_USART_CHANNEL_1)
+ static void halUsartTaskUsart1Dre(void);
+ static void halUsartTaskUsart1Txc(void);
+ static void halUsartTaskUsart1Rxc(void);
+ #if defined(_USE_USART_ERROR_EVENT_)
+ static void halUsartTaskUsart1Err(void);
+ #endif
+#endif
+
+static void halUsartHwController(UsartChannel_t tty);
+static void halSigUsartReceptionComplete(UsartChannel_t tty);
+static void halSetUsartClockPinDirection(HAL_UsartDescriptor_t *descriptor);
+
+/******************************************************************************
+ Static variables section
+******************************************************************************/
+#ifdef HW_CONTROL_PINS_PORT_ASSIGNMENT
+ static HAL_AppTimer_t halUsartAppTimer;
+#endif // HW_CONTROL_PINS_PORT_ASSIGNMENT
+HAL_UsartDescriptor_t *halPointDescrip[NUM_USART_CHANNELS] =
+{
+ #if defined(HAL_USE_USART_CHANNEL_0)
+ NULL,
+ #endif
+ #if defined(HAL_USE_USART_CHANNEL_1)
+ NULL
+ #endif
+};
+static volatile HalUsartTaskBitMask_t halUsartTaskBitMask = 0; // HAL USART tasks' bit mask.
+static const HalUsartTask_t PROGMEM_DECLARE(halUsartHandlers[HAL_USART_TASKS_NUMBER]) =
+{
+ #if defined(HAL_USE_USART_CHANNEL_0)
+ halUsartTaskUsart0Dre,
+ halUsartTaskUsart0Txc,
+ halUsartTaskUsart0Rxc,
+ #if defined(_USE_USART_ERROR_EVENT_)
+ halUsartTaskUsart0Err,
+ #endif
+ #endif
+
+ #if defined(HAL_USE_USART_CHANNEL_1)
+ halUsartTaskUsart1Dre,
+ halUsartTaskUsart1Txc,
+ halUsartTaskUsart1Rxc,
+ #if defined(_USE_USART_ERROR_EVENT_)
+ halUsartTaskUsart1Err,
+ #endif
+ #endif
+}; // List Of possible HAL USART tasks.
+
+/******************************************************************************
+ DTR service
+******************************************************************************/
+volatile bool halEnableDtrWakeUp = false;
+void (* dtrWakeUpCallback)(void) = NULL;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief HAL USART task. Exact action depends on USART internal task.
+******************************************************************************/
+void halSigUsartHandler(void)
+{
+ HalUsartTask_t handler;
+ HalUsartTaskBitMask_t mask = 1;
+ HalUsartTaskId_t index = 0;
+
+ for ( ; index < HAL_USART_TASKS_NUMBER; index++, mask <<= 1)
+ {
+ if (halUsartTaskBitMask & mask)
+ {
+ ATOMIC_SECTION_ENTER
+ halUsartTaskBitMask ^= mask;
+ ATOMIC_SECTION_LEAVE
+ HANDLERS_GET(&handler, index);
+ handler();
+ }
+ }
+}
+
+/**************************************************************************//**
+\brief Posts specific USART task.
+
+\param[in]
+ taskId - unique identifier of the task to be posted.
+******************************************************************************/
+void halPostUsartTask(HalUsartTaskId_t taskId)
+{
+ halUsartTaskBitMask |= (HalUsartTaskBitMask_t)1 << taskId;
+ halPostTask2(HAL_TASK_USART);
+}
+
+/**************************************************************************//**
+\brief Puts the byte received to the cyclic buffer.
+
+\param[in]
+ tty - channel number.
+\param[in]
+ data - data to put.
+******************************************************************************/
+void halUsartRxBufferFiller(UsartChannel_t tty, uint8_t data)
+{
+ uint16_t old;
+ uint8_t i;
+ HalUsartService_t *halUsartControl;
+
+ i = HAL_GET_INDEX_BY_CHANNEL(tty);
+ if (NULL == halPointDescrip[i])
+ {// abnormal
+ halDisableUsartRxcInterrupt(tty); // disable usart
+ return;
+ }
+
+ if (halPointDescrip[i]->flowControl & USART_SPI_WRITE_MODE)
+ return;
+
+ if (halPointDescrip[i]->flowControl & USART_SPI_READ_MODE)
+ { // For spi mode.
+ *(uint8_t*)(halPointDescrip[i]->rxBuffer) = data;
+ halPointDescrip[i]->rxBuffer++;
+ return;
+ } // For spi mode.
+
+ halUsartControl = &halPointDescrip[i]->service;
+ if (NULL != halPointDescrip[i]->rxBuffer)
+ {
+ old = halUsartControl->rxPointOfWrite;
+
+ if (++halUsartControl->rxPointOfWrite == halPointDescrip[i]->rxBufferLength)
+ halUsartControl->rxPointOfWrite = 0;
+
+ if (halUsartControl->rxPointOfWrite == halUsartControl->rxPointOfRead)
+ { // Buffer full.
+ halUsartControl->rxPointOfWrite = old;
+ return;
+ } // Buffer full.
+
+ halPointDescrip[i]->rxBuffer[old] = data;
+ halUsartControl->rxBytesInBuffer++;
+
+#ifdef HW_CONTROL_PINS_PORT_ASSIGNMENT
+ if ((halPointDescrip[i]->flowControl & USART_FLOW_CONTROL_HARDWARE) && (HW_CONTROL_PINS_PORT_ASSIGNMENT == halPointDescrip[i]->tty))
+ {
+ if (halUsartControl->rxBytesInBuffer > (halPointDescrip[i]->rxBufferLength >> BUFFER_RESERV))
+ GPIO_USART_CTS_set();// CTS_ON
+ }
+#endif // HW_CONTROL_PINS_PORT_ASSIGNMENT
+ }
+}
+
+#if defined(_USE_USART_ERROR_EVENT_)
+/**************************************************************************//**
+\brief Save status register for analyzing of the error reason.
+
+\param[in]
+ tty - channel number.
+\param[in]
+ status - usart status register.
+******************************************************************************/
+void halUsartSaveErrorReason(UsartChannel_t tty, uint8_t status)
+{
+ HalUsartService_t *halUsartControl;
+ uint8_t i;
+
+ i = HAL_GET_INDEX_BY_CHANNEL(tty);
+ if (NULL == halPointDescrip[i])
+ {// abnormal
+ halDisableUsartRxcInterrupt(tty); // disable usart
+ return;
+ }
+
+ halUsartControl = &halPointDescrip[i]->service;
+ halUsartControl->errorReason = status;
+}
+#endif
+
+/**************************************************************************//**
+\brief Registers uasrt's event handlers. Performs configuration
+of usart registers. Performs configuration of RTS, CTS and DTR pins.
+
+\param[in]
+ descriptor - pointer to HAL_UsartDescriptor_t structure
+
+\return
+ Returns positive usart descriptor on success or -1 in cases: \n
+ - bad usart channel. \n
+ - unsupported parameters. \n
+ - the channel was already opened. \n
+ - there are not enough resources. \n
+******************************************************************************/
+int HAL_OpenUsart(HAL_UsartDescriptor_t *descriptor)
+{
+ uint8_t i; // Descriptor index
+
+ if (NULL == descriptor)
+ return -1;
+ if (false == halIsUsartChannelCorrect(descriptor->tty))
+ return -1;
+
+#ifdef HW_CONTROL_PINS_PORT_ASSIGNMENT
+ if ((descriptor->flowControl & USART_FLOW_CONTROL_HARDWARE) &&
+ (HW_CONTROL_PINS_PORT_ASSIGNMENT != descriptor->tty))
+ return -1; // Hardware control cannot be used for this channel.
+#endif // HW_CONTROL_PINS_PORT_ASSIGNMENT
+
+ i = HAL_GET_INDEX_BY_CHANNEL(descriptor->tty);
+ if (NULL != halPointDescrip[i])
+ return -1; // Channel is already opened.
+
+ halPointDescrip[i] = descriptor;
+#ifdef HW_CONTROL_PINS_PORT_ASSIGNMENT
+ if (HW_CONTROL_PINS_PORT_ASSIGNMENT == descriptor->tty)
+ {
+ if (descriptor->flowControl & USART_DTR_CONTROL)
+ GPIO_USART_DTR_make_in();
+ if (descriptor->flowControl & USART_FLOW_CONTROL_HARDWARE)
+ {
+ GPIO_USART_CTS_make_out();
+ GPIO_USART_RTS_make_in();
+ if (NULL == descriptor->rxBuffer)
+ GPIO_USART_CTS_set(); // CTS_ON
+ else
+ GPIO_USART_CTS_clr(); // CTS_OFF
+ }
+ }
+#endif // HW_CONTROL_PINS_PORT_ASSIGNMENT
+
+ if (USART_MODE_SYNC == descriptor->mode)
+ halSetUsartClockPinDirection(descriptor);
+
+ descriptor->service.txPointOfRead = 0;
+ descriptor->service.txPointOfWrite = 0;
+ if (NULL == descriptor->rxBuffer)
+ descriptor->rxBufferLength = 0;
+ if (NULL == descriptor->txBuffer)
+ descriptor->txBufferLength = 0;
+ descriptor->service.rxPointOfRead = 0;
+ descriptor->service.rxPointOfWrite = 0;
+ descriptor->service.usartShiftRegisterEmpty = 1;
+
+ halSetUsartConfig(descriptor);
+
+ return descriptor->tty;
+}
+
+/**************************************************************************//**
+\brief Frees the usart channel and pins, if hardware flow control was used.
+
+\param[in]
+ descriptor - the usart descriptor.
+\return
+ 0 on success, \n
+ -1 if bad descriptor or channel is already closed.
+******************************************************************************/
+int HAL_CloseUsart(HAL_UsartDescriptor_t *descriptor)
+{
+ uint8_t i;
+
+ if (NULL == descriptor)
+ return -1;
+ if (false == halIsUsartChannelCorrect(descriptor->tty))
+ return -1;
+ i = HAL_GET_INDEX_BY_CHANNEL(descriptor->tty);
+ if (NULL == halPointDescrip[i])
+ return -1; // Channel is already closed.
+
+ halCloseUsart(halPointDescrip[i]->tty);
+#ifdef HW_CONTROL_PINS_PORT_ASSIGNMENT
+ if (halPointDescrip[i]->flowControl & USART_FLOW_CONTROL_HARDWARE)
+ GPIO_USART_CTS_make_in();
+#endif // HW_CONTROL_PINS_PORT_ASSIGNMENT
+
+ if (USART_MODE_SYNC == halPointDescrip[i]->mode)
+ {
+ halPointDescrip[i]->syncMode = USART_CLK_MODE_SLAVE;
+ halSetUsartClockPinDirection(halPointDescrip[i]);
+ }
+ halPointDescrip[i] = NULL;
+
+ return 0;
+}
+
+/**************************************************************************//**
+\brief Controls RTS and DTR the pins and makes decision if the usart can transmit
+ byte.
+
+\param[in]
+ tty - channel number.
+******************************************************************************/
+static void halUsartHwController(UsartChannel_t tty)
+{
+ uint8_t i;
+ HalUsartService_t *halUsartControl;
+
+ i = HAL_GET_INDEX_BY_CHANNEL(tty);
+ if (NULL == halPointDescrip[i])
+ return; // Port closed.
+
+ halUsartControl = &halPointDescrip[i]->service;
+#ifdef HW_CONTROL_PINS_PORT_ASSIGNMENT
+ if (HW_CONTROL_PINS_PORT_ASSIGNMENT == tty)
+ {
+ uint8_t hw1 = 0;
+ uint8_t hw2 = 0;
+
+ if (halPointDescrip[i]->flowControl & USART_DTR_CONTROL)
+ hw1 = GPIO_USART_DTR_read();
+
+ if (halPointDescrip[i]->flowControl & USART_FLOW_CONTROL_HARDWARE)
+ hw2 = GPIO_USART_RTS_read();
+
+ if (hw1 || hw2)
+ {
+ halUsartAppTimer.interval = USART_HW_CONTROLLER_TIMER_PERIOD;
+ halUsartAppTimer.mode = TIMER_ONE_SHOT_MODE;
+ halUsartAppTimer.callback = hwControlPinsPollCallback;
+ HAL_StartAppTimer(&halUsartAppTimer);
+ return;
+ }
+ }
+#endif // HW_CONTROL_PINS_PORT_ASSIGNMENT
+
+ uint16_t poW;
+ uint16_t poR;
+
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ poW = halUsartControl->txPointOfWrite;
+ poR = halUsartControl->txPointOfRead;
+ END_MEASURE(HAL_USART_HW_CONTROLLER_LIMIT)
+ ATOMIC_SECTION_LEAVE
+
+ if (poW != poR)
+ {
+ halSendUsartByte(tty, halPointDescrip[i]->txBuffer[poR++]);
+ if (poR == halPointDescrip[i]->txBufferLength)
+ poR = 0;
+ halEnableUsartDremInterrupt(tty);
+
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ halUsartControl->txPointOfRead = poR;
+ END_MEASURE(HAL_USART_HW_CONTROLLER_LIMIT)
+ ATOMIC_SECTION_LEAVE
+
+ }
+ else
+ {
+ // data register empty interrupt was disabled
+ halEnableUsartTxcInterrupt(tty);// TX Complete interrupt enable
+ }
+}
+
+/**************************************************************************//**
+\brief Writes a number of bytes to a usart channel.
+txCallback function will be used to notify when the transmission is finished.
+If hardware flow control is used for transmitting then RTS and DTR pins will
+be tested during transmission.
+
+\param[in]
+ descriptor - pointer to HAL_UsartDescriptor_t structure;
+
+\param[in]
+ buffer - pointer to the application data buffer;
+
+\param[in]
+ length - number of bytes to transfer;
+
+\return
+ -1 - bad descriptor; \n
+ Number of bytes placed to the buffer - success.
+******************************************************************************/
+int HAL_WriteUsart(HAL_UsartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length)
+{
+ uint8_t i;
+ uint16_t poW;
+ uint16_t poR;
+ uint16_t old;
+ uint16_t wasWrote = 0;
+ bool needStartTrmt = false;
+ HalUsartService_t *halUsartControl;
+
+ if (NULL == descriptor)
+ return -1;
+ if (false == halIsUsartChannelCorrect(descriptor->tty))
+ return -1;
+ if (!buffer || !length)
+ return -1;
+ i = HAL_GET_INDEX_BY_CHANNEL(descriptor->tty);
+ if (descriptor != halPointDescrip[i])
+ return -1; // Channel is not opened.
+
+ halUsartControl = &descriptor->service;
+ if (0 == descriptor->txBufferLength)
+ { // Callback mode
+ if (halUsartControl->txPointOfWrite != halUsartControl->txPointOfRead)
+ return -1; // there is unsent data
+ descriptor->txBuffer = buffer;
+ halUsartControl->txPointOfWrite = length;
+ halUsartControl->txPointOfRead = 0;
+ needStartTrmt = true;
+ wasWrote = length;
+ } // Callback mode.
+ else
+ { // Polling mode.
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ poW = halUsartControl->txPointOfWrite;
+ poR = halUsartControl->txPointOfRead;
+ END_MEASURE(HALATOM_WRITE_USART_TIME_LIMIT)
+ ATOMIC_SECTION_LEAVE
+
+ if (poW == poR)
+ needStartTrmt = true; // Buffer empty.
+
+ while (wasWrote < length)
+ {
+ old = poW;
+
+ if (++poW == descriptor->txBufferLength)
+ poW = 0;
+
+ if (poW == poR)
+ { // Buffer full.
+ poW = old;
+ break;
+ } // Buffer full.
+
+ descriptor->txBuffer[old] = buffer[wasWrote++];
+ }
+
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ halUsartControl->txPointOfWrite = poW;
+ END_MEASURE(HALATOM_WRITE_USART_TIME_LIMIT)
+ ATOMIC_SECTION_LEAVE
+ } // Polling mode
+
+ if (needStartTrmt)
+ {
+ halUsartControl->usartShiftRegisterEmpty = 0; // Buffer and shift register is full
+ // Enable interrupt. Transaction will be launched in the callback.
+ halEnableUsartDremInterrupt(descriptor->tty);
+ }
+
+ return wasWrote;
+}
+
+/*************************************************************************//**
+\brief Reads length bytes from usart and places ones to buffer.
+
+\param[in]
+ descriptor - usart descriptor;
+\param[out]
+ buffer - pointer to a application buffer;
+\param[in]
+ length - the number of bytes which should be placed to buffer
+
+\return
+ -1 - bad descriptor, bad number to read or number of bytes that \n
+ were placed to buffer.
+*****************************************************************************/
+int HAL_ReadUsart(HAL_UsartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length)
+{
+ uint8_t i = 0;
+ uint16_t wasRead = 0;
+ uint16_t poW;
+ uint16_t poR;
+ HalUsartService_t *halUsartControl;
+#ifdef HW_CONTROL_PINS_PORT_ASSIGNMENT
+ uint16_t number;
+#endif // HW_CONTROL_PINS_PORT_ASSIGNMENT
+
+ if (NULL == descriptor)
+ return -1;
+ if (false == halIsUsartChannelCorrect(descriptor->tty))
+ return -1;
+ if (!buffer || !length)
+ return -1;
+ i = HAL_GET_INDEX_BY_CHANNEL(descriptor->tty);
+ if (descriptor != halPointDescrip[i])
+ return -1; // Channel is not opened.
+
+ halUsartControl = &halPointDescrip[i]->service;
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ poW = halUsartControl->rxPointOfWrite;
+ poR = halUsartControl->rxPointOfRead;
+ END_MEASURE(HALATOM_READ_USART_TIME_LIMIT)
+ ATOMIC_SECTION_LEAVE
+
+ while ((poR != poW) && (wasRead < length))
+ {
+ buffer[wasRead] = descriptor->rxBuffer[poR];
+ if (++poR == descriptor->rxBufferLength)
+ poR = 0;
+ wasRead++;
+ }
+
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ halUsartControl->rxPointOfRead = poR;
+ halUsartControl->rxBytesInBuffer -= wasRead;
+#ifdef HW_CONTROL_PINS_PORT_ASSIGNMENT
+ number = halUsartControl->rxBytesInBuffer;
+#endif // HW_CONTROL_PINS_PORT_ASSIGNMENT
+ END_MEASURE(HALATOM_READ_USART_TIME_LIMIT)
+ ATOMIC_SECTION_LEAVE
+
+#ifdef HW_CONTROL_PINS_PORT_ASSIGNMENT
+ if ((HW_CONTROL_PINS_PORT_ASSIGNMENT == descriptor->tty) && (descriptor->flowControl & USART_FLOW_CONTROL_HARDWARE))
+ if (number <= (descriptor->rxBufferLength >> BUFFER_RESERV))
+ GPIO_USART_CTS_clr();
+#endif // HW_CONTROL_PINS_PORT_ASSIGNMENT
+
+ return wasRead;
+}
+
+/**************************************************************************//**
+\brief Forbids to the host data transmiting. Only HW_CONTROL_PINS_PORT_ASSIGNMENT
+ port can be used for hardware flow control.
+
+\param[in]
+ descriptor - usart descriptor.
+
+\return
+ -1 - bad descriptor, bad usart, unsupported mode;
+ 0 - on success.
+******************************************************************************/
+#ifdef HW_CONTROL_PINS_PORT_ASSIGNMENT
+int HAL_OnUsartCts(HAL_UsartDescriptor_t *descriptor)
+{
+ uint8_t i;
+
+ if (NULL == descriptor)
+ return -1;
+
+ if (false == halIsUsartChannelCorrect(descriptor->tty))
+ return -1;
+
+ i = HAL_GET_INDEX_BY_CHANNEL(descriptor->tty);
+ if (descriptor != halPointDescrip[i])
+ return -1; // Channel is not opened.
+
+ if (HW_CONTROL_PINS_PORT_ASSIGNMENT != descriptor->tty)
+ return -1;
+
+ GPIO_USART_CTS_set();// CTS_ON
+
+ return 0;
+}
+#endif // HW_CONTROL_PINS_PORT_ASSIGNMENT
+
+/**************************************************************************//**
+\brief Allows to transfer a host data. Only HW_CONTROL_PINS_PORT_ASSIGNMENT
+can be used for hardware flow control.
+
+\param[in]
+ descriptor - usart descriptor.
+
+\return
+ -1 - bad descriptor, bad usart, unsupported mode;
+ 0 - on success.
+******************************************************************************/
+#ifdef HW_CONTROL_PINS_PORT_ASSIGNMENT
+int HAL_OffUsartCts(HAL_UsartDescriptor_t *descriptor)
+{
+ uint8_t i;
+
+ if (NULL == descriptor)
+ return -1;
+
+ if (false == halIsUsartChannelCorrect(descriptor->tty))
+ return -1;
+
+ i = HAL_GET_INDEX_BY_CHANNEL(descriptor->tty);
+ if (descriptor != halPointDescrip[i])
+ return -1; // Channel is not opened.
+
+ if (HW_CONTROL_PINS_PORT_ASSIGNMENT != descriptor->tty)
+ return -1;
+
+ GPIO_USART_CTS_clr(); // CTS_OFF
+
+ return 0;
+}
+#endif // HW_CONTROL_PINS_PORT_ASSIGNMENT
+
+/**************************************************************************//**
+\brief Fills UsartHardwareControl_t variable by potential of RTS pin. Only
+ HW_CONTROL_PINS_PORT_ASSIGNMENT can be used for hardware flow control.
+
+\param[in]
+ descriptor - usart descriptor.
+\return
+ -1 - bad descriptor, bad usart, unsupported mode;
+ 0 - on success.
+******************************************************************************/
+#ifdef HW_CONTROL_PINS_PORT_ASSIGNMENT
+int HAL_ReadUsartRts(HAL_UsartDescriptor_t *descriptor)
+{
+ uint8_t i;
+
+ if (NULL == descriptor)
+ return -1;
+
+ if (false == halIsUsartChannelCorrect(descriptor->tty))
+ return -1;
+
+ i = HAL_GET_INDEX_BY_CHANNEL(descriptor->tty);
+ if (descriptor != halPointDescrip[i])
+ return -1; // Channel is not opened.
+
+ if (HW_CONTROL_PINS_PORT_ASSIGNMENT != descriptor->tty)
+ return -1;
+
+ return GPIO_USART_RTS_read();
+}
+#endif // HW_CONTROL_PINS_PORT_ASSIGNMENT
+
+/**************************************************************************//**
+\brief Fills UsartHardwareControl_t variable by potential of DTR pin. Only
+ HW_CONTROL_PINS_PORT_ASSIGNMENT can be used for hardware flow control.
+
+\param[in]
+ descriptor - usart descriptor.
+\return
+ -1 - bad descriptor, bad usart, unsupported mode;
+ 0 - on success.
+******************************************************************************/
+#ifdef HW_CONTROL_PINS_PORT_ASSIGNMENT
+int HAL_ReadUsartDtr(HAL_UsartDescriptor_t *descriptor)
+{
+ uint8_t i;
+
+ if (NULL == descriptor)
+ return -1;
+
+ if (false == halIsUsartChannelCorrect(descriptor->tty))
+ return -1;
+
+ i = HAL_GET_INDEX_BY_CHANNEL(descriptor->tty);
+ if (descriptor != halPointDescrip[i])
+ return -1; // Channel is not opened.
+
+ if (HW_CONTROL_PINS_PORT_ASSIGNMENT != descriptor->tty)
+ return -1;
+
+ return GPIO_USART_DTR_read();
+}
+#endif // HW_CONTROL_PINS_PORT_ASSIGNMENT
+
+// Interrupt handlers
+/**************************************************************************//**
+\brief Hardware Control pins polling timer callback.
+******************************************************************************/
+#ifdef HW_CONTROL_PINS_PORT_ASSIGNMENT
+void hwControlPinsPollCallback(void)
+{
+ halUsartHwController(HW_CONTROL_PINS_PORT_ASSIGNMENT);
+}
+#endif // HW_CONTROL_PINS_PORT_ASSIGNMENT
+
+/**************************************************************************//**
+\brief Transmission complete interrupt handler.
+
+\param[in]
+ tty - USART channel identifier.
+******************************************************************************/
+void halSigUsartTransmissionComplete(UsartChannel_t tty)
+{
+ uint8_t i;
+ HalUsartService_t *halUsartControl;
+ uint16_t poW;
+ uint16_t poR;
+
+ i = HAL_GET_INDEX_BY_CHANNEL(tty);
+ if (NULL == halPointDescrip[i])
+ {
+ assert(false, USARTC_HALSIGUSARTTRANSMISSIONCOMPLETE_0);
+ return; // Descriptor with "tty" channel is not found.
+ }
+
+ halUsartControl = &halPointDescrip[i]->service;
+
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ poW = halUsartControl->txPointOfWrite;
+ poR = halUsartControl->txPointOfRead;
+ END_MEASURE(HAL_USART_TRANS_COMPLETE_LIMIT)
+ ATOMIC_SECTION_LEAVE
+
+ if (poW == poR)
+ halUsartControl->usartShiftRegisterEmpty = 1; // Buffer is empty, shift register is empty too.
+
+ if (0 == halPointDescrip[i]->txBufferLength)
+ halPointDescrip[i]->txBuffer = NULL; // nulling pointer for callback mode
+
+ if (NULL != halPointDescrip[i]->txCallback)
+ halPointDescrip[i]->txCallback();
+}
+
+/**************************************************************************//**
+\brief Reception complete interrupt handler.
+
+\param[in]
+ tty - USART channel identifier.
+******************************************************************************/
+static void halSigUsartReceptionComplete(UsartChannel_t tty)
+{
+ uint8_t i;
+ HalUsartService_t *halUsartControl;
+ uint16_t number;
+
+ i = HAL_GET_INDEX_BY_CHANNEL(tty);
+ if (NULL == halPointDescrip[i])
+ {
+ assert(false, USARTC_HALSIGUSARTRECEPTIONCOMPLETE_0);
+ return; // Descriptor with "tty" channel is not found.
+ }
+
+ if (halPointDescrip[i]->flowControl & (USART_SPI_READ_MODE | USART_SPI_WRITE_MODE))
+ return; // for spi mode
+
+ halUsartControl = &halPointDescrip[i]->service;
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ number = halUsartControl->rxBytesInBuffer;
+ END_MEASURE(HALATOM_USART_RX_COMPLETE_TIME_LIMIT)
+ ATOMIC_SECTION_LEAVE
+
+ if (number)
+ if (NULL != halPointDescrip[i]->rxCallback)
+ halPointDescrip[i]->rxCallback(number);
+}
+
+#if defined(_USE_USART_ERROR_EVENT_)
+/**************************************************************************//**
+\brief Error occurred action handler.
+
+\param[in]
+ tty - USART channel identifier.
+******************************************************************************/
+static void halSigUsartErrorOccurred(UsartChannel_t tty)
+{
+ uint8_t i;
+ HalUsartService_t *halUsartControl;
+ UsartErrorReason_t errReason = FRAME_ERROR;
+
+ i = HAL_GET_INDEX_BY_CHANNEL(tty);
+ if (NULL == halPointDescrip[i])
+ {
+ assert(false, USARTC_HALSIGUSARTERROROCCURED_0);
+ return; // Descriptor with "tty" channel is not found.
+ }
+
+ halUsartControl = &halPointDescrip[i]->service;
+ if (halUsartControl->errorReason & HAL_BM_FRAME_ERROR)
+ errReason = FRAME_ERROR;
+ else if (halUsartControl->errorReason & HAL_BM_DATA_OVERRUN)
+ errReason = DATA_OVERRUN;
+ else if (halUsartControl->errorReason & HAL_BM_PARITY_ERROR)
+ errReason = PARITY_ERROR;
+ else
+ {
+ assert(false, USARTC_HALUNKNOWNERRORREASON_0);
+ }
+
+ if (NULL != halPointDescrip[i]->errCallback)
+ halPointDescrip[i]->errCallback(errReason);
+}
+#endif
+
+/**************************************************************************//**
+\brief Enables DTR wake up.
+
+\param[in] callback - callback method pointer.
+******************************************************************************/
+void HAL_EnableDtrWakeUp(void (* callback)(void))
+{
+ dtrWakeUpCallback = callback;
+ halEnableDtrWakeUp = true;
+}
+
+/**************************************************************************//**
+\brief Disables DTR wake up.
+******************************************************************************/
+void HAL_DisableDtrWakeUp(void)
+{
+ halEnableDtrWakeUp = false;
+}
+
+/**************************************************************************//**
+\brief Checks the status of tx buffer.
+
+\param[in]
+ descriptor - pointer to HAL_UsartDescriptor_t structure;
+
+\return
+ -1 - bad descriptor, no tx buffer; \n
+ 1 - tx buffer is empty; \n
+ 0 - tx buffer is not empty;
+******************************************************************************/
+int HAL_IsTxEmpty(HAL_UsartDescriptor_t *descriptor)
+{
+ uint8_t i;
+ HalUsartService_t *halUsartControl;
+ uint16_t poW;
+ uint16_t poR;
+
+ if (NULL == descriptor)
+ return -1;
+ if (false == halIsUsartChannelCorrect(descriptor->tty))
+ return -1;
+ i = HAL_GET_INDEX_BY_CHANNEL(descriptor->tty);
+ if (descriptor != halPointDescrip[i])
+ return -1; // Channel is not opened.
+
+ halUsartControl = &halPointDescrip[i]->service;
+ ATOMIC_SECTION_ENTER
+ BEGIN_MEASURE
+ poW = halUsartControl->txPointOfWrite;
+ poR = halUsartControl->txPointOfRead;
+ END_MEASURE(HAL_USART_TX_EMPTY_LIMIT)
+ ATOMIC_SECTION_LEAVE
+ if (poW == poR)
+ return halUsartControl->usartShiftRegisterEmpty;
+ return 0;
+}
+
+/**************************************************************************//**
+\brief Checks the channel number.
+
+\param[in]
+ channel - channel to be verified.
+
+\return
+ true if channel is possible, \n
+ false otherwise.
+******************************************************************************/
+bool halIsUsartChannelCorrect(UsartChannel_t channel)
+{
+ switch (channel)
+ {
+#ifdef USART_CHANNEL_0
+ case USART_CHANNEL_0:
+#endif // USART_CHANNEL_0
+#ifdef USART_CHANNEL_1
+ case USART_CHANNEL_1:
+#endif // USART_CHANNEL_0
+#if defined(USART_CHANNEL_0) || defined(USART_CHANNEL_1)
+ return true;
+#endif
+ default:
+ return false;
+ }
+}
+
+/**************************************************************************//**
+\brief Set clock pin direction for synchronous mode.
+
+\param[in]
+ descriptor - pointer to usart channel descriptor.
+******************************************************************************/
+static void halSetUsartClockPinDirection(HAL_UsartDescriptor_t *descriptor)
+{
+ if (USART_CLK_MODE_MASTER == descriptor->syncMode)
+ {
+ switch (descriptor->tty)
+ {
+#ifdef USART_CHANNEL_0
+ case USART_CHANNEL_0:
+ GPIO_USART0_EXTCLK_make_out();
+ break;
+#endif // USART_CHANNEL_0
+#ifdef USART_CHANNEL_1
+ case USART_CHANNEL_1:
+ GPIO_USART1_EXTCLK_make_out();
+ break;
+#endif // USART_CHANNEL_1
+ default:
+ break;
+ }
+ }
+ else
+ {
+ switch (descriptor->tty)
+ {
+#ifdef USART_CHANNEL_0
+ case USART_CHANNEL_0:
+ GPIO_USART0_EXTCLK_make_in();
+ GPIO_USART0_EXTCLK_make_pullup();
+ break;
+#endif // USART_CHANNEL_0
+#ifdef USART_CHANNEL_1
+ case USART_CHANNEL_1:
+ GPIO_USART1_EXTCLK_make_in();
+ GPIO_USART1_EXTCLK_make_pullup();
+ break;
+#endif // USART_CHANNEL_1
+ default:
+ break;
+ }
+ }
+}
+
+#if defined(HAL_USE_USART_CHANNEL_0)
+/**************************************************************************//**
+\brief Wrapper for data empty handler for usart channel 0
+******************************************************************************/
+static void halUsartTaskUsart0Dre(void)
+{
+ halUsartHwController(USART_CHANNEL_0);
+}
+
+/**************************************************************************//**
+\brief Wrapper for transmit complete handler for usart channel 0
+******************************************************************************/
+static void halUsartTaskUsart0Txc(void)
+{
+ halSigUsartTransmissionComplete(USART_CHANNEL_0);
+}
+
+/**************************************************************************//**
+\brief Wrapper for receive complete handler for usart channel 0
+******************************************************************************/
+static void halUsartTaskUsart0Rxc(void)
+{
+ halSigUsartReceptionComplete(USART_CHANNEL_0);
+}
+
+#if defined(_USE_USART_ERROR_EVENT_)
+/**************************************************************************//**
+\brief Wrapper for error occurred handler for usart channel 0
+******************************************************************************/
+static void halUsartTaskUsart0Err(void)
+{
+ halSigUsartErrorOccurred(USART_CHANNEL_0);
+}
+#endif // defined(_USE_USART_ERROR_EVENT_)
+#endif // defined(HAL_USE_USART_CHANNEL_0)
+
+#if defined(HAL_USE_USART_CHANNEL_1)
+/**************************************************************************//**
+\brief Wrapper for data empty handler for usart channel 1
+******************************************************************************/
+static void halUsartTaskUsart1Dre(void)
+{
+ halUsartHwController(USART_CHANNEL_1);
+}
+
+/**************************************************************************//**
+\brief Wrapper for transmit complete handler for usart channel 1
+******************************************************************************/
+static void halUsartTaskUsart1Txc(void)
+{
+ halSigUsartTransmissionComplete(USART_CHANNEL_1);
+}
+
+/**************************************************************************//**
+\brief Wrapper for receive complete handler for usart channel 0
+******************************************************************************/
+static void halUsartTaskUsart1Rxc(void)
+{
+ halSigUsartReceptionComplete(USART_CHANNEL_1);
+}
+
+#if defined(_USE_USART_ERROR_EVENT_)
+/**************************************************************************//**
+\brief Wrapper for error occurred handler for usart channel 1
+******************************************************************************/
+static void halUsartTaskUsart1Err(void)
+{
+ halSigUsartErrorOccurred(USART_CHANNEL_1);
+}
+#endif // defined(_USE_USART_ERROR_EVENT_)
+#endif // defined(HAL_USE_USART_CHANNEL_1)
+//eof usart.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/usb.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/usb.c
new file mode 100644
index 00000000..b164f1dc
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/usb.c
@@ -0,0 +1,435 @@
+/**************************************************************************//**
+ \file usb.c
+
+ \brief Implementation of usb hardware independent module.
+
+ \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:
+ 17/07/08 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halUsb.h>
+#include <usb.h>
+
+/******************************************************************************
+ External global variables section
+******************************************************************************/
+// user's request handler
+extern void (* sendReqToUpper)(uint8_t *req);
+// Holds the internal state for each endpoint of the UDP
+extern UsbEndpoint_t endpoints[USB_END_POINTS_NUMBER];
+// Device current state
+extern volatile uint8_t deviceState;
+// Previous device current state
+extern volatile uint8_t previousDeviceState;
+// pointer to request memory. Memory allocate by user.
+extern uint8_t *requestMemory;
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+void (* resumeCallback)(void) = NULL;
+void (* suspendCallback)(void) = NULL;
+void (* endOfBusResetCallback)(void) = NULL;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+ Registers user's end of bus reset handler
+
+Parameters:
+ f - pointer to user's callback
+******************************************************************************/
+void HAL_RegisterEndOfBusResetHandler(void (* f)(void))
+{
+ endOfBusResetCallback = f;
+}
+
+/******************************************************************************
+ Registers user's resume handler
+
+Parameters:
+ f - pointer to user's callback
+******************************************************************************/
+void HAL_RegisterResumeHandler(void (* f)(void))
+{
+ resumeCallback = f;
+}
+
+/******************************************************************************
+ Registers user's suspend handler
+
+Parameters:
+ f - pointer to user's callback
+******************************************************************************/
+void HAL_RegisterSuspendHandler(void (* f)(void))
+{
+ suspendCallback = f;
+}
+
+/******************************************************************************
+ Registers user's request handler
+
+Parameters:
+ f - pointer to user's callback
+******************************************************************************/
+void HAL_RegisterRequestHandler(void (* f)(uint8_t *req))
+{
+ sendReqToUpper = f;
+}
+
+/******************************************************************************
+Configures an endpoint according to its Endpoint Descriptor.
+
+Parameters:
+ descriptor - Pointer to an Endpoint descriptor.
+******************************************************************************/
+void HAL_ConfigureEndpoint(HAL_UsbEndPointDescptr_t *descriptor)
+{
+ UsbEndpoint_t *endpoint;
+ uint8_t eptnum;
+ uint8_t type;
+ HAL_UsbEndPointDirect_t direction;
+
+ // NULL descriptor -> Control endpoint 0
+ if (NULL == descriptor)
+ {
+ eptnum = USB_END_POINT_0;
+ endpoint = &(endpoints[USB_END_POINT_0]);
+ type = EP_CONTROL;
+ direction = EP_OUT;
+ endpoint->size = UDP_ENDPOINTS_MAXPACKETSIZE(USB_END_POINT_0);
+ }
+ else
+ {
+ eptnum = descriptor->bEndpointAddress & 0x0F;
+ endpoint = &(endpoints[eptnum]);
+ type = descriptor->bmAttributes & 0x03;
+ if (descriptor->bEndpointAddress & 0x80)
+ direction = EP_IN;
+ else
+ direction = EP_OUT;
+ endpoint->size = descriptor->wMaxPacketSize;
+ }
+
+ // Abort the current transfer is the endpoint was configured and in
+ // Write or Read state
+ if ((UDP_ENDPOINT_RECEIVING == endpoint->state) || (UDP_ENDPOINT_SENDING == endpoint->state))
+ halEndOfTransfer(eptnum, STATUS_RESET);
+
+ endpoint->state = UDP_ENDPOINT_IDLE;
+ halConfigureEndpoint(eptnum, type, direction);
+}
+
+/******************************************************************************
+Sends data through a USB endpoint. Sets up the transfer descriptor,
+writes one or two data payloads (depending on the number of FIFO bank
+for the endpoint) and then starts the actual transfer. The operation is
+complete when all the data has been sent.
+
+*If the size of the buffer is greater than the size of the endpoint
+(or twice the size if the endpoint has two FIFO banks), then the buffer
+must be kept allocated until the transfer is finished*. This means that
+it is not possible to declare it on the stack (i.e. as a local variable
+of a function which returns after starting a transfer).
+
+Parameters:
+ eptnum - Endpoint number.
+ data - Pointer to a buffer with the data to send.
+ size - Size of the data buffer.
+ callback - Optional callback function to invoke when the transfer is complete.
+ argument - Optional argument to the callback function.
+
+Returns:
+ STATUS_SUCCESS if the transfer has been started; otherwise, the
+ corresponding error status code.
+******************************************************************************/
+uint8_t HAL_UsbWrite(uint8_t eptnum, void *data, uint32_t size, TransferCallback_t callback, void *argument)
+{
+ UsbEndpoint_t *endpoint = &(endpoints[eptnum]);
+ UsbTransfer_t *transfer = &(endpoint->transfer);
+
+ // Check that the endpoint is in Idle state
+ if (UDP_ENDPOINT_IDLE != endpoint->state)
+ return STATUS_BUSY;
+
+ // Setup the transfer descriptor
+ transfer->data = (void *) data;
+ transfer->remaining = size;
+ transfer->buffered = 0;
+ transfer->transferred = 0;
+ transfer->callback = callback;
+ transfer->argument = argument;
+
+ // Send the first packet
+ endpoint->state = UDP_ENDPOINT_SENDING;
+ halStartUsbWrite(eptnum);
+
+ // Enable interrupt on endpoint
+ halEnableEndPointTxInterrupt(eptnum);
+
+ return STATUS_SUCCESS;
+}
+
+/******************************************************************************
+Reads incoming data on an USB endpoint This methods sets the transfer
+descriptor and activate the endpoint interrupt. The actual transfer is
+then carried out by the endpoint interrupt handler. The Read operation
+finishes either when the buffer is full, or a short packet (inferior to
+endpoint maximum size) is received.
+
+*The buffer must be kept allocated until the transfer is finished*.
+
+Parameters:
+ eptnum - Endpoint number.
+ data - Pointer to a data buffer.
+ size - Size of the data buffer in bytes.
+ callback - Optional end-of-transfer callback function.
+ argument - Optional argument to the callback function.
+
+Returns:
+ STATUS_SUCCESS if the read operation has been started; otherwise,
+ the corresponding error code.
+******************************************************************************/
+uint8_t HAL_UsbRead(uint8_t eptnum, void *data, uint32_t size, TransferCallback_t callback, void *argument)
+{
+ UsbEndpoint_t *endpoint = &(endpoints[eptnum]);
+ UsbTransfer_t *transfer = &(endpoint->transfer);
+
+ if (NULL == data)
+ return STATUS_ABORTED;
+
+ // Return if the endpoint is not in IDLE state
+ if (UDP_ENDPOINT_IDLE != endpoint->state)
+ return STATUS_BUSY;
+
+ // Endpoint enters Receiving state
+ endpoint->state = UDP_ENDPOINT_RECEIVING;
+
+ // Set the transfer descriptor
+ transfer->data = data;
+ transfer->remaining = size;
+ transfer->buffered = 0;
+ transfer->transferred = 0;
+ transfer->callback = callback;
+ transfer->argument = argument;
+
+ // Enable interrupt on endpoint
+ halEnableEndPointRxInterrupt(eptnum);
+
+ return STATUS_SUCCESS;
+}
+
+/******************************************************************************
+Sets the HALT feature on the given endpoint (if not already in this state).
+
+Parameters:
+ eptnum - Endpoint number.
+******************************************************************************/
+void HAL_Halt(uint8_t eptnum)
+{
+ UsbEndpoint_t *endpoint = &(endpoints[eptnum]);
+
+ // Check that endpoint is enabled and not already in Halt state
+ if ((UDP_ENDPOINT_DISABLED != endpoint->state) && (UDP_ENDPOINT_HALTED != endpoint->state))
+ {
+ // Abort the current transfer if necessary
+ halEndOfTransfer(eptnum, STATUS_ABORTED);
+
+ halEndpointHaltState(eptnum);
+
+ // Enable the endpoint interrupt
+ halEnableEndPointStallInterrupt(eptnum);
+ }
+}
+
+/******************************************************************************
+Clears the Halt feature on the given endpoint.
+
+Parameters:
+ eptnum - Endpoint number.
+******************************************************************************/
+void HAL_Unhalt(uint8_t eptnum)
+{
+ UsbEndpoint_t *endpoint = &(endpoints[eptnum]);
+
+ // Check if the endpoint is enabled
+ if (UDP_ENDPOINT_DISABLED != endpoint->state)
+ {
+ // Return endpoint to Idle state
+ endpoint->state = UDP_ENDPOINT_IDLE;
+
+ halEndpointUnHaltState(eptnum);
+ }
+}
+
+/******************************************************************************
+Returns the current Halt status of an endpoint.
+
+Parameters:
+ eptnum - Endpoint number.
+
+Returns:
+ 1 - if the endpoint is currently halted;
+ 0 - otherwise.
+******************************************************************************/
+uint8_t HAL_IsHalted(uint8_t eptnum)
+{
+ UsbEndpoint_t *endpoint = &(endpoints[eptnum]);
+ if (UDP_ENDPOINT_HALTED == endpoint->state)
+ return 1;
+ else
+ return 0;
+}
+
+/******************************************************************************
+Causes the given endpoint to acknowledge the next packet it receives with
+a STALL handshake.
+
+Parameters:
+ eptnum - Endpoint number.
+
+Returns:
+ STATUS_SUCCESS or STATUS_BUSY.
+******************************************************************************/
+uint8_t HAL_Stall(uint8_t eptnum)
+{
+ UsbEndpoint_t *endpoint = &(endpoints[eptnum]);
+
+ // Check that endpoint is in Idle state
+ if (UDP_ENDPOINT_IDLE != endpoint->state)
+ {
+ return STATUS_BUSY;
+ }
+
+ halSendStallToHost(eptnum);
+ // Enable the endpoint interrupt
+ halEnableEndPointStallInterrupt(eptnum);
+
+ return STATUS_SUCCESS;
+}
+
+/******************************************************************************
+Sets the device address to the given value.
+
+Parameters:
+ address - New device address.
+******************************************************************************/
+void HAL_SetAddress(uint8_t *address)
+{
+ halSetUsbAddress(*address);
+ // If the address is 0, the device returns to the Default state
+ if (*address)
+ deviceState = DEVICE_PREADDRESSED;
+ // If the address is non-zero, the device enters the Address state
+ else
+ deviceState = DEVICE_DEFAULT;
+}
+
+/******************************************************************************
+Sets the current device configuration.
+
+Parameters:
+ cfgnum - Configuration number to set.
+******************************************************************************/
+void HAL_SetConfiguration(uint8_t cfgnum)
+{
+ // If the configuration number if non-zero, the device enters the
+ // Configured state
+ if (cfgnum)
+ {
+ deviceState = DEVICE_CONFIGURED;
+ }
+ // If the configuration number is zero, the device goes back to the Address
+ // state
+ else
+ {
+ deviceState = DEVICE_ADDRESS;
+ // Abort all transfers
+ halDisableEndpoints();
+ }
+}
+
+/******************************************************************************
+Initializes the USB driver.
+
+Parameters:
+ reqMem - Memory for usb request. Memory allocate by user.
+******************************************************************************/
+void HAL_UsbInit(uint8_t *reqMem)
+{
+ requestMemory = reqMem;
+
+ // Reset endpoint structures
+ halResetEndpoints();
+
+ // Device is in the Attached state
+ deviceState = DEVICE_SUSPENDED;
+ previousDeviceState = DEVICE_POWERED;
+ halInitUsbDevice();
+ halUsbInterrupt();
+}
+
+/******************************************************************************
+Returns the current state of the USB device.
+
+Returns:
+ Device current state.
+******************************************************************************/
+uint8_t HAL_GetState(void)
+{
+ return deviceState;
+}
+
+/******************************************************************************
+Endpoint interrupt handler.
+******************************************************************************/
+void halEndPointHandler(void)
+{
+ halCommonEndpointHandler();
+}
+
+/******************************************************************************
+usb suspend interrupt handler.
+******************************************************************************/
+void halSuspendHandler(void)
+{
+ if (NULL != suspendCallback)
+ suspendCallback();
+}
+
+/******************************************************************************
+usb resume interrupt handler.
+******************************************************************************/
+void halResumeHandler(void)
+{
+ if (NULL != resumeCallback)
+ resumeCallback();
+}
+
+/******************************************************************************
+usb bus reset interrupt handler.
+******************************************************************************/
+void halBusResetHandler(void)
+{
+ halEndOfBusResetHandler();
+ if (NULL != endOfBusResetCallback)
+ endOfBusResetCallback();
+}
+
+// eof usb.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/w1.c b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/w1.c
new file mode 100644
index 00000000..99b92d1a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/avr/common/src/w1.c
@@ -0,0 +1,382 @@
+/**************************************************************************//**
+ \file w1.c
+
+ \brief The implementation of the 1-wire interface.
+
+ \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:
+ 10/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halW1.h>
+#include <w1.h>
+#include <atomic.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define HAL_ROM_BYTE_LEN 8
+#define HAL_ROM_BIT_LEN 64
+#define HAL_W1_CRC_POLINOM 0x8C
+#define HAL_SEARCH_ROM_CMD 0xF0
+#define HAL_SEARCH_ALRM_CMD 0xEC
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/*******************************************************************************
+ 1-Wire search procedure for all devices discovering
+ Parameters:
+ cmd - ROM function command.
+ family - 8-bit family code.
+ data - pointer of SRAM where are stored the 8 bytes ROM
+ codes returned by the devices.
+ count - number of devices wish to find.
+ actCount - number of devices have been found.
+ Returns:
+ W1_SUCCESS_STATUS - if at least one device has been found.
+ W1_NO_DEVICE_STATUS - if there are no any devices presented
+ on the bus with specified family code.
+ W1_INVALID_CRC - if during searching invalid CRC has
+ been read and no devices with
+ spicified family code has been found.
+*******************************************************************************/
+W1Status_t halCommSearchW1(uint8_t cmd,
+ uint8_t family,
+ uint8_t *data,
+ uint8_t count,
+ uint8_t *actCount);
+
+/*******************************************************************************
+ 1-Wire search procedure for one device discovering
+ Parameters:
+ cmd - ROM function command.
+ Returns:
+ W1_SUCCESS_STATUS - if device has been found, ROM number
+ in ROM_NO buffer.
+ W1_NO_DEVICE_STATUS - if device has not been found.
+ W1_INVALID_CRC - if during searching invalid CRC has
+ been read.
+*******************************************************************************/
+W1Status_t halSearchW1(uint8_t cmd);
+
+/*******************************************************************************
+ Calculating 1-Wire 8-bit CRC
+ Parameters:
+ data - data buffer pointer.
+ length - data length.
+ Returns:
+ CRC value based on polynomial x^8 + x^5 + x^4 + 1
+*******************************************************************************/
+uint8_t halW1CRC(uint8_t *data, uint8_t length);
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+// 8-byte buffer that contains the current ROM registration
+// number discovered
+static uint8_t ROM_NO[HAL_ROM_BYTE_LEN];
+// Bit index that identifies from which bit the next search
+// discrepancy check should start
+static uint8_t LastDiscrepancy;
+// Flag to indicate previos search was the last device
+static uint8_t LastDeviceFlag;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/*******************************************************************************
+ 1-Wire search procedure with search ROM command only
+ Parameters:
+ family - 8-bit family code.
+ data - pointer of SRAM where are stored the 8 bytes ROM
+ codes returned by the devices.
+ count - number of devices wish to find.
+ actCount - number of devices have been found.
+ Returns:
+ W1_SUCCESS_STATUS - if at least one device has been found.
+ W1_NO_DEVICE_STATUS - if there are no any devices presented
+ on the bus with specified family code.
+ W1_INVALID_CRC - if during searching invalid CRC has
+ been read and no devices with
+ spicified family code has been found.
+*******************************************************************************/
+W1Status_t HAL_SearchW1Device(uint8_t family,
+ uint8_t *data,
+ uint8_t count,
+ uint8_t *actCount)
+{
+ return halCommSearchW1(HAL_SEARCH_ROM_CMD, family, data, count, actCount);
+}
+
+/*******************************************************************************
+ 1-Wire search procedure with alarm search command only
+ Parameters:
+ family - 8-bit family code.
+ data - pointer of SRAM where are stored the 8 bytes ROM
+ codes returned by the devices.
+ count - number of devices wish to find.
+ actCount - number of devices have been found.
+ Returns:
+ W1_SUCCESS_STATUS - if at least one device has been found.
+ W1_NO_DEVICE_STATUS - if there are no any devices presented
+ on the bus with specified family code.
+ W1_INVALID_CRC - if during searching invalid CRC has
+ been read and no devices with
+ spicified family code has been found.
+*******************************************************************************/
+W1Status_t HAL_AlarmSearchW1Device(uint8_t family,
+ uint8_t *data,
+ uint8_t count,
+ uint8_t *actCount)
+{
+ return halCommSearchW1(HAL_SEARCH_ALRM_CMD, family, data, count, actCount);
+}
+
+/*******************************************************************************
+ 1-Wire search procedure for all devices discovering
+ Parameters:
+ cmd - ROM function command.
+ family - 8-bit family code.
+ data - pointer of SRAM where are stored the 8 bytes ROM
+ codes returned by the devices.
+ count - number of devices wish to find.
+ actCount - number of devices have been found.
+ Returns:
+ W1_SUCCESS_STATUS - if at least one device has been found.
+ W1_NO_DEVICE_STATUS - if there are no any devices presented
+ on the bus with specified family code.
+ W1_INVALID_CRC - if during searching invalid CRC has
+ been read and no devices with
+ spicified family code has been found.
+*******************************************************************************/
+W1Status_t halCommSearchW1(uint8_t cmd,
+ uint8_t family,
+ uint8_t *data,
+ uint8_t count,
+ uint8_t *actCount)
+{
+ W1Status_t w1_result;
+ uint8_t i;
+
+ // Reset the searh state
+ LastDiscrepancy = 0;
+ LastDeviceFlag = 0;
+ // Setup family code
+ if (W1_ANY_FAMILY != family)
+ {
+ ROM_NO[0] = family;
+ LastDiscrepancy = HAL_ROM_BIT_LEN + 1;
+ for (i = 1; i < HAL_ROM_BYTE_LEN; i++) ROM_NO[i] = 0;
+ }
+ i = 0;
+ // Discovering
+ do
+ {
+ w1_result = halSearchW1(cmd);
+ if (W1_SUCCESS_STATUS != w1_result)
+ break;
+ // There is some device with specified family code
+ if ((ROM_NO[0] == family) || (W1_ANY_FAMILY == family))
+ {
+ *(uint64_t *)(data + 8 * i) = *(uint64_t *)ROM_NO;
+ i++;
+ }
+ else // There are not any devices with specified family code
+ {
+ w1_result = W1_NO_DEVICE_STATUS;
+ break;
+ }
+ }
+ while (!LastDeviceFlag && (i < count));
+
+ if (NULL != actCount)
+ *actCount = i;
+
+ if (i != 0)
+ return W1_SUCCESS_STATUS;
+ else
+ return w1_result;
+}
+
+/*******************************************************************************
+ 1-Wire search procedure for one device discovering
+ Parameters:
+ cmd - ROM function command.
+ Returns:
+ W1_SUCCESS_STATUS - if device has been found, ROM number
+ in ROM_NO buffer.
+ W1_NO_DEVICE_STATUS - if device has not been found.
+ W1_INVALID_CRC - if during searching invalid CRC has
+ been read.
+*******************************************************************************/
+W1Status_t halSearchW1(uint8_t cmd)
+{
+ uint8_t id_bit_number;
+ uint8_t last_zero, rom_byte_number;
+ uint8_t id_bit, cmp_id_bit;
+ uint8_t rom_byte_mask, search_direction;
+
+ // initialize for search
+ id_bit_number = 1;
+ last_zero = 0;
+ rom_byte_number = 0;
+ rom_byte_mask = 1;
+
+ // 1-Wire reset
+ ATOMIC_SECTION_ENTER
+ id_bit = halResetW1();
+ ATOMIC_SECTION_LEAVE
+ if (W1_NO_DEVICE_STATUS == id_bit)
+ {
+ LastDiscrepancy = 0;
+ LastDeviceFlag = 0;
+ return W1_NO_DEVICE_STATUS;
+ }
+
+ // issue the search command
+ ATOMIC_SECTION_ENTER
+ halWriteW1(cmd);
+ ATOMIC_SECTION_LEAVE
+ // search 64-bit uniqued registration number
+ do
+ {
+ // read a bit and its complement
+ ATOMIC_SECTION_ENTER
+ id_bit = halReadW1Bit();
+ cmp_id_bit = halReadW1Bit();
+ ATOMIC_SECTION_LEAVE
+ // check for no devices on 1-wire
+ if ((1 == id_bit) && (1 == cmp_id_bit))
+ return W1_NO_DEVICE_STATUS;
+
+ // all devices coupled have 0 or 1
+ if (id_bit != cmp_id_bit)
+ {
+ search_direction = id_bit;
+ // there is descepancy
+ }
+ else
+ {
+ // if this discrepancy if before the Last Discrepancy
+ // on a previous next then pick the same as last time (old branch)
+ if (id_bit_number < LastDiscrepancy)
+ search_direction = ((ROM_NO[rom_byte_number] & rom_byte_mask) > 0);
+ // if equal to last pick 1, if not then pick 0 (new branch)
+ else
+ search_direction = (id_bit_number == LastDiscrepancy);
+ // if 0 was picked then record its position in LastZero
+ if (0 == search_direction)
+ last_zero = id_bit_number;
+ }
+
+ if (1 == search_direction)
+ ROM_NO[rom_byte_number] |= rom_byte_mask;
+ else
+ ROM_NO[rom_byte_number] &= ~rom_byte_mask;
+ ATOMIC_SECTION_ENTER
+ halWriteW1bit(search_direction);
+ ATOMIC_SECTION_LEAVE
+ id_bit_number++;
+ rom_byte_mask <<= 1;
+
+ if (rom_byte_mask == 0)
+ {
+ rom_byte_number++;
+ rom_byte_mask = 1;
+ }
+ } while (rom_byte_number < HAL_ROM_BYTE_LEN);
+
+ // Invalid CRC
+ if (halW1CRC(ROM_NO, HAL_ROM_BYTE_LEN))
+ return W1_INVALID_CRC;
+
+ LastDiscrepancy = last_zero;
+ // check for last device
+ if (0 == LastDiscrepancy)
+ LastDeviceFlag = 1;
+
+ return W1_SUCCESS_STATUS;
+}
+
+/*******************************************************************************
+ Calculating 1-Wire 8-bit CRC
+ Parameters:
+ data - data buffer pointer.
+ length - data length.
+ Returns:
+ CRC value based on polynomial x^8 + x^5 + x^4 + 1
+*******************************************************************************/
+uint8_t halW1CRC(uint8_t *data, uint8_t length)
+{
+ uint8_t reg;
+ uint8_t b;
+
+ for (reg = 0; length > 0; length--, data++)
+ {
+ for (b = 0; b < 8; b++)
+ {
+ if (((*data >> b) & 1) ^ (reg & 1))
+ {
+ reg >>= 1;
+ reg ^= HAL_W1_CRC_POLINOM;
+ }
+ else
+ reg >>= 1;
+ }
+ }
+ return reg;
+}
+
+/*******************************************************************************
+Resets all devices connected to the bus.
+Parameters:
+ none.
+Returns:
+ 0 - there are some devices at the bus.
+ 1 - there are not any devices at the bus.
+*******************************************************************************/
+uint8_t HAL_ResetW1(void)
+{
+ return halResetW1();
+};
+
+/*******************************************************************************
+Writes byte to the bus
+Parameters:
+ value - byte to write.
+Returns:
+ none.
+*******************************************************************************/
+void HAL_WriteW1(uint8_t value)
+{
+ halWriteW1(value);
+}
+
+/*******************************************************************************
+Reads byte from the bus.
+Parameters:
+ none.
+Returns:
+ byte read from the bus.
+*******************************************************************************/
+uint8_t HAL_ReadW1(void)
+{
+ return halReadW1();
+}
+
+// eof halW1.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/ISD/src/isdImageStorage.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/ISD/src/isdImageStorage.c
new file mode 100644
index 00000000..a173da69
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/ISD/src/isdImageStorage.c
@@ -0,0 +1,626 @@
+/**************************************************************************//**
+\file isdImageStorage.c
+
+\brief Implementation of image storage driver.
+
+\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:
+ 25.05.11 A. Khromykh - Created
+*******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifdef _OTAU_
+#if (APP_USE_OTAU == 1)
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <isdImageStorage.h>
+#include <usart.h>
+#include <rs232Controller.h>
+#include <queue.h>
+#include <dbg.h>
+#include <appTimer.h>
+#include <mnUtils.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+// Size of length field in frame
+#define LEN_SIZE (sizeof(((IsdCommandFrame_t*)NULL)->length))
+// Start of frame market
+#define SOF 0x2A
+// 500 ms interbyte timeout should be enough for everyone
+#define INTERBYTE_TIMEOUT 500
+// 5000 ms timeout between request to storage system and response from it.
+#define INTERMESSAGE_TIMEOUT 5000
+#define USART_RX_BUFFER_LENGTH 104
+
+#ifndef APP_MAX_COMMAND_PAYLOAD_SIZE
+ #define APP_MAX_COMMAND_PAYLOAD_SIZE 100
+#endif
+
+// code from runner
+#define ISD_ZCL_COMMAND_INDICATION 0x0046
+#define ISD_ZCL_COMMAND_REQUEST 0x0044
+#define ISD_DRIVER_INIT_REQUEST 0x0100
+#define ISD_DRIVER_INIT_RESPONSE 0x0101
+#define ISD_COMMAND_ID_SIZE (sizeof(uint16_t))
+#define ISD_INIT_MARKER 0x55
+/******************************************************************************
+ Types section
+******************************************************************************/
+// States of tx FSM
+typedef enum _TxState_t
+{
+ TX_ERR_OR_OFF,
+ TX_IDLE,
+ TX_SENDING_SOF,
+ TX_SENDING_DATA,
+} TxState_t;
+
+// States of rx FSM
+typedef enum _RxState_t
+{
+ RX_ERR_OR_OFF,
+ RX_WAITING_START, // AKA IDLE
+ RX_WAITING_LEN,
+ RX_WAITING_DATA,
+} RxState_t;
+
+BEGIN_PACK
+typedef struct PACK _IsdCommandFrame_t
+{
+ uint16_t length;
+ uint16_t commandId;
+ uint8_t payload[APP_MAX_COMMAND_PAYLOAD_SIZE];
+} IsdCommandFrame_t;
+
+typedef struct PACK
+{
+ uint8_t srcAddrMode;
+ ShortAddr_t srcShortAddress;
+ ExtAddr_t srcExtAddress;
+ ProfileId_t srcProfileId;
+ Endpoint_t srcEndpointId;
+ ClusterId_t srcClusterId;
+
+ ClusterId_t clusterId;
+ uint8_t direction;
+ uint8_t commandId;
+ uint8_t payload[1];
+} IsdCommandIndication_t;
+
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(3,(
+ uint8_t direction : 1,
+ uint8_t generalCommand : 1,
+ uint8_t reserved : 6
+ ))
+} IsdCommandOptions_t;
+
+typedef struct PACK
+{
+ uint8_t addrMode;
+ ShortAddr_t shortAddress;
+ ExtAddr_t extAddress;
+ ProfileId_t profileId;
+ uint8_t endpoint;
+ uint8_t dstEndpoint;
+ ClusterId_t clusterId;
+ uint8_t defaultResponse;
+ IsdCommandOptions_t commandOptions;
+ uint8_t commandId;
+ uint8_t recordsCount;
+ uint8_t request[1];
+} IsdCommandRequest_t;
+END_PACK
+
+/******************************************************************************
+ Static Function Prototypes section
+******************************************************************************/
+static void isdUsartReceivedHandler(uint16_t bytesAmount);
+static void isdSendCommandFrame(void);
+static void isdUsartTransmittedHandler(void);
+static void isdInterbyteTimeoutExpired(void);
+static void isdIntermessageTimeoutExpired(void);
+static void isdInitReq(void);
+static void isdInitResp(void);
+static void isdSerialNotify(void);
+static void isdSetState(ISD_Status_t state);
+
+/******************************************************************************
+ Static variables section
+******************************************************************************/
+static HAL_UsartDescriptor_t usartDescriptor;
+static RxState_t rxState = RX_ERR_OR_OFF;
+static TxState_t txState = TX_ERR_OR_OFF;
+static uint8_t usartDescriptorRxBuffer[USART_RX_BUFFER_LENGTH];
+static IsdCommandFrame_t isdBuffer;
+
+static HAL_AppTimer_t interbyteTimer =
+{
+ .interval = INTERBYTE_TIMEOUT,
+ .mode = TIMER_ONE_SHOT_MODE,
+ .callback = isdInterbyteTimeoutExpired,
+};
+
+static HAL_AppTimer_t intermessageTimer =
+{
+ .interval = INTERMESSAGE_TIMEOUT,
+ .mode = TIMER_ONE_SHOT_MODE,
+ .callback = isdIntermessageTimeoutExpired,
+};
+
+static IsdOpenCb_t generalCb;
+static IsdUpgradeEndCb_t upgradeEndCb;
+static IsdQueryNextImageCb_t queryNextImageCb;
+static IsdImageBlockCb_t imageBlockCb;
+
+static ISD_Status_t isdState;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Open image storage driver
+
+\param[in] cb - callback about driver actions
+******************************************************************************/
+void ISD_Open(IsdOpenCb_t cb)
+{
+ // Implementation depends on 'length' field in IsdCommandFrame_t being one byte
+ // In case of change, several modifications would be required
+ assert_static(2 == LEN_SIZE);
+ // Also depends on 'length' field being first field of command frame
+ assert_static(0 == offsetof(IsdCommandFrame_t, length));
+
+#ifdef BSP_ENABLE_RS232_CONTROL
+ BSP_EnableRs232();
+#endif /* BSP_ENABLE_RS232_CONTROL */
+
+ usartDescriptor.tty = APP_USART_CHANNEL;
+ usartDescriptor.mode = USART_MODE_ASYNC;
+ usartDescriptor.flowControl = USART_FLOW_CONTROL_NONE;
+ usartDescriptor.baudrate = USART_BAUDRATE_38400;
+ usartDescriptor.dataLength = USART_DATA8;
+ usartDescriptor.parity = USART_PARITY_NONE;
+ usartDescriptor.stopbits = USART_STOPBIT_1;
+ usartDescriptor.rxBuffer = usartDescriptorRxBuffer;
+ usartDescriptor.rxBufferLength = USART_RX_BUFFER_LENGTH; //BULK_SIZE
+ usartDescriptor.txBuffer = NULL;
+ usartDescriptor.txBufferLength = 0;
+ usartDescriptor.rxCallback = isdUsartReceivedHandler;
+ usartDescriptor.txCallback = isdUsartTransmittedHandler;
+
+ generalCb = cb;
+
+ if (-1 != HAL_OpenUsart(&usartDescriptor))
+ {
+ rxState = RX_WAITING_START;
+ txState = TX_IDLE;
+ isdInitReq();
+ }
+ else
+ {
+ rxState = RX_ERR_OR_OFF;
+ txState = TX_ERR_OR_OFF;
+ isdSetState(ISD_HARDWARE_FAULT);
+ }
+}
+
+/**************************************************************************//**
+\brief Request to storage system about communication.
+******************************************************************************/
+static void isdInitReq(void)
+{
+ isdBuffer.commandId = ISD_DRIVER_INIT_REQUEST;
+ isdBuffer.length = ISD_COMMAND_ID_SIZE + sizeof(uint8_t);
+ isdBuffer.payload[0] = ISD_INIT_MARKER;
+
+ HAL_StartAppTimer(&intermessageTimer);
+ isdSendCommandFrame();
+}
+
+/**************************************************************************//**
+\brief Response from storage system about communication.
+******************************************************************************/
+static void isdInitResp(void)
+{
+ HAL_StopAppTimer(&intermessageTimer);
+
+ if (ISD_INIT_MARKER != isdBuffer.payload[0])
+ isdSetState(ISD_COMMUNICATION_LOST);
+ else
+ isdSetState(ISD_SUCCESS);
+}
+
+/**************************************************************************//**
+\brief Close image storage driver
+******************************************************************************/
+void ISD_Close(void)
+{
+ rxState = RX_ERR_OR_OFF;
+ txState = TX_ERR_OR_OFF;
+ HAL_CloseUsart(&usartDescriptor);
+}
+
+/**************************************************************************//**
+\brief Reset rx FSM on expiration of interbyte timeout
+******************************************************************************/
+static void isdInterbyteTimeoutExpired(void)
+{
+ if (RX_ERR_OR_OFF != rxState)
+ rxState = RX_WAITING_START;
+}
+
+/**************************************************************************//**
+\brief Callback about timout expiration between request and response
+******************************************************************************/
+static void isdIntermessageTimeoutExpired(void)
+{
+ isdSetState(ISD_COMMUNICATION_LOST);
+ isdInitReq();
+}
+
+/**************************************************************************//**
+\brief Callback on reception of serial byte(s)
+
+\param[in] bytesAmount number of received bytes
+******************************************************************************/
+static void isdUsartReceivedHandler(uint16_t bytesAmount)
+{
+ static uint16_t rxCnt = 0;
+ while (bytesAmount)
+ {
+ switch (rxState)
+ {
+ case RX_WAITING_START:
+ {
+ uint8_t data;
+ if (HAL_ReadUsart(&usartDescriptor, &data, sizeof(uint8_t)) <= 0)
+ {
+ rxState = RX_ERR_OR_OFF;
+ isdSetState(ISD_HARDWARE_FAULT);
+ return;
+ }
+ if (SOF == data)
+ rxState = RX_WAITING_LEN;
+
+ bytesAmount--;
+ }
+ break;
+
+ case RX_WAITING_LEN:
+ {
+ if (bytesAmount >= sizeof(uint16_t))
+ {
+ if (HAL_ReadUsart(&usartDescriptor, (uint8_t *)&isdBuffer.length, sizeof(uint16_t)) <= 0)
+ {
+ rxState = RX_ERR_OR_OFF;
+ isdSetState(ISD_HARDWARE_FAULT);
+ return;
+ }
+
+ // Limit length to avoid possible buffer overflow
+ isdBuffer.length = MIN(isdBuffer.length, sizeof(IsdCommandFrame_t) - LEN_SIZE);
+
+ if (isdBuffer.length > 0)
+ rxState = RX_WAITING_DATA;
+ else
+ rxState = RX_WAITING_START; // Do not allow zero len
+
+ bytesAmount -= sizeof(uint16_t);
+ rxCnt = 0;
+ }
+ else
+ return;
+ }
+ break;
+
+ case RX_WAITING_DATA:
+ {
+ int readCnt;
+ uint8_t *readPtr = (uint8_t *)&isdBuffer;
+
+ readPtr += offsetof(IsdCommandFrame_t, commandId) + rxCnt;
+ readCnt = HAL_ReadUsart(&usartDescriptor, readPtr, MIN(bytesAmount, (uint16_t) (isdBuffer.length - rxCnt)));
+
+ if (readCnt <= 0)
+ {
+ rxState = RX_ERR_OR_OFF;
+ isdSetState(ISD_HARDWARE_FAULT);
+ return;
+ }
+
+ bytesAmount -= readCnt;
+ rxCnt += readCnt;
+ if (rxCnt >= isdBuffer.length)
+ {
+ // Full packet is received
+ rxState = RX_WAITING_START;
+ isdSerialNotify();
+ }
+ }
+ break;
+
+ case RX_ERR_OR_OFF:
+ default:
+ return;
+ }
+ }
+
+ HAL_StopAppTimer(&interbyteTimer);
+
+ if (RX_WAITING_DATA == rxState || RX_WAITING_LEN == rxState)
+ HAL_StartAppTimer(&interbyteTimer);
+}
+
+/**************************************************************************//**
+\brief Sends new command frame
+
+\return result code
+******************************************************************************/
+static void isdSendCommandFrame(void)
+{
+ static uint8_t sof = SOF;
+
+ if (HAL_WriteUsart(&usartDescriptor, &sof, sizeof(sof)) > 0)
+ {
+ txState = TX_SENDING_SOF;
+ }
+ else
+ {
+ txState = TX_ERR_OR_OFF;
+ isdSetState(ISD_HARDWARE_FAULT);
+ }
+}
+
+/**************************************************************************//**
+\brief Callback on completion of single serial transmit
+******************************************************************************/
+static void isdUsartTransmittedHandler(void)
+{
+ switch (txState)
+ {
+ case TX_SENDING_SOF:
+ {
+ uint8_t *writePtr = (uint8_t *)&isdBuffer;
+
+ writePtr += offsetof(IsdCommandFrame_t, length);
+ if (HAL_WriteUsart(&usartDescriptor, writePtr, isdBuffer.length + LEN_SIZE) <= 0)
+ {
+ txState = TX_ERR_OR_OFF;
+ isdSetState(ISD_HARDWARE_FAULT);
+ }
+ else
+ txState = TX_SENDING_DATA;
+ }
+ break;
+
+ case TX_SENDING_DATA:
+ txState = TX_IDLE;
+ break;
+
+ case TX_IDLE:
+ case TX_ERR_OR_OFF:
+ default:
+ break;
+ }
+}
+
+/**************************************************************************//**
+\brief Send query next image request to storage system
+
+\param[in] addressing - pointer to structure that include client network information; \n
+\param[in] data - data payload; \n
+\param[in] cd - callback about response receiving from storage system.
+******************************************************************************/
+void ISD_QueryNextImageReq(ZCL_Addressing_t *addressing, ZCL_OtauQueryNextImageReq_t *data, IsdQueryNextImageCb_t cb)
+{
+ IsdCommandIndication_t *serialData = (IsdCommandIndication_t *)isdBuffer.payload;
+
+ if (ISD_SUCCESS != isdState)
+ return;
+
+ serialData->clusterId = addressing->clusterId;
+ serialData->commandId = QUERY_NEXT_IMAGE_REQUEST_ID;
+ serialData->srcAddrMode = addressing->addrMode;
+ serialData->srcShortAddress = addressing->addr.shortAddress;
+ serialData->srcExtAddress = addressing->addr.extAddress;
+ serialData->srcProfileId = addressing->profileId;
+ serialData->srcEndpointId = addressing->endpointId;
+ serialData->srcClusterId = addressing->clusterId;
+ serialData->direction = addressing->clusterSide;
+
+ memcpy(serialData->payload, data, sizeof(ZCL_OtauQueryNextImageReq_t));
+
+ isdBuffer.commandId = ISD_ZCL_COMMAND_INDICATION;
+ isdBuffer.length = ISD_COMMAND_ID_SIZE + sizeof(IsdCommandIndication_t) +
+ sizeof(ZCL_OtauQueryNextImageReq_t) - sizeof(uint8_t);
+
+ queryNextImageCb = cb;
+
+ HAL_StartAppTimer(&intermessageTimer);
+ isdSendCommandFrame();
+}
+
+/**************************************************************************//**
+\brief Send image block request to storage system
+
+\param[in] addressing - pointer to structure that include client network information; \n
+\param[in] data - data payload; \n
+\param[in] cd - callback about response receiving from storage system.
+******************************************************************************/
+void ISD_ImageBlockReq(ZCL_Addressing_t *addressing, ZCL_OtauImageBlockReq_t *data, IsdImageBlockCb_t cb)
+{
+ IsdCommandIndication_t *serialData = (IsdCommandIndication_t *)isdBuffer.payload;
+
+ if (ISD_SUCCESS != isdState)
+ return;
+
+ serialData->clusterId = addressing->clusterId;
+ serialData->commandId = IMAGE_BLOCK_REQUEST_ID;
+ serialData->srcAddrMode = addressing->addrMode;
+ serialData->srcShortAddress = addressing->addr.shortAddress;
+ serialData->srcExtAddress = addressing->addr.extAddress;
+ serialData->srcProfileId = addressing->profileId;
+ serialData->srcEndpointId = addressing->endpointId;
+ serialData->srcClusterId = addressing->clusterId;
+ serialData->direction = addressing->clusterSide;
+
+ memcpy(serialData->payload, data, sizeof(ZCL_OtauImageBlockReq_t));
+
+ isdBuffer.commandId = ISD_ZCL_COMMAND_INDICATION;
+ isdBuffer.length = ISD_COMMAND_ID_SIZE + sizeof(IsdCommandIndication_t) +
+ sizeof(ZCL_OtauImageBlockReq_t) - sizeof(uint8_t);
+
+ imageBlockCb = cb;
+
+ HAL_StartAppTimer(&intermessageTimer);
+ isdSendCommandFrame();
+}
+
+/**************************************************************************//**
+\brief Send upgrade end request to storage system
+
+\param[in] addressing - pointer to structure that include client network information; \n
+\param[in] data - data payload; \n
+\param[in] cd - callback about response receiving from storage system.
+******************************************************************************/
+void ISD_UpgradeEndReq(ZCL_Addressing_t *addressing, ZCL_OtauUpgradeEndReq_t *data, IsdUpgradeEndCb_t cb)
+{
+ IsdCommandIndication_t *serialData = (IsdCommandIndication_t *)isdBuffer.payload;
+
+ if (ISD_SUCCESS != isdState)
+ return;
+
+ serialData->clusterId = addressing->clusterId;
+ serialData->commandId = UPGRADE_END_REQUEST_ID;
+ serialData->srcAddrMode = addressing->addrMode;
+ serialData->srcShortAddress = addressing->addr.shortAddress;
+ serialData->srcExtAddress = addressing->addr.extAddress;
+ serialData->srcProfileId = addressing->profileId;
+ serialData->srcEndpointId = addressing->endpointId;
+ serialData->srcClusterId = addressing->clusterId;
+ serialData->direction = addressing->clusterSide;
+
+ memcpy(serialData->payload, data, sizeof(ZCL_OtauUpgradeEndReq_t));
+
+ isdBuffer.commandId = ISD_ZCL_COMMAND_INDICATION;
+ isdBuffer.length = ISD_COMMAND_ID_SIZE + sizeof(IsdCommandIndication_t) +
+ sizeof(ZCL_OtauUpgradeEndReq_t) - sizeof(uint8_t);
+
+ upgradeEndCb = cb;
+
+ HAL_StartAppTimer(&intermessageTimer);
+ isdSendCommandFrame();
+}
+
+/**************************************************************************//**
+\brief Receive any messages from storage system
+******************************************************************************/
+static void isdSerialNotify(void)
+{
+ IsdCommandRequest_t *req = (IsdCommandRequest_t *)isdBuffer.payload;
+
+ if (ISD_DRIVER_INIT_RESPONSE == isdBuffer.commandId)
+ {
+ isdInitResp();
+ return;
+ }
+
+ if (ISD_ZCL_COMMAND_REQUEST != isdBuffer.commandId)
+ return;
+
+ if (OTAU_CLUSTER_ID != req->clusterId)
+ return;
+
+ switch (req->commandId)
+ {
+ case QUERY_NEXT_IMAGE_RESPONSE_ID:
+ {
+ ZCL_OtauQueryNextImageResp_t *resp = (ZCL_OtauQueryNextImageResp_t *)req->request;
+
+ HAL_StopAppTimer(&intermessageTimer);
+ if (queryNextImageCb)
+ {
+ queryNextImageCb(resp);
+ queryNextImageCb = NULL;
+ }
+ }
+ break;
+ case IMAGE_BLOCK_RESPONSE_ID:
+ {
+ ZCL_OtauImageBlockResp_t *resp = (ZCL_OtauImageBlockResp_t *)req->request;
+
+ HAL_StopAppTimer(&intermessageTimer);
+ if (imageBlockCb)
+ {
+ imageBlockCb(resp);
+ imageBlockCb = NULL;
+ }
+ }
+ break;
+ case UPGRADE_END_RESPONSE_ID:
+ {
+ ZCL_OtauUpgradeEndResp_t *resp = (ZCL_OtauUpgradeEndResp_t *)req->request;
+
+ HAL_StopAppTimer(&intermessageTimer);
+ if (upgradeEndCb)
+ {
+ upgradeEndCb(resp);
+ upgradeEndCb = NULL;
+ }
+ else
+ {
+ ZCL_Addressing_t addr =
+ {
+ .addrMode = req->addrMode,
+ .profileId = req->profileId,
+ .endpointId = req->dstEndpoint,
+ .clusterId = req->clusterId,
+ .clusterSide = ZCL_CLIENT_CLUSTER_TYPE,
+ .manufacturerSpecCode = 0,
+ };
+
+ if (APS_EXT_ADDRESS == addr.addrMode)
+ addr.addr.extAddress = req->extAddress;
+ else
+ addr.addr.shortAddress = req->shortAddress;
+
+ ZCL_UnsolicitedUpgradeEndResp(&addr, resp);
+ }
+ }
+ break;
+ }
+}
+
+/**************************************************************************//**
+\brief Set actual driver state and report to high layer about that.
+
+\param[in] state - actual driver state
+******************************************************************************/
+static void isdSetState(ISD_Status_t state)
+{
+ isdState = state;
+
+ if (generalCb)
+ generalCb(state);
+}
+
+#endif // (APP_USE_OTAU == 1)
+#endif // _OTAU_
+
+// eof isdImageStorage.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/Makefile b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/Makefile
new file mode 100644
index 00000000..ef22558f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/Makefile
@@ -0,0 +1,107 @@
+COMPONENTS_PATH = ../../..
+#include $(COMPONENTS_PATH)/Makerules
+include $(MAKERULES)
+
+DEBUG = NO
+###### Option to switch on the fake driver ##########
+ifndef APP_USE_FAKE_OFD_DRIVER
+ APP_USE_FAKE_OFD_DRIVER = 0
+endif
+
+# Hardware flags.
+CFLAGS += $(CFLAGS_HW)
+
+##### PATHS FLAGS OF INCLUDES #########
+CFLAGS += -I./include
+CFLAGS += -I./../include
+CFLAGS += -I$(HAL_PATH)/include
+CFLAGS += -I$(HAL_HWD_COMMON_PATH)/include
+CFLAGS += -I$(SE_PATH)/include
+
+ifeq ($(DEBUG), YES)
+ CFLAGS += -D_DEBUG_
+endif
+
+#### ASM DEFINES FLAGS #######
+ifeq ($(COMPILER_TYPE), GCC)
+ ASMFLAGS = $(filter -mmcu%,$(CFLAGS))
+ ASM_FILE_EXT = s
+endif
+ifeq ($(COMPILER_TYPE), IAR)
+ ASMFLAGS = -s+ # Enables case sensitivity.
+ ASMFLAGS += -w+ # Enables warnings.
+ ASMFLAGS += -M'<>'# Change asm.macro argument quote chars.
+ ASMFLAGS += -t8 # Set tab spacing.
+ ASMFLAGS += -u_enhancedCore
+ ASMFLAGS += -D__HAS_ENHANCED_CORE__=1
+ ASMFLAGS += -D__HAS_MUL__=1
+ ASMFLAGS += -D__MEMORY_MODEL__=2
+ ifneq (, $(findstring $(HAL), ATMEGA1281 ATMEGA1284 AT90USB1287 ATMEGA128RFA1))
+ ASMFLAGS += -v3 # Select processor option: Relative jumps do not wrap.
+ endif
+ ifneq (, $(findstring $(HAL), ATMEGA2561 ATXMEGA256A3 ATXMEGA256D3))
+ ASMFLAGS += -v5 # Select processor option: Relative jumps do not wrap.
+ endif
+ ifneq (, $(findstring $(HAL), ATXMEGA256A3 ATXMEGA256D3))
+ ASMFLAGS += --xmega #Enable Xmega specific instructions
+ endif
+ ASMFLAGS += -D__HAS_ELPM__=1
+ ASMFLAGS += -S
+ ASM_FILE_EXT = s90
+endif
+
+###### LIB ##########
+BUILDDIR = .
+
+LIBDIR = ./../lib
+LDFLAGS = -L$(LIBDIR)
+PROG = OFD.elf
+LIBS = $(LIBDIR)/lib$(OFD_LIB).a
+
+driver_label:
+ @echo
+ @echo ----------------------------------------------------
+ @echo Otau flash driver library creation.
+ @echo ----------------------------------------------------
+
+ifneq ($(APP_USE_FAKE_OFD_DRIVER), 1)
+modules = \
+ ofdAt25fDriver \
+ ofdAt45dbDriver \
+ ofdCommand \
+ ofdCrcService \
+ ofdSpiSerializer
+
+asm_modules = \
+ ofdIntFlashRead
+else
+modules = \
+ ofdFakeDriver
+endif
+
+objects = $(addsuffix .o,$(addprefix $(BUILDDIR)/objs/,$(modules)))
+sources = $(addsuffix .c,$(addprefix $(BUILDDIR)/src/,$(modules)))
+objects_asm = $(addsuffix .o,$(addprefix $(BUILDDIR)/objs/,$(asm_modules)))
+sources_asm = $(addsuffix .$(ASM_FILE_EXT),$(addprefix $(BUILDDIR)/src/,$(asm_modules)))
+
+###### TARGETS ################
+all: driver_label LIB_OFD
+
+################ c part ######################
+$(BUILDDIR)/objs/%.o: $(BUILDDIR)/src/%.c
+ $(CC) $(CFLAGS) $^ -o $@
+
+################ assembler part ######################
+$(BUILDDIR)/objs/%.o: $(BUILDDIR)/src/%.$(ASM_FILE_EXT)
+ $(AS) $(ASMFLAGS) -o $@ $^
+
+################
+LIB_OFD : $(objects) $(objects_asm)
+ $(AR) $(AR_KEYS) $(LIBDIR)/lib$(OFD_LIB).a $(objects) $(objects_asm)
+ $(SIZE) -td $(LIBDIR)/lib$(OFD_LIB).a
+################
+clean:
+ @echo ----------------------------------------------------
+ @echo OTAU flash driver cleaning.
+ @echo ----------------------------------------------------
+ rm -f $(objects) $(objects_asm) $(LIBS) $(BUILDDIR)/list/*.* \ No newline at end of file
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/include/ofdMemoryDriver.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/include/ofdMemoryDriver.h
new file mode 100644
index 00000000..d158af26
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/include/ofdMemoryDriver.h
@@ -0,0 +1,310 @@
+/**************************************************************************//**
+\file ofdMemoryDriver.h
+
+\brief The implementation interface of external flash.
+
+\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:
+ 31/07/09 A. Khromykh - Created
+*******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+#ifndef _OFDMEMORYDRIVER_H
+#define _OFDMEMORYDRIVER_H
+
+#ifdef _OTAU_
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <gpio.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#if EXTERNAL_MEMORY == AT25F2048
+
+ #if !defined(ATMEGA1281) && !defined(ATMEGA128RFA1)
+ #error 'at25f2048 is supported only for atmega1281/128rfa1.'
+ #endif
+
+ // flash instruction format (see at25f2048 manual)
+ #define WREN 0x06
+ #define WRDI 0x04
+ #define RDSR 0x05
+ #define WRSR 0x01
+ #define READ 0x03
+ #define PROGRAM 0x02
+ #define SECTOR_ERASE 0x52
+ #define CHIP_ERASE 0x62
+ #define RDID 0x15
+
+ // status register bits
+ #define RDY 0x01
+ #define WEN 0x02
+ #define BP0 0x04
+ #define BP1 0x08
+ #define WPEN 0x80
+
+ // Atmel ID
+ #define OFD_MANUFACTURER_ID 0x1F
+ // at25f2048
+ #define OFD_DEVICE_ID 0x63
+
+ #define PAGE_SIZE 256
+
+ // flash sectors
+ #define SECTOR_ONE 0x00000000ul
+ #define SECTOR_TWO 0x00010000ul
+ #define SECTOR_THREE 0x00020000ul
+ #define SECTOR_FOUR 0x00030000ul
+ // 2 Mbits
+ #define OFD_FLASH_SIZE 262144
+ // image consists mcu flash - bootloader size + eeprom size. 128k - 4k + 4k
+ #define OFD_IMAGE_SIZE 131072
+ #define OFD_FLASH_START_ADDRESS 0
+ #define OFD_IMAGE1_START_ADDRESS OFD_FLASH_START_ADDRESS
+ #define OFD_IMAGE2_START_ADDRESS (OFD_FLASH_START_ADDRESS + OFD_IMAGE_SIZE)
+
+ #define OFD_MCU_FLASH_SIZE OFD_IMAGE_SIZE
+ #define OFD_MCU_EEPROM_SIZE 4096
+ #define OFD_EEPROM_OFFSET_WITHIN_IMAGE (OFD_MCU_FLASH_SIZE - OFD_MCU_EEPROM_SIZE)
+ // 1 byte (action for bootloader), 2 bytes (images crc), 1 byte table of image types.
+ #define OFD_SERVICE_INFO_SIZE 4
+
+#elif EXTERNAL_MEMORY == AT45DB041
+
+ #if !defined(ATMEGA1281) && !defined(ATMEGA128RFA1) && !defined(ATXMEGA256A3) && !defined(ATXMEGA256D3)
+ #error 'at45db041 is supported only for atmega1281/128rfa1, atxmega256a/d3.'
+ #endif
+
+ // flash instruction format (see at45db041 manual)
+ #define WRITE_BUF1 0x84
+ #define WRITE_BUF2 0x87
+ #define RDSR 0xD7
+ #define READ 0xE8
+ #define PROGRAM_BUF1 0x88
+ #define PROGRAM_BUF2 0x89
+ #define BLOCK_ERASE 0x50
+
+ // status register bits
+ #define RDY 0x80
+ // unchanged bit mask within status register xx0111xx
+ #define STATUS_UNCHANGED_BIT_MASK 0x3C
+ #define STATUS_UNCHANGED_BITS 0x1C
+
+ #define PAGE_SIZE 264
+ // block addresses
+ #define FIRST_HALF_BLOCK_NUMBER 0
+ #define SECOND_HALF_BLOCK_NUMBER 128
+
+ // 4 Mbits
+ #define OFD_FLASH_SIZE 540672
+
+ #if defined(ATMEGA1281) || defined(ATMEGA128RFA1)
+ // image consists mcu flash - bootloader size + eeprom size. 128k - 4k + 4k
+ // image uses 497 pages. 1 block = 8 pages
+ #define OFD_USED_BLOCKS_AMOUNT 63
+ #define OFD_IMAGE_SIZE 131072
+ #define OFD_MCU_FLASH_SIZE OFD_IMAGE_SIZE
+ #define OFD_EEPROM_OFFSET_WITHIN_IMAGE (OFD_MCU_FLASH_SIZE - OFD_MCU_EEPROM_SIZE)
+ #define OFD_LOAD_NO_COMMAND_TO_NVM
+ #elif defined(ATXMEGA256A3) || defined(ATXMEGA256D3)
+ // image consists mcu flash + eeprom size. 256k + 4k
+ // image uses 1009 pages. 1 block = 8 pages
+ #define OFD_USED_BLOCKS_AMOUNT 128
+ #define OFD_IMAGE_SIZE 266240
+ #define OFD_MCU_FLASH_SIZE 262144
+ #define OFD_EEPROM_OFFSET_WITHIN_IMAGE OFD_MCU_FLASH_SIZE
+ #define OFD_LOAD_NO_COMMAND_TO_NVM NVM.CMD = NVM_CMD_NO_OPERATION_gc
+ #endif
+
+ #define OFD_FLASH_START_ADDRESS 0
+ #define OFD_IMAGE1_START_ADDRESS OFD_FLASH_START_ADDRESS
+ #define OFD_IMAGE2_START_ADDRESS 270336
+
+ #define OFD_MCU_EEPROM_SIZE 4096
+ // 1 byte (action for bootloader), 2 bytes (images crc), 1 byte table of image types.
+ #define OFD_SERVICE_INFO_SIZE 4
+
+#elif EXTERNAL_MEMORY == AT25DF041A
+
+ #if !defined(ATXMEGA256A3) && !defined(ATXMEGA256D3)
+ #error 'at25df041a is supported only for atxmega256a3.'
+ #endif
+
+ // flash instruction format (see at25df041a manual)
+ #define WREN 0x06
+ #define WRDI 0x04
+ #define RDSR 0x05
+ #define WRSR 0x01
+ #define READ 0x03
+ #define PROGRAM 0x02
+ #define SECTOR_ERASE 0xD8
+ #define CHIP_ERASE 0x60
+ #define RDID 0x9F
+ #define PROTECT_SECTOR 0x36
+ #define UNPROTECT_SECTOR 0x39
+
+ // status register arguments
+ #define GLOBAL_UNPROTECT 0x00
+ #define GLOBAL_PROTECT 0x7F
+
+ // status register bits
+ #define RDY 0x01
+ #define WEN 0x02
+ #define SWP0 0x04
+ #define SWP1 0x08
+ #define WPP 0x10
+ #define EPE 0x20
+ #define SPM 0x40
+ #define WPRL 0x80
+
+ // Atmel ID
+ #define OFD_MANUFACTURER_ID 0x1F
+ // at25df041a
+ #define OFD_DEVICE_ID_1 0x44
+ #define OFD_DEVICE_ID_2 0x01
+ #define EXT_STRING_LENGTH 0x00
+
+ #define PAGE_SIZE 256
+
+ // flash sectors
+ #define SECTOR_ONE 0x00000000ul
+ #define SECTOR_TWO 0x00010000ul
+ #define SECTOR_THREE 0x00020000ul
+ #define SECTOR_FOUR 0x00030000ul
+ // 4 Mbits
+ #define OFD_FLASH_SIZE 524288
+ // image consists mcu flash size + eeprom size. 256k + 4k
+ #define OFD_IMAGE_SIZE 266240
+ #define OFD_FLASH_START_ADDRESS 0
+ #define OFD_IMAGE1_START_ADDRESS OFD_FLASH_START_ADDRESS
+ // this is fake start address used for code compatibility
+ #define OFD_IMAGE2_START_ADDRESS (OFD_FLASH_START_ADDRESS + OFD_IMAGE_SIZE)
+
+ #define OFD_MCU_FLASH_SIZE OFD_IMAGE_SIZE
+ #define OFD_MCU_EEPROM_SIZE 4096
+ #define OFD_EEPROM_OFFSET_WITHIN_IMAGE (OFD_MCU_FLASH_SIZE - OFD_MCU_EEPROM_SIZE)
+ // 1 byte (action for bootloader), 2 bytes (images crc), 1 byte table of image types.
+ #define OFD_SERVICE_INFO_SIZE 4
+
+#else
+ #error 'Unknown memory type.'
+#endif
+
+#define OFD_START_EEPROM_SREC_ADDRESS 0x810000
+#define OFD_LITTLE_TO_BIG_ENDIAN(A) ((((uint32_t)A & 0xFFul) << 24) \
+ | (((uint32_t)A & 0xFF00ul) << 8) \
+ | (((uint32_t)A >> 8) & 0xFF00ul) \
+ | (((uint32_t)A >> 24) & 0xFFul))
+
+
+typedef struct
+{
+ union
+ {
+ uint32_t flashOffset;
+ uint16_t eepromOffset;
+ };
+ uint8_t *data;
+ uint32_t length;
+} OfdInternalMemoryAccessParam_t;
+
+// image type table
+typedef uint8_t OfdImageTable_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Starts image erasing in the external memory.
+******************************************************************************/
+void ofdEraseImage(void);
+
+/**************************************************************************//**
+\brief Writes data to the external memory.
+******************************************************************************/
+void ofdWriteData(void);
+
+/**************************************************************************//**
+\brief Checks image crc.
+******************************************************************************/
+void ofdCheckCrc(void);
+
+/**************************************************************************//**
+\brief Starts saving internal flash.
+******************************************************************************/
+void ofdSaveCurrentFlashImage(void);
+
+/**************************************************************************//**
+\brief Reads image crc from internal eeprom.
+******************************************************************************/
+void ofdReadCrc(void);
+
+/**************************************************************************//**
+\brief Counts crc current memory area. CRC-8. Polynom 0x31 x^8 + x^5 + x^4 + 1.
+
+\param[in]
+ crc - first crc state
+\param[in]
+ pcBlock - pointer to the memory for crc counting
+\param[in]
+ length - memory size
+
+\return
+ current area crc
+******************************************************************************/
+uint8_t ofdCrc(uint8_t crc, uint8_t *pcBlock, uint8_t length);
+
+/**************************************************************************//**
+\brief Finds storage space.
+******************************************************************************/
+void ofdFindStorageSpace(void);
+
+/**************************************************************************//**
+\brief Sets action for internal bootloader.
+******************************************************************************/
+void ofdSetActionForBootloader(void);
+
+/**************************************************************************//**
+\brief Flushs memory buffer to flash.
+******************************************************************************/
+void ofdFlushData(void);
+
+#if EXTERNAL_MEMORY == AT25DF041A
+/**************************************************************************//**
+\brief Unprotects memory sectors for writing and erasing.
+******************************************************************************/
+void ofdUnprotectMemorySectors(void);
+#endif
+
+/******************************************************************************
+ Inline static functions prototypes section.
+******************************************************************************/
+// Macros for the EXT_MEM_CS pin manipulation.
+#if defined(ATMEGA1281)
+
+HAL_ASSIGN_PIN(EXT_MEM_CS, F, 3);
+
+#elif defined(ATMEGA128RFA1)
+
+HAL_ASSIGN_PIN(EXT_MEM_CS, G, 5);
+
+#elif defined(ATXMEGA256A3) || defined(ATXMEGA256D3)
+
+HAL_ASSIGN_PIN(EXT_MEM_CS, D, 4);
+
+#endif
+
+#endif // _OTAU_
+
+#endif /* _OFDMEMORYDRIVER_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdAt25Driver.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdAt25Driver.c
new file mode 100644
index 00000000..4f470eb4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdAt25Driver.c
@@ -0,0 +1,742 @@
+/**************************************************************************//**
+\file ofdAt25fDriver.c
+
+\brief Implementation of chip-flash interface.
+
+\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:
+ 5/12/07 A. Khromykh - Created
+*******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifdef _OTAU_
+#if ((EXTERNAL_MEMORY == AT25F2048) ||(EXTERNAL_MEMORY == AT25DF041A)) && (APP_USE_OTAU == 1)
+#if APP_USE_FAKE_OFD_DRIVER == 0
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <ofdExtMemory.h>
+#include <ofdMemoryDriver.h>
+#include <spi.h>
+#include <eeprom.h>
+#include <appTimer.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define SPI_BUSY_POLL_PERIOD 10
+// cycles of counting flash crc before context gap.
+#define ATOMIC_COUNTING 128
+#define EEPROM_OK 0
+#define EEPROM_BUSY -2
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum
+{
+ FLASH_BUSY,
+ FLASH_READY
+} FlashBusyState_t;
+
+typedef enum
+{
+ FLASH_TRANSACTION,
+ EEPROM_TRANSACTION
+} DelayedTransactionType_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+static inline uint8_t ofdReadStatusRegister(void);
+static inline void ofdStartPollTimer(DelayedTransactionType_t type);
+static void ofdReadImageTable(void);
+static void ofdSaveCrcCallback(void);
+static void ofdContinueEraseImage(void);
+static void ofdSaveCurrentEepromImage(void);
+static void ofdFlushCrcCallback(OFD_Status_t status, OFD_ImageInfo_t *pInfo);
+static void ofdSaveCurrentEepromImageContinue(void);
+static void ofdPollBusyState(void);
+static void ofdStartFlashDelayedTransaction(void);
+static void ofdStartEepromDelayedTransaction(void);
+uint8_t ofdReadInternalFlash(uint32_t flashAddress);
+#if defined(_OFD_DEBUG_)
+void ofdReadData(uint32_t address, uint8_t *data, uint16_t size, OFD_Callback_t cb);
+#endif
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+extern HAL_SpiDescriptor_t spiDesc;
+extern OFD_Position_t sectorNumber;
+extern OFD_Position_t actionSector;
+extern OFD_Callback_t ofdCallback;
+extern OFD_Callback_t ofdAuxCallback;
+extern OFD_MemoryAccessParam_t localAccessStructure;
+extern OFD_ImageInfo_t imageInfo;
+extern OfdImageTable_t imageTable;
+extern OfdInternalMemoryAccessParam_t internalAccessParam;
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+static HAL_AppTimer_t ofdBusyTimer =
+{
+ .interval = SPI_BUSY_POLL_PERIOD,
+ .mode = TIMER_ONE_SHOT_MODE,
+};
+void (* delayedTransaction)(void) = NULL;
+#if defined(_OFD_DEBUG_)
+static HAL_UsartDescriptor_t usartDescriptor;
+static uint32_t debugOffset = 0ul;
+static uint8_t debugBuffer[OFD_BLOCK_SIZE];
+#endif
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Checks flash station.
+
+\return flash states: \n
+ FLASH_BUSY \n
+ FLASH_READY
+******************************************************************************/
+static inline FlashBusyState_t ofdCheckBusyState(void)
+{
+ uint8_t statusReg = ofdReadStatusRegister();
+
+ if (!(statusReg & RDY))
+ return FLASH_READY;
+
+ return FLASH_BUSY;
+}
+
+/**************************************************************************//**
+\brief Starts flash delayed transaction.
+******************************************************************************/
+static void ofdStartFlashDelayedTransaction(void)
+{
+ if (FLASH_READY == ofdCheckBusyState())
+ delayedTransaction();
+ else
+ ofdStartPollTimer(FLASH_TRANSACTION);
+}
+
+/**************************************************************************//**
+\brief Starts eeprom delayed transaction.
+******************************************************************************/
+static void ofdStartEepromDelayedTransaction(void)
+{
+ if (!HAL_IsEepromBusy())
+ delayedTransaction();
+ else
+ ofdStartPollTimer(EEPROM_TRANSACTION);
+}
+
+/**************************************************************************//**
+\brief Starts timer for start delayed transaction.
+
+\param[in]
+ type - transaction type (flash or eeprom)
+******************************************************************************/
+static inline void ofdStartPollTimer(DelayedTransactionType_t type)
+{
+ if (FLASH_TRANSACTION == type)
+ ofdBusyTimer.callback = ofdStartFlashDelayedTransaction;
+ else
+ ofdBusyTimer.callback = ofdStartEepromDelayedTransaction;
+
+ HAL_StartAppTimer(&ofdBusyTimer);
+}
+
+/**************************************************************************//**
+\brief Routine of eeprom access.
+\param[in]
+ result - result of hal eeprom action
+\param[in]
+ action - initiator action
+\return
+ false - incorrect parameters
+ true - eeprom transaction is started
+******************************************************************************/
+static bool ofdEepromHandler(int result, void(* action)())
+{
+ switch (result)
+ {
+ case EEPROM_OK:
+ return true;
+ case EEPROM_BUSY:
+ delayedTransaction = action;
+ ofdStartPollTimer(EEPROM_TRANSACTION);
+ return true;
+ default:
+ return false;
+ }
+}
+
+/**************************************************************************//**
+\brief Returns SUCCESS status.
+******************************************************************************/
+static void ofdReturnSuccessStatus(void)
+{
+ if (ofdCallback)
+ ofdCallback(OFD_STATUS_SUCCESS);
+}
+
+/**************************************************************************//**
+\brief Reads image table.
+******************************************************************************/
+static void ofdReadImageTable(void)
+{
+ HAL_EepromParams_t params;
+
+ params.address = OFD_SERVICE_INFO_SIZE - sizeof(OfdImageTable_t);
+ params.data = &imageTable;
+ params.length = sizeof(OfdImageTable_t);
+
+ if (!ofdEepromHandler(HAL_ReadEeprom(&params, ofdReturnSuccessStatus), ofdReadImageTable))
+ if (ofdCallback)
+ ofdCallback(OFD_STATUS_INCORRECT_EEPROM_PARAMETER);
+}
+
+/**************************************************************************//**
+\brief Reads manufacturer ID and chip ID.
+******************************************************************************/
+void ofdFindStorageSpace(void)
+{
+ uint64_t manufacId = RDID;
+
+ if (FLASH_BUSY == ofdCheckBusyState())
+ { // waits till flash ready
+ delayedTransaction = ofdFindStorageSpace;
+ ofdStartPollTimer(FLASH_TRANSACTION);
+ return;
+ }
+
+ GPIO_EXT_MEM_CS_clr();
+#if EXTERNAL_MEMORY == AT25F2048
+ HAL_ReadSpi(&spiDesc, (uint8_t *)&manufacId, sizeof(uint32_t)-1);
+#elif EXTERNAL_MEMORY == AT25DF041A
+ HAL_ReadSpi(&spiDesc, (uint8_t *)&manufacId, sizeof(uint64_t)-3);
+#endif
+ GPIO_EXT_MEM_CS_set();
+
+ if (OFD_MANUFACTURER_ID == (uint8_t)(manufacId >> 8))
+ {
+#if EXTERNAL_MEMORY == AT25F2048
+ if (OFD_DEVICE_ID == (uint8_t)(manufacId >> 16))
+#elif EXTERNAL_MEMORY == AT25DF041A
+ if ((OFD_DEVICE_ID_1 == (uint8_t)(manufacId >> 16)) &&
+ (OFD_DEVICE_ID_2 == (uint8_t)(manufacId >> 24)) &&
+ (EXT_STRING_LENGTH == (uint8_t)(manufacId >> 32)))
+#endif
+ {
+ // read image table to global variable
+ ofdReadImageTable();
+ return;
+ }
+ }
+
+ if (ofdCallback)
+ ofdCallback(OFD_STATUS_UNKNOWN_EXTERNAL_FLASH_TYPE);
+}
+
+/**************************************************************************//**
+\brief Reads status register from the external flash.
+
+\return status register
+******************************************************************************/
+static inline uint8_t ofdReadStatusRegister(void)
+{
+ uint16_t regStatus = RDSR;
+
+ GPIO_EXT_MEM_CS_clr();
+ HAL_ReadSpi(&spiDesc, (uint8_t *)&regStatus, sizeof(uint16_t));
+ GPIO_EXT_MEM_CS_set();
+
+ return (uint8_t)(regStatus >> 8);
+}
+
+/**************************************************************************//**
+\brief Sends "write enable" command to the external flash.
+******************************************************************************/
+void ofdSendWriteEnable(void)
+{
+ uint8_t wren = WREN;
+
+ GPIO_EXT_MEM_CS_clr();
+ HAL_WriteSpi(&spiDesc, &wren, sizeof(uint8_t));
+ GPIO_EXT_MEM_CS_set();
+}
+
+/**************************************************************************//**
+\brief Starts physical sector erasing in the external memory.
+
+\param[in]
+ sectorNumber - address from erased sector
+******************************************************************************/
+void ofdEraseSector(uint32_t sectorNumber)
+{
+ uint32_t erasedSector = sectorNumber | ((uint32_t)SECTOR_ERASE << 24);
+
+ ofdSendWriteEnable();
+ erasedSector = OFD_LITTLE_TO_BIG_ENDIAN(erasedSector);
+ GPIO_EXT_MEM_CS_clr();
+ HAL_WriteSpi(&spiDesc, (uint8_t *)&erasedSector, sizeof(uint32_t));
+ GPIO_EXT_MEM_CS_set();
+}
+
+/**************************************************************************//**
+\brief Starts image erasing in the external memory.
+******************************************************************************/
+void ofdEraseImage(void)
+{
+ if (FLASH_BUSY == ofdCheckBusyState())
+ { // waits till flash ready
+ delayedTransaction = ofdEraseImage;
+ ofdStartPollTimer(FLASH_TRANSACTION);
+ return;
+ }
+
+ if (OFD_POSITION_1 == sectorNumber)
+ ofdEraseSector(SECTOR_ONE);
+ else
+ ofdEraseSector(SECTOR_THREE);
+
+ delayedTransaction = ofdContinueEraseImage;
+ ofdStartPollTimer(FLASH_TRANSACTION);
+}
+
+/**************************************************************************//**
+\brief Continues image erasing in the external memory.
+******************************************************************************/
+static void ofdContinueEraseImage(void)
+{
+ if (OFD_POSITION_1 == sectorNumber)
+ ofdEraseSector(SECTOR_TWO);
+ else
+ ofdEraseSector(SECTOR_FOUR);
+
+ ofdReturnSuccessStatus();
+}
+
+/**************************************************************************//**
+\brief Writes data to the external memory.
+******************************************************************************/
+void ofdWriteData(void)
+{
+ uint8_t *dataPointer;
+ uint16_t dataLength;
+ uint32_t dataAddress;
+ uint8_t writeInstruc = PROGRAM;
+
+ if (!localAccessStructure.length)
+ {
+ ofdReturnSuccessStatus();
+ return;
+ }
+
+ if (FLASH_BUSY == ofdCheckBusyState())
+ { // waits till flash ready
+ delayedTransaction = ofdWriteData;
+ ofdStartPollTimer(FLASH_TRANSACTION);
+ return;
+ }
+
+ dataAddress = OFD_LITTLE_TO_BIG_ENDIAN(localAccessStructure.offset);
+ dataAddress >>= 8;
+ dataPointer = localAccessStructure.data;
+ dataLength = PAGE_SIZE - (uint8_t)localAccessStructure.offset;
+ if (dataLength >= localAccessStructure.length)
+ dataLength = localAccessStructure.length;
+
+ localAccessStructure.data += dataLength;
+ localAccessStructure.offset += dataLength;
+ localAccessStructure.length -= dataLength;
+
+ ofdSendWriteEnable();
+ GPIO_EXT_MEM_CS_clr();
+ HAL_WriteSpi(&spiDesc, &writeInstruc, sizeof(uint8_t));
+ HAL_WriteSpi(&spiDesc, (uint8_t *)&dataAddress, sizeof(uint32_t)-1);
+ HAL_WriteSpi(&spiDesc, dataPointer, dataLength);
+ GPIO_EXT_MEM_CS_set();
+
+ delayedTransaction = ofdWriteData;
+ ofdStartPollTimer(FLASH_TRANSACTION);
+}
+
+/**************************************************************************//**
+\brief Calls callback about end of eeprom saving.
+******************************************************************************/
+static void ofdSaveCrcCallback(void)
+{
+ if (ofdCallback)
+ ((OFD_InfoCallback_t)ofdCallback)(OFD_STATUS_SUCCESS, &imageInfo);
+}
+
+/**************************************************************************//**
+\brief Saves image table to the internal eeprom.
+******************************************************************************/
+void ofdSaveImageTable(void)
+{
+ HAL_EepromParams_t params;
+
+ params.address = OFD_SERVICE_INFO_SIZE-1;
+ params.data = &imageTable;
+ params.length = sizeof(OfdImageTable_t);
+
+ if (!ofdEepromHandler(HAL_WriteEeprom(&params, ofdSaveCrcCallback), ofdSaveImageTable))
+ if (ofdCallback)
+ ((OFD_InfoCallback_t)ofdCallback)(OFD_STATUS_INCORRECT_EEPROM_PARAMETER, &imageInfo);
+}
+
+/**************************************************************************//**
+\brief Saves crc to the internal eeprom.
+******************************************************************************/
+void ofdSaveCrc(void)
+{
+ HAL_EepromParams_t params;
+
+ params.address = sectorNumber + 1;
+ params.data = &imageInfo.crc;
+ params.length = sizeof(uint8_t);
+
+ if (!ofdEepromHandler(HAL_WriteEeprom(&params, ofdSaveImageTable), ofdSaveCrc))
+ if (ofdCallback)
+ ((OFD_InfoCallback_t)ofdCallback)(OFD_STATUS_INCORRECT_EEPROM_PARAMETER, &imageInfo);
+}
+
+/**************************************************************************//**
+\brief Flushs memory buffer to flash.
+******************************************************************************/
+void ofdFlushData(void)
+{}
+
+/**************************************************************************//**
+\brief Checks image crc.
+******************************************************************************/
+void ofdCheckCrc(void)
+{
+ uint32_t address;
+ uint8_t writeInstruc = READ;
+ uint8_t atomicCounting = ATOMIC_COUNTING;
+
+ if (FLASH_BUSY == ofdCheckBusyState())
+ { // waits till flash ready
+ delayedTransaction = ofdCheckCrc;
+ ofdStartPollTimer(FLASH_TRANSACTION);
+ return;
+ }
+
+ while (atomicCounting--)
+ {
+ address = localAccessStructure.offset;
+ address = OFD_LITTLE_TO_BIG_ENDIAN(address<<8);
+ GPIO_EXT_MEM_CS_clr();
+ HAL_WriteSpi(&spiDesc, &writeInstruc, sizeof(uint8_t));
+ HAL_WriteSpi(&spiDesc, (uint8_t *)&address, sizeof(uint32_t)-1);
+ HAL_ReadSpi(&spiDesc, localAccessStructure.data, OFD_BLOCK_FOR_CHECK_CRC);
+ GPIO_EXT_MEM_CS_set(); // release spi cs
+ imageInfo.crc = ofdCrc(imageInfo.crc, localAccessStructure.data, OFD_BLOCK_FOR_CHECK_CRC);
+ localAccessStructure.offset += OFD_BLOCK_FOR_CHECK_CRC;
+ localAccessStructure.length -= OFD_BLOCK_FOR_CHECK_CRC;
+ if (!localAccessStructure.length)
+ {
+ ofdSaveCrc();
+ return;
+ }
+ }
+ // context gap
+ delayedTransaction = ofdCheckCrc;
+ ofdStartPollTimer(FLASH_TRANSACTION);
+}
+
+/**************************************************************************//**
+\brief Callback for saving internal flash.
+
+\param[in] status - status of the data flash writing
+******************************************************************************/
+void ofdWriteFlashDataCallback(OFD_Status_t status)
+{
+ uint32_t maxOffset;
+
+ if (OFD_STATUS_SUCCESS != status)
+ {
+ if (ofdAuxCallback)
+ ofdAuxCallback(status);
+ return;
+ }
+ if (OFD_POSITION_1 == sectorNumber)
+ maxOffset = OFD_IMAGE1_START_ADDRESS + OFD_MCU_FLASH_SIZE - OFD_MCU_EEPROM_SIZE;
+ else
+ maxOffset = OFD_IMAGE2_START_ADDRESS + OFD_MCU_FLASH_SIZE - OFD_MCU_EEPROM_SIZE;
+
+ if (localAccessStructure.offset < maxOffset)
+ { // save mcu flash
+ ofdSaveCurrentFlashImage();
+ return;
+ }
+
+ internalAccessParam.eepromOffset = 0;
+ // save eeprom image
+ ofdSaveCurrentEepromImage();
+}
+
+/**************************************************************************//**
+\brief Starts saving internal flash.
+******************************************************************************/
+void ofdSaveCurrentFlashImage(void)
+{
+#if EXTERNAL_MEMORY == AT25F2048
+ uint16_t itr;
+
+ localAccessStructure.length = OFD_BLOCK_FOR_CHECK_CRC;
+ localAccessStructure.data = internalAccessParam.data;
+ for (itr = 0; itr < OFD_BLOCK_FOR_CHECK_CRC; itr++)
+ internalAccessParam.data[itr] = ofdReadInternalFlash(internalAccessParam.flashOffset++);
+ internalAccessParam.length -= OFD_BLOCK_FOR_CHECK_CRC;
+ ofdCallback = ofdWriteFlashDataCallback;
+ ofdWriteData();
+#elif EXTERNAL_MEMORY == AT25DF041A
+ ofdSetActionForBootloader();
+#endif
+}
+
+/**************************************************************************//**
+\brief Callback for saving internal eeprom.
+
+\param[in] status - status of the data eeprom writing
+******************************************************************************/
+void ofdWriteEepromDataCallback(OFD_Status_t status)
+{
+ uint32_t maxOffset;
+
+ if (OFD_STATUS_SUCCESS != status)
+ {
+ if (ofdAuxCallback)
+ ofdAuxCallback(status);
+ return;
+ }
+ if (OFD_POSITION_1 == sectorNumber)
+ maxOffset = OFD_IMAGE1_START_ADDRESS + OFD_MCU_FLASH_SIZE;
+ else
+ maxOffset = OFD_IMAGE2_START_ADDRESS + OFD_MCU_FLASH_SIZE;
+
+ if (localAccessStructure.offset < maxOffset)
+ { // save mcu eeprom
+ ofdSaveCurrentEepromImage();
+ return;
+ }
+
+ // start check crc
+ OFD_FlushAndCheckCrc(sectorNumber, internalAccessParam.data, ofdFlushCrcCallback);
+}
+
+/**************************************************************************//**
+\brief Starts saving internal eeprom.
+******************************************************************************/
+static void ofdSaveCurrentEepromImage(void)
+{
+ HAL_EepromParams_t params;
+
+ params.address = internalAccessParam.eepromOffset;
+ params.data = internalAccessParam.data;
+ params.length = OFD_BLOCK_FOR_CHECK_CRC;
+
+ if (!ofdEepromHandler(HAL_ReadEeprom(&params, ofdSaveCurrentEepromImageContinue), ofdSaveCurrentEepromImage))
+ if (ofdAuxCallback)
+ ofdAuxCallback(OFD_STATUS_INCORRECT_EEPROM_PARAMETER);
+}
+
+/**************************************************************************//**
+\brief Continues saving internal flash.
+******************************************************************************/
+static void ofdSaveCurrentEepromImageContinue(void)
+{
+ localAccessStructure.length = OFD_BLOCK_FOR_CHECK_CRC;
+ localAccessStructure.data = internalAccessParam.data;
+ if (0 == internalAccessParam.eepromOffset)
+ memset(internalAccessParam.data, 0xFF, OFD_SERVICE_INFO_SIZE);
+
+ internalAccessParam.eepromOffset += OFD_BLOCK_FOR_CHECK_CRC;
+ internalAccessParam.length -= OFD_BLOCK_FOR_CHECK_CRC;
+ ofdCallback = ofdWriteEepromDataCallback;
+ ofdWriteData();
+}
+
+/**************************************************************************//**
+\brief Callback for start of saving of action for bootloader.
+
+\param[in]
+ status - status of the crc saving to eeprom
+\param[in]
+ pInfo - ponter to image information
+******************************************************************************/
+static void ofdFlushCrcCallback(OFD_Status_t status, OFD_ImageInfo_t *pInfo)
+{
+ (void)pInfo;
+
+ if (OFD_STATUS_SUCCESS != status)
+ {
+ if (ofdAuxCallback)
+ ofdAuxCallback(status);
+ return;
+ }
+ ofdSetActionForBootloader();
+}
+
+/**************************************************************************//**
+\brief Sets action for internal bootloader.
+******************************************************************************/
+void ofdSetActionForBootloader(void)
+{
+ HAL_EepromParams_t params;
+
+ params.address = 0;
+ params.data = (uint8_t *)&actionSector;
+ params.length = sizeof(OFD_Position_t);
+
+ if (!ofdEepromHandler(HAL_WriteEeprom(&params, ofdPollBusyState), ofdSetActionForBootloader))
+ if (ofdAuxCallback)
+ ofdAuxCallback(OFD_STATUS_INCORRECT_EEPROM_PARAMETER);
+}
+
+/**************************************************************************//**
+\brief Waits for end of image saving.
+******************************************************************************/
+static void ofdPollBusyState(void)
+{
+ if (FLASH_BUSY == ofdCheckBusyState())
+ { // waits till flash ready
+ delayedTransaction = ofdPollBusyState;
+ ofdStartPollTimer(FLASH_TRANSACTION);
+ return;
+ }
+
+ if (ofdAuxCallback)
+ ofdAuxCallback(OFD_STATUS_SUCCESS);
+}
+
+/**************************************************************************//**
+\brief Reads image crc from internal eeprom.
+******************************************************************************/
+void ofdReadCrc(void)
+{
+ HAL_EepromParams_t params;
+
+ params.address = sectorNumber + 1;
+ params.data = &imageInfo.crc;
+ params.length = sizeof(uint8_t);
+
+ if (!ofdEepromHandler(HAL_ReadEeprom(&params, ofdSaveCrcCallback), ofdReadCrc))
+ if (ofdCallback)
+ ((OFD_InfoCallback_t)ofdCallback)(OFD_STATUS_INCORRECT_EEPROM_PARAMETER, &imageInfo);
+}
+
+#if EXTERNAL_MEMORY == AT25DF041A
+/**************************************************************************//**
+\brief Unprotects memory sectors for writing and erasing.
+******************************************************************************/
+void ofdUnprotectMemorySectors(void)
+{
+ uint8_t unprotect = WRSR;
+ uint8_t unprotectArg = GLOBAL_UNPROTECT;
+
+ ofdSendWriteEnable();
+ GPIO_EXT_MEM_CS_clr();
+ HAL_WriteSpi(&spiDesc, &unprotect, sizeof(uint8_t));
+ HAL_WriteSpi(&spiDesc, &unprotectArg, sizeof(uint8_t));
+ GPIO_EXT_MEM_CS_set();
+}
+#endif
+
+#if defined(_OFD_DEBUG_)
+/**************************************************************************//**
+\brief Flash read callback.
+******************************************************************************/
+void ofdReadConfirm(OFD_Status_t status)
+{
+ HAL_WriteUsart(&usartDescriptor, debugBuffer, OFD_BLOCK_SIZE);
+}
+
+/**************************************************************************//**
+\brief Usart write callback.
+******************************************************************************/
+void usartWriteConfirm(void)
+{
+ debugOffset += OFD_BLOCK_SIZE;
+ if (debugOffset < OFD_IMAGE_SIZE)
+ {
+ ofdReadData(debugOffset, debugBuffer, OFD_BLOCK_SIZE, ofdReadConfirm);
+ }
+}
+
+/**************************************************************************//**
+\brief Initialization of usart for consinsting of flash transmitting.
+******************************************************************************/
+void ofdInitDebugInterface(void)
+{
+ usartDescriptor.tty = USART_CHANNEL_1;
+ usartDescriptor.mode = USART_MODE_ASYNC;
+ usartDescriptor.flowControl = USART_FLOW_CONTROL_NONE;
+ usartDescriptor.baudrate = USART_BAUDRATE_38400;
+ usartDescriptor.dataLength = USART_DATA8;
+ usartDescriptor.parity = USART_PARITY_NONE;
+ usartDescriptor.stopbits = USART_STOPBIT_1;
+ usartDescriptor.rxBuffer = NULL;
+ usartDescriptor.rxBufferLength = 0;
+ usartDescriptor.txBuffer = NULL;
+ usartDescriptor.txBufferLength = 0;
+ usartDescriptor.rxCallback = NULL;
+ usartDescriptor.txCallback = usartWriteConfirm;
+
+ HAL_OpenUsart(&usartDescriptor);
+ ofdReadData(debugOffset, debugBuffer, OFD_BLOCK_SIZE, ofdReadConfirm);
+}
+
+/**************************************************************************//**
+\brief Reads data from the external memory.
+
+\param[in]
+ address - flash cell address
+\param[out]
+ data - pointer to memory buffer
+\param[in]
+ size - size of memory buffer
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void ofdReadData(uint32_t address, uint8_t *data, uint16_t size, OFD_Callback_t cb)
+{
+ uint8_t writeInstruc = READ;
+
+ while (FLASH_BUSY == ofdCheckBusyState())
+ {;}// waits till flash ready
+
+ address = OFD_LITTLE_TO_BIG_ENDIAN(address<<8);
+ GPIO_EXT_MEM_CS_clr();
+ HAL_WriteSpi(&spiDesc, &writeInstruc, sizeof(uint8_t));
+ HAL_WriteSpi(&spiDesc, (uint8_t *)&address, sizeof(uint32_t)-1);
+ HAL_ReadSpi(&spiDesc, data, size);
+ GPIO_EXT_MEM_CS_set();
+ if (cb)
+ cb(OFD_STATUS_SUCCESS);
+}
+#endif // defined(_OFD_DEBUG_)
+
+#endif // APP_USE_FAKE_OFD_DRIVER == 0
+#endif // ((EXTERNAL_MEMORY == AT25F2048) ||(EXTERNAL_MEMORY == AT25DF041A)) && (APP_USE_OTAU == 1)
+#endif // _OTAU_
+// eof ofdAt25fDriver.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdAt45dbDriver.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdAt45dbDriver.c
new file mode 100644
index 00000000..f06d765d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdAt45dbDriver.c
@@ -0,0 +1,758 @@
+/**************************************************************************//**
+\file ofdAt45dbDriver.c
+
+\brief Implementation of chip-flash interface.
+
+\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:
+ 20/07/10 A. Khromykh - Created
+*******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifdef _OTAU_
+#if (EXTERNAL_MEMORY == AT45DB041) && (APP_USE_OTAU == 1)
+#if APP_USE_FAKE_OFD_DRIVER == 0
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <ofdExtMemory.h>
+#include <ofdMemoryDriver.h>
+#include <spi.h>
+#include <eeprom.h>
+#include <appTimer.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define SPI_BUSY_POLL_PERIOD 10
+// cycles of counting flash crc before context gap.
+#define ATOMIC_COUNTING 128
+#define EEPROM_OK 0
+#define EEPROM_BUSY -2
+#define ALL_DATA_HAS_BEEN_SAVED 0xFFFFFFFFul
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum
+{
+ FLASH_BUSY,
+ FLASH_READY
+} FlashBusyState_t;
+
+typedef enum
+{
+ FLASH_TRANSACTION,
+ EEPROM_TRANSACTION
+} DelayedTransactionType_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+static inline uint8_t ofdReadStatusRegister(void);
+static inline void ofdStartPollTimer(DelayedTransactionType_t type);
+static void ofdReadImageTable(void);
+static void ofdSaveCrcCallback(void);
+static void ofdSaveCurrentEepromImage(void);
+static void ofdFlushCrcCallback(OFD_Status_t status, OFD_ImageInfo_t *pInfo);
+static void ofdSaveCurrentEepromImageContinue(void);
+static void ofdPollBusyState(void);
+static void ofdStartFlashDelayedTransaction(void);
+static void ofdStartEepromDelayedTransaction(void);
+static void ofdClearFlashInternalBuffer(void);
+uint8_t ofdReadInternalFlash(uint32_t flashAddress);
+#if defined(_OFD_DEBUG_)
+void ofdReadData(uint32_t address, uint8_t *data, uint16_t size, OFD_Callback_t cb);
+#endif
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+extern HAL_SpiDescriptor_t spiDesc;
+extern OFD_Position_t sectorNumber;
+extern OFD_Position_t actionSector;
+extern OFD_Callback_t ofdCallback;
+extern OFD_Callback_t ofdAuxCallback;
+extern OFD_MemoryAccessParam_t localAccessStructure;
+extern OFD_ImageInfo_t imageInfo;
+extern OfdImageTable_t imageTable;
+extern OfdInternalMemoryAccessParam_t internalAccessParam;
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+static HAL_AppTimer_t ofdBusyTimer =
+{
+ .interval = SPI_BUSY_POLL_PERIOD,
+ .mode = TIMER_ONE_SHOT_MODE,
+};
+void (* delayedTransaction)(void) = NULL;
+static uint16_t serviceGapData = 0;
+static uint32_t flushedPageAddr = ALL_DATA_HAS_BEEN_SAVED;
+#if defined(_OFD_DEBUG_)
+static HAL_UsartDescriptor_t usartDescriptor;
+static uint32_t debugOffset = 0ul;
+static uint8_t debugBuffer[OFD_BLOCK_SIZE];
+#endif
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Checks flash state.
+
+\return flash states: \n
+ FLASH_BUSY \n
+ FLASH_READY
+******************************************************************************/
+static inline FlashBusyState_t ofdCheckBusyState(void)
+{
+ uint8_t statusReg = ofdReadStatusRegister();
+
+ if (statusReg & RDY)
+ return FLASH_READY;
+
+ return FLASH_BUSY;
+}
+
+/**************************************************************************//**
+\brief Starts flash delayed transaction.
+******************************************************************************/
+static void ofdStartFlashDelayedTransaction(void)
+{
+ if (FLASH_READY == ofdCheckBusyState())
+ delayedTransaction();
+ else
+ ofdStartPollTimer(FLASH_TRANSACTION);
+}
+
+/**************************************************************************//**
+\brief Starts eeprom delayed transaction.
+******************************************************************************/
+static void ofdStartEepromDelayedTransaction(void)
+{
+ if (!HAL_IsEepromBusy())
+ delayedTransaction();
+ else
+ ofdStartPollTimer(EEPROM_TRANSACTION);
+}
+
+/**************************************************************************//**
+\brief Starts timer for start delayed transaction.
+
+\param[in]
+ type - transaction type (flash or eeprom)
+******************************************************************************/
+static inline void ofdStartPollTimer(DelayedTransactionType_t type)
+{
+ if (FLASH_TRANSACTION == type)
+ ofdBusyTimer.callback = ofdStartFlashDelayedTransaction;
+ else
+ ofdBusyTimer.callback = ofdStartEepromDelayedTransaction;
+
+ HAL_StartAppTimer(&ofdBusyTimer);
+}
+
+/**************************************************************************//**
+\brief Routine of eeprom access.
+\param[in]
+ result - result of hal eeprom action
+\param[in]
+ action - initiator action
+\return
+ false - incorrect parameters
+ true - eeprom transaction is started
+******************************************************************************/
+static bool ofdEepromHandler(int result, void(* action)())
+{
+ switch (result)
+ {
+ case EEPROM_OK:
+ return true;
+ case EEPROM_BUSY:
+ delayedTransaction = action;
+ ofdStartPollTimer(EEPROM_TRANSACTION);
+ return true;
+ default:
+ return false;
+ }
+}
+
+/**************************************************************************//**
+\brief Returns SUCCESS status.
+******************************************************************************/
+static void ofdReturnSuccessStatus(void)
+{
+ if (ofdCallback)
+ ofdCallback(OFD_STATUS_SUCCESS);
+}
+
+/**************************************************************************//**
+\brief Reads image table.
+******************************************************************************/
+static void ofdReadImageTable(void)
+{
+ HAL_EepromParams_t params;
+
+ params.address = OFD_SERVICE_INFO_SIZE - sizeof(OfdImageTable_t);
+ params.data = &imageTable;
+ params.length = sizeof(OfdImageTable_t);
+
+ if (!ofdEepromHandler(HAL_ReadEeprom(&params, ofdReturnSuccessStatus), ofdReadImageTable))
+ if (ofdCallback)
+ ofdCallback(OFD_STATUS_INCORRECT_EEPROM_PARAMETER);
+}
+
+/**************************************************************************//**
+\brief Reads status register and check unchanged bits.
+******************************************************************************/
+void ofdFindStorageSpace(void)
+{
+ if (STATUS_UNCHANGED_BITS == (ofdReadStatusRegister() & STATUS_UNCHANGED_BIT_MASK))
+ {
+ // read image table to global variable
+ ofdReadImageTable();
+ return;
+ }
+
+ if (ofdCallback)
+ ofdCallback(OFD_STATUS_UNKNOWN_EXTERNAL_FLASH_TYPE);
+}
+
+/**************************************************************************//**
+\brief Reads status register from the external flash.
+
+\return status register
+******************************************************************************/
+static inline uint8_t ofdReadStatusRegister(void)
+{
+ uint16_t regStatus = RDSR;
+
+ GPIO_EXT_MEM_CS_clr();
+ HAL_ReadSpi(&spiDesc, (uint8_t *)&regStatus, sizeof(uint16_t));
+ GPIO_EXT_MEM_CS_set();
+
+ return (uint8_t)(regStatus >> 8);
+}
+
+/**************************************************************************//**
+\brief Starts physical block(8 pages) erasing in the external memory.
+
+\param[in]
+ blockNumber - address of the erased block
+******************************************************************************/
+void ofdEraseBlock(uint8_t blockNumber)
+{
+ uint32_t erasedBlock = OFD_LITTLE_TO_BIG_ENDIAN((uint32_t)blockNumber << 4);
+
+ erasedBlock >>= 8;
+ erasedBlock |= BLOCK_ERASE;
+
+ GPIO_EXT_MEM_CS_clr();
+ HAL_WriteSpi(&spiDesc, (uint8_t *)&erasedBlock, sizeof(uint32_t));
+ GPIO_EXT_MEM_CS_set();
+}
+
+/**************************************************************************//**
+\brief Starts image erasing in the external memory.
+******************************************************************************/
+void ofdEraseImage(void)
+{
+ if (FLASH_BUSY == ofdCheckBusyState())
+ { // waits till flash ready
+ delayedTransaction = ofdEraseImage;
+ ofdStartPollTimer(FLASH_TRANSACTION);
+ return;
+ }
+
+ if (OFD_POSITION_1 == sectorNumber)
+ ofdEraseBlock(FIRST_HALF_BLOCK_NUMBER + serviceGapData++);
+ else
+ ofdEraseBlock(SECOND_HALF_BLOCK_NUMBER + serviceGapData++);
+
+ if (serviceGapData < OFD_USED_BLOCKS_AMOUNT)
+ {
+ delayedTransaction = ofdEraseImage;
+ ofdStartPollTimer(FLASH_TRANSACTION);
+ }
+ else
+ {
+ serviceGapData = 0;
+ ofdReturnSuccessStatus();
+ }
+}
+
+/**************************************************************************//**
+\brief Writes data to the external memory.
+******************************************************************************/
+void ofdWriteData(void)
+{
+ uint8_t *dataPointer;
+ uint16_t dataLength;
+ uint32_t address;
+ uint32_t pageAddr;
+ uint32_t byteAddr;
+
+ if (!localAccessStructure.length)
+ {
+ ofdReturnSuccessStatus();
+ return;
+ }
+
+ if (FLASH_BUSY == ofdCheckBusyState())
+ { // waits till flash ready
+ delayedTransaction = ofdWriteData;
+ ofdStartPollTimer(FLASH_TRANSACTION);
+ return;
+ }
+
+ pageAddr = localAccessStructure.offset / PAGE_SIZE;
+
+ if ((pageAddr > flushedPageAddr) && (ALL_DATA_HAS_BEEN_SAVED != flushedPageAddr))
+ { // there is gap in the image address map.
+ ofdFlushData();
+ delayedTransaction = ofdClearFlashInternalBuffer;
+ ofdStartPollTimer(FLASH_TRANSACTION);
+ return;
+ }
+
+ flushedPageAddr = pageAddr;
+ byteAddr = localAccessStructure.offset % PAGE_SIZE;
+ dataPointer = localAccessStructure.data;
+
+ if ((byteAddr + localAccessStructure.length) > PAGE_SIZE)
+ dataLength = PAGE_SIZE - byteAddr;
+ else
+ dataLength = localAccessStructure.length;
+
+ localAccessStructure.data += dataLength;
+ localAccessStructure.offset += dataLength;
+ localAccessStructure.length -= dataLength;
+
+ address = OFD_LITTLE_TO_BIG_ENDIAN(byteAddr);
+ address |= WRITE_BUF1;
+
+ GPIO_EXT_MEM_CS_clr();
+ HAL_WriteSpi(&spiDesc, (uint8_t *)&address, sizeof(uint32_t));
+ HAL_WriteSpi(&spiDesc, dataPointer, dataLength);
+ GPIO_EXT_MEM_CS_set();
+
+ if (PAGE_SIZE == (byteAddr + dataLength))
+ {
+ ofdFlushData();
+ delayedTransaction = ofdClearFlashInternalBuffer;
+ ofdStartPollTimer(FLASH_TRANSACTION);
+ return;
+ }
+
+ ofdReturnSuccessStatus();
+}
+
+/**************************************************************************//**
+\brief Calls callback about end of eeprom saving.
+******************************************************************************/
+static void ofdSaveCrcCallback(void)
+{
+ if (ofdCallback)
+ ((OFD_InfoCallback_t)ofdCallback)(OFD_STATUS_SUCCESS, &imageInfo);
+}
+
+/**************************************************************************//**
+\brief Saves image table to the internal eeprom.
+******************************************************************************/
+void ofdSaveImageTable(void)
+{
+ HAL_EepromParams_t params;
+
+ params.address = OFD_SERVICE_INFO_SIZE-1;
+ params.data = &imageTable;
+ params.length = sizeof(OfdImageTable_t);
+
+ if (!ofdEepromHandler(HAL_WriteEeprom(&params, ofdSaveCrcCallback), ofdSaveImageTable))
+ if (ofdCallback)
+ ((OFD_InfoCallback_t)ofdCallback)(OFD_STATUS_INCORRECT_EEPROM_PARAMETER, &imageInfo);
+}
+
+/**************************************************************************//**
+\brief Saves crc to the internal eeprom.
+******************************************************************************/
+void ofdSaveCrc(void)
+{
+ HAL_EepromParams_t params;
+
+ params.address = sectorNumber + 1;
+ params.data = &imageInfo.crc;
+ params.length = sizeof(uint8_t);
+
+ if (!ofdEepromHandler(HAL_WriteEeprom(&params, ofdSaveImageTable), ofdSaveCrc))
+ if (ofdCallback)
+ ((OFD_InfoCallback_t)ofdCallback)(OFD_STATUS_INCORRECT_EEPROM_PARAMETER, &imageInfo);
+}
+
+/**************************************************************************//**
+\brief Clears internal flash buffer.
+******************************************************************************/
+static void ofdClearFlashInternalBuffer(void)
+{
+ uint32_t address = 0ul;
+ uint64_t data;
+ uint8_t itr;
+
+ if (FLASH_BUSY == ofdCheckBusyState())
+ { // waits till flash ready
+ delayedTransaction = ofdClearFlashInternalBuffer;
+ ofdStartPollTimer(FLASH_TRANSACTION);
+ return;
+ }
+
+ memset((uint8_t *)&data, 0xFF, sizeof(uint64_t));
+
+ address |= WRITE_BUF1;
+ GPIO_EXT_MEM_CS_clr();
+ HAL_WriteSpi(&spiDesc, (uint8_t *)&address, sizeof(uint32_t));
+ for (itr = 0; itr < (PAGE_SIZE / sizeof(uint64_t)); itr++)
+ HAL_WriteSpi(&spiDesc, (uint8_t *)&data, sizeof(uint64_t));
+ GPIO_EXT_MEM_CS_set();
+
+ ofdWriteData();
+}
+
+/**************************************************************************//**
+\brief Flushs memory buffer to flash.
+******************************************************************************/
+void ofdFlushData(void)
+{
+ if (ALL_DATA_HAS_BEEN_SAVED == flushedPageAddr)
+ return;
+
+ flushedPageAddr = OFD_LITTLE_TO_BIG_ENDIAN(flushedPageAddr << 1);
+ flushedPageAddr >>= 8;
+ flushedPageAddr |= PROGRAM_BUF1;
+ GPIO_EXT_MEM_CS_clr();
+ HAL_WriteSpi(&spiDesc, (uint8_t *)&flushedPageAddr, sizeof(uint32_t));
+ GPIO_EXT_MEM_CS_set();
+ flushedPageAddr = ALL_DATA_HAS_BEEN_SAVED;
+}
+
+/**************************************************************************//**
+\brief Checks image crc.
+******************************************************************************/
+void ofdCheckCrc(void)
+{
+ uint32_t address;
+ uint32_t pageAddr;
+ uint32_t byteAddr;
+ uint8_t atomicCounting = ATOMIC_COUNTING;
+
+ if (FLASH_BUSY == ofdCheckBusyState())
+ { // waits till flash ready
+ delayedTransaction = ofdCheckCrc;
+ ofdStartPollTimer(FLASH_TRANSACTION);
+ return;
+ }
+
+ while (atomicCounting--)
+ {
+ pageAddr = localAccessStructure.offset / PAGE_SIZE;
+ byteAddr = localAccessStructure.offset % PAGE_SIZE;
+ address = byteAddr | (pageAddr << 9) | ((uint32_t)READ << 24);
+ address = OFD_LITTLE_TO_BIG_ENDIAN(address);
+ GPIO_EXT_MEM_CS_clr();
+ HAL_WriteSpi(&spiDesc, (uint8_t *)&address, sizeof(uint32_t));
+ // load 32 don't care bits
+ HAL_WriteSpi(&spiDesc, (uint8_t *)&address, sizeof(uint32_t));
+ HAL_ReadSpi(&spiDesc, localAccessStructure.data, OFD_BLOCK_FOR_CHECK_CRC);
+ GPIO_EXT_MEM_CS_set(); // release spi cs
+ imageInfo.crc = ofdCrc(imageInfo.crc, localAccessStructure.data, OFD_BLOCK_FOR_CHECK_CRC);
+ localAccessStructure.offset += OFD_BLOCK_FOR_CHECK_CRC;
+ localAccessStructure.length -= OFD_BLOCK_FOR_CHECK_CRC;
+ if (!localAccessStructure.length)
+ {
+ ofdSaveCrc();
+ return;
+ }
+ }
+ // context gap
+ delayedTransaction = ofdCheckCrc;
+ ofdStartPollTimer(FLASH_TRANSACTION);
+}
+
+/**************************************************************************//**
+\brief Callback for saving internal flash.
+
+\param[in] status - status of the data flash writing
+******************************************************************************/
+void ofdWriteFlashDataCallback(OFD_Status_t status)
+{
+ uint32_t maxOffset;
+
+ if (OFD_STATUS_SUCCESS != status)
+ {
+ if (ofdAuxCallback)
+ ofdAuxCallback(status);
+ return;
+ }
+ if (OFD_POSITION_1 == sectorNumber)
+ maxOffset = OFD_IMAGE1_START_ADDRESS + OFD_EEPROM_OFFSET_WITHIN_IMAGE;
+ else
+ maxOffset = OFD_IMAGE2_START_ADDRESS + OFD_EEPROM_OFFSET_WITHIN_IMAGE;
+
+ if (localAccessStructure.offset < maxOffset)
+ { // save mcu flash
+ ofdSaveCurrentFlashImage();
+ return;
+ }
+
+ internalAccessParam.eepromOffset = 0;
+ // save eeprom image
+ ofdSaveCurrentEepromImage();
+}
+
+/**************************************************************************//**
+\brief Starts saving internal flash.
+******************************************************************************/
+void ofdSaveCurrentFlashImage(void)
+{
+ uint16_t itr;
+
+ localAccessStructure.length = OFD_BLOCK_FOR_CHECK_CRC;
+ localAccessStructure.data = internalAccessParam.data;
+ for (itr = 0; itr < OFD_BLOCK_FOR_CHECK_CRC; itr++)
+ {
+ OFD_LOAD_NO_COMMAND_TO_NVM;
+ internalAccessParam.data[itr] = ofdReadInternalFlash(internalAccessParam.flashOffset++);
+ }
+ internalAccessParam.length -= OFD_BLOCK_FOR_CHECK_CRC;
+ ofdCallback = ofdWriteFlashDataCallback;
+ ofdWriteData();
+}
+
+/**************************************************************************//**
+\brief Callback for saving internal eeprom.
+
+\param[in] status - status of the data eeprom writing
+******************************************************************************/
+void ofdWriteEepromDataCallback(OFD_Status_t status)
+{
+ uint32_t maxOffset;
+
+ if (OFD_STATUS_SUCCESS != status)
+ {
+ if (ofdAuxCallback)
+ ofdAuxCallback(status);
+ return;
+ }
+ if (OFD_POSITION_1 == sectorNumber)
+ maxOffset = OFD_IMAGE1_START_ADDRESS + OFD_IMAGE_SIZE;
+ else
+ maxOffset = OFD_IMAGE2_START_ADDRESS + OFD_IMAGE_SIZE;
+
+ if (localAccessStructure.offset < maxOffset)
+ { // save mcu eeprom
+ ofdSaveCurrentEepromImage();
+ return;
+ }
+
+ // start check crc
+ OFD_FlushAndCheckCrc(sectorNumber, internalAccessParam.data, ofdFlushCrcCallback);
+}
+
+/**************************************************************************//**
+\brief Starts saving internal eeprom.
+******************************************************************************/
+static void ofdSaveCurrentEepromImage(void)
+{
+ HAL_EepromParams_t params;
+
+ params.address = internalAccessParam.eepromOffset;
+ params.data = internalAccessParam.data;
+ params.length = OFD_BLOCK_FOR_CHECK_CRC;
+
+ if (!ofdEepromHandler(HAL_ReadEeprom(&params, ofdSaveCurrentEepromImageContinue), ofdSaveCurrentEepromImage))
+ if (ofdAuxCallback)
+ ofdAuxCallback(OFD_STATUS_INCORRECT_EEPROM_PARAMETER);
+}
+
+/**************************************************************************//**
+\brief Continues saving internal flash.
+******************************************************************************/
+static void ofdSaveCurrentEepromImageContinue(void)
+{
+ localAccessStructure.length = OFD_BLOCK_FOR_CHECK_CRC;
+ localAccessStructure.data = internalAccessParam.data;
+ if (0 == internalAccessParam.eepromOffset)
+ memset(internalAccessParam.data, 0xFF, OFD_SERVICE_INFO_SIZE);
+
+ internalAccessParam.eepromOffset += OFD_BLOCK_FOR_CHECK_CRC;
+ internalAccessParam.length -= OFD_BLOCK_FOR_CHECK_CRC;
+ ofdCallback = ofdWriteEepromDataCallback;
+ ofdWriteData();
+}
+
+/**************************************************************************//**
+\brief Callback for start of saving of action for bootloader.
+
+\param[in]
+ status - status of the crc saving to eeprom
+\param[in]
+ pInfo - ponter to image information
+******************************************************************************/
+static void ofdFlushCrcCallback(OFD_Status_t status, OFD_ImageInfo_t *pInfo)
+{
+ (void)pInfo;
+
+ if (OFD_STATUS_SUCCESS != status)
+ {
+ if (ofdAuxCallback)
+ ofdAuxCallback(status);
+ return;
+ }
+ ofdSetActionForBootloader();
+}
+
+/**************************************************************************//**
+\brief Sets action for internal bootloader.
+******************************************************************************/
+void ofdSetActionForBootloader(void)
+{
+ HAL_EepromParams_t params;
+
+ params.address = 0;
+ params.data = (uint8_t *)&actionSector;
+ params.length = sizeof(OFD_Position_t);
+
+ if (!ofdEepromHandler(HAL_WriteEeprom(&params, ofdPollBusyState), ofdSetActionForBootloader))
+ if (ofdAuxCallback)
+ ofdAuxCallback(OFD_STATUS_INCORRECT_EEPROM_PARAMETER);
+}
+
+/**************************************************************************//**
+\brief Waits for end of image saving.
+******************************************************************************/
+static void ofdPollBusyState(void)
+{
+ if (FLASH_BUSY == ofdCheckBusyState())
+ { // waits till flash ready
+ delayedTransaction = ofdPollBusyState;
+ ofdStartPollTimer(FLASH_TRANSACTION);
+ return;
+ }
+
+ if (ofdAuxCallback)
+ ofdAuxCallback(OFD_STATUS_SUCCESS);
+}
+
+/**************************************************************************//**
+\brief Reads image crc from internal eeprom.
+******************************************************************************/
+void ofdReadCrc(void)
+{
+ HAL_EepromParams_t params;
+
+ params.address = sectorNumber + 1;
+ params.data = &imageInfo.crc;
+ params.length = sizeof(uint8_t);
+
+ if (!ofdEepromHandler(HAL_ReadEeprom(&params, ofdSaveCrcCallback), ofdReadCrc))
+ if (ofdCallback)
+ ((OFD_InfoCallback_t)ofdCallback)(OFD_STATUS_INCORRECT_EEPROM_PARAMETER, &imageInfo);
+}
+
+#if defined(_OFD_DEBUG_)
+/**************************************************************************//**
+\brief Flash read callback.
+******************************************************************************/
+void ofdReadConfirm(OFD_Status_t status)
+{
+ HAL_WriteUsart(&usartDescriptor, debugBuffer, OFD_BLOCK_SIZE);
+}
+
+/**************************************************************************//**
+\brief Usart write callback.
+******************************************************************************/
+void usartWriteConfirm(void)
+{
+ debugOffset += OFD_BLOCK_SIZE;
+ if (debugOffset < OFD_IMAGE_SIZE)
+ {
+ ofdReadData(debugOffset, debugBuffer, OFD_BLOCK_SIZE, ofdReadConfirm);
+ }
+}
+
+/**************************************************************************//**
+\brief Initialization of usart for consinsting of flash transmitting.
+******************************************************************************/
+void ofdInitDebugInterface(void)
+{
+#if defined(ATMEGA1281) || defined(ATMEGA128RFA1)
+ usartDescriptor.tty = USART_CHANNEL_1;
+#elif defined(ATXMEGA256A3) || defined(ATXMEGA256D3)
+ usartDescriptor.tty = USART_CHANNEL_F0;
+#endif
+ usartDescriptor.mode = USART_MODE_ASYNC;
+ usartDescriptor.flowControl = USART_FLOW_CONTROL_NONE;
+ usartDescriptor.baudrate = USART_BAUDRATE_38400;
+ usartDescriptor.dataLength = USART_DATA8;
+ usartDescriptor.parity = USART_PARITY_NONE;
+ usartDescriptor.stopbits = USART_STOPBIT_1;
+ usartDescriptor.rxBuffer = NULL;
+ usartDescriptor.rxBufferLength = 0;
+ usartDescriptor.txBuffer = NULL;
+ usartDescriptor.txBufferLength = 0;
+ usartDescriptor.rxCallback = NULL;
+ usartDescriptor.txCallback = usartWriteConfirm;
+
+ HAL_OpenUsart(&usartDescriptor);
+ ofdReadData(debugOffset, debugBuffer, OFD_BLOCK_SIZE, ofdReadConfirm);
+}
+
+/**************************************************************************//**
+\brief Reads data from the external memory.
+
+\param[in]
+ address - flash cell address
+\param[out]
+ data - pointer to memory buffer
+\param[in]
+ size - size of memory buffer
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void ofdReadData(uint32_t address, uint8_t *data, uint16_t size, OFD_Callback_t cb)
+{
+ uint32_t pageAddr;
+ uint32_t byteAddr;
+
+
+ while (FLASH_BUSY == ofdCheckBusyState())
+ {;}// waits till flash ready
+ pageAddr = address / PAGE_SIZE;
+ byteAddr = address % PAGE_SIZE;
+ address = byteAddr | (pageAddr << 9) | ((uint32_t)READ << 24);
+ address = OFD_LITTLE_TO_BIG_ENDIAN(address);
+ GPIO_EXT_MEM_CS_clr();
+ HAL_WriteSpi(&spiDesc, (uint8_t *)&address, sizeof(uint32_t));
+ // load 32 don't care bits
+ HAL_WriteSpi(&spiDesc, (uint8_t *)&address, sizeof(uint32_t));
+ HAL_ReadSpi(&spiDesc, data, size);
+ GPIO_EXT_MEM_CS_set();
+ if (cb)
+ cb(OFD_STATUS_SUCCESS);
+}
+#endif // defined(_OFD_DEBUG_)
+
+#endif // APP_USE_FAKE_OFD_DRIVER == 0
+#endif // (EXTERNAL_MEMORY == AT45DB041) && (APP_USE_OTAU == 1)
+#endif // _OTAU_
+// eof ofdAt25fDriver.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdCommand.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdCommand.c
new file mode 100644
index 00000000..02a71723
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdCommand.c
@@ -0,0 +1,243 @@
+/**************************************************************************//**
+\file ofdCommand.c
+
+\brief Implementation of OTAU flash driver interface.
+
+\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:
+ 7/08/09 A. Khromykh - Created
+*******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifdef _OTAU_
+#if (APP_USE_OTAU == 1)
+#if APP_USE_FAKE_OFD_DRIVER == 0
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <ofdExtMemory.h>
+#include <ofdMemoryDriver.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define CRC_INITIALIZATION_VALUE 0xFF
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+OFD_Position_t sectorNumber = 0;
+OFD_Position_t actionSector = 0;
+OFD_Callback_t ofdCallback = NULL;
+OFD_Callback_t ofdAuxCallback = NULL;
+OFD_MemoryAccessParam_t localAccessStructure;
+OfdInternalMemoryAccessParam_t internalAccessParam;
+OFD_ImageInfo_t imageInfo;
+OfdImageTable_t imageTable;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Erases image in the external memory.
+
+\param[in]
+ pos - image position in the external memory
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_EraseImage(OFD_Position_t pos, OFD_Callback_t cb)
+{
+ if (pos >= OFD_POSITION_MAX)
+ {
+ if (cb)
+ cb(OFD_STATUS_INCORRECT_API_PARAMETER);
+ return;
+ }
+
+ sectorNumber = pos;
+ ofdCallback = cb;
+ ofdEraseImage();
+}
+
+/**************************************************************************//**
+\brief Writes data to the external memory.
+
+\param[in]
+ pos - image position for new data
+\param[in]
+ accessParam - pointer to the access structure
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_Write(OFD_Position_t pos, OFD_MemoryAccessParam_t *accessParam, OFD_Callback_t cb)
+{
+ if ((pos >= OFD_POSITION_MAX) || (NULL == accessParam))
+ {
+ if (cb)
+ cb(OFD_STATUS_INCORRECT_API_PARAMETER);
+ return;
+ }
+
+ sectorNumber = pos;
+ ofdCallback = cb;
+ localAccessStructure = *accessParam;
+
+ // set table info like "image was written through api"
+ imageTable |= (OfdImageTable_t)(1 << pos);
+
+ if (localAccessStructure.offset >= OFD_START_EEPROM_SREC_ADDRESS)
+ localAccessStructure.offset -= (OFD_START_EEPROM_SREC_ADDRESS - OFD_EEPROM_OFFSET_WITHIN_IMAGE);
+
+ if (OFD_POSITION_1 == sectorNumber)
+ localAccessStructure.offset += OFD_IMAGE1_START_ADDRESS;
+ else
+ localAccessStructure.offset += OFD_IMAGE2_START_ADDRESS;
+
+ ofdWriteData();
+}
+
+/**************************************************************************//**
+\brief Flushes data from internal buffer, checks image crc and saves it to
+the external memory.
+
+\param[in]
+ pos - image position for new data
+\param[in]
+ countBuff - pointer to the memory for internal data (memory size must be OFD_BLOCK_FOR_CHECK_CRC)
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_FlushAndCheckCrc(OFD_Position_t pos, uint8_t *countBuff, OFD_InfoCallback_t cb)
+{
+ if ((pos >= OFD_POSITION_MAX) || (NULL == countBuff))
+ {
+ if (cb)
+ cb(OFD_STATUS_INCORRECT_API_PARAMETER, &imageInfo);
+ return;
+ }
+
+ ofdFlushData();
+
+ sectorNumber = pos;
+ ofdCallback = (OFD_Callback_t)cb;
+ imageInfo.crc = CRC_INITIALIZATION_VALUE;
+
+ localAccessStructure.data = countBuff;
+ localAccessStructure.length = OFD_IMAGE_SIZE;
+ if (OFD_POSITION_1 == sectorNumber)
+ localAccessStructure.offset = OFD_IMAGE1_START_ADDRESS;
+ else
+ localAccessStructure.offset = OFD_IMAGE2_START_ADDRESS;
+
+ ofdCheckCrc();
+}
+
+/**************************************************************************//**
+\brief Saves current mcu flash and eeprom to the external memory, checks crc for its
+and set command for bootloader.
+
+\param[in]
+ whereToSave - image position for current mcu flash and eeprom
+\param[in]
+ from - new image position
+\param[in]
+ copyBuff - pointer to the memory for internal data (memory size must be OFD_BLOCK_FOR_CHECK_CRC)
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_SwitchToNewImage(OFD_Position_t whereToSave, OFD_Position_t from, uint8_t *copyBuff, OFD_Callback_t cb)
+{
+ if ((whereToSave >= OFD_POSITION_MAX) || (from >= OFD_POSITION_MAX) || (whereToSave == from) || (NULL == copyBuff))
+ {
+ if (cb)
+ cb(OFD_STATUS_INCORRECT_API_PARAMETER);
+ return;
+ }
+
+ sectorNumber = whereToSave;
+ actionSector = from;
+ ofdAuxCallback = cb;
+
+ // set table info like "image was saved from mcu"
+ imageTable &= (OfdImageTable_t)~(1 << sectorNumber);
+
+ internalAccessParam.flashOffset = 0ul;
+ internalAccessParam.data = copyBuff;
+ internalAccessParam.length = OFD_IMAGE_SIZE;
+
+ if (OFD_POSITION_1 == sectorNumber)
+ localAccessStructure.offset = OFD_IMAGE1_START_ADDRESS;
+ else
+ localAccessStructure.offset = OFD_IMAGE2_START_ADDRESS;
+
+ ofdSaveCurrentFlashImage();
+}
+
+/**************************************************************************//**
+\brief Reads image informations.
+
+\param[in]
+ pos - image position
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_ReadImageInfo(OFD_Position_t pos, OFD_InfoCallback_t cb)
+{
+ if (pos >= OFD_POSITION_MAX)
+ {
+ if (cb)
+ cb(OFD_STATUS_INCORRECT_API_PARAMETER, &imageInfo);
+ return;
+ }
+
+ sectorNumber = pos;
+
+ if (imageTable & (1 << pos))
+ imageInfo.type = OFD_IMAGE_WAS_WRITTEN_THROUGH_API;
+ else
+ imageInfo.type = OFD_IMAGE_WAS_SAVED_FROM_MCU;
+
+ ofdCallback = (OFD_Callback_t)cb;
+
+ ofdReadCrc();
+}
+
+/**************************************************************************//**
+\brief Sets command for bootloader.
+
+\param[in]
+ from - image position
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_ChangeImage(OFD_Position_t from, OFD_Callback_t cb)
+{
+ if (from >= OFD_POSITION_MAX)
+ {
+ if (cb)
+ cb(OFD_STATUS_INCORRECT_API_PARAMETER);
+ return;
+ }
+
+ actionSector = from;
+ ofdAuxCallback = cb;
+ ofdSetActionForBootloader();
+}
+
+#endif // APP_USE_FAKE_OFD_DRIVER == 0
+#endif // (APP_USE_OTAU == 1)
+#endif // _OTAU_
+
+// eof ofdCommand.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdCrcService.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdCrcService.c
new file mode 100644
index 00000000..3ba6ed45
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdCrcService.c
@@ -0,0 +1,66 @@
+/**************************************************************************//**
+\file ofdCrcService.c
+
+\brief Implementation of crc counting algorithm.
+
+\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:
+ 7/08/09 A. Khromykh - Created
+*******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifdef _OTAU_
+#if (APP_USE_OTAU == 1)
+#if APP_USE_FAKE_OFD_DRIVER == 0
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Counts crc current memory area. CRC-8. Polynom 0x31 x^8 + x^5 + x^4 + 1.
+
+\param[in]
+ crc - first crc state
+\param[in]
+ pcBlock - pointer to the memory for crc counting
+\param[in]
+ length - memory size
+
+\return
+ current area crc
+******************************************************************************/
+uint8_t ofdCrc(uint8_t crc, uint8_t *pcBlock, uint8_t length)
+{
+ uint8_t i;
+
+ while (length--)
+ {
+ crc ^= *pcBlock++;
+
+ for (i = 0; i < 8; i++)
+ crc = crc & 0x80 ? (crc << 1) ^ 0x31 : crc << 1;
+ }
+
+ return crc;
+}
+
+#endif // APP_USE_FAKE_OFD_DRIVER == 0
+#endif // (APP_USE_OTAU == 1)
+#endif // _OTAU_
+
+// eof ofdCrcService.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdFakeDriver.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdFakeDriver.c
new file mode 100644
index 00000000..2d781c70
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdFakeDriver.c
@@ -0,0 +1,218 @@
+/**************************************************************************//**
+\file ofdFakeDriver.c
+
+\brief Implementation of OTAU fake flash driver.
+
+\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:
+ 2/06/10 A. Khromykh - Created
+*******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifdef _OTAU_
+#if (APP_USE_OTAU == 1)
+#if APP_USE_FAKE_OFD_DRIVER == 1
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <ofdExtMemory.h>
+#include <appTimer.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define CALL_CALLBACK_TIME 10
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+static void ofdRunDriverCb(void);
+static void ofdRunInfoDriverCb(void);
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+static HAL_AppTimer_t ofdCallbackRunner =
+{
+ .interval = CALL_CALLBACK_TIME,
+ .mode = TIMER_ONE_SHOT_MODE,
+};
+OFD_Callback_t ofdFuncCb = NULL;
+OFD_InfoCallback_t ofdFuncInfoCb = NULL;
+OFD_ImageInfo_t ofdImageInfo =
+{
+ .type = OFD_IMAGE_WAS_SAVED_FROM_MCU,
+ .crc = 0x00
+};
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Run flash driver callback if that has been initialized.
+******************************************************************************/
+static void ofdRunDriverCb(void)
+{
+ if (ofdFuncCb)
+ {
+ ofdFuncCb(OFD_STATUS_SUCCESS);
+ }
+}
+
+/**************************************************************************//**
+\brief Run flash information driver callback if that has been initialized.
+******************************************************************************/
+static void ofdRunInfoDriverCb(void)
+{
+ if (ofdFuncInfoCb)
+ {
+ ofdFuncInfoCb(OFD_STATUS_SUCCESS, &ofdImageInfo);
+ }
+}
+
+/**************************************************************************//**
+\brief Opens serial interface and checks memory type.
+
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_Open(OFD_Callback_t cb)
+{
+ ofdFuncCb = cb;
+ ofdCallbackRunner.callback = ofdRunDriverCb;
+ HAL_StartAppTimer(&ofdCallbackRunner);
+}
+
+/**************************************************************************//**
+\brief Closes serial interface.
+******************************************************************************/
+void OFD_Close(void)
+{
+}
+
+/**************************************************************************//**
+\brief Erases image in the external memory.
+
+\param[in]
+ pos - image position in the external memory
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_EraseImage(OFD_Position_t pos, OFD_Callback_t cb)
+{
+ (void)pos;
+ ofdFuncCb = cb;
+ ofdCallbackRunner.callback = ofdRunDriverCb;
+ HAL_StartAppTimer(&ofdCallbackRunner);
+}
+
+/**************************************************************************//**
+\brief Writes data to the external memory.
+
+\param[in]
+ pos - image position for new data
+\param[in]
+ accessParam - pointer to the access structure
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_Write(OFD_Position_t pos, OFD_MemoryAccessParam_t *accessParam, OFD_Callback_t cb)
+{
+ (void)pos;
+ (void)accessParam;
+ ofdFuncCb = cb;
+ ofdCallbackRunner.callback = ofdRunDriverCb;
+ HAL_StartAppTimer(&ofdCallbackRunner);
+}
+
+/**************************************************************************//**
+\brief Flushes data from internal buffer, checks image crc and saves it to
+the external memory.
+
+\param[in]
+ pos - image position for new data
+\param[in]
+ countBuff - pointer to the memory for internal data (memory size must be OFD_BLOCK_FOR_CHECK_CRC)
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_FlushAndCheckCrc(OFD_Position_t pos, uint8_t *countBuff, OFD_InfoCallback_t cb)
+{
+ (void)pos;
+ (void)countBuff;
+ ofdFuncInfoCb = cb;
+ ofdCallbackRunner.callback = ofdRunInfoDriverCb;
+ HAL_StartAppTimer(&ofdCallbackRunner);
+}
+
+/**************************************************************************//**
+\brief Saves current mcu flash and eeprom to the external memory, checks crc for its
+and set command for bootloader.
+
+\param[in]
+ whereToSave - image position for current mcu flash and eeprom
+\param[in]
+ from - new image position
+\param[in]
+ copyBuff - pointer to the memory for internal data (memory size must be OFD_BLOCK_FOR_CHECK_CRC)
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_SwitchToNewImage(OFD_Position_t whereToSave, OFD_Position_t from, uint8_t *copyBuff, OFD_Callback_t cb)
+{
+ (void)whereToSave;
+ (void)from;
+ (void)copyBuff;
+ ofdFuncCb = cb;
+ ofdCallbackRunner.callback = ofdRunDriverCb;
+ HAL_StartAppTimer(&ofdCallbackRunner);
+}
+
+/**************************************************************************//**
+\brief Sets command for bootloader.
+
+\param[in]
+ from - image position
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_ChangeImage(OFD_Position_t from, OFD_Callback_t cb)
+{
+ (void)from;
+ ofdFuncCb = cb;
+ ofdCallbackRunner.callback = ofdRunDriverCb;
+ HAL_StartAppTimer(&ofdCallbackRunner);
+}
+
+/**************************************************************************//**
+\brief Reads image informations.
+
+\param[in]
+ pos - image position
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_ReadImageInfo(OFD_Position_t pos, OFD_InfoCallback_t cb)
+{
+ (void)pos;
+ ofdFuncInfoCb = cb;
+ ofdCallbackRunner.callback = ofdRunInfoDriverCb;
+ HAL_StartAppTimer(&ofdCallbackRunner);
+}
+
+#endif // _OTAU_
+#endif // (APP_USE_OTAU == 1)
+#endif // APP_USE_FAKE_OFD_DRIVER == 1
+
+// eof ofdFakeDriver.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdIntFlashRead.s b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdIntFlashRead.s
new file mode 100644
index 00000000..b3267377
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdIntFlashRead.s
@@ -0,0 +1,40 @@
+/**************************************************************************//**
+ \file ofdIntFlashRead.s
+
+ \brief Implementation of internal flash reading.
+
+ \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:
+ 13/08/09 A. Khromykh - Created
+*******************************************************************************/
+
+/*******************************************************************************
+Reads byte from internal flash
+Parameters:
+ R25:R24:R23:R22 - Byte address into flash.
+Returns:
+ R24 - read byte from flash.
+*******************************************************************************/
+.section .text
+.global ofdReadInternalFlash
+ofdReadInternalFlash:
+ push r31 ; Store Z to stack
+ push r30 ; Store Z to stack
+ in r25, 0x3B ; Save RAMPZ.
+ out 0x3B, r24 ; Load RAMPZ with the MSB of the address.
+ movw r30, r22 ; Move low bytes of address to ZH:ZL from R23:R22
+ elpm r24, Z ; Extended load program memory from Z address
+ out 0x3B, r25 ; Restore RAMPZ register.
+ pop r30 ; Restore Z
+ pop r31 ; Restore Z
+ ret ; return from function
+
+; eof ofdIntFlashRead.s
+
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdIntFlashRead.s90 b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdIntFlashRead.s90
new file mode 100644
index 00000000..9fc8e941
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdIntFlashRead.s90
@@ -0,0 +1,40 @@
+/**************************************************************************//**
+ \file ofdIntFlashRead.s90
+
+ \brief Implementation of internal flash reading.
+
+ \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:
+ 19/02/10 A. Khromykh - Created
+*******************************************************************************/
+
+/*******************************************************************************
+Reads byte from internal flash
+Parameters:
+ R19:R18:R17:R16 - Byte address into flash.
+Returns:
+ R16 - read byte from flash.
+*******************************************************************************/
+PUBLIC ofdReadInternalFlash
+RSEG CODE
+ofdReadInternalFlash:
+ push r31 ; Store Z to stack
+ push r30 ; Store Z to stack
+ in r19, 0x3B ; Save RAMPZ.
+ out 0x3B, r18 ; Load RAMPZ with the MSB of the address.
+ movw r31:r30, r17:r16 ; Move low bytes of address to ZH:ZL from R17:R16
+ elpm r16, Z ; Extended load program memory from Z address
+ out 0x3B, r19 ; Restore RAMPZ register.
+ pop r30 ; Restore Z
+ pop r31 ; Restore Z
+ ret ; return from function
+
+; eof ofdIntFlashRead.s90
+END
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdSpiSerializer.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdSpiSerializer.c
new file mode 100644
index 00000000..9994f2ed
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/OFD/src/ofdSpiSerializer.c
@@ -0,0 +1,91 @@
+/**************************************************************************//**
+\file ofdSerializer.c
+
+\brief Implementation of capturing of serial interface.
+
+\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:
+ 7/08/09 A. Khromykh - Created
+*******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifdef _OTAU_
+#if (APP_USE_OTAU == 1)
+#if APP_USE_FAKE_OFD_DRIVER == 0
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <ofdExtMemory.h>
+#include <ofdMemoryDriver.h>
+#include <spi.h>
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+extern OFD_Callback_t ofdCallback;
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+HAL_SpiDescriptor_t spiDesc;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Opens serial interface and checks memory type.
+
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_Open(OFD_Callback_t cb)
+{
+ ofdCallback = cb;
+
+#if defined(ATMEGA1281) || defined(ATMEGA128RFA1)
+ spiDesc.tty = SPI_CHANNEL_0;
+ spiDesc.baudRate = SPI_CLOCK_RATE_2000;
+#elif defined(ATXMEGA256A3) || defined(ATXMEGA256D3)
+ spiDesc.tty = SPI_CHANNEL_D;
+ spiDesc.baudRate = SPI_CLOCK_RATE_8000;
+#endif
+ spiDesc.clockMode = SPI_CLOCK_MODE3;
+ spiDesc.dataOrder = SPI_DATA_MSB_FIRST;
+ spiDesc.callback = NULL;
+
+ if (-1 == HAL_OpenSpi(&spiDesc))
+ if (ofdCallback)
+ ofdCallback(OFD_SERIAL_INTERFACE_BUSY);
+
+ GPIO_EXT_MEM_CS_set();
+ GPIO_EXT_MEM_CS_make_out();
+ ofdFindStorageSpace();
+#if EXTERNAL_MEMORY == AT25DF041A
+ ofdUnprotectMemorySectors();
+#endif
+}
+
+/**************************************************************************//**
+\brief Closes serial interface.
+******************************************************************************/
+void OFD_Close(void)
+{
+ HAL_CloseSpi(&spiDesc);
+}
+
+#endif // APP_USE_FAKE_OFD_DRIVER == 0
+#endif // (APP_USE_OTAU == 1)
+#endif // _OTAU_
+
+// eof ofdSerialize.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/DFU/include/dfuProtocol.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/DFU/include/dfuProtocol.h
new file mode 100644
index 00000000..c525cfd1
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/DFU/include/dfuProtocol.h
@@ -0,0 +1,81 @@
+/****************************************************************************//**
+ \file dfuProtocol.h
+
+ \brief Declaration of Device firmware upgrade commands.
+
+ \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:
+ 08/09/11 N. Fomin - Created
+*******************************************************************************/
+#ifndef _DFUPROTOCOL_H
+#define _DFUPROTOCOL_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <usbSetupProcess.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+// data size in request structure
+#define DFU_REQUEST_DATA_SIZE 6
+// request codes for mass storage class
+#define DFU_DETACH 0x00
+#define DFU_GETSTATUS 0x03
+#define DFU_GETSTATE 0x05
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+// Usb host request
+typedef struct PACK
+{
+ UsbRequest_t request;
+ uint8_t bData[DFU_REQUEST_DATA_SIZE];
+} UsbDfuRequest_t;
+
+// Usb dfu get status response
+typedef struct PACK
+{
+ uint8_t bStatus;
+ uint8_t bPollTimeout[3];
+ uint8_t bState;
+ uint8_t iString;
+} DfuGetStatusResponse_t;
+
+// Usb dfu get state response
+typedef struct PACK
+{
+ uint8_t bState;
+} DfuGetStateResponse_t;
+
+typedef union PACK
+{
+ DfuGetStatusResponse_t getStatusResponse;
+ DfuGetStateResponse_t getStateResponse;
+} UsbDfuResponse_t;
+
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Device firmware upgrade request handler.
+\param[in]
+ data - pointer to host's request.
+******************************************************************************/
+void dfuRequestHandler(uint8_t *data);
+
+#endif /* _DFUPROTOCOL_H */
+// eof dfuProtocol.h \ No newline at end of file
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/DFU/src/dfuProtocol.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/DFU/src/dfuProtocol.c
new file mode 100644
index 00000000..c19f312b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/DFU/src/dfuProtocol.c
@@ -0,0 +1,135 @@
+/****************************************************************************//**
+ \file dfuProtocol.c
+
+ \brief Implementation of Device firmware upgrade commands.
+
+ \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:
+ 08/09/11 N. Fomin - Created
+*******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <dfuProtocol.h>
+#include <usb.h>
+#include <resetReason.h>
+#include <halFlash.h>
+#include <usbEnumeration.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define DFU_STATUS_OK 0x00
+#define DFU_STATUS_MAX_POLL_TIMEOUT 0xFF
+#define DFU_STATUS_NO_STRING 0x00
+
+#define BOOTLOADER_FLAG_FLASH_OFFSET 5
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+static UsbDfuResponse_t dfuResponse;
+static bool detachReceived = false;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief EEPROM write callback.
+******************************************************************************/
+void dfuResetAction(void)
+{
+ HAL_WarmReset();
+}
+/**************************************************************************//**
+\brief DFU detach request handler.
+******************************************************************************/
+static void dfuDetach(void)
+{
+ uint8_t bootloaderFlag = 0x5A;
+ HAL_EepromParams_t eepromParams = {
+ .address = (FLASH_BOOTLOADER_PAGES + FLASH_EEPROM_PAGES) * IFLASH_BYTES_PER_PAGE -
+ BOOTLOADER_FLAG_FLASH_OFFSET,
+ .data = &bootloaderFlag,
+ .length = 1
+ };
+ uint16_t page;
+
+#if defined(AT91SAM7X256) || defined(AT91SAM3S4C)
+ // Acknowledge the request
+ sendZLP();
+#endif
+
+ detachReceived = true;
+
+ halFlashPrepareForWrite();
+ page = halFlashPreparePage(&eepromParams);
+ halFlashWritePage(page, false);
+ halFlashRestoreFromWrite();
+
+ HAL_RegisterEndOfBusResetHandler(dfuResetAction);
+}
+/**************************************************************************//**
+\brief DFU get status request handler.
+******************************************************************************/
+static void dfuGetStatus(void)
+{
+ uint8_t i = 2;
+
+ dfuResponse.getStatusResponse.bStatus = DFU_STATUS_OK;
+ while(i--)
+ dfuResponse.getStatusResponse.bPollTimeout[i] = DFU_STATUS_MAX_POLL_TIMEOUT;
+ dfuResponse.getStatusResponse.bState = detachReceived;
+ dfuResponse.getStatusResponse.iString = DFU_STATUS_NO_STRING;
+
+ HAL_UsbWrite(0, (void *)&dfuResponse, sizeof(DfuGetStatusResponse_t), NULL, NULL);
+}
+
+/**************************************************************************//**
+\brief DFU get state request handler.
+******************************************************************************/
+static void dfuGetState(void)
+{
+ dfuResponse.getStateResponse.bState = detachReceived;
+
+ HAL_UsbWrite(0, (void *)&dfuResponse, sizeof(DfuGetStateResponse_t), NULL, NULL);
+}
+/**************************************************************************//**
+\brief Device firmware upgrade request handler.
+\param[in]
+ data - pointer to host's request.
+******************************************************************************/
+void dfuRequestHandler(uint8_t *data)
+{
+ UsbDfuRequest_t *pRequest = NULL;
+
+ pRequest = (UsbDfuRequest_t *)data;
+ if (NULL == pRequest)
+ return;
+
+ // Check request code
+ switch (pRequest->request.bRequest)
+ {
+ case DFU_DETACH:
+ dfuDetach();
+ break;
+ case DFU_GETSTATUS:
+ dfuGetStatus();
+ break;
+ case DFU_GETSTATE:
+ dfuGetState();
+ break;
+ default:
+ HAL_Stall(0);
+ break;
+ }
+}
+
+//eof dfuProtocol.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/include/abstractMemory.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/include/abstractMemory.h
new file mode 100644
index 00000000..2eab5f00
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/include/abstractMemory.h
@@ -0,0 +1,83 @@
+/****************************************************************************//**
+ \file abstactMemory.h
+
+ \brief Declaration of abstract memory commands.
+
+ \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:
+ 29/08/11 N. Fomin - Created
+*******************************************************************************/
+#ifndef _ABSTRACT_MEMORY_H
+#define _ABSTRACT_MEMORY_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <hsmci.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum
+{
+ memorySuccessStatus,
+ memoryErrorStatus
+} MemoryStatus_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Writes data to memory at "address".
+\param[in]
+ descriptor - pointer to hsmci descriptor;
+ address - address of blocks to write.
+ callback - pointer to function to nofity upper layer about end of write
+ procedure.
+\return
+ status of write procedure.
+******************************************************************************/
+MemoryStatus_t absMemWrite(HAL_HsmciDescriptor_t *descriptor, uint32_t address, void (*callback)(MemoryStatus_t));
+
+/**************************************************************************//**
+\brief Reads data from memory at "address".
+\param[in]
+ descriptor - pointer to hsmci descriptor;
+ address - address of blocks to read.
+ callback - pointer to function to nofity upper layer about end of read
+ procedure.
+\return
+ status of read procedure.
+******************************************************************************/
+MemoryStatus_t absMemRead(HAL_HsmciDescriptor_t *descriptor, uint32_t address, void (*callback)(MemoryStatus_t));
+
+/**************************************************************************//**
+\brief Performs memory initialization.
+\param[in]
+ descriptor - pointer to hsmci descriptor.
+\return
+ status of initialization procedure.
+******************************************************************************/
+MemoryStatus_t absMemInit(HAL_HsmciDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Reads memory capacity.
+\param[in]
+ descriptor - pointer to hsmci descriptor.
+\param[out]
+ lastBlockNumber - number of last accessible block of memory.
+\return
+ status of read capacity procedure.
+******************************************************************************/
+MemoryStatus_t absMemCapacity(HAL_HsmciDescriptor_t *descriptor, uint32_t *lastBlockNumber);
+
+#endif /* _ABSTRACT_MEMORY_H */
+// eof abstactMemory.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/include/mem.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/include/mem.h
new file mode 100644
index 00000000..0197f13a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/include/mem.h
@@ -0,0 +1,106 @@
+/****************************************************************************//**
+ \file mem.h
+
+ \brief Declaration of memory commands.
+
+ \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:
+ 29/08/11 N. Fomin - Created
+*******************************************************************************/
+#ifndef _MEM_H
+#define _MEM_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <hsmci.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+// block length
+#define STANDARD_BLOCK_LENGTH 512
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum
+{
+ memSuccess,
+ hsmciError,
+ voltageError,
+ commandError,
+ initTimeoutError,
+ stateError,
+ hsmciReadError,
+ hsmciWriteError,
+ setMaxFreqError
+} MemStatus_t;
+
+typedef struct
+{
+ uint32_t lastLogicalBlock;
+ uint32_t logicalBlockLength;
+} MemCapacityInfo_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Writes one data block to memory at "address".
+\param[in]
+ descriptor - pointer to hsmci descriptor;
+ address - address of block to write.
+\return
+ status of write procedure.
+******************************************************************************/
+MemStatus_t memWriteBlock(HAL_HsmciDescriptor_t *descriptor, uint32_t address, void (*callback)(MemStatus_t));
+
+/**************************************************************************//**
+\brief Reads one data block from memory at "address".
+\param[in]
+ descriptor - pointer to hsmci descriptor;
+ address - address of block to read.
+\return
+ status of read procedure.
+******************************************************************************/
+MemStatus_t memReadBlock(HAL_HsmciDescriptor_t *descriptor, uint32_t address, void (*callback)(MemStatus_t));
+
+/**************************************************************************//**
+\brief Performs memory initialization.
+\param[in]
+ commandDescr - pointer to hsmci command descriptor.
+\return
+ status of initialization procedure.
+******************************************************************************/
+MemStatus_t memInit(HAL_HsmciDescriptor_t *commandDescr);
+
+/**************************************************************************//**
+\brief Reads memory capacity.
+\param[in]
+ descriptor - pointer to hsmci descriptor.
+\param[out]
+ capInfo - pointer to memory capacity structure.
+\return
+ status of read capacity procedure.
+******************************************************************************/
+MemStatus_t memGetCapacityInfo(HAL_HsmciDescriptor_t *descriptor, MemCapacityInfo_t *capInfo);
+
+/**************************************************************************//**
+\brief Checks if memory is ready for any data transfer.
+\return
+ false - memory is busy;
+ true - memory is ready.
+******************************************************************************/
+bool memIsBusy(void);
+
+#endif /* _MEM_H */
+// eof mem.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/include/mscProtocol.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/include/mscProtocol.h
new file mode 100644
index 00000000..aa5964ad
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/include/mscProtocol.h
@@ -0,0 +1,79 @@
+/****************************************************************************//**
+ \file mscProtocol.h
+
+ \brief Declaration of mass storage device protocol command.
+
+ \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:
+ 29/08/11 N. Fomin - Created
+*******************************************************************************/
+#ifndef _MSCPROTOCOL_H
+#define _MSCPROTOCOL_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <usbSetupProcess.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+// data size in request structure
+#define MSC_REQUEST_DATA_SIZE 1
+
+// request codes for mass storage class
+#define BULK_ONLY_MASS_STORAGE_RESET 0xFF
+#define GET_MAX_LUN 0xFE
+// maximum size of CBW data
+#define CBW_DATA_SIZE 16
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+typedef struct PACK
+{
+ UsbRequest_t request;
+ uint8_t bData[MSC_REQUEST_DATA_SIZE];
+} UsbMscRequest_t;
+// MSC command block wrapper (CBW)
+typedef struct PACK
+{
+ uint32_t dCBWSignature;
+ uint32_t cDBWTag;
+ uint32_t dCBWDataTransferLength;
+ uint8_t bmCBWFlags;
+ uint8_t bCBWLUN;
+ uint8_t bCBWCBLength;
+ uint8_t CBWCB[CBW_DATA_SIZE];
+} MscCBW_t;
+// MSC command status wrapper (CSW)
+typedef struct PACK
+{
+ uint32_t dCSWSignature;
+ uint32_t cDSWTag;
+ uint32_t dCSWDataResidue;
+ uint8_t bCSWStatus;
+} MscCSW_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Mass storage device request handler.
+\param[in]
+ data - pointer to host's request.
+******************************************************************************/
+void msdRequestHandler(uint8_t *data);
+
+#endif /* _MSCPROTOCOL_H */
+// eof msdProtocol.h \ No newline at end of file
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/include/scsiProtocol.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/include/scsiProtocol.h
new file mode 100644
index 00000000..6a10b4dc
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/include/scsiProtocol.h
@@ -0,0 +1,114 @@
+/****************************************************************************//**
+ \file scsiProtocol.h
+
+ \brief Declaration of scsi protocol commands.
+
+ \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:
+ 29/08/11 N. Fomin - Created
+*******************************************************************************/
+#ifndef _SCSIPROTOCOL_H
+#define _SCSIPROTOCOL_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+// Maximum response length for scsi command
+#define MAX_COMMAND_RESPONSE_LENGTH 36
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Checks if received scsi command is supported.
+\param[in]
+ data - pointer to received command with parameters.
+\return
+ false - command is not supported;
+ true - command is supported.
+******************************************************************************/
+bool scsiIsValidCommand(uint8_t *data);
+
+/**************************************************************************//**
+\brief Checks if any response or data transfer needed for received
+ scsi command.
+\param[in]
+ command - received command.
+\return
+ false - response is not needed;
+ true - response is needed.
+******************************************************************************/
+bool scsiIsDataInOutPhaseNeeded(uint8_t *data);
+
+/**************************************************************************//**
+\brief Checks if command is read or write command.
+\param[in]
+ command - received command.
+\return
+ false - command is not read/write command;
+ true - command is read/write command.
+******************************************************************************/
+bool scsiIsReadWriteCommand(uint8_t *data);
+
+/**************************************************************************//**
+\brief Checks if command is read command.
+\param[in]
+ command - received command.
+\return
+ false - command is not read command;
+ true - command is read command.
+******************************************************************************/
+bool scsiIsReadCommand(uint8_t *data);
+
+/**************************************************************************//**
+\brief Blocks for read/write command.
+\param[in]
+ data - pointer to received command with parameters.
+\return
+ number of blocks to read or write from memory.
+******************************************************************************/
+uint16_t scsiBlocksAmount(uint8_t *data);
+
+/**************************************************************************//**
+\brief Response for scsi command.
+\param[in]
+ command - received command.
+\param[out]
+ buffer - buffer with scsi command response.
+\return
+ length of response
+******************************************************************************/
+uint8_t scsiGetCommandResponse(uint8_t *data, uint8_t *buffer);
+
+/**************************************************************************//**
+\brief Sets number of last available memory block for scsi response.
+\param[in]
+ lastBlock - received command.
+\param[out]
+ buffer - number of last available memory block
+******************************************************************************/
+void scsiSetCapacity(uint32_t lastBlock);
+
+/**************************************************************************//**
+\brief Block address for read/write command.
+\param[in]
+ data - pointer to received command with parameters.
+\return
+ block address for read or write from memory.
+******************************************************************************/
+uint32_t scsiGetBlockAddress(uint8_t *data);
+
+#endif /* _SCSIPROTOCOL_H */
+// eof scsiProtocol.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/abstractMemory.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/abstractMemory.c
new file mode 100644
index 00000000..dc11be63
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/abstractMemory.c
@@ -0,0 +1,225 @@
+/****************************************************************************//**
+ \files abstractMemory.c
+
+ \brief Implementation of amstract memory commands.
+
+ \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:
+ 30/08/11 N. Fomin - Created
+*******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <mem.h>
+#include <abstractMemory.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define RETRY_COUNT 5
+
+/******************************************************************************
+ External global variables section
+******************************************************************************/
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef struct
+{
+ uint16_t transferLength;
+ uint16_t blocksToTransfer;
+ uint32_t logicalBlockAddress;
+ HAL_HsmciDescriptor_t *hsmciDescriptor;
+ uint8_t *dataBuffer;
+} AbsMemInternal_t;
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+static void (*absMemCallback)(MemoryStatus_t status);
+static AbsMemInternal_t apsMemInternal;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Current memory read callback.
+\param[in]
+ status - status of read operation.
+******************************************************************************/
+void absMemReadBlockCallback(MemStatus_t status)
+{
+ uint8_t i = RETRY_COUNT;
+ apsMemInternal.blocksToTransfer--;
+ uint16_t blocksRemaining = apsMemInternal.transferLength - apsMemInternal.blocksToTransfer;
+ HAL_HsmciDescriptor_t *descriptor = apsMemInternal.hsmciDescriptor;
+
+ if (memSuccess != status)
+ absMemCallback(memoryErrorStatus);
+ if (0 == apsMemInternal.blocksToTransfer)
+ {
+ descriptor->dataTransferDescriptor->buffer = apsMemInternal.dataBuffer;
+ absMemCallback(memorySuccessStatus);
+ return;
+ }
+
+ descriptor->dataTransferDescriptor->buffer += blocksRemaining * STANDARD_BLOCK_LENGTH;
+
+ while(i--)
+ {
+ if (memSuccess == memReadBlock(descriptor, apsMemInternal.logicalBlockAddress + blocksRemaining, absMemReadBlockCallback))
+ break;
+ }
+ if (0 == i)
+ absMemCallback(memoryErrorStatus);
+}
+
+/**************************************************************************//**
+\brief Current memory write callback.
+\param[in]
+ status - status of write operation.
+******************************************************************************/
+void absMemWriteBlockCallback(MemStatus_t status)
+{
+ uint8_t i = RETRY_COUNT;
+ apsMemInternal.blocksToTransfer--;
+ uint16_t blocksRemaining = apsMemInternal.transferLength - apsMemInternal.blocksToTransfer;
+ HAL_HsmciDescriptor_t *descriptor = apsMemInternal.hsmciDescriptor;
+
+ if (memSuccess != status)
+ absMemCallback(memoryErrorStatus);
+ if (0 == apsMemInternal.blocksToTransfer)
+ {
+ descriptor->dataTransferDescriptor->buffer = apsMemInternal.dataBuffer;
+ absMemCallback(memorySuccessStatus);
+ return;
+ }
+
+ descriptor->dataTransferDescriptor->buffer += blocksRemaining * STANDARD_BLOCK_LENGTH;
+
+ while(i--)
+ {
+ if (memSuccess == memWriteBlock(descriptor, apsMemInternal.logicalBlockAddress + blocksRemaining, absMemWriteBlockCallback))
+ break;
+ }
+ if (0 == i)
+ absMemCallback(memoryErrorStatus);
+}
+
+/**************************************************************************//**
+\brief Performs memory initialization.
+\param[in]
+ descriptor - pointer to hsmci descriptor.
+\return
+ status of initialization procedure.
+******************************************************************************/
+MemoryStatus_t absMemInit(HAL_HsmciDescriptor_t *descriptor)
+{
+ if (memSuccess != memInit(descriptor))
+ return memoryErrorStatus;
+
+ return memorySuccessStatus;
+}
+
+/**************************************************************************//**
+\brief Reads memory capacity.
+\param[in]
+ descriptor - pointer to hsmci descriptor.
+\param[out]
+ lastBlockNumber - number of last accessible block of memory.
+\return
+ status of read capacity procedure.
+******************************************************************************/
+MemoryStatus_t absMemCapacity(HAL_HsmciDescriptor_t *descriptor, uint32_t *lastBlockNumber)
+{
+ MemCapacityInfo_t capInfo;
+ uint8_t i = RETRY_COUNT;
+ MemStatus_t status;
+
+ while(i--)
+ {
+ status = memGetCapacityInfo(descriptor, &capInfo);
+ if (memSuccess == status)
+ {
+ *lastBlockNumber = capInfo.lastLogicalBlock;
+ return memorySuccessStatus;
+ }
+ }
+
+ return memoryErrorStatus;
+}
+
+/**************************************************************************//**
+\brief Writes data to memory at "address".
+\param[in]
+ descriptor - pointer to hsmci descriptor;
+ address - address of blocks to write.
+ callback - pointer to function to nofity upper layer about end of write
+ procedure.
+\return
+ status of write procedure.
+******************************************************************************/
+MemoryStatus_t absMemWrite(HAL_HsmciDescriptor_t *descriptor, uint32_t address, void (*callback)(MemoryStatus_t))
+{
+ HAL_HsmciDataTransferDescriptor_t *dataDescr = descriptor->dataTransferDescriptor;
+ uint8_t i;
+ absMemCallback = callback;
+
+ apsMemInternal.logicalBlockAddress = address;
+ apsMemInternal.transferLength = dataDescr->length / STANDARD_BLOCK_LENGTH;
+ apsMemInternal.blocksToTransfer = apsMemInternal.transferLength;
+ apsMemInternal.dataBuffer = descriptor->dataTransferDescriptor->buffer;
+
+ dataDescr->length = STANDARD_BLOCK_LENGTH;
+
+ i = RETRY_COUNT;
+ while(i--)
+ {
+ if (memSuccess == memWriteBlock(descriptor, address, absMemWriteBlockCallback))
+ return memorySuccessStatus;
+ }
+
+ return memoryErrorStatus;
+}
+
+/**************************************************************************//**
+\brief Reads data from memory at "address".
+\param[in]
+ descriptor - pointer to hsmci descriptor;
+ address - address of blocks to read.
+ callback - pointer to function to nofity upper layer about end of read
+ procedure.
+\return
+ status of read procedure.
+******************************************************************************/
+MemoryStatus_t absMemRead(HAL_HsmciDescriptor_t *descriptor, uint32_t address, void (*callback)(MemoryStatus_t))
+{
+ HAL_HsmciDataTransferDescriptor_t *dataDescr = descriptor->dataTransferDescriptor;
+ uint8_t i;
+ absMemCallback = callback;
+
+ apsMemInternal.logicalBlockAddress = address;
+ apsMemInternal.transferLength = dataDescr->length / STANDARD_BLOCK_LENGTH;
+ apsMemInternal.blocksToTransfer = apsMemInternal.transferLength;
+ apsMemInternal.dataBuffer = descriptor->dataTransferDescriptor->buffer;
+
+ dataDescr->length = STANDARD_BLOCK_LENGTH;
+
+ i = RETRY_COUNT;
+ while(i--)
+ {
+ if (memSuccess == memReadBlock(descriptor, address, absMemReadBlockCallback))
+ return memorySuccessStatus;
+ }
+
+ return memoryErrorStatus;
+}
+
+//eof abstractMemory.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/massStorageDevice.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/massStorageDevice.c
new file mode 100644
index 00000000..94c36c42
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/massStorageDevice.c
@@ -0,0 +1,327 @@
+/****************************************************************************//**
+ \file massStorageDevice.c
+
+ \brief Implementation of mass storage API.
+
+ \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:
+ 29/08/11 N. Fomin - Created
+*******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <mscProtocol.h>
+#include <usbEnumeration.h>
+#include <massStorageDevice.h>
+#include <scsiProtocol.h>
+#include <abstractMemory.h>
+#include <usbDescriptors.h>
+#include <mem.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+#define CBW_SIZE 31
+#define CBW_SIGNATURE 0x43425355
+
+#define CSW_SIZE 13
+#define CSW_COMMAND_FAILED_STATUS 1
+#define CSW_COMMAND_SUCCESS_STATUS 0
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum
+{
+ MSD_COMMAND_TRANSPORT,
+ MSD_SCSI_ANSWER,
+ MSD_DATA_INOUT,
+ MSD_STATUS_TRANSPORT
+} MsdState_t;
+
+typedef struct
+{
+ uint32_t bufferOffset;
+ uint16_t buffersToTransfer;
+ uint32_t blockAddress;
+} MsdReadWriteControl_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+static void msdBufferReadCallback(MemoryStatus_t status);
+static void msdBufferWriteCallback(MemoryStatus_t status);
+
+/******************************************************************************
+ External global variables section
+******************************************************************************/
+static UsbMscRequest_t request;
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+// pointer to application hsmci descriptor
+static HAL_HsmciDescriptor_t msdDescr;
+HAL_HsmciDescriptor_t *msdPointDescr;
+static HAL_HsmciCommandDescriptor_t commandDescr;
+static HAL_HsmciDataTransferDescriptor_t dataTransferDescr;
+static MsdReadWriteControl_t rwControl;
+static MscCSW_t csw;
+static MsdState_t msdState;
+static MSD_Callback_t msdCallback = NULL;
+
+void msdRcvCallback(void *pArg, uint8_t status, uint16_t transferred, uint16_t remaining);
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Transmitting callback of usb.
+\param[in]
+ pArg - pointer to some data;
+ status - result of the USB transfer.;
+ transferred - how much data are transferred;
+ remaining - how much data are not transferred.
+******************************************************************************/
+void msdTmtCallback(void *pArg, uint8_t status, uint16_t transferred, uint16_t remaining)
+{
+ (void)pArg;
+ (void)status;
+ (void)remaining;
+ (void)transferred;
+
+ if (MSD_DATA_INOUT == msdState)
+ {
+ rwControl.buffersToTransfer--;
+ rwControl.blockAddress += msdDescr.dataTransferDescriptor->length / STANDARD_BLOCK_LENGTH;
+ if (0 == rwControl.buffersToTransfer)
+ {
+ csw.bCSWStatus = CSW_COMMAND_SUCCESS_STATUS;
+ msdState = MSD_STATUS_TRANSPORT;
+ memcpy(msdDescr.dataTransferDescriptor->buffer, (uint8_t*)&csw, CSW_SIZE);
+ HAL_UsbWrite(MSD_TRANSMIT_PIPE, msdDescr.dataTransferDescriptor->buffer, CSW_SIZE, msdTmtCallback, NULL);
+ return;
+ }
+ else
+ if (memorySuccessStatus != absMemRead(&msdDescr, rwControl.blockAddress, msdBufferReadCallback))
+ msdCallback(MSD_READ_ERROR);
+
+ }
+ if (MSD_SCSI_ANSWER == msdState)
+ {
+ csw.bCSWStatus = CSW_COMMAND_SUCCESS_STATUS;
+ msdState = MSD_STATUS_TRANSPORT;
+ memcpy(msdDescr.dataTransferDescriptor->buffer, (uint8_t*)&csw, CSW_SIZE);
+ HAL_UsbWrite(MSD_TRANSMIT_PIPE, msdDescr.dataTransferDescriptor->buffer, CSW_SIZE, msdTmtCallback, NULL);
+ return;
+ }
+ if (MSD_STATUS_TRANSPORT == msdState)
+ {
+ if (msdCallback)
+ msdCallback(MSD_STATUS_SUCCESS);
+ msdState = MSD_COMMAND_TRANSPORT;
+ HAL_UsbRead(MSD_RECEIVE_PIPE, msdDescr.dataTransferDescriptor->buffer, CBW_SIZE, msdRcvCallback, NULL);
+ return;
+ }
+}
+
+/**************************************************************************//**
+\brief Receiving callback of usb.
+\param[in]
+ pArg - pointer to some data;
+ status - result of the USB transfer.;
+ transferred - how much data are transferred;
+ remaining - how much data are not transferred.
+******************************************************************************/
+void msdRcvCallback(void *pArg, uint8_t status, uint16_t transferred, uint16_t remaining)
+{
+ bool validAndMeaningful = true;
+ MscCBW_t *cbw = (MscCBW_t *)(msdDescr.dataTransferDescriptor->buffer);
+ uint8_t length;
+
+ (void)pArg;
+ (void)status;
+ (void)remaining;
+
+ if (MSD_COMMAND_TRANSPORT == msdState)
+ {
+ /* check that CBW is valid */
+ if ((CBW_SIZE != transferred) || (CBW_SIGNATURE != cbw->dCBWSignature))
+ validAndMeaningful = false;
+ if (!validAndMeaningful)
+ {
+ HAL_Stall(ADDRESS_MSC_BULKIN_PIPE & 0x03);
+ return;
+ }
+ /* check that CBW is meaningful */
+ if ((cbw->bCBWLUN > 0x0F) || (cbw->bCBWCBLength == 0) || (cbw->bCBWCBLength > 0x10) || (cbw->bmCBWFlags & 0x7F))
+ validAndMeaningful = false;
+ if (!validAndMeaningful)
+ return;
+ /* fill csw with parameters from cbw */
+ csw.cDSWTag = cbw->cDBWTag;
+ csw.dCSWSignature = CBW_SIGNATURE;
+ /* check that command is valid */
+ if (!scsiIsValidCommand(cbw->CBWCB))
+ {
+ csw.bCSWStatus = CSW_COMMAND_FAILED_STATUS;
+ msdState = MSD_STATUS_TRANSPORT;
+ memcpy(msdDescr.dataTransferDescriptor->buffer, (uint8_t*)&csw, CSW_SIZE);
+ HAL_UsbWrite(MSD_TRANSMIT_PIPE, msdDescr.dataTransferDescriptor->buffer, CSW_SIZE, msdTmtCallback, NULL);
+ return;
+ }
+ /* check that no data in-out phase is needed */
+ if (!scsiIsDataInOutPhaseNeeded(cbw->CBWCB))
+ {
+ csw.bCSWStatus = CSW_COMMAND_SUCCESS_STATUS;
+ msdState = MSD_STATUS_TRANSPORT;
+ memcpy(msdDescr.dataTransferDescriptor->buffer, (uint8_t*)&csw, CSW_SIZE);
+ HAL_UsbWrite(MSD_TRANSMIT_PIPE, msdDescr.dataTransferDescriptor->buffer, CSW_SIZE, msdTmtCallback, NULL);
+ return;
+ }
+ /* check that command is no read-write command */
+ if (!scsiIsReadWriteCommand(cbw->CBWCB))
+ {
+ csw.bCSWStatus = CSW_COMMAND_SUCCESS_STATUS;
+ msdState = MSD_SCSI_ANSWER;
+ length = scsiGetCommandResponse(cbw->CBWCB, msdDescr.dataTransferDescriptor->buffer);
+ HAL_UsbWrite(MSD_TRANSMIT_PIPE, msdDescr.dataTransferDescriptor->buffer, length, msdTmtCallback, NULL);
+ return;
+ }
+ /* check that command is read command */
+ rwControl.buffersToTransfer = scsiBlocksAmount(cbw->CBWCB) * (msdDescr.dataTransferDescriptor->length / STANDARD_BLOCK_LENGTH);
+ rwControl.blockAddress = scsiGetBlockAddress(cbw->CBWCB);
+ if (scsiIsReadCommand(cbw->CBWCB))
+ {
+ if (memorySuccessStatus != absMemRead(&msdDescr, rwControl.blockAddress, msdBufferReadCallback))
+ msdCallback(MSD_READ_ERROR);
+ }
+ else
+ HAL_UsbRead(MSD_RECEIVE_PIPE, msdDescr.dataTransferDescriptor->buffer,
+ BULK_SIZE, msdRcvCallback, NULL);
+ msdState = MSD_DATA_INOUT;
+ return;
+ }
+ if (MSD_DATA_INOUT == msdState)
+ {
+ /* increase internal write buffer offset*/
+ rwControl.bufferOffset += transferred;
+ /* if buffer is full perform write to flash */
+ if (rwControl.bufferOffset == msdDescr.dataTransferDescriptor->length)
+ {
+ if (memorySuccessStatus != absMemWrite(&msdDescr, rwControl.blockAddress, msdBufferWriteCallback))
+ msdCallback(MSD_WRITE_ERROR);
+ /* wait for hsmci bus becomes free */
+ rwControl.bufferOffset = 0;
+ rwControl.buffersToTransfer--;
+ rwControl.blockAddress += msdDescr.dataTransferDescriptor->length / STANDARD_BLOCK_LENGTH;
+ return;
+ }
+ if (0 != rwControl.buffersToTransfer)
+ HAL_UsbRead(MSD_RECEIVE_PIPE, msdDescr.dataTransferDescriptor->buffer + rwControl.bufferOffset,
+ BULK_SIZE, msdRcvCallback, NULL);
+
+ }
+}
+
+/**************************************************************************//**
+\brief Opens mass storage device.
+\param[in]
+ callback - pointer to function to notify about MSD errors and transactions;
+ responseBuffer - pointer to hsmci command response buffer; it should have
+ a size of four;
+ buffer - pointer to buffer for hsmci data transfer; it should be
+ a multiplier of 512;
+ length - length of buffer for data transfer.
+******************************************************************************/
+void MSD_Open(MSD_Callback_t callback, uint32_t *responseBuffer, uint8_t *buffer, uint32_t length)
+{
+ uint32_t lastBlock;
+
+ msdCallback = callback;
+
+ msdDescr.dataTransferDescriptor = &dataTransferDescr;
+ msdDescr.commandDescriptor = &commandDescr;
+ msdDescr.dataTransferDescriptor->buffer = buffer;
+ msdDescr.dataTransferDescriptor->length = length;
+ msdDescr.commandDescriptor->responseBuffer = responseBuffer;
+ msdDescr.dataTransferDescriptor->commandDescr = &commandDescr;
+
+ msdPointDescr = & msdDescr;
+
+ if (-1 == HAL_OpenHsmci(&msdDescr))
+ if (msdCallback)
+ msdCallback(MSD_INTERFACE_BUSY);
+
+ if (memorySuccessStatus != absMemInit(&msdDescr))
+ if (msdCallback)
+ msdCallback(MSD_MEMORY_INIT_ERROR);
+
+ if (memorySuccessStatus != absMemCapacity(&msdDescr, &lastBlock))
+ if (msdCallback)
+ msdCallback(MSD_READ_CAPACITY_ERROR);
+
+ scsiSetCapacity(lastBlock);
+
+ rwControl.bufferOffset = 0;
+ rwControl.buffersToTransfer = 0;
+ msdState = MSD_COMMAND_TRANSPORT;
+ csw.dCSWDataResidue = 0;
+
+ HAL_RegisterEndOfBusResetHandler(usbBusResetAction);
+ if (DEVICE_POWERED != HAL_GetState())
+ HAL_UsbInit((uint8_t *)&request);
+}
+
+/**************************************************************************//**
+\brief Closes mass storage device.
+******************************************************************************/
+void MSD_Close(void)
+{
+ if (-1 == HAL_CloseHsmci(&msdDescr))
+ if (msdCallback)
+ msdCallback(MSD_INTERFACE_BUSY);
+}
+
+/**************************************************************************//**
+\brief Memory read callback function.
+\param[in]
+ status - status of memory read procedure.
+******************************************************************************/
+static void msdBufferReadCallback(MemoryStatus_t status)
+{
+ if (memorySuccessStatus != status)
+ msdCallback(MSD_READ_ERROR);
+ HAL_UsbWrite(MSD_TRANSMIT_PIPE, msdDescr.dataTransferDescriptor->buffer,
+ msdDescr.dataTransferDescriptor->length, msdTmtCallback, NULL);
+}
+
+/**************************************************************************//**
+\brief Memory write callback function.
+\param[in]
+ status - status of memory write procedure.
+******************************************************************************/
+static void msdBufferWriteCallback(MemoryStatus_t status)
+{
+ if (memorySuccessStatus != status)
+ msdCallback(MSD_WRITE_ERROR);
+ if (0 == rwControl.buffersToTransfer)
+ {
+ csw.bCSWStatus = CSW_COMMAND_SUCCESS_STATUS;
+ msdState = MSD_STATUS_TRANSPORT;
+ memcpy(msdDescr.dataTransferDescriptor->buffer, (uint8_t*)&csw, CSW_SIZE);
+ HAL_UsbWrite(MSD_TRANSMIT_PIPE, msdDescr.dataTransferDescriptor->buffer, CSW_SIZE, msdTmtCallback, NULL);
+ }
+ else
+ HAL_UsbRead(MSD_RECEIVE_PIPE, msdDescr.dataTransferDescriptor->buffer,
+ BULK_SIZE, msdRcvCallback, NULL);
+}
+
+// eof massStorageDevice.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/mmc.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/mmc.c
new file mode 100644
index 00000000..b512bd04
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/mmc.c
@@ -0,0 +1,618 @@
+/****************************************************************************//**
+ \files mmc.c
+
+ \brief Implementation of mmc protocol.
+
+ \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:
+ 30/08/11 N. Fomin - Created
+*******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <mem.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+// card voltage ranges
+#define OCR_VDD_16_17 (1 << 4)
+#define OCR_VDD_17_18 (1 << 5)
+#define OCR_VDD_18_19 (1 << 6)
+#define OCR_VDD_19_20 (1 << 7)
+#define OCR_VDD_20_21 (1 << 8)
+#define OCR_VDD_21_22 (1 << 9)
+#define OCR_VDD_22_23 (1 << 10)
+#define OCR_VDD_23_24 (1 << 11)
+#define OCR_VDD_24_25 (1 << 12)
+#define OCR_VDD_25_26 (1 << 13)
+#define OCR_VDD_26_27 (1 << 14)
+#define OCR_VDD_27_28 (1 << 15)
+#define OCR_VDD_28_29 (1 << 16)
+#define OCR_VDD_29_30 (1 << 17)
+#define OCR_VDD_30_31 (1 << 18)
+#define OCR_VDD_31_32 (1 << 19)
+#define OCR_VDD_32_33 (1 << 20)
+#define OCR_VDD_33_34 (1 << 21)
+#define OCR_VDD_34_35 (1 << 22)
+#define OCR_VDD_35_36 (1 << 23)
+// R1 response statuses
+#define STATUS_APP_CMD (1UL << 5)
+#define STATUS_SWITCH_ERROR (1UL << 7)
+#define STATUS_READY_FOR_DATA (1UL << 8)
+#define STATUS_IDLE (0UL << 9)
+#define STATUS_READY (1UL << 9)
+#define STATUS_IDENT (2UL << 9)
+#define STATUS_STBY (3UL << 9)
+#define STATUS_TRAN (4UL << 9)
+#define STATUS_DATA (5UL << 9)
+#define STATUS_RCV (6UL << 9)
+#define STATUS_PRG (7UL << 9)
+#define STATUS_DIS (8UL << 9)
+#define STATUS_STATE (0xFUL << 9)
+#define STATUS_ERASE_RESET (1UL << 13)
+#define STATUS_WP_ERASE_SKIP (1UL << 15)
+#define STATUS_CIDCSD_OVERWRITE (1UL << 16)
+#define STATUS_OVERRUN (1UL << 17)
+#define STATUS_UNERRUN (1UL << 18)
+#define STATUS_ERROR (1UL << 19)
+#define STATUS_CC_ERROR (1UL << 20)
+#define STATUS_CARD_ECC_FAILED (1UL << 21)
+#define STATUS_ILLEGAL_COMMAND (1UL << 22)
+#define STATUS_COM_CRC_ERROR (1UL << 23)
+#define STATUS_UN_LOCK_FAILED (1UL << 24)
+#define STATUS_CARD_IS_LOCKED (1UL << 25)
+#define STATUS_WP_VIOLATION (1UL << 26)
+#define STATUS_ERASE_PARAM (1UL << 27)
+#define STATUS_ERASE_SEQ_ERROR (1UL << 28)
+#define STATUS_BLOCK_LEN_ERROR (1UL << 29)
+#define STATUS_ADDRESS_MISALIGN (1UL << 30)
+#define STATUS_ADDR_OUT_OR_RANGE (1UL << 31)
+// R1 response sets
+#define ERROR_STATUS (STATUS_ADDR_OUT_OR_RANGE | STATUS_ADDRESS_MISALIGN | STATUS_BLOCK_LEN_ERROR | STATUS_ERASE_SEQ_ERROR | \
+ STATUS_ERASE_PARAM | STATUS_WP_VIOLATION | STATUS_CARD_IS_LOCKED | STATUS_UN_LOCK_FAILED | \
+ STATUS_COM_CRC_ERROR | STATUS_ILLEGAL_COMMAND | STATUS_CARD_ECC_FAILED | STATUS_CC_ERROR | STATUS_ERROR | \
+ STATUS_UNERRUN | STATUS_OVERRUN | STATUS_CIDCSD_OVERWRITE | STATUS_SWITCH_ERROR)
+// command arguments
+#define CMD0_IDLE_STATE_ARGUMENT 0
+#define CMD1_ACCESS_MODE_SECTOR (1UL << 30)
+#define CMD1_HOST_VOLTAGE_RANGE (OCR_VDD_27_28 | OCR_VDD_28_29 | OCR_VDD_29_30 | OCR_VDD_30_31 | \
+ OCR_VDD_31_32 | OCR_VDD_32_33 | OCR_VDD_33_34 | OCR_VDD_34_35 | \
+ OCR_VDD_35_36)
+#define CMD2_ARGUMENT 0
+#define CMD6_SET_4_LINE_BUS 0x03B70100
+#define CMD6_SET_HS_MODE 0x03B90100
+// relative card address
+#define REVALITE_CARD_ADDRESS (1 << 16)
+// command responses length
+#define NO_RESPONSE_LENGTH 0
+#define R1_RESPONSE_LENGTH 1
+#define R2_RESPONSE_LENGTH 4
+#define R3_RESPONSE_LENGTH 1
+// retry amount of card initialization
+#define RETRY_AMOUNT 10000
+// memory frequency masks for CDS memory register
+#define FREQ_UNITS_MASK 0x07
+#define FREQ_MULTIPLIER_MASK 0x78
+#define FREQ_MULTIPLIER_OFFSET 0x03
+// csd register definitions
+#define CSD_SPEC_VERS_FOUR 4
+
+/******************************************************************************
+ External global variables section
+******************************************************************************/
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef union
+{
+ uint32_t reg;
+ struct
+ {
+ uint32_t reserved1 : 5;
+ uint32_t appCmd : 1;
+ uint32_t urgentBkops : 1;
+ uint32_t switchError : 1;
+ uint32_t readyForData : 1;
+ uint32_t currentState : 4;
+ uint32_t eraseReset : 1;
+ uint32_t reserved2 : 1;
+ uint32_t wpEraseSkip : 1;
+ uint32_t cidCsdOverwrite : 1;
+ uint32_t overrun : 1;
+ uint32_t underrun : 1;
+ uint32_t error : 1;
+ uint32_t ccEror : 1;
+ uint32_t cardEccFailed : 1;
+ uint32_t illegalCommand : 1;
+ uint32_t comCrcError : 1;
+ uint32_t lockUnlockFailed : 1;
+ uint32_t cardIsLocked : 1;
+ uint32_t wpViolation : 1;
+ uint32_t eraseParam : 1;
+ uint32_t eraseSeqError : 1;
+ uint32_t blockLenError : 1;
+ uint32_t addressMisalign : 1;
+ uint32_t addressOutOfRange: 1;
+ };
+} MmcCardStatus_t;
+
+typedef union
+{
+ uint32_t reg;
+ struct
+ {
+ uint32_t reserverd1 : 7;
+ uint32_t voltage170_195: 1;
+ uint32_t voltage20_26 : 7;
+ uint32_t voltage27_36 : 9;
+ uint32_t reserved2 : 5;
+ uint32_t accessMode : 2;
+ uint32_t busy : 1;
+ };
+} MmcOcrRegister_t;
+
+typedef struct
+{
+ uint8_t tranSpeed;
+ uint8_t nsac;
+ uint8_t taac;
+ uint8_t reserved3 : 2;
+ uint8_t specVersion : 4;
+ uint8_t csdStructure : 2;
+ uint32_t cSizeDown : 10;
+ uint32_t reserved2 : 2;
+ uint32_t dsrImp : 1;
+ uint32_t readBlkMisalign : 1;
+ uint32_t writeBlkMisalign: 1;
+ uint32_t readBlPartial : 1;
+ uint32_t readBlLen : 4;
+ uint32_t ccc : 12;
+ uint32_t wpGroupSize : 5;
+ uint32_t eraseGroupMult : 5;
+ uint32_t eraseGroupSize : 5;
+ uint32_t cSizeMult : 3;
+ uint32_t vddWCurrMax : 3;
+ uint32_t vddWCurrMin : 3;
+ uint32_t vddRCurrMax : 3;
+ uint32_t vddRCurrMin : 3;
+ uint32_t cSizeUp : 2;
+ uint8_t notUsed : 1;
+ uint8_t crc : 7;
+ uint8_t ecc : 2;
+ uint8_t fileFormat : 2;
+ uint8_t tmpWriteProtect : 1;
+ uint8_t permWriteProtect : 1;
+ uint8_t copy : 1;
+ uint8_t fileFormatGroup : 1;
+ uint16_t contentPropApp : 1;
+ uint16_t reserved1 : 4;
+ uint16_t writeBlPartial : 1;
+ uint16_t writeBlLen : 4;
+ uint16_t r2wFactor : 3;
+ uint16_t defaultEcc : 2;
+ uint16_t wpGroupEnable : 1;
+} MmcCSDRegister_t;
+
+/******************************************************************************
+ Constants section
+******************************************************************************/
+static const uint32_t mmcFrequencyUnits[8] = {100, 1000, 10000, 100000, 0, 0, 0, 0};
+static const uint32_t mmcFrequencyMulptiplier[16] = {0, 10, 12, 13, 15, 20, 26, 30, 35, 40, 45, 52, 55, 60, 70, 80};
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+static bool memSendCommand(HAL_HsmciDescriptor_t *descriptor, uint32_t command, uint32_t argument, uint8_t respLength);
+static bool memCheckState(HAL_HsmciDescriptor_t *descriptor, uint16_t state);
+static bool setMaximumCommunicationFrequency(HAL_HsmciDescriptor_t *descriptor, uint8_t freqCode, bool hsMode);
+static MemStatus_t setBusWidthAndHsMode(HAL_HsmciDescriptor_t *descriptor, MmcCSDRegister_t *csdReg);
+static void (*absMemoryCallback)(MemStatus_t) = NULL;
+static HAL_HsmciDescriptor_t *memDescriptor = NULL;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief HSMCI write callback.
+******************************************************************************/
+void memWriteCallback(void)
+{
+ MmcCardStatus_t *cardStatus;
+
+ cardStatus = (MmcCardStatus_t *)(memDescriptor->commandDescriptor->responseBuffer);
+ if (0 != (cardStatus->reg & ERROR_STATUS))
+ absMemoryCallback(hsmciWriteError);
+ absMemoryCallback(memSuccess);
+}
+
+/**************************************************************************//**
+\brief HSMCI read callback.
+******************************************************************************/
+void memReadCallback(void)
+{
+ MmcCardStatus_t *cardStatus;
+
+ cardStatus = (MmcCardStatus_t *)(memDescriptor->commandDescriptor->responseBuffer);
+ if (0 != (cardStatus->reg & ERROR_STATUS))
+ absMemoryCallback(hsmciReadError);
+ absMemoryCallback(memSuccess);
+}
+/**************************************************************************//**
+\brief Performs MMC memory initialization.
+\param[in]
+ commandDescr - pointer to hsmci command descriptor.
+\return
+ status of initialization procedure.
+******************************************************************************/
+MemStatus_t memInit(HAL_HsmciDescriptor_t *descriptor)
+{
+ uint16_t i = RETRY_AMOUNT;
+ MmcCardStatus_t *cardStatus;
+ MmcOcrRegister_t *ocrRegister;
+ MmcCSDRegister_t *csdReg;
+ HAL_HsmciCommandDescriptor_t *commandDescr = descriptor->commandDescriptor;
+ uint32_t sendOpCondResponse;
+ MemStatus_t status;
+
+ /* send first command - CMD0 with power init parameters */
+ if (!memSendCommand(descriptor, POWER_ON_INIT, CMD0_IDLE_STATE_ARGUMENT, NO_RESPONSE_LENGTH))
+ return hsmciError;
+ /* wait for hsmci bus becomes free */
+ while (!HAL_HsmciCheckReady());
+ /* send CMD0 command to go to idle mode */
+ if (!memSendCommand(descriptor, GO_IDLE_STATE, CMD0_IDLE_STATE_ARGUMENT, NO_RESPONSE_LENGTH))
+ return hsmciError;
+ /* wait for hsmci bus becomes free */
+ while (!HAL_HsmciCheckReady());
+ /* wait for internal initialization process */
+ for (; i > 0; i--)
+ {
+ /* send CMD1 command to check host and device voltage correlation */
+ if (!memSendCommand(descriptor, SEND_OP_COND, CMD1_HOST_VOLTAGE_RANGE | CMD1_ACCESS_MODE_SECTOR, R3_RESPONSE_LENGTH))
+ return hsmciError;
+ /* wait for hsmci bus becomes free */
+ while (!HAL_HsmciCheckReady());
+ ocrRegister = (MmcOcrRegister_t *)(commandDescr->responseBuffer);
+ if (!(ocrRegister->reg & CMD1_HOST_VOLTAGE_RANGE))
+ return voltageError;
+ if (0 == ocrRegister->busy)
+ continue;
+ break;
+ }
+ if (0 == i)
+ return initTimeoutError;
+ sendOpCondResponse = commandDescr->responseBuffer[0];
+ i = RETRY_AMOUNT;
+ while (i--)
+ {
+ /* send CMD2 command to get card CID number */
+ if (!memSendCommand(descriptor, ALL_SEND_CID, CMD2_ARGUMENT, R2_RESPONSE_LENGTH))
+ return hsmciError;
+ /* wait for hsmci bus becomes free */
+ while (!HAL_HsmciCheckReady());
+ if (sendOpCondResponse != commandDescr->responseBuffer[0])
+ break;
+ }
+ if (0 == i)
+ return stateError;
+ /* send CMD3 command to set card relative address */
+ if (!memSendCommand(descriptor, SEND_RELATIVE_ADDR, REVALITE_CARD_ADDRESS, R1_RESPONSE_LENGTH))
+ return hsmciError;
+ /* wait for hsmci bus becomes free */
+ while (!HAL_HsmciCheckReady());
+ cardStatus = (MmcCardStatus_t *)(commandDescr->responseBuffer);
+ if (0 != (cardStatus->reg & ERROR_STATUS))
+ return commandError;
+ if (!memCheckState(descriptor, STATUS_STBY))
+ return stateError;
+ /* send CMD9 command to read CSD register */
+ if (!memSendCommand(descriptor, SEND_CSD, REVALITE_CARD_ADDRESS, R2_RESPONSE_LENGTH))
+ return hsmciError;
+ /* wait for hsmci bus becomes free */
+ while (!HAL_HsmciCheckReady());
+ /* read allowed maximum communication frequency and set it */
+ csdReg = (MmcCSDRegister_t *)(commandDescr->responseBuffer);
+ status = setBusWidthAndHsMode(descriptor, csdReg);
+ if (status != memSuccess)
+ return setMaxFreqError;
+
+ return memSuccess;
+}
+
+/**************************************************************************//**
+\brief Reads MMC memory capacity.
+\param[in]
+ descriptor - pointer to hsmci descriptor.
+\param[out]
+ capInfo - pointer to memory capacity structure.
+\return
+ status of read capacity procedure.
+******************************************************************************/
+MemStatus_t memGetCapacityInfo(HAL_HsmciDescriptor_t *descriptor, MemCapacityInfo_t *capInfo)
+{
+ MmcCardStatus_t *cardStatus;
+ MmcCSDRegister_t *csdReg;
+ HAL_HsmciCommandDescriptor_t *commandDescr = descriptor->commandDescriptor;
+
+ /* send CMD13 command to discover current state */
+ if (!memSendCommand(descriptor, SEND_STATUS, REVALITE_CARD_ADDRESS, R1_RESPONSE_LENGTH))
+ return hsmciError;
+ /* wait for hsmci bus becomes free */
+ while (!HAL_HsmciCheckReady());
+
+ cardStatus = (MmcCardStatus_t *)(commandDescr->responseBuffer);
+ if (STATUS_TRAN == (cardStatus->reg & STATUS_TRAN))
+ {
+ /* send CMD7 command to switch to stand-by state*/
+ if (!memSendCommand(descriptor, SELECT_CARD, ~REVALITE_CARD_ADDRESS, R1_RESPONSE_LENGTH))
+ return hsmciError;
+ /* wait for hsmci bus becomes free */
+ while (!HAL_HsmciCheckReady());
+ cardStatus = (MmcCardStatus_t *)(commandDescr->responseBuffer);
+ if (0 != (cardStatus->reg & ERROR_STATUS))
+ return commandError;
+ if (!memCheckState(descriptor, STATUS_STBY))
+ return stateError;
+ }
+ /* send CMD9 command to read CSD register */
+ if (!memSendCommand(descriptor, SEND_CSD, REVALITE_CARD_ADDRESS, R2_RESPONSE_LENGTH))
+ return hsmciError;
+ /* wait for hsmci bus becomes free */
+ while (!HAL_HsmciCheckReady());
+
+ capInfo->logicalBlockLength = STANDARD_BLOCK_LENGTH;
+ csdReg = (MmcCSDRegister_t *)(commandDescr->responseBuffer);
+ capInfo->lastLogicalBlock = (1 << (csdReg->cSizeMult + 2)) * (csdReg->cSizeUp + 1 + (csdReg->cSizeDown << 2)) * ((1 << csdReg->readBlLen) / STANDARD_BLOCK_LENGTH) - 1;
+
+ if (!memCheckState(descriptor, STATUS_STBY))
+ return stateError;
+
+ /* send CMD7 command to switch to transfer state */
+ if (!memSendCommand(descriptor, SELECT_CARD, REVALITE_CARD_ADDRESS, R1_RESPONSE_LENGTH))
+ return hsmciError;
+ /* wait for hsmci bus becomes free */
+ while (!HAL_HsmciCheckReady());
+ cardStatus = (MmcCardStatus_t *)(commandDescr->responseBuffer);
+ if (0 != (cardStatus->reg & ERROR_STATUS))
+ return commandError;
+ if (!memCheckState(descriptor, STATUS_TRAN))
+ return stateError;
+
+ return memSuccess;
+}
+
+/**************************************************************************//**
+\brief Checks MMC memory state.
+\param[in]
+ descriptor - pointer to hsmci descriptor;
+ state - state in which MMC memory meant to be.
+\return
+ false - check failed;
+ true - check success.
+******************************************************************************/
+static bool memSendCommand(HAL_HsmciDescriptor_t *descriptor, uint32_t command, uint32_t argument, uint8_t respLength)
+{
+ descriptor->commandDescriptor->command = command;
+ descriptor->commandDescriptor->argument = argument;
+ descriptor->commandDescriptor->responseLength = respLength;
+
+ if (-1 == HAL_WriteHsmciCommand(descriptor))
+ return false;
+
+ return true;
+}
+
+/**************************************************************************//**
+\brief Sends MMC command.
+\param[in]
+ descriptor - pointer to hsmci descriptor;
+ command - command index and attributes;
+ argument - command argument;
+ respLength - command response length.
+\return
+ false - command sent failed;
+ true - command sent success.
+******************************************************************************/
+static bool memCheckState(HAL_HsmciDescriptor_t *descriptor, uint16_t state)
+{
+ MmcCardStatus_t *cardStatus;
+ /* send CMD13 command to discover current state */
+ if (!memSendCommand(descriptor, SEND_STATUS, REVALITE_CARD_ADDRESS, R1_RESPONSE_LENGTH))
+ return hsmciError;
+ /* wait for hsmci bus becomes free */
+ while (!HAL_HsmciCheckReady());
+ cardStatus = (MmcCardStatus_t *)(descriptor->commandDescriptor->responseBuffer);
+
+ return (cardStatus->reg & STATUS_STATE) == state;
+}
+
+/**************************************************************************//**
+\brief Writes one data block to MMC memory at "address".
+\param[in]
+ descriptor - pointer to hsmci descriptor;
+ address - address of block to write.
+\return
+ status of write procedure.
+******************************************************************************/
+MemStatus_t memWriteBlock(HAL_HsmciDescriptor_t *descriptor, uint32_t address, void (*callback)(MemStatus_t))
+{
+ HAL_HsmciCommandDescriptor_t *commandDescr = descriptor->commandDescriptor;
+ HAL_HsmciDataTransferDescriptor_t *dataDescr = descriptor->dataTransferDescriptor;
+
+ memDescriptor = descriptor;
+
+ if (!memCheckState(descriptor, STATUS_TRAN))
+ return stateError;
+
+ commandDescr->command = WRITE_BLOCK;
+ commandDescr->argument = address << 9;
+ commandDescr->responseLength = R1_RESPONSE_LENGTH;
+
+ dataDescr->direction = HSMCI_WRITE;
+ dataDescr->blockSize = STANDARD_BLOCK_LENGTH;
+ absMemoryCallback = callback;
+ descriptor->callback = memWriteCallback;
+
+ if (-1 == HAL_WriteHsmci(descriptor))
+ return hsmciWriteError;
+
+ return memSuccess;
+}
+
+/**************************************************************************//**
+\brief Reads one data block from MMC memory at "address".
+\param[in]
+ descriptor - pointer to hsmci descriptor;
+ address - address of block to read.
+\return
+ status of read procedure.
+******************************************************************************/
+MemStatus_t memReadBlock(HAL_HsmciDescriptor_t *descriptor, uint32_t address, void (*callback)(MemStatus_t))
+{
+ HAL_HsmciCommandDescriptor_t *commandDescr = descriptor->commandDescriptor;
+ HAL_HsmciDataTransferDescriptor_t *dataDescr = descriptor->dataTransferDescriptor;
+
+ memDescriptor = descriptor;
+
+ if (!memCheckState(descriptor, STATUS_TRAN))
+ return stateError;
+
+ commandDescr->command = READ_SINGLE_BLOCK;
+ commandDescr->argument = address << 9;
+ commandDescr->responseLength = R1_RESPONSE_LENGTH;
+
+ dataDescr->direction = HSMCI_READ;
+ dataDescr->blockSize = STANDARD_BLOCK_LENGTH;
+ absMemoryCallback = callback;
+ descriptor->callback = memReadCallback;
+
+ if (-1 == HAL_ReadHsmci(descriptor))
+ return hsmciReadError;
+
+ return memSuccess;
+}
+
+/**************************************************************************//**
+\brief Checks if MMC memory is ready for any data transfer.
+\return
+ false - memory is busy;
+ true - memory is ready.
+******************************************************************************/
+bool memIsBusy(void)
+{
+ return HAL_HsmciCheckReady();
+}
+
+/**************************************************************************//**
+\brief Sets maximum bus frequency for MMC memory.
+\param[in]
+ descriptor - pointer to hsmci descriptor;
+ freqCode - frequency code.
+\return
+ false - setting failed;
+ true - setting success.
+******************************************************************************/
+static bool setMaximumCommunicationFrequency(HAL_HsmciDescriptor_t *descriptor, uint8_t freqCode, bool hsMode)
+{
+ uint32_t freqUnit = mmcFrequencyUnits[freqCode & FREQ_UNITS_MASK];
+ uint32_t freqMult = mmcFrequencyMulptiplier[(freqCode & FREQ_MULTIPLIER_MASK) >> FREQ_MULTIPLIER_OFFSET];
+
+ descriptor->clockRate = freqUnit * freqMult * 100;
+ if (hsMode)
+ descriptor->clockRate *= 2;
+ if (-1 == HAL_SetHsmciSpeed(descriptor))
+ return false;
+
+ return true;
+}
+
+/**************************************************************************//**
+\brief Sets maximum 4-line dat bus and high speed mode if card supports it.
+\param[in]
+ descriptor - pointer to hsmci descriptor;
+ csdReg - pointer to csd register structure.
+\return
+ status of operation.
+******************************************************************************/
+static MemStatus_t setBusWidthAndHsMode(HAL_HsmciDescriptor_t *descriptor, MmcCSDRegister_t *csdReg)
+{
+ MmcCardStatus_t *cardStatus;
+ uint8_t specVersion = csdReg->specVersion;
+ uint8_t tranSpeed = csdReg->tranSpeed;
+ HAL_HsmciCommandDescriptor_t *commandDescr = descriptor->commandDescriptor;
+
+ /* send CMD7 command to switch to transfer state */
+ if (!memSendCommand(descriptor, SELECT_CARD, REVALITE_CARD_ADDRESS, R1_RESPONSE_LENGTH))
+ return hsmciError;
+ /* wait for hsmci bus becomes free */
+ while (!HAL_HsmciCheckReady());
+ cardStatus = (MmcCardStatus_t *)(commandDescr->responseBuffer);
+ if (0 != (cardStatus->reg & ERROR_STATUS))
+ return commandError;
+ if (!memCheckState(descriptor, STATUS_TRAN))
+ return stateError;
+
+ /* send CMD16 command to set card block length */
+ if (!memSendCommand(descriptor, SET_BLOCKLEN, STANDARD_BLOCK_LENGTH, R1_RESPONSE_LENGTH))
+ return hsmciError;
+ /* wait for hsmci bus becomes free */
+ while (!HAL_HsmciCheckReady());
+ cardStatus = (MmcCardStatus_t *)(commandDescr->responseBuffer);
+ if (0 != (cardStatus->reg & ERROR_STATUS))
+ return commandError;
+ if (!memCheckState(descriptor, STATUS_TRAN))
+ return stateError;
+
+ if (specVersion < CSD_SPEC_VERS_FOUR)
+ {
+ if (!setMaximumCommunicationFrequency(descriptor, tranSpeed, false))
+ return hsmciError;
+ else
+ return memSuccess;
+ }
+
+ /* send CMD6 command to switch to 4-line bus */
+ if (!memSendCommand(descriptor, SWITCH, CMD6_SET_4_LINE_BUS, R1_RESPONSE_LENGTH))
+ return hsmciError;
+ /* wait for hsmci bus becomes free */
+ while (!HAL_HsmciCheckReady());
+ cardStatus = (MmcCardStatus_t *)(commandDescr->responseBuffer);
+ if (0 != (cardStatus->reg & ERROR_STATUS))
+ return commandError;
+ if (!memCheckState(descriptor, STATUS_TRAN))
+ return stateError;
+
+ descriptor->busWidth = HSMCI_BUS_WIDTH_4;
+ if (-1 == HAL_SetHsmciBusWidth(descriptor))
+ return hsmciError;
+
+ /* send CMD6 command to switch to high speed mode */
+ if (!memSendCommand(descriptor, SWITCH, CMD6_SET_HS_MODE, R1_RESPONSE_LENGTH))
+ return hsmciError;
+ /* wait for hsmci bus becomes free */
+ while (!HAL_HsmciCheckReady());
+ cardStatus = (MmcCardStatus_t *)(commandDescr->responseBuffer);
+ if (0 != (cardStatus->reg & ERROR_STATUS))
+ return commandError;
+ if (!memCheckState(descriptor, STATUS_TRAN))
+ return stateError;
+
+ descriptor->highSpeedMode = true;
+ if (-1 == HAL_SetHsmciHighSpeedMode(descriptor))
+ return hsmciError;
+
+ if (!setMaximumCommunicationFrequency(descriptor, tranSpeed, false))
+ return hsmciError;
+
+ return memSuccess;
+}
+
+//eof mmc.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/mscProtocol.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/mscProtocol.c
new file mode 100644
index 00000000..47e5c2d8
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/mscProtocol.c
@@ -0,0 +1,53 @@
+/****************************************************************************//**
+ \file mscProtocol.c
+
+ \brief Implementation of communication device protocol command.
+
+ \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:
+ 29/08/11 N. Fomin - Created
+*******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <mscProtocol.h>
+#include <usb.h>
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Mass storage device request handler.
+\param[in]
+ data - pointer to host's request.
+******************************************************************************/
+void msdRequestHandler(uint8_t *data)
+{
+ UsbMscRequest_t *pRequest = NULL;
+
+ pRequest = (UsbMscRequest_t *)data;
+ if (NULL == pRequest)
+ return;
+
+ // Check request code
+ switch (pRequest->request.bRequest)
+ {
+ case BULK_ONLY_MASS_STORAGE_RESET:
+ break;
+ case GET_MAX_LUN:
+ HAL_Stall(0);
+ break;
+ default:
+ HAL_Stall(0);
+ break;
+ }
+}
+
+//eof mscProtocol.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/scsiProtocol.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/scsiProtocol.c
new file mode 100644
index 00000000..68c3cfb6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/MSD/src/scsiProtocol.c
@@ -0,0 +1,398 @@
+/****************************************************************************//**
+ \files scsiProtocol.h
+
+ \brief Implementation of communication device protocol command.
+
+ \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:
+ 30/08/11 N. Fomin - Created
+*******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <scsiProtocol.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+// scsi commands
+#define INQUIRY 0x12
+#define READ_CAPACITY_10 0x25
+#define READ_10 0x28
+#define REQUEST_SENSE 0x03
+#define TEST_UNIT_READY 0x00
+#define WRITE_10 0x2A
+#define PREVENT_ALLOW_MEDIUM_REMOVAL 0x1E
+#define MODE_SENSE_6 0x1A
+#define READ_FORMAT_CAPACITIES 0x23
+#define VERIFY_10 0x2F
+
+// capacity definitions
+#define BLOCK_SIZE 512
+
+//inquiry definitions
+#define INQUIRY_PERIPHERAL 0x00
+#define INQUIRY_REMOVABLE 0x80
+#define INQUIRY_VERSION 0x04
+#define INQUIRY_RESPONSE_FORMAT 0x02
+#define INQUIRY_ADDITIONAL_LENGTH 0x20
+#define INQUIRY_FLAGS 0x00
+#define INQUIRY_VENDOR_ID "Atmel "
+#define INQUIRY_PRODUCT_ID "Mass Storage "
+#define INQUIRY_PRODUCT_REVISION "0001"
+
+// request sense definitions
+#define REQUEST_SENSE_CODE 0xF0
+#define REQUEST_SENSE_OBSOLETE 0x00
+#define REQUEST_SENSE_NORMAL_FLAGS 0x00
+#define REQUEST_SENSE_ERROR_FLAGS 0x05
+#define REQUEST_SENSE_INFO 0x00
+#define REQUEST_SENSE_ADDITIONAL_SENSE_LENGTH 0x0A
+#define REQUEST_SENSE_CMD_SPECIFIC_INFO 0x00
+#define REQUEST_SENSE_NORMAL_ADDITIONAL_SENSE_CODE 0x00
+#define REQUEST_SENSE_ERROR_ADDITIONAL_SENSE_CODE 0x20
+#define REQUEST_SENSE_ADDITIONAL_SENSE_CODE_QUALIFIER 0x00
+#define REQUEST_SENSE_FIELD_REPLACABLE_UNIT_CODE 0x00
+#define REQUEST_SENSE_SENSE_KEY_SPECIFIC_VALID 0x80
+#define REQUEST_SENSE_SENSE_KEY_SPECIFIC 0x00
+
+// mode sense definitions
+#define MODE_SENSE_LENGTH 0x03
+#define MODE_SENSE_MEDIA_TYPE 0x00
+#define MODE_SENSE_DEVICE_SPECIFIC 0x00
+#define MODE_SENSE_BLOCK_DESC_LENGTH 0x00
+
+// format capacities definitions
+#define FORMAT_CAPACITIES_RESERVED 0x00
+#define FORMAT_CAPACITIES_LENGTH 0x08
+#define FORMAT_CAPACITIES_DESC_TYPE 0x01
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+typedef struct PACK
+{
+ uint32_t lastLogicalBlock;
+ uint32_t logicalBlockLength;
+} ScsiReadCapacityResponse_t;
+
+typedef struct PACK
+{
+ uint8_t peripheral;
+ uint8_t removable;
+ uint8_t version;
+ uint8_t responseDataFormat;
+ uint8_t additionalLength;
+ uint8_t flags[3];
+ uint8_t vendorId[8];
+ uint8_t productId[16];
+ uint8_t productRevision[4];
+} ScsiInquiryResponse_t;
+
+typedef struct PACK
+{
+ uint8_t responseCodeAndValid;
+ uint8_t obsolete;
+ uint8_t flags;
+ uint32_t information;
+ uint8_t addSenseLen;
+ uint32_t cmdSpecificInfo;
+ uint8_t additionalSenseCode;
+ uint8_t additionalSenseCodeQualifier;
+ uint8_t fieldReplacableUnitCode;
+ uint8_t senseKeySpecific[3];
+} ScsiRequestSenseResponse_t;
+
+typedef struct PACK
+{
+ uint8_t modeDataLength;
+ uint8_t mediumType;
+ uint8_t deviceSpecific;
+ uint8_t blockDescriptorLength;
+} ScsiModeSense6Response_t;
+
+typedef struct PACK
+{
+ uint8_t reserved[3];
+ uint8_t length;
+ uint32_t blocksNumber;
+ uint8_t descType;
+ uint8_t blockLengthUp;
+ uint16_t blockLengthDown;
+} ScsiReadFormatCapacities_t;
+
+typedef struct PACK
+{
+ uint8_t flags;
+ uint32_t logicalBlockAddress;
+ uint8_t groupNumber;
+ uint16_t transferLength;
+ uint8_t control;
+} ScsiReadWriteCommand_t;
+
+typedef struct PACK
+{
+ uint8_t index;
+ union
+ {
+ ScsiReadWriteCommand_t rwCommand;
+ };
+} ScsiCommand_t;
+END_PACK
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+static bool defaultRequestSenseResponse;
+static uint32_t lastLogicalBlockNum;
+
+/******************************************************************************
+ Constants section
+******************************************************************************/
+const ScsiInquiryResponse_t inquiryResponse = {
+ INQUIRY_PERIPHERAL,
+ INQUIRY_REMOVABLE,
+ INQUIRY_VERSION,
+ INQUIRY_RESPONSE_FORMAT,
+ INQUIRY_ADDITIONAL_LENGTH,
+ {INQUIRY_FLAGS, INQUIRY_FLAGS, INQUIRY_FLAGS},
+ INQUIRY_VENDOR_ID,
+ INQUIRY_PRODUCT_ID,
+ INQUIRY_PRODUCT_REVISION
+};
+
+const ScsiRequestSenseResponse_t normalRequestSenseResponse = {
+ REQUEST_SENSE_CODE,
+ REQUEST_SENSE_OBSOLETE,
+ REQUEST_SENSE_NORMAL_FLAGS,
+ SWAP32(REQUEST_SENSE_INFO),
+ REQUEST_SENSE_ADDITIONAL_SENSE_LENGTH,
+ SWAP32(REQUEST_SENSE_CMD_SPECIFIC_INFO),
+ REQUEST_SENSE_NORMAL_ADDITIONAL_SENSE_CODE,
+ REQUEST_SENSE_ADDITIONAL_SENSE_CODE_QUALIFIER,
+ REQUEST_SENSE_FIELD_REPLACABLE_UNIT_CODE,
+ {REQUEST_SENSE_SENSE_KEY_SPECIFIC_VALID, REQUEST_SENSE_SENSE_KEY_SPECIFIC, REQUEST_SENSE_SENSE_KEY_SPECIFIC}
+};
+
+const ScsiRequestSenseResponse_t errorRequestSenseResponse = {
+ REQUEST_SENSE_CODE,
+ REQUEST_SENSE_OBSOLETE,
+ REQUEST_SENSE_ERROR_FLAGS,
+ SWAP32(REQUEST_SENSE_INFO),
+ REQUEST_SENSE_ADDITIONAL_SENSE_LENGTH,
+ SWAP32(REQUEST_SENSE_CMD_SPECIFIC_INFO),
+ REQUEST_SENSE_ERROR_ADDITIONAL_SENSE_CODE,
+ REQUEST_SENSE_ADDITIONAL_SENSE_CODE_QUALIFIER,
+ REQUEST_SENSE_FIELD_REPLACABLE_UNIT_CODE,
+ {REQUEST_SENSE_SENSE_KEY_SPECIFIC_VALID, REQUEST_SENSE_SENSE_KEY_SPECIFIC, REQUEST_SENSE_SENSE_KEY_SPECIFIC}
+};
+
+const ScsiModeSense6Response_t modeSense6Response = {
+ MODE_SENSE_LENGTH,
+ MODE_SENSE_MEDIA_TYPE,
+ MODE_SENSE_DEVICE_SPECIFIC,
+ MODE_SENSE_BLOCK_DESC_LENGTH
+};
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Checks if received scsi command is supported.
+\param[in]
+ data - pointer to received command with parameters.
+\return
+ false - command is not supported;
+ true - command is supported.
+******************************************************************************/
+bool scsiIsValidCommand(uint8_t *data)
+{
+ ScsiCommand_t *command = (ScsiCommand_t *)data;
+
+ command->rwCommand.transferLength = SWAP16(command->rwCommand.transferLength);
+ command->rwCommand.logicalBlockAddress = SWAP32(command->rwCommand.logicalBlockAddress);
+
+ switch (command->index)
+ {
+ case INQUIRY:
+ case READ_CAPACITY_10:
+ case TEST_UNIT_READY:
+ case PREVENT_ALLOW_MEDIUM_REMOVAL:
+ case READ_10:
+ case WRITE_10:
+ case MODE_SENSE_6:
+ case READ_FORMAT_CAPACITIES:
+ case VERIFY_10:
+ defaultRequestSenseResponse = true;
+ break;
+ case REQUEST_SENSE:
+ return true;
+ default:
+ defaultRequestSenseResponse = false;
+ break;
+ }
+
+ return defaultRequestSenseResponse;
+}
+
+/**************************************************************************//**
+\brief Checks if any response or data transfer needed for received
+ scsi command.
+\param[in]
+ command - received command.
+\return
+ false - response is not needed;
+ true - response is needed.
+******************************************************************************/
+bool scsiIsDataInOutPhaseNeeded(uint8_t *data)
+{
+ ScsiCommand_t *command = (ScsiCommand_t *)data;
+
+ if ((TEST_UNIT_READY == command->index) || (PREVENT_ALLOW_MEDIUM_REMOVAL == command->index)
+ || (VERIFY_10 == command->index))
+ return false;
+ if ((READ_10 == command->index) || (WRITE_10 == command->index))
+ if (0 == command->rwCommand.transferLength)
+ return false;
+ return true;
+}
+
+/**************************************************************************//**
+\brief Checks if command is read or write command.
+\param[in]
+ command - received command.
+\return
+ false - command is not read/write command;
+ true - command is read/write command.
+******************************************************************************/
+bool scsiIsReadWriteCommand(uint8_t *data)
+{
+ ScsiCommand_t *command = (ScsiCommand_t *)data;
+
+ return ((READ_10 == command->index) || (WRITE_10 == command->index));
+}
+
+/**************************************************************************//**
+\brief Checks if command is read command.
+\param[in]
+ command - received command.
+\return
+ false - command is not read command;
+ true - command is read command.
+******************************************************************************/
+bool scsiIsReadCommand(uint8_t *data)
+{
+ ScsiCommand_t *command = (ScsiCommand_t *)data;
+
+ return (READ_10 == command->index);
+}
+
+/**************************************************************************//**
+\brief Blocks for read/write command.
+\param[in]
+ data - pointer to received command with parameters.
+\return
+ number of blocks to read or write from memory.
+******************************************************************************/
+uint16_t scsiBlocksAmount(uint8_t *data)
+{
+ ScsiCommand_t *command = (ScsiCommand_t *)data;
+
+ if ((READ_10 == command->index) || (WRITE_10 == command->index))
+ return command->rwCommand.transferLength;
+
+ return 0;
+}
+
+/**************************************************************************//**
+\brief Response for scsi command.
+\param[in]
+ command - received command.
+\param[out]
+ buffer - buffer with scsi command response.
+\return
+ length of response
+******************************************************************************/
+uint8_t scsiGetCommandResponse(uint8_t *data, uint8_t *buffer)
+{
+ ScsiCommand_t *command = (ScsiCommand_t *)data;
+ ScsiReadCapacityResponse_t readCapacityResponse = {
+ .lastLogicalBlock = SWAP32(lastLogicalBlockNum),
+ .logicalBlockLength = SWAP32(BLOCK_SIZE)
+ };
+ ScsiReadFormatCapacities_t readFormatCapacitiesResponse = {
+ .reserved = {FORMAT_CAPACITIES_RESERVED, FORMAT_CAPACITIES_RESERVED, FORMAT_CAPACITIES_RESERVED},
+ .length = FORMAT_CAPACITIES_LENGTH,
+ .blocksNumber = SWAP32(lastLogicalBlockNum + 1),
+ .descType = FORMAT_CAPACITIES_DESC_TYPE,
+ .blockLengthUp = 0,
+ .blockLengthDown = SWAP16(BLOCK_SIZE)
+ };
+
+ if (INQUIRY == command->index)
+ {
+ memcpy(buffer, (uint8_t *)&inquiryResponse, sizeof(ScsiInquiryResponse_t));
+ return sizeof(ScsiInquiryResponse_t);
+ }
+ if (READ_CAPACITY_10 == command->index)
+ {
+ memcpy(buffer, (uint8_t *)&readCapacityResponse, sizeof(ScsiReadCapacityResponse_t));
+ return sizeof(ScsiReadCapacityResponse_t);
+ }
+ if (REQUEST_SENSE == command->index)
+ {
+ if (defaultRequestSenseResponse)
+ memcpy(buffer, (uint8_t *)&normalRequestSenseResponse, sizeof(ScsiRequestSenseResponse_t));
+ else
+ memcpy(buffer, (uint8_t *)&errorRequestSenseResponse, sizeof(ScsiRequestSenseResponse_t));
+ return sizeof(ScsiRequestSenseResponse_t);
+ }
+ if (MODE_SENSE_6 == command->index)
+ {
+ memcpy(buffer, (uint8_t *)&modeSense6Response, sizeof(ScsiModeSense6Response_t));
+ return sizeof(ScsiModeSense6Response_t);
+ }
+ if (READ_FORMAT_CAPACITIES == command->index)
+ {
+ memcpy(buffer, (uint8_t *)&readFormatCapacitiesResponse, sizeof(ScsiReadFormatCapacities_t));
+ return sizeof(ScsiReadFormatCapacities_t);
+ }
+ return 0;
+}
+
+/**************************************************************************//**
+\brief Sets number of last available memory block for scsi response.
+\param[in]
+ lastBlock - received command.
+\param[out]
+ buffer - number of last available memory block
+******************************************************************************/
+void scsiSetCapacity(uint32_t lastBlock)
+{
+ lastLogicalBlockNum = lastBlock;
+}
+
+/**************************************************************************//**
+\brief Block address for read/write command.
+\param[in]
+ data - pointer to received command with parameters.
+\return
+ block address for read or write from memory.
+******************************************************************************/
+uint32_t scsiGetBlockAddress(uint8_t *data)
+{
+ ScsiCommand_t *command = (ScsiCommand_t *)data;
+
+ return command->rwCommand.logicalBlockAddress;
+}
+
+//eof scsiProtocol.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/VCP/Makefile b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/VCP/Makefile
new file mode 100644
index 00000000..604aa147
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/VCP/Makefile
@@ -0,0 +1,71 @@
+COMPONENTS_PATH = ../../../..
+#include $(COMPONENTS_PATH)/Makerules
+include $(MAKERULES)
+
+DEBUG = NO
+
+# Hardware flags.
+CFLAGS += $(CFLAGS_HW)
+
+##### PATHS FLAGS OF INCLUDES #########
+CFLAGS += -I./include
+CFLAGS += -I$(HAL_PATH)/include
+CFLAGS += -I./../common/include
+CFLAGS += -I$(SE_PATH)/include
+CFLAGS += -I$(HAL_PATH)/drivers/include
+CFLAGS += -I$(HAL_HWD_COMMON_PATH)/include
+
+#### DEFINES FLAGS #######
+ifeq ($(DEBUG), YES)
+ CFLAGS += -DUSB_TRACE
+endif
+
+###### LIB ##########
+BUILDDIR = .
+COMMONBUILDDIR = ./../common
+
+LIBDIR = ./../../lib
+LDFLAGS = -L$(LIBDIR)
+PROG = VCP.elf
+LIBS = $(LIBDIR)/lib$(VCP_LIB).a
+
+driver_label:
+ @echo
+ @echo ----------------------------------------------------
+ @echo VCP library creation.
+ @echo ----------------------------------------------------
+
+modules = \
+ vcpCdcProtocol \
+ vcpVirtualUsart
+
+commonModules = \
+ usbDescriptors \
+ usbEnumeration \
+ usbSetupProcess
+
+objects = $(addsuffix .o,$(addprefix $(BUILDDIR)/objs/,$(modules)))
+sources = $(addsuffix .c,$(addprefix $(BUILDDIR)/src/,$(modules)))
+
+commonObjects = $(addsuffix .o,$(addprefix $(COMMONBUILDDIR)/objs/,$(commonModules)))
+CommonSources = $(addsuffix .c,$(addprefix $(COMMONBUILDDIR)/src/,$(commonModules)))
+
+OBJS = $(objects)
+OBJS += $(commonObjects)
+
+###### TARGETS ################
+all: driver_label LIB_VCP
+################
+$(BUILDDIR)/objs/%.o: $(BUILDDIR)/src/%.c
+ $(CC) $(CFLAGS) $^ -o $@
+$(COMMONBUILDDIR)/objs/%.o: $(COMMONBUILDDIR)/src/%.c
+ $(CC) $(CFLAGS) $^ -o $@
+
+################
+LIB_VCP : $(OBJS)
+ $(AR) $(AR_KEYS) $(LIBDIR)/lib$(VCP_LIB).a $(OBJS)
+ $(SIZE) -td $(LIBDIR)/lib$(VCP_LIB).a
+################
+clean:
+ rm -f $(objects) $(LIBS) $(BUILDDIR)/list/*.*
+ rm -f $(commonObjects) $(LIBS) $(COMMONBUILDDIR)/list/*.* \ No newline at end of file
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/VCP/include/vcpCdcProtocol.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/VCP/include/vcpCdcProtocol.h
new file mode 100644
index 00000000..e8044c41
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/VCP/include/vcpCdcProtocol.h
@@ -0,0 +1,119 @@
+/****************************************************************************//**
+ \file vcpCdcProtocol.h
+
+ \brief Declaration of communication device protocol command.
+
+ \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:
+ 05/09/08 A. Khromykh - Created
+*******************************************************************************/
+#ifndef _VCPCDCPROTOCOL_H
+#define _VCPCDCPROTOCOL_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <usbSetupProcess.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+// data size in request structure
+#define CDC_REQUEST_DATA_SIZE 7
+// data size in notification structure
+#define NOTIFICATION_DATA_SIZE 2
+
+// request codes for communication interface class
+#define SEND_ENCAPSULATED_COMMAND 0x00
+#define GET_ENCAPSULATED_RESPONSE 0x01
+#define SET_COMM_FEATURE 0x02
+#define GET_COMM_FEATURE 0x03
+#define CLEAR_COMM_FEATURE 0x04
+#define SET_AUX_LINE_STATE 0x10
+#define SET_HOOK_STATE 0x11
+#define PULSE_SETUP 0x12
+#define SEND_PULSE 0x13
+#define SET_PULSE_TIME 0x14
+#define RING_AUX_JACK 0x15
+#define SET_LINE_CODING 0x20
+#define GET_LINE_CODING 0x21
+#define SET_CONTROL_LINE_STATE 0x22
+#define SEND_BREAK 0x23
+#define SET_RINGER_PARMS 0x30
+#define GET_RINGER_PARMS 0x31
+#define SET_OPERATION_PARMS 0x32
+#define GET_OPERATION_PARMS 0x33
+#define SET_LINE_PARMS 0x34
+#define GET_LINE_PARMS 0x35
+#define DIAL_DIGITS 0x36
+#define SET_UNIT_PARAMETER 0x37
+#define GET_UNIT_PARAMETER 0x38
+#define CLEAR_UNIT_PARAMETER 0x39
+#define GET_PROFILE 0x3A
+#define SET_ETHERNET_MULTICAST_FILTERS 0x40
+#define SET_ETHERNET_POWER_MANAGEMENT_PATTERNFILTER 0x41
+#define GET_ETHERNET_POWER_MANAGEMENT_PATTERNFILTER 0x42
+#define SET_ETHERNET_PACKET_FILTER 0x43
+#define GET_ETHERNET_STATISTIC 0x44
+#define SET_ATM_DATA_FORMAT 0x50
+#define GET_ATM_DEVICE_STATISTICS 0x51
+#define SET_ATM_DEFAULT_VC 0x52
+#define GET_ATM_VC_STATISTICS 0x53
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+// Usb host request
+typedef struct PACK
+{
+ UsbRequest_t request;
+ uint8_t bData[CDC_REQUEST_DATA_SIZE];
+} UsbCdcRequest_t;
+
+// Usb GetLineCoding device response
+typedef struct PACK
+{
+ uint32_t dwDTERate;
+ uint8_t bCharFormat;
+ uint8_t bParityType;
+ uint8_t bDataBits;
+} GetLineCodingResponse_t;
+
+typedef union PACK
+{
+ GetLineCodingResponse_t getLineCoding;
+} UsbCdcResponse_t;
+
+// Usb VCP notification
+typedef struct PACK
+{
+ uint8_t bmRequestType;
+ uint8_t bNotification;
+ uint16_t wValue;
+ uint16_t wIndex;
+ uint16_t wLength;
+ uint8_t bData[NOTIFICATION_DATA_SIZE];
+} UsbNotification_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+communication device request handler
+
+Parameters:
+ data - pointer to host's request
+******************************************************************************/
+void vcpRequestHandler(uint8_t *data);
+
+#endif /* _VCPCDCPROTOCOL_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/VCP/src/vcpCdcProtocol.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/VCP/src/vcpCdcProtocol.c
new file mode 100644
index 00000000..6ea63557
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/VCP/src/vcpCdcProtocol.c
@@ -0,0 +1,226 @@
+/****************************************************************************//**
+ \file vcpCdcProtocol.h
+
+ \brief Implementation of communication device protocol command.
+
+ \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:
+ 11/09/08 A. Khromykh - Created
+*******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <vcpCdcProtocol.h>
+#include <usbEnumeration.h>
+#include <usart.h>
+#include <usb.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+// virtual uart speed
+#define VU_1200 0x4B0
+#define VU_2400 0x960
+#define VU_4800 0x12C0
+#define VU_9600 0x2580
+#define VU_19200 0x4B00
+#define VU_38400 0x9600
+#define VU_57600 0xE100
+#define VU_115200 0x1C200
+
+// char size
+#define VU_1STOPBIT 0
+#define VU_1d5STOPBITS 1
+#define VU_2STOPBITS 2
+
+// parity
+#define VU_NONE 0
+#define VU_ODD 1
+#define VU_EVEN 2
+#define VU_MARK 3
+#define VU_SPACE 4
+
+// data bits number
+#define VU_5DATABITS 5
+#define VU_6DATABITS 6
+#define VU_7DATABITS 7
+#define VU_8DATABITS 8
+#define VU_16DATABITS 16
+
+/******************************************************************************
+ External global variables section
+******************************************************************************/
+extern HAL_UsartDescriptor_t *vcpPointDescrip;
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+UsbCdcRequest_t request;
+UsbCdcResponse_t response;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+Get baud rate meaning for cdc response.
+
+Parameters:
+ baudRate - virtual uart baudRate
+******************************************************************************/
+void vcpGetBaudRate(uint32_t baudRate)
+{
+ (void)baudRate;
+ response.getLineCoding.dwDTERate = VU_115200;
+}
+
+/******************************************************************************
+Get number of stop bits meaning for cdc response.
+
+Parameters:
+ stopBits - virtual uart stop bits
+******************************************************************************/
+void vcpGetStopBits(uint8_t stopBits)
+{
+ (void)stopBits;
+ response.getLineCoding.bCharFormat = VU_1STOPBIT;
+}
+
+/******************************************************************************
+Get parity meaning for cdc response.
+
+Parameters:
+ parity - virtual uart parity
+******************************************************************************/
+void vcpGetParity(uint8_t parity)
+{
+ (void)parity;
+ response.getLineCoding.bParityType = VU_NONE;
+}
+
+/******************************************************************************
+Get data length meaning for cdc response.
+
+Parameters:
+ dataLength - virtual uart data length
+******************************************************************************/
+void vcpGetDataLength(uint8_t dataLength)
+{
+ (void)dataLength;
+ response.getLineCoding.bDataBits = VU_8DATABITS;
+}
+
+/******************************************************************************
+Get virtual uart data and send answer to host.
+******************************************************************************/
+void vcpResponseGetLineCoding(void)
+{
+ vcpGetBaudRate(vcpPointDescrip->baudrate);
+ vcpGetStopBits(vcpPointDescrip->stopbits);
+ vcpGetParity(vcpPointDescrip->parity);
+ vcpGetDataLength(vcpPointDescrip->dataLength);
+
+ HAL_UsbWrite(0, (void *)&response, sizeof(GetLineCodingResponse_t), 0, 0);
+}
+
+/******************************************************************************
+Set baud rate meaning to virtual port.
+
+Parameters:
+ baudRate - virtual uart baud rate
+******************************************************************************/
+void vcpSetBaudRate(uint32_t baudRate)
+{
+ (void)baudRate;
+}
+
+/******************************************************************************
+Set number stop bits to virtual port.
+
+Parameters:
+ stopBits - virtual uart stop bits
+******************************************************************************/
+void vcpSetStopBits(uint8_t stopBits)
+{
+ (void)stopBits;
+}
+
+/******************************************************************************
+Set parity meaning to virtual port.
+
+Parameters:
+ parity - virtual uart parity
+******************************************************************************/
+void vcpSetParity(uint8_t parity)
+{
+ (void)parity;
+}
+
+/******************************************************************************
+Set data length to virtual port.
+
+Parameters:
+ dataLength - virtual uart data length
+******************************************************************************/
+void vcpSetDataLength(uint8_t dataLength)
+{
+ (void)dataLength;
+}
+
+/******************************************************************************
+Set virtual uart data and send response to host.
+******************************************************************************/
+void vcpResponseSetLineCoding(void)
+{
+ vcpSetBaudRate(response.getLineCoding.dwDTERate);
+ vcpSetStopBits(response.getLineCoding.bCharFormat);
+ vcpSetParity(response.getLineCoding.bParityType);
+ vcpSetDataLength(response.getLineCoding.bDataBits);
+
+#if defined(AT91SAM7X256) || defined(AT91SAM3S4C)
+ sendZLP();
+#endif
+}
+
+/******************************************************************************
+communication device request handler
+
+Parameters:
+ data - pointer to host's request
+******************************************************************************/
+void vcpRequestHandler(uint8_t *data)
+{
+ UsbCdcRequest_t *pRequest = NULL;
+
+ pRequest = (UsbCdcRequest_t *)data;
+ if (NULL == pRequest)
+ return;
+
+ // Check request code
+ switch (pRequest->request.bRequest)
+ {
+ case SET_LINE_CODING:
+ HAL_UsbRead(0, (void *)&response, sizeof(GetLineCodingResponse_t), (TransferCallback_t)vcpResponseSetLineCoding, 0);
+ break;
+ case GET_LINE_CODING:
+ vcpResponseGetLineCoding();
+ break;
+ case SET_CONTROL_LINE_STATE:
+ //vcpReadDataFromSetControlLineState(pRequest->wValue); // possible in the future
+ #if defined(AT91SAM7X256) || defined(AT91SAM3S4C)
+ sendZLP();
+ #endif
+ break;
+ default:
+ HAL_Stall(0);
+ break;
+ }
+}
+
+//eof vcpCdcProtocol.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/VCP/src/vcpVirtualUsart.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/VCP/src/vcpVirtualUsart.c
new file mode 100644
index 00000000..29469576
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/VCP/src/vcpVirtualUsart.c
@@ -0,0 +1,498 @@
+/****************************************************************************//**
+ \file vcpVirtualUart.c
+
+ \brief Implementation of virtual uart API.
+
+ \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:
+ 11/09/08 A. Khromykh - Created
+*******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <string.h>
+#include <vcpCdcProtocol.h>
+#include <usbDescriptors.h>
+#include <usbEnumeration.h>
+#include <vcpVirtualUsart.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+// usart control
+typedef struct
+{
+ uint16_t rxUnusedRemaining;
+} VcpControl_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+Tuning of received buffer and enable received pipe if there is free place
+in the buffer.
+Parameters:
+ descriptor - pointer to HAL_UartDescriptor_t structure;
+Returns:
+ none.
+******************************************************************************/
+void vcpEnableReadPipe(void);
+
+/******************************************************************************
+ External global variables section
+******************************************************************************/
+extern UsbCdcRequest_t request;
+extern UsbCdcResponse_t response;
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+// pointer to application uart descriptor
+HAL_UsartDescriptor_t *vcpPointDescrip = NULL;
+// structure for internal ring buffer
+VcpControl_t vcpControl;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+Transmitting callback of virtual uart
+Parameters:
+ pArg - pointer to some data.
+ status - result of the USB transfer.
+ transferred - how much data are transferred
+ remaining - how much data are not transferred
+Returns:
+ none.
+******************************************************************************/
+void vcpTmtCallback(void *pArg, uint8_t status, uint16_t transferred, uint16_t remaining)
+{
+ (void)pArg;
+ (void)status;
+ (void)remaining;
+ uint16_t copyPor = vcpPointDescrip->service.txPointOfRead;
+ uint16_t copyPow = vcpPointDescrip->service.txPointOfWrite;
+ bool endOfTransferring = true;
+
+ if (NULL != vcpPointDescrip)
+ {
+ if (NULL != vcpPointDescrip->txBuffer)
+ { /* polling mode */
+ copyPor += transferred;
+ if (copyPor == vcpPointDescrip->txBufferLength)
+ copyPor = 0;
+
+ if (copyPor != copyPow)
+ {
+ if (copyPor > copyPow)
+ {
+ HAL_UsbWrite(VCP_TRANSMIT_PIPE, &vcpPointDescrip->txBuffer[copyPor],
+ (vcpPointDescrip->txBufferLength - copyPor), vcpTmtCallback, NULL);
+ }
+ else
+ {
+ HAL_UsbWrite(VCP_TRANSMIT_PIPE, &vcpPointDescrip->txBuffer[copyPor],
+ (copyPow - copyPor), vcpTmtCallback, NULL);
+ }
+ }
+ endOfTransferring = false;
+ vcpPointDescrip->service.txPointOfRead = copyPor;
+ } /* polling mode */
+
+ if (!endOfTransferring)
+ return;
+
+ if (!(transferred % BULK_SIZE) && transferred)
+ {
+ /*
+ Universal Serial Bus Class Definitions for Communication Devices
+ 3.8.1.1 Segment Delineation
+ This positive delineation is done using a USB short packet mechanism. When a segment spans N USB packets, the
+ first packet through packet N-1 shall be the maximum packet size defined for the USB endpoint. If the Nth packet is
+ less than maximum packet size the USB transfer of this short packet will identify the end of the segment. If the Nth
+ packet is exactly maximum packet size, it shall be followed by a zero-length packet (which is a short packet) to assure
+ the end of segment is properly identified.
+ When transmitting data to the networking device, it is assumed that the client of the host USB driver takes the
+ appropriate actions to cause a short packet to be sent to the networking device. For segments with lengths that are an
+ even multiple of the pipe’s “max packet size”, the ability to write a buffer of zero length is required to generate this
+ short packet.
+ */
+ HAL_UsbWrite(VCP_TRANSMIT_PIPE, NULL, 0, vcpTmtCallback, NULL);
+ }
+ else
+ {
+ if (NULL != vcpPointDescrip->txCallback)
+ vcpPointDescrip->txCallback();
+ }
+
+ }
+}
+
+/******************************************************************************
+Receiving callback of virtual uart
+Parameters:
+ pArg - pointer to something data.
+ status - result of the USB transfer.
+ transferred - how much data are transferred
+ remaining - how much data are not transferred
+Returns:
+ none.
+******************************************************************************/
+void vcpRcvCallback(void *pArg, uint8_t status, uint16_t transferred, uint16_t remaining)
+{
+ (void)pArg;
+ (void)status;
+ (void)remaining;
+ uint16_t number;
+ uint16_t copyPor;
+ uint16_t copyPow;
+ uint16_t copyUnr;
+
+ vcpPointDescrip->service.rxPointOfWrite += transferred;
+ copyPor = vcpPointDescrip->service.rxPointOfRead;
+ copyPow = vcpPointDescrip->service.rxPointOfWrite;
+ copyUnr = vcpControl.rxUnusedRemaining;
+
+ if (NULL != vcpPointDescrip)
+ {
+ if (NULL != vcpPointDescrip->rxCallback)
+ {
+ if (copyPow < copyPor)
+ number = copyUnr - (copyPor - copyPow);
+ else
+ number = copyPow - copyPor;
+
+ vcpPointDescrip->rxCallback(number);
+ vcpEnableReadPipe();
+ }
+ }
+}
+
+/******************************************************************************
+Open virtual com port and register uart's event handlers.
+
+Parameters:
+ descriptor - pointer to HAL_UartDescriptor_t structure
+
+Returns:
+ Returns positive uart descriptor on success or -1 in cases:
+ - bad uart channel;
+ - there are not enough resources;
+ - receiving buffer is less bulk endpoint size;
+******************************************************************************/
+int VCP_OpenUsart(HAL_UsartDescriptor_t *descriptor)
+{
+ if (NULL == descriptor)
+ return -1;
+
+ if (USART_CHANNEL_VCP != descriptor->tty)
+ return -1;
+
+ if (NULL != vcpPointDescrip)
+ return -1; /* source was opened */
+
+ vcpPointDescrip = descriptor;
+
+ vcpPointDescrip->service.rxPointOfRead = 0;
+ vcpPointDescrip->service.rxPointOfWrite = 0;
+ vcpControl.rxUnusedRemaining = vcpPointDescrip->rxBufferLength;
+ vcpPointDescrip->service.txPointOfRead = 0;
+ vcpPointDescrip->service.txPointOfWrite = 0;
+ HAL_RegisterEndOfBusResetHandler(usbBusResetAction);
+ if (DEVICE_POWERED != HAL_GetState())
+ HAL_UsbInit((uint8_t *)&request);
+
+ return (int)descriptor->tty;
+}
+
+/******************************************************************************
+Frees the virtual uart channel.
+Parameters:
+ descriptor - the uart descriptor.
+Returns:
+ Returns 0 on success or -1 if bad descriptor.
+******************************************************************************/
+int VCP_CloseUsart(HAL_UsartDescriptor_t *descriptor)
+{
+ if (NULL == descriptor)
+ return -1;
+
+ if (vcpPointDescrip != descriptor)
+ return -1;
+
+ vcpPointDescrip = NULL;
+
+ return 0;
+}
+
+/******************************************************************************
+Writes a number of bytes to a virtual uart channel.
+txCallback function will be used to notify when the transmission is finished.
+Parameters:
+ descriptor - pointer to HAL_UartDescriptor_t structure;
+ buffer - pointer to the application data buffer;
+ length - number of bytes to transfer;
+Returns:
+ -1 - bad descriptor;
+ Number of bytes placed to the buffer - success.
+******************************************************************************/
+int VCP_WriteUsart(HAL_UsartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length)
+{
+ uint16_t copyPow = vcpPointDescrip->service.txPointOfWrite;
+ uint16_t copyPor = vcpPointDescrip->service.txPointOfRead;
+ uint16_t freePlace;
+ uint16_t wasWrote = 0;
+
+ if (NULL == descriptor)
+ return -1;
+
+ if (vcpPointDescrip != descriptor)
+ return -1;
+
+ if (!buffer || !length)
+ return -1;
+
+ if (NULL == descriptor->txBuffer)
+ { /* callback mode */
+ if (STATUS_SUCCESS != HAL_UsbWrite(VCP_TRANSMIT_PIPE, buffer, length, vcpTmtCallback, NULL))
+ return -1; // there is unsent data
+ return length;
+ } /* callback mode */
+ else
+ { /* polling mode */
+ if (copyPor > copyPow)
+ {
+ freePlace = copyPor - copyPow;
+ if (freePlace < length)
+ return -1; // there is unsent data
+ memcpy(&descriptor->txBuffer[copyPow], buffer, length);
+ HAL_UsbWrite(VCP_TRANSMIT_PIPE, buffer, length, vcpTmtCallback, NULL);
+ copyPow += length;
+
+ }
+ else // point of write more or equal point of read
+ {
+ freePlace = descriptor->txBufferLength - copyPow + copyPor;
+ if (freePlace < length)
+ return -1; // there is unsent data
+
+ uint16_t tempValue = descriptor->txBufferLength - copyPow;
+ if (length > tempValue)
+ {
+ memcpy(&descriptor->txBuffer[copyPow], buffer, tempValue);
+ HAL_UsbWrite(VCP_TRANSMIT_PIPE, buffer, tempValue, vcpTmtCallback, NULL);
+ buffer += tempValue;
+ length -= tempValue;
+ memcpy(descriptor->txBuffer, buffer, length);
+ copyPow = length;
+ }
+ else
+ {
+ memcpy(&descriptor->txBuffer[copyPow], buffer, length);
+ HAL_UsbWrite(VCP_TRANSMIT_PIPE, buffer, length, vcpTmtCallback, NULL);
+ copyPow += length;
+ }
+ }
+
+ if (copyPow == descriptor->txBufferLength)
+ copyPow = 0;
+ vcpPointDescrip->service.txPointOfWrite = copyPow;
+ wasWrote = length;
+
+ return wasWrote;
+ } /* polling mode */
+}
+
+/******************************************************************************
+Tuning of received buffer and enable received pipe if there is free place
+in the buffer.
+Parameters:
+ none;
+Returns:
+ none.
+******************************************************************************/
+void vcpEnableReadPipe(void)
+{
+ uint16_t copyPor = vcpPointDescrip->service.rxPointOfRead;
+ uint16_t copyPow = vcpPointDescrip->service.rxPointOfWrite;
+ uint16_t copyUnr = vcpControl.rxUnusedRemaining;
+ uint8_t usbResult = STATUS_SUCCESS;
+
+ do
+ {
+ if (copyPor < copyPow)
+ {
+ if ((vcpPointDescrip->rxBufferLength - copyPow) < BULK_SIZE)
+ {
+ copyUnr = copyPow;
+ if (0 == copyPor)
+ {
+ usbResult = STATUS_BUSY;
+ break;
+ }
+ copyPow = 0;
+ }
+ else
+ {
+ usbResult = HAL_UsbRead(VCP_RECEIVE_PIPE, &vcpPointDescrip->rxBuffer[copyPow], BULK_SIZE, vcpRcvCallback, NULL);
+ break;
+ }
+ }
+ else
+ {
+ // empty buffer
+ if (copyPow == copyPor)
+ {
+ if ((vcpPointDescrip->rxBufferLength - copyPow) < BULK_SIZE)
+ {
+ copyUnr = vcpPointDescrip->rxBufferLength;
+ copyPor = 0;
+ copyPow = 0;
+ }
+ usbResult = HAL_UsbRead(VCP_RECEIVE_PIPE, &vcpPointDescrip->rxBuffer[copyPow], BULK_SIZE, vcpRcvCallback, NULL);
+ } // copyPor > copyPow
+ else
+ {
+ if ((copyPor - copyPow) >= BULK_SIZE)
+ usbResult = HAL_UsbRead(VCP_RECEIVE_PIPE, &vcpPointDescrip->rxBuffer[copyPow], BULK_SIZE, vcpRcvCallback, NULL);
+ else
+ usbResult = STATUS_BUSY;
+ }
+ break;
+ }
+ } while(1);
+
+ if (STATUS_SUCCESS == usbResult)
+ {
+ vcpPointDescrip->service.rxPointOfRead = copyPor;
+ vcpPointDescrip->service.rxPointOfWrite = copyPow;
+ vcpControl.rxUnusedRemaining = copyUnr;
+ }
+}
+
+/*****************************************************************************
+Reads length bytes from uart and places ones to buffer.
+Parameters:
+ descriptor - uart descriptor;
+ buffer - pointer to a application buffer;
+ length - the number of bytes which should be placed to buffer
+Returns:
+ -1 - bad descriptor, bad number to read;
+ number of bytes that were placed to buffer.
+*****************************************************************************/
+int VCP_ReadUsart(HAL_UsartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length)
+{
+ uint16_t wasRead = 0;
+ uint16_t firstPart = 0;
+ uint16_t copyPor = vcpPointDescrip->service.rxPointOfRead;
+ uint16_t copyPow = vcpPointDescrip->service.rxPointOfWrite;
+ uint16_t copyUnr = vcpControl.rxUnusedRemaining;
+
+ if (NULL == descriptor)
+ return -1;
+
+ if (vcpPointDescrip != descriptor)
+ return -1;
+
+ if (!buffer || !length)
+ return -1;
+
+ do
+ {
+ // buffer is empty
+ if (copyPow == copyPor)
+ break;
+
+ // [----**********---------] --- empty **** busy
+ // por pow
+ // [*****---------*******###] ### unused at the current moment
+ // pow por ur
+ // por - point of read(user read from buffer)
+ // pow - point of write(HAL write to buffer)
+ // ur - unused remaining(because remaining less then max packet size at the start read moment.)
+ if (copyPor < copyPow)
+ {
+ wasRead = copyPow - copyPor;
+
+ if (wasRead > length)
+ {
+ wasRead = length;
+ memcpy(buffer, &vcpPointDescrip->rxBuffer[copyPor], wasRead);
+ copyPor += length;
+ }
+ else
+ {
+ memcpy(buffer, &vcpPointDescrip->rxBuffer[copyPor], wasRead);
+ copyPor = copyPow;
+ }
+ break;
+ }
+ else //copyPor > copyPow
+ {
+ if ((copyPor + length) < copyUnr)
+ {
+ wasRead = length;
+ memcpy(buffer, &vcpPointDescrip->rxBuffer[copyPor], wasRead);
+ copyPor += length;
+ break;
+ }
+ else
+ {
+ firstPart = copyUnr - copyPor;
+ memcpy(buffer, &vcpPointDescrip->rxBuffer[copyPor], firstPart);
+ buffer += firstPart;
+ length -= firstPart;
+ copyUnr = vcpPointDescrip->rxBufferLength;
+ copyPor = 0;
+ }
+ }
+ } while(1);
+
+ vcpPointDescrip->service.rxPointOfRead = copyPor;
+ vcpPointDescrip->service.rxPointOfWrite = copyPow;
+ vcpControl.rxUnusedRemaining = copyUnr;
+
+ vcpEnableReadPipe();
+ wasRead += firstPart;
+
+ return wasRead;
+}
+
+/**************************************************************************//**
+\brief Checks the status of tx buffer.
+
+\param[in] descriptor - pointer to HAL_UsartDescriptor_t structure;
+\return -1 - bad descriptor, no tx buffer; \n
+ 1 - tx buffer is empty; \n
+ 0 - tx buffer is not empty;
+******************************************************************************/
+int VCP_IsTxEmpty(HAL_UsartDescriptor_t *descriptor)
+{
+ HalUsartService_t *halUsartControl;
+ uint16_t copyPow;
+ uint16_t copyPor;
+
+ if (NULL == descriptor)
+ return -1;
+
+ if (vcpPointDescrip != descriptor)
+ return -1;
+
+ halUsartControl = &descriptor->service;
+ copyPow = halUsartControl->txPointOfWrite;
+ copyPor = halUsartControl->txPointOfRead;
+
+ if (copyPow == copyPor)
+ return 1;
+ else
+ return 0;
+}
+
+// eof vcpVirtualUart.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbDescriptors.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbDescriptors.h
new file mode 100644
index 00000000..6c07c4cb
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbDescriptors.h
@@ -0,0 +1,184 @@
+/****************************************************************************//**
+ \file usbDescriptors.h
+
+ \brief Declaration of descriptors structures.
+
+ \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:
+ 05/09/08 A. Khromykh - Created
+ 26/08/11 N. Fomin - Modified (MSD support)
+*******************************************************************************/
+#ifndef _USBDESCRIPTORS_H
+#define _USBDESCRIPTORS_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <usb.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define VCP_INTERFACE_ENDPOINTS_NUMBER 2
+#define MSD_INTERFACE_ENDPOINTS_NUMBER 2
+
+#define NUMBER_OF_FIRST_INTERFACE 0x00
+#define NUMBER_OF_SECOND_INTERFACE 0x01
+#define NUMBER_OF_THIRD_INTERFACE 0x02
+#define NUMBER_OF_FOURTH_INTERFACE 0x03
+
+#define BULK_SIZE 0x0040
+
+#define ADDRESS_MSC_BULKIN_PIPE 0x85
+#define ADDRESS_MSC_BULKOUT_PIPE 0x06
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+// USB standard device descriptor structure.
+BEGIN_PACK
+typedef struct PACK
+{
+ uint8_t bLength; // Size of this descriptor in bytes
+ uint8_t bDescriptorType; // Descriptor type
+ uint16_t bcdUSB; // USB specification release number in BCD format
+ uint8_t bDeviceClass; // Device class code
+ uint8_t bDeviceSubClass; // Device subclass code
+ uint8_t bDeviceProtocol; // Device protocol code
+ uint8_t bMaxPacketSize0; // Maximum packet size of endpoint 0 (in bytes)
+ uint16_t idVendor; // Vendor ID
+ uint16_t idProduct; // Product ID
+ uint16_t bcdDevice; // Device release number in BCD format
+ uint8_t iManufacturer; // Index of the manufacturer string descriptor
+ uint8_t iProduct; // Index of the product string descriptor
+ uint8_t iSerialNumber; // Index of the serial number string descriptor
+ uint8_t bNumConfigurations; // Number of possible configurations for the device
+} DeviceDescriptor_t;
+
+// USB standard configuration descriptor structure.
+typedef struct PACK
+{
+ uint8_t bLength; // Size of the descriptor in bytes
+ uint8_t bDescriptorType; // Descriptor type
+ uint16_t wTotalLength; // Length of all descriptors returned along with this configuration descriptor
+ uint8_t bNumInterfaces; // Number of interfaces in this configuration
+ uint8_t bConfigurationValue; // Value for selecting this configuration
+ uint8_t iConfiguration; // Index of the configuration string descriptor
+ uint8_t bmAttributes; // Configuration characteristics
+ uint8_t bMaxPower; // Maximum power consumption of the device when in this configuration
+} ConfigurationDescriptor_t;
+
+// USB standard interface descriptor structure.
+typedef struct PACK
+{
+ uint8_t bLength; // Size of the descriptor in bytes
+ uint8_t bDescriptorType; // Descriptor type
+ uint8_t bInterfaceNumber; // Number of the interface in its configuration
+ uint8_t bAlternateSetting; // Value to select this alternate interface setting
+ uint8_t bNumEndpoints; // Number of endpoints used by the interface (excluding endpoint 0)
+ uint8_t bInterfaceClass; // Interface class code
+ uint8_t bInterfaceSubClass; // Interface subclass code
+ uint8_t bInterfaceProtocol; // Interface protocol code
+ uint8_t iInterface; // Index of the interface string descriptor
+} InterfaceDescriptor_t;
+
+// USB header functional descriptor.
+typedef struct PACK
+{
+ uint8_t bFunctionalLength; // Size of the descriptor in bytes
+ uint8_t bDescriptorType; // Descriptor type
+ uint8_t bDescriptorSubtype; // Header functional descriptor subtype
+ uint16_t bcdCDC; // USB Class Definitions for Communication
+ // Devices Specification release number in binary-coded decimal.
+} HeaderFunctionalDescriptor_t;
+
+// USB Abstract Control Management Functional Descriptor.
+typedef struct PACK
+{
+ uint8_t bFunctionalLength; // Size of the descriptor in bytes
+ uint8_t bDescriptorType; // Descriptor type
+ uint8_t bDescriptorSubtype; // ACM descriptor subtype
+ uint8_t bmCapabilities; // The capabilities that this configuration supports
+} AbstractControlManagmentDescriptor_t;
+
+// USB Union Functional Descriptor.
+typedef struct PACK
+{
+ uint8_t bFunctionalLength; // Size of the descriptor in bytes
+ uint8_t bDescriptorType; // Descriptor type
+ uint8_t bDescriptorSubtype; // Union functional descriptor subtype
+ uint8_t bMasterInterface; // The interface number of the Communication or Data Class interface, designated as the master or controlling interface for the union
+ uint8_t bSlaveInterface0; // Interface number of first slave or associated interface in the union
+} UnionFunctionalDescriptor_t;
+
+// USB Call Management Functional Descriptor.
+typedef struct PACK
+{
+ uint8_t bFunctionalLength; // Size of the descriptor in bytes
+ uint8_t bDescriptorType; // Descriptor type
+ uint8_t bDescriptorSubtype; // Union functional descriptor subtype
+ uint8_t bmCapabilities; // The capabilities that this configuration supports
+ uint8_t bDataInterface; // Interface number of Data Class interface optionally used for call management
+} CallManagmentFunctionalDescriptor_t;
+
+// USB Interface Association Descriptor.
+typedef struct PACK
+{
+ uint8_t bLength; // Size of the descriptor in bytes
+ uint8_t bDescriptorType; // Descriptor type
+ uint8_t bFirstInterface; // Interface number of the first interface that is associated with this function
+ uint8_t bInterfaceCount; // Number of contiguous interfaces that are associated with this function
+ uint8_t bFunctionClass; // Class code
+ uint8_t bFunctionSubClass; // Subclass code
+ uint8_t bFunctionProtocol; // Protocol code
+ uint8_t iFunction; // Index of string descriptor describing this function
+} InterfaceAssociationDescriptor_t;
+
+typedef struct PACK
+{
+ uint8_t bLength; // Size of the descriptor in bytes
+ uint8_t bDescriptorType; // Descriptor type
+ uint8_t bmAttributes; // Descriptor attributes
+ uint16_t wDetachTimeOut; // Wait timeout of USB reset after DFU_DETACH request recieption
+ uint16_t wTransferSize; // Maximum number of bytes that the device can accept per control-write transaction
+ uint16_t bcdDFUVersion; // DFU Version
+} DfuFunctionalDescriptor_t;
+
+// USB frame for interface request.
+typedef struct PACK
+{
+ ConfigurationDescriptor_t config;
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+#if (MSD_SUPPORT == 1) || (DFU_SUPPORT == 1)
+ InterfaceAssociationDescriptor_t cdcIAD;
+#endif // (MSD_SUPPORT == 1) || (DFU_SUPPORT == 1)
+ InterfaceDescriptor_t interface1;
+ HeaderFunctionalDescriptor_t headerFunctional;
+ CallManagmentFunctionalDescriptor_t cmFunctionak;
+ AbstractControlManagmentDescriptor_t acmFunctional;
+ UnionFunctionalDescriptor_t unionFunctional;
+ HAL_UsbEndPointDescptr_t endpointIfc1;
+ InterfaceDescriptor_t interface2;
+ HAL_UsbEndPointDescptr_t endpointIfc2[VCP_INTERFACE_ENDPOINTS_NUMBER];
+#endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+#if (MSD_SUPPORT == 1)
+ InterfaceDescriptor_t interface3;
+ HAL_UsbEndPointDescptr_t endpointIfc3[MSD_INTERFACE_ENDPOINTS_NUMBER];
+#endif // (MSD_SUPPORT == 1)
+#if (DFU_SUPPORT == 1)
+ InterfaceDescriptor_t interface4;
+ DfuFunctionalDescriptor_t dfuFuncional;
+#endif // (MSD_SUPPORT == 1)
+} ConfigurationFrameResponse_t;
+END_PACK
+
+#endif /* _VCPDESCRIPTORS_H */
+// eof usbDescriptors.h \ No newline at end of file
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbEnumeration.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbEnumeration.h
new file mode 100644
index 00000000..8c04756b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbEnumeration.h
@@ -0,0 +1,53 @@
+/****************************************************************************//**
+ \file usbEnumeration.h
+
+ \brief Declaration of enumeration process command.
+
+ \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:
+ 12/09/08 A. Khromykh - Created
+ 26/08/11 N. Fomin - Modified (MSD support)
+*******************************************************************************/
+#ifndef _USBENUMERATION_H
+#define _USBENUMERATION_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+Standard usb request handler
+
+Parameters:
+ data - pointer to host's request
+******************************************************************************/
+void runtimeRequestHandler(uint8_t *data);
+
+/******************************************************************************
+Standard usb request handler
+
+Parameters:
+ data - pointer to host's request
+******************************************************************************/
+void usbBusResetAction(void);
+
+#if defined(AT91SAM7X256) || defined(AT91SAM3S4C)
+/******************************************************************************
+send zero-length packet through control pipe
+******************************************************************************/
+void sendZLP(void);
+#endif
+
+#endif /* _USBENUMERATION_H */
+// eof usbEnumeration.h \ No newline at end of file
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbSetupProcess.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbSetupProcess.h
new file mode 100644
index 00000000..f499a80e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/include/usbSetupProcess.h
@@ -0,0 +1,51 @@
+/****************************************************************************//**
+ \file usbSetupProcess.h
+
+ \brief Declaration of setup (after numeration) process command.
+
+ \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:
+ 26/08/11 N. Fomin - Created
+*******************************************************************************/
+#ifndef _USBESETUPPROCESS_H
+#define _USBESETUPPROCESS_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+// Usb host request
+typedef struct PACK
+{
+ uint8_t bmRequestType;
+ uint8_t bRequest;
+ uint16_t wValue;
+ uint16_t wIndex;
+ uint16_t wLength;
+} UsbRequest_t;
+END_PACK
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+Usb setup process request handler
+
+Parameters:
+ data - pointer to host's request
+******************************************************************************/
+void setupProcessRequestHandler(uint8_t *data);
+
+#endif /* _USBESETUPPROCESS_H */
+// eof usbSetupProcess.h \ No newline at end of file
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbDescriptors.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbDescriptors.c
new file mode 100644
index 00000000..663beeee
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbDescriptors.c
@@ -0,0 +1,424 @@
+/****************************************************************************//**
+ \file usbDescriptors.c
+
+ \brief Virtual communication port descriptors.
+
+ \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:
+ 11/09/08 A. Khromykh - Created
+ 26/08/11 N. Fomin - Modified (MSD support)
+*******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <usbDescriptors.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+// Descriptor's type definitions.
+#define DESCRIPTOR_TYPE_DEVICE 0x01
+#define DESCRIPTOR_TYPE_CONFIGURATION 0x02
+#define DESCRIPTOR_TYPE_STRING 0x03
+#define DESCRIPTOR_TYPE_INTERFACE 0x04
+#define DESCRIPTOR_TYPE_CS_INTERFACE 0x24
+#define DESCRIPTOR_TYPE_ENDPOINT 0x05
+#define DESCRIPTOR_TYPE_DEVICE_QUALIFIER 0x06
+#define DESCRIPTOR_TYPE_OTHER_SPEED_CFG 0x07
+#define DESCRIPTOR_TYPE_INTERFACE_POWER 0x08
+#define DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION 0x0B
+#define DESCRIPTOR_TYPE_DFU_FUNCTIONAL 0x21
+
+// String definitions' indexes.
+#define MANUFACTURER_STRING_INDEX 0
+#define PRODUCT_STRING_INDEX 0
+#define SERIAL_NUMBER_STRING_INDEX 0
+#define CONFIGURATION_STRING_INDEX 0
+#define FIRST_INTERFACE_STRING_INDEX 0
+#define SECOND_INTERFACE_STRING_INDEX 0
+#define THIRD_INTERFACE_STRING_INDEX 0
+#define FOURTH_INTERFACE_STRING_INDEX 0
+
+#define VENDOR_ID 0x03EB // Atmel
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (MSD_SUPPORT == 1)
+ #if (DFU_SUPPORT == 1)
+ #define PRODUCT_ID 0x6122
+ #else
+ #define PRODUCT_ID 0x6121
+ #endif // (DFU_SUPPORT == 1)
+ #else // (MSD_SUPPORT == 1)
+ #if (DFU_SUPPORT == 1)
+ #define PRODUCT_ID 0x6120
+ #else
+ #define PRODUCT_ID 0x6119
+ #endif // (DFU_SUPPORT == 1)
+ #endif // (MSD_SUPPORT == 1)
+#else // (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (MSD_SUPPORT == 1)
+ #if (DFU_SUPPORT == 1)
+ #define PRODUCT_ID 0x6124
+ #else
+ #define PRODUCT_ID 0x6123
+ #endif // (DFU_SUPPORT == 1)
+ #else // (MSD_SUPPORT == 1)
+ #define PRODUCT_ID 0x6119
+ #endif // (MSD_SUPPORT == 1)
+#endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+
+#define DEVICE_RELEASE 0x0001
+#define USB_BUS_RELEASE 0x0200
+
+// Number of possible configurations for the device.
+#define NUMBER_OF_CONFIGURATIONS 0x01
+
+// Class specification parameters of communication device.
+#define CDC_DEVICE_CLASS 0x02
+#define CDC_DEVICE_SUBCLASS 0x00
+#define CDC_DEVICE_PROTOCOL 0x00
+
+// Class specification parameters of mass storage device.
+#define MSC_DEVICE_CLASS 0x00
+#define MSC_DEVICE_SUBCLASS 0x00
+#define MSC_DEVICE_PROTOCOL 0x00
+
+// Class specification parameters of composite device with CDC.
+#define COMB_DEVICE_CLASS 0xef
+#define COMB_DEVICE_SUBCLASS 0x02
+#define COMB_DEVICE_PROTOCOL 0x01
+
+// Endpoint definitions' sizes.
+#if defined(AT91SAM7X256)
+ #define SZ_CONTROL_ENDPOINT 0x08 // endpoint 0 is control pipe
+#elif defined(AT90USB1287) || defined(AT91SAM3S4C)
+ #define SZ_CONTROL_ENDPOINT 0x40 // endpoint 0 is control pipe
+#endif
+#define SZ_ACM_INT_ENDPOINT 0x0008 // endpoint 3 is interrupt pipe for abstraction control model
+#define SZ_CDC_BULKIN_ENDPOINT BULK_SIZE // endpoint 2 is bulk pipe for input communication data
+#define SZ_CDC_BULKOUT_ENDPOINT BULK_SIZE // endpoint 1 is bulk pipe for output communication data
+#define SZ_MSC_BULKIN_ENDPOINT BULK_SIZE // endpoint 2 is bulk pipe for input communication data
+#define SZ_MSC_BULKOUT_ENDPOINT BULK_SIZE // endpoint 1 is bulk pipe for output communication data
+
+// Configuration descriptor parameters.
+// Common size of all descriptors in the vcp configuration besides configuration descriptor
+#define COMMON_VCP_CFG_SIZE (sizeof(InterfaceDescriptor_t) + \
+ sizeof(HeaderFunctionalDescriptor_t) + \
+ sizeof(CallManagmentFunctionalDescriptor_t) + \
+ sizeof(AbstractControlManagmentDescriptor_t) + \
+ sizeof(UnionFunctionalDescriptor_t) + \
+ sizeof(HAL_UsbEndPointDescptr_t) + \
+ sizeof(InterfaceDescriptor_t) + \
+ sizeof(HAL_UsbEndPointDescptr_t) + \
+ sizeof(HAL_UsbEndPointDescptr_t))
+// Common size of all descriptors in the msd configuration besides configuration descriptor
+#define COMMON_MSD_CFG_SIZE (sizeof(InterfaceDescriptor_t) + \
+ sizeof(HAL_UsbEndPointDescptr_t) + \
+ sizeof(HAL_UsbEndPointDescptr_t))
+// Commom size of all descriptors for DFU besides configuration descriptor
+#define COMMON_DFU_CFG_SIZE (sizeof(InterfaceDescriptor_t) + \
+ sizeof(DfuFunctionalDescriptor_t))
+
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (MSD_SUPPORT == 1)
+ #if (DFU_SUPPORT == 1)
+ #define CFG_SIZE (COMMON_DFU_CFG_SIZE + COMMON_MSD_CFG_SIZE + COMMON_VCP_CFG_SIZE + sizeof(ConfigurationDescriptor_t) + \
+ sizeof(InterfaceAssociationDescriptor_t))
+ #else // (DFU_SUPPORT == 1)
+ #define CFG_SIZE (COMMON_MSD_CFG_SIZE + COMMON_VCP_CFG_SIZE + sizeof(ConfigurationDescriptor_t) + \
+ sizeof(InterfaceAssociationDescriptor_t))
+ #endif // (DFU_SUPPORT == 1)
+ #else // (MSD_SUPPORT == 1)
+ #if (DFU_SUPPORT == 1)
+ #define CFG_SIZE (COMMON_DFU_CFG_SIZE + COMMON_VCP_CFG_SIZE + sizeof(ConfigurationDescriptor_t) + \
+ sizeof(InterfaceAssociationDescriptor_t))
+ #else // (DFU_SUPPORT == 1)
+ #define CFG_SIZE (COMMON_VCP_CFG_SIZE + sizeof(ConfigurationDescriptor_t))
+ #endif // (DFU_SUPPORT == 1)
+ #endif
+#else // (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (DFU_SUPPORT == 1)
+ #define CFG_SIZE (COMMON_DFU_CFG_SIZE + COMMON_MSD_CFG_SIZE + sizeof(ConfigurationDescriptor_t))
+ #else // (DFU_SUPPORT == 1)
+ #define CFG_SIZE (COMMON_MSD_CFG_SIZE + sizeof(ConfigurationDescriptor_t))
+ #endif // (DFU_SUPPORT == 1)
+#endif
+
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (MSD_SUPPORT == 1)
+ #if (DFU_SUPPORT == 1)
+ #define NUMBER_OF_INTERFACES 0x04
+ #else
+ #define NUMBER_OF_INTERFACES 0x03
+ #endif
+ #else
+ #define NUMBER_OF_INTERFACES 0x02
+ #endif
+#else
+ #if (DFU_SUPPORT == 1)
+ #define NUMBER_OF_INTERFACES 0x02
+ #else
+ #define NUMBER_OF_INTERFACES 0x01
+ #endif
+#endif
+
+#define CFG_SELECTING_VALUE 0x01
+#define CFG_CHARACTERISTICS 0x80 // D7 is reserved and must be set to one for historical reasons.
+#define MAXIMUM_POWER_CONSUMPTION 0x32 // Step is 2 mA.
+
+// Parameters for interfaces descriptors
+#define ALTERNATIVE_SETTING 0x00
+#define NUMBER_USING_ENDPOINTS_FIRST_IFC 0x01
+#define NUMBER_USING_ENDPOINTS_SECOND_IFC 0x02
+#define NUMBER_USING_ENDPOINTS_THIRD_IFC 0x02
+#define NUMBER_USING_ENDPOINTS_FOURTH_IFC 0x00
+#define FIRST_IFC_CLASS 0x02
+#define FIRST_IFC_SUBCLASS 0x02
+#define FIRST_IFC_PROTOCOL 0x00
+#define SECOND_IFC_CLASS 0x0A
+#define SECOND_IFC_SUBCLASS 0x00
+#define SECOND_IFC_PROTOCOL 0x00
+#define THIRD_IFC_CLASS 0x08
+#define THIRD_IFC_SUBCLASS 0x06
+#define THIRD_IFC_PROTOCOL 0x50
+#define FOURTH_IFC_CLASS 0xFE
+#define FOURTH_IFC_SUBCLASS 0x01
+#define FOURTH_IFC_PROTOCOL 0x01
+
+// Header descriptor parameters.
+#define HEADER_SUBTYPE 0x00
+#define CDC_CLASS_DEFINITION 0x0110
+
+// call management functional descriptor parameters.
+#define CALL_MNGMT_SUBTYPE 0x01
+#define CALL_MNGMT_CAPABILITIES 0x01 // See cdc specification.
+#define NUMBER_OF_CALL_MNGMT 0x00
+
+// abstract control management functional descriptor parameters.
+#define ACM_SUBTYPE 0x02
+#define ACM_CAPABILITIES 0x02 // see cdc specification
+
+// Union functional descriptor parameters.
+#define UNION_SUBTYPE 0x06
+#define MASTER_IFC_TYPE 0x00
+#define SLAVE0_IFC_TYPE 0x01
+
+// Endpoints descriptor parameters.
+#define ADDRESS_CDC_INTERRUPT_PIPE 0x83
+#define ADDRESS_CDC_BULKIN_PIPE 0x82
+#define ADDRESS_CDC_BULKOUT_PIPE 0x01
+#define INTERRUPT_TYPE_PIPE 0x03
+#define BULK_TYPE_PIPE 0x02
+#define INTERRUPT_PIPE_POLLING 0x0A // step is 1 ms
+#define BULK_MAX_SPEED 0x00
+
+// dfu functional descriptor parameters
+#define DFU_ATTRIBUTES 0x01
+#define DFU_DETACH_TIMEOUT 0xFFFF
+#define DFU_TRANSFER_SIZE SZ_CONTROL_ENDPOINT
+#define DFU_VERSION 0x0101
+
+/******************************************************************************
+ Constants section
+******************************************************************************/
+const DeviceDescriptor_t deviceDescr = {
+ sizeof(DeviceDescriptor_t), // Size of this descriptor in bytes
+ DESCRIPTOR_TYPE_DEVICE, // Descriptor type
+ USB_BUS_RELEASE, // USB specification release number in BCD format
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (MSD_SUPPORT != 1) && (DFU_SUPPORT != 1)
+ CDC_DEVICE_CLASS, // Device class code
+ CDC_DEVICE_SUBCLASS, // Device subclass code
+ CDC_DEVICE_PROTOCOL, // Device protocol code
+ #else // (MSD_SUPPORT != 1) && (DFU_SUPPORT != 1)
+ COMB_DEVICE_CLASS, // Device class code
+ COMB_DEVICE_SUBCLASS, // Device subclass code
+ COMB_DEVICE_PROTOCOL, // Device protocol code
+ #endif // (MSD_SUPPORT != 1) && (DFU_SUPPORT != 1)
+#else // (APP_INTERFACE == APP_INTERFACE_VCP)
+ MSC_DEVICE_CLASS, // Device class code
+ MSC_DEVICE_SUBCLASS, // Device subclass code
+ MSC_DEVICE_PROTOCOL, // Device protocol code
+#endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+ SZ_CONTROL_ENDPOINT, // Maximum packet size of endpoint 0 (in bytes)
+ VENDOR_ID, // Vendor ID
+ PRODUCT_ID, // Product ID
+ DEVICE_RELEASE, // Device release number in BCD format
+ MANUFACTURER_STRING_INDEX, // Index of the manufacturer string descriptor
+ PRODUCT_STRING_INDEX, // Index of the product string descriptor
+ SERIAL_NUMBER_STRING_INDEX, // Index of the serial number string descriptor
+ NUMBER_OF_CONFIGURATIONS // Number of possible configurations for the device
+};
+
+const ConfigurationFrameResponse_t usbConfigDescr = {
+ { // configuration
+ sizeof(ConfigurationDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_CONFIGURATION, // Descriptor type
+ CFG_SIZE, // Length of all descriptors returned along with this configuration descriptor
+ NUMBER_OF_INTERFACES, // Number of interfaces in this configuration
+ CFG_SELECTING_VALUE, // Value for selecting this configuration
+ CONFIGURATION_STRING_INDEX, // Index of the configuration string descriptor
+ CFG_CHARACTERISTICS, // Configuration characteristics
+ MAXIMUM_POWER_CONSUMPTION // Maximum power consumption of the device when in this configuration
+ },
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (MSD_SUPPORT == 1) || (DFU_SUPPORT == 1)
+ { // cdcIAD
+ sizeof(InterfaceAssociationDescriptor_t), // Size of this descriptor in bytes
+ DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION, // Descriptor type
+ NUMBER_OF_FIRST_INTERFACE, // Interface number of the first interface that is associated with this function
+ 2, // Number of contiguous interfaces that are associated with this function
+ CDC_DEVICE_CLASS, // Class code
+ CDC_DEVICE_SUBCLASS, // Subclass code
+ CDC_DEVICE_PROTOCOL, // Protocol code
+ FIRST_INTERFACE_STRING_INDEX //Index of string descriptor describing this function
+ },
+ #endif // (MSD_SUPPORT == 1) || (DFU_SUPPORT == 1)
+ { // interface 1
+ sizeof(InterfaceDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_INTERFACE, // Descriptor type
+ NUMBER_OF_FIRST_INTERFACE, // Number of the interface in its configuration
+ ALTERNATIVE_SETTING, // Value to select this alternate interface setting
+ NUMBER_USING_ENDPOINTS_FIRST_IFC, // Number of endpoints used by the interface (excluding endpoint 0)
+ FIRST_IFC_CLASS, // Interface class code
+ FIRST_IFC_SUBCLASS, // Interface subclass code
+ FIRST_IFC_PROTOCOL, // Interface protocol code
+ FIRST_INTERFACE_STRING_INDEX // Index of the interface string descriptor
+ },
+ { // header functional descriptor
+ sizeof(HeaderFunctionalDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_CS_INTERFACE, // Descriptor type
+ HEADER_SUBTYPE, // Header functional descriptor subtype
+ CDC_CLASS_DEFINITION // USB Class Definitions for Communication
+ },
+ { // Call Management Functional Descriptor
+ sizeof(CallManagmentFunctionalDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_CS_INTERFACE, // Descriptor type
+ CALL_MNGMT_SUBTYPE, // bDescriptor subtype: Call Management Func
+ CALL_MNGMT_CAPABILITIES, // bmCapabilities: D1 + D0
+ NUMBER_OF_CALL_MNGMT // bDataInterface: Data Class Interface 1
+ },
+ { // Abstract Control Management Functional Descriptor
+ sizeof(AbstractControlManagmentDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_CS_INTERFACE, // Descriptor type
+ ACM_SUBTYPE, // Abstract Control Management Functional descriptor subtype
+ ACM_CAPABILITIES // bmCapabilities: see cdc specification (support command type)
+ },
+ { // Union Functional Descriptor
+ sizeof(UnionFunctionalDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_CS_INTERFACE, // Descriptor type
+ UNION_SUBTYPE, // Union Functional descriptor subtype
+ MASTER_IFC_TYPE, // bMasterInterface: CDC Interface
+ SLAVE0_IFC_TYPE // bSlaveInterface0: Data Class Interface
+ },
+ { // endpoint 3
+ sizeof(HAL_UsbEndPointDescptr_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_ENDPOINT, // Descriptor type
+ ADDRESS_CDC_INTERRUPT_PIPE, // Address and direction of the endpoint
+ INTERRUPT_TYPE_PIPE, // Endpoint type and additional characteristics (for isochronous endpoints)
+ SZ_ACM_INT_ENDPOINT, // Maximum packet size (in bytes) of the endpoint
+ INTERRUPT_PIPE_POLLING // Polling rate of the endpoint
+ },
+ { // interface 2
+ sizeof(InterfaceDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_INTERFACE, // Descriptor type
+ NUMBER_OF_SECOND_INTERFACE, // Number of the interface in its configuration
+ ALTERNATIVE_SETTING, // Value to select this alternate interface setting
+ NUMBER_USING_ENDPOINTS_SECOND_IFC, // Number of endpoints used by the interface (excluding endpoint 0)
+ SECOND_IFC_CLASS, // Interface class code
+ SECOND_IFC_SUBCLASS, // Interface subclass code
+ SECOND_IFC_PROTOCOL, // Interface protocol code
+ SECOND_INTERFACE_STRING_INDEX // Index of the interface string descriptor
+ },
+ {{ // endpoint 1
+ sizeof(HAL_UsbEndPointDescptr_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_ENDPOINT, // Descriptor type
+ ADDRESS_CDC_BULKOUT_PIPE, // Address and direction of the endpoint
+ BULK_TYPE_PIPE, // Endpoint type and additional characteristics (for isochronous endpoints)
+ SZ_CDC_BULKOUT_ENDPOINT, // Maximum packet size (in bytes) of the endpoint
+ BULK_MAX_SPEED // Polling rate of the endpoint
+ },
+ { // endpoint 2
+ sizeof(HAL_UsbEndPointDescptr_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_ENDPOINT, // Descriptor type
+ ADDRESS_CDC_BULKIN_PIPE, // Address and direction of the endpoint
+ BULK_TYPE_PIPE, // Endpoint type and additional characteristics (for isochronous endpoints)
+ SZ_CDC_BULKIN_ENDPOINT, // Maximum packet size (in bytes) of the endpoint
+ BULK_MAX_SPEED // Polling rate of the endpoint
+ }},
+#endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+#if (MSD_SUPPORT == 1)
+ { // interface 3
+ sizeof(InterfaceDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_INTERFACE, // Descriptor type
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ NUMBER_OF_THIRD_INTERFACE, // Number of the interface in its configuration
+#else
+ NUMBER_OF_FIRST_INTERFACE, // Number of the interface in its configuration
+#endif
+ ALTERNATIVE_SETTING, // Value to select this alternate interface setting
+ NUMBER_USING_ENDPOINTS_THIRD_IFC, // Number of endpoints used by the interface (excluding endpoint 0)
+ THIRD_IFC_CLASS, // Interface class code
+ THIRD_IFC_SUBCLASS, // Interface subclass code
+ THIRD_IFC_PROTOCOL, // Interface protocol code
+ THIRD_INTERFACE_STRING_INDEX // Index of the interface string descriptor
+ },
+ {{ // endpoint 6
+ sizeof(HAL_UsbEndPointDescptr_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_ENDPOINT, // Descriptor type
+ ADDRESS_MSC_BULKOUT_PIPE, // Address and direction of the endpoint
+ BULK_TYPE_PIPE, // Endpoint type and additional characteristics (for isochronous endpoints)
+ SZ_MSC_BULKOUT_ENDPOINT, // Maximum packet size (in bytes) of the endpoint
+ BULK_MAX_SPEED // Polling rate of the endpoint
+ },
+ { // endpoint 5
+ sizeof(HAL_UsbEndPointDescptr_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_ENDPOINT, // Descriptor type
+ ADDRESS_MSC_BULKIN_PIPE, // Address and direction of the endpoint
+ BULK_TYPE_PIPE, // Endpoint type and additional characteristics (for isochronous endpoints)
+ SZ_MSC_BULKIN_ENDPOINT, // Maximum packet size (in bytes) of the endpoint
+ BULK_MAX_SPEED // Polling rate of the endpoint
+ }},
+#endif // (MSD_SUPPORT == 1)
+#if (DFU_SUPPORT == 1)
+ { // interface 4
+ sizeof(InterfaceDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_INTERFACE, // Descriptor type
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (MSD_SUPPORT == 1)
+ NUMBER_OF_FOURTH_INTERFACE, // Number of the interface in its configuration
+ #else
+ NUMBER_OF_THIRD_INTERFACE, // Number of the interface in its configuration
+ #endif // (MSD_SUPPORT == 1)
+#else
+ #if (MSD_SUPPORT == 1)
+ NUMBER_OF_SECOND_INTERFACE, // Number of the interface in its configuration
+ #else
+ #error
+ #endif // (MSD_SUPPORT == 1)
+#endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+ ALTERNATIVE_SETTING, // Value to select this alternate interface setting
+ NUMBER_USING_ENDPOINTS_FOURTH_IFC, // Number of endpoints used by the interface (excluding endpoint 0)
+ FOURTH_IFC_CLASS, // Interface class code
+ FOURTH_IFC_SUBCLASS, // Interface subclass code
+ FOURTH_IFC_PROTOCOL, // Interface protocol code
+ FOURTH_INTERFACE_STRING_INDEX // Index of the interface string descriptor
+ },
+ { // Functional descriptor
+ sizeof(DfuFunctionalDescriptor_t), // Size of the descriptor in bytes
+ DESCRIPTOR_TYPE_DFU_FUNCTIONAL, // Descriptor type
+ DFU_ATTRIBUTES, // Descriptor attributes
+ DFU_DETACH_TIMEOUT, // Wait timeout of USB reset after DFU_DETACH request recieption
+ DFU_TRANSFER_SIZE, // Maximum number of bytes that the device can accept per control-write transaction
+ DFU_VERSION // DFU Version
+ }
+#endif // (DFU_SUPPORT == 1)
+};
+
+// eof usbDescriptors.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbEnumeration.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbEnumeration.c
new file mode 100644
index 00000000..f430b08d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbEnumeration.c
@@ -0,0 +1,231 @@
+/****************************************************************************//**
+ \file usbEnumeration.c
+
+ \brief Implementation of enumeration proccess.
+
+ \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:
+ 11/09/08 A. Khromykh - Created
+ 26/08/11 N. Fomin - Modified (MSD support)
+*******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <usbDescriptors.h>
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ #include <vcpVirtualUsart.h>
+#endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+#if (MSD_SUPPORT == 1)
+ #include <hsmci.h>
+#endif // (MSD_SUPPORT == 1)
+#include <usbSetupProcess.h>
+#include <massStorageDevice.h>
+#include <usbEnumeration.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+// request codes for runtime work
+#define USB_GET_STATUS 0
+#define USB_CLEAR_FEATURE 1
+#define USB_SET_FEATURE 3
+#define USB_SET_ADDRESS 5
+#define USB_GET_DESCRIPTOR 6
+#define USB_SET_DESCRIPTOR 7
+#define USB_GET_CONFIGURATION 8
+#define USB_SET_CONFIGURATION 9
+#define USB_GET_INTERFACE 10
+#define USB_SET_INTERFACE 11
+#define USB_SYNCH_FRAME 12
+
+// Descriptor type definitions.
+#define DESCRIPTOR_TYPE_DEVICE 0x01
+#define DESCRIPTOR_TYPE_CONFIGURATION 0x02
+#define DESCRIPTOR_TYPE_STRING 0x03
+#define DESCRIPTOR_TYPE_INTERFACE 0x04
+#define DESCRIPTOR_TYPE_CS_INTERFACE 0x24
+#define DESCRIPTOR_TYPE_ENDPOINT 0x05
+#define DESCRIPTOR_TYPE_DEVICE_QUALIFIER 0x06
+#define DESCRIPTOR_TYPE_OTHER_SPEED_CFG 0x07
+#define DESCRIPTOR_TYPE_INTERFACE_POWER 0x08
+
+/******************************************************************************
+ External global variables section
+******************************************************************************/
+extern const ConfigurationFrameResponse_t usbConfigDescr;
+extern const DeviceDescriptor_t deviceDescr;
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ extern HAL_UsartDescriptor_t *vcpPointDescrip;
+#endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+#if (MSD_SUPPORT == 1)
+ extern HAL_HsmciDescriptor_t *msdPointDescr;
+#endif // (MSD_SUPPORT == 1)
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+usb bulk out receiving callbacks
+
+Parameters:
+ pArg - argument
+ status - index of the requested descriptor
+ length - maximum number of bytes to return
+******************************************************************************/
+void vcpRcvCallback(void *pArg, uint8_t status, uint16_t transferred, uint16_t remaining);
+void msdRcvCallback(void *pArg, uint8_t status, uint16_t transferred, uint16_t remaining);
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+// virtual communication port address on usb
+static uint16_t usbAddress = 0;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+#if defined(AT91SAM7X256) || defined(AT91SAM3S4C)
+/******************************************************************************
+send zero-length packet through control pipe
+******************************************************************************/
+void sendZLP(void)
+{
+ // Acknowledge the request
+ HAL_UsbWrite(0, NULL, 0, NULL, NULL);
+}
+#endif
+
+/******************************************************************************
+Configures the device by setting it into the Configured state.
+
+Parameters:
+ cfgnum - configuration number to set
+******************************************************************************/
+void runtimeSetConfiguration(uint8_t cfgnum)
+{
+ // Set & save the desired configuration
+ HAL_SetConfiguration(cfgnum);
+
+ #if defined(AT91SAM7X256) || defined(AT91SAM3S4C)
+ // Acknowledge the request
+ sendZLP();
+ #endif
+}
+
+/******************************************************************************
+runtime get descriptor command handler
+
+Parameters:
+ type - type of the requested descriptor
+ index - index of the requested descriptor
+ length - maximum number of bytes to return
+******************************************************************************/
+void runtimeGetDescriptorHandler(uint8_t type, uint8_t index, uint16_t length)
+{
+ (void)index;
+
+ // Check the descriptor type
+ switch (type)
+ {
+ case DESCRIPTOR_TYPE_DEVICE:
+ // Adjust length and send descriptor
+ if (length > deviceDescr.bLength)
+ length = deviceDescr.bLength;
+ HAL_UsbWrite(0, (void *)&deviceDescr, length, 0, 0);
+ break;
+ case DESCRIPTOR_TYPE_CONFIGURATION:
+ // Adjust length and send descriptor
+ if (length > usbConfigDescr.config.wTotalLength)
+ length = usbConfigDescr.config.wTotalLength;
+ HAL_UsbWrite(0, (void *)&usbConfigDescr, length, 0, 0);
+ break;
+ case DESCRIPTOR_TYPE_INTERFACE:
+ HAL_Stall(0);
+ break;
+ case DESCRIPTOR_TYPE_DEVICE_QUALIFIER:
+ HAL_Stall(0);
+ break;
+ case DESCRIPTOR_TYPE_OTHER_SPEED_CFG:
+ HAL_Stall(0);
+ break;
+ case DESCRIPTOR_TYPE_ENDPOINT:
+ HAL_Stall(0);
+ break;
+ case DESCRIPTOR_TYPE_STRING:
+ HAL_Stall(0);
+ break;
+ default:
+ HAL_Stall(0);
+ break;
+ }
+}
+
+/******************************************************************************
+Standard usb request handler
+
+Parameters:
+ data - pointer to host's request
+******************************************************************************/
+void runtimeRequestHandler(uint8_t *data)
+{
+ UsbRequest_t *pRequest = NULL;
+
+ pRequest = (UsbRequest_t *)data;
+ if (NULL == pRequest)
+ return;
+
+ // Check request code
+ switch (pRequest->bRequest)
+ {
+ case USB_GET_DESCRIPTOR:
+ // Send the requested descriptor
+ runtimeGetDescriptorHandler((uint8_t)(pRequest->wValue >> 8), (uint8_t)(pRequest->wValue), pRequest->wLength);
+ break;
+ case USB_SET_ADDRESS:
+ usbAddress = pRequest->wValue & 0x7F;
+ #if defined(AT91SAM7X256) || defined(AT91SAM3S4C)
+ HAL_UsbWrite(0, 0, 0, (TransferCallback_t) HAL_SetAddress, (void *)&usbAddress);
+ #elif defined(AT90USB1287)
+ HAL_SetAddress((uint8_t *)&usbAddress);
+ #endif
+ break;
+ case USB_SET_CONFIGURATION:
+ // Set the requested configuration
+ runtimeSetConfiguration((uint8_t)pRequest->wValue);
+ #if (APP_INTERFACE == APP_INTERFACE_VCP)
+ HAL_ConfigureEndpoint((void *)&(usbConfigDescr.endpointIfc1));
+ HAL_ConfigureEndpoint((void *)&(usbConfigDescr.endpointIfc2[0]));
+ HAL_ConfigureEndpoint((void *)&(usbConfigDescr.endpointIfc2[1]));
+ HAL_UsbRead(VCP_RECEIVE_PIPE, vcpPointDescrip->rxBuffer, BULK_SIZE, vcpRcvCallback, NULL);
+ #endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (MSD_SUPPORT == 1)
+ HAL_ConfigureEndpoint((void *)&(usbConfigDescr.endpointIfc3[0]));
+ HAL_ConfigureEndpoint((void *)&(usbConfigDescr.endpointIfc3[1]));
+ HAL_UsbRead(MSD_RECEIVE_PIPE, msdPointDescr->dataTransferDescriptor->buffer, BULK_SIZE, msdRcvCallback, NULL);
+ #endif // (MSD_SUPPORT == 1)
+ break;
+ default:
+ setupProcessRequestHandler(data);
+ break;
+ }
+}
+
+/******************************************************************************
+Standard usb request handler
+
+Parameters:
+ data - pointer to host's request
+******************************************************************************/
+void usbBusResetAction(void)
+{
+ HAL_RegisterRequestHandler(runtimeRequestHandler);
+}
+
+// eof usbEnumeration.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbSetupProcess.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbSetupProcess.c
new file mode 100644
index 00000000..2a3b305e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBClasses/common/src/usbSetupProcess.c
@@ -0,0 +1,90 @@
+/****************************************************************************//**
+ \file usbSetupProcess.c
+
+ \brief Implementation of setup (after numeration) proccess.
+
+ \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:
+ 26/08/11 N. Fomin - Created
+*******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <usbDescriptors.h>
+#if (APP_INTERFACE == APP_INTERFACE_VCP)
+ #include <vcpCdcProtocol.h>
+ #if (MSD_SUPPORT == 1)
+ #include <mscProtocol.h>
+ #endif // (MSD_SUPPORT == 1)
+#else
+ #if (MSD_SUPPORT == 1)
+ #include <mscProtocol.h>
+ #else
+ #include <usbSetupProcess.h>
+ #endif // (MSD_SUPPORT == 1)
+#endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+#if (DFU_SUPPORT == 1)
+ #include <dfuProtocol.h>
+ #if (APP_INTERFACE != APP_INTERFACE_VCP) && (MSD_SUPPORT != 1)
+ #error
+ #endif // (APP_INTERFACE != APP_INTERFACE_VCP) || (MSD_SUPPORT != 1)
+#endif // (DFU_SUPPORT == 1)
+
+/******************************************************************************
+Usb setup process request handler
+
+Parameters:
+ data - pointer to host's request
+******************************************************************************/
+void setupProcessRequestHandler(uint8_t *data)
+{
+ UsbRequest_t *pRequest = NULL;
+
+ pRequest = (UsbRequest_t *)data;
+ if (NULL == pRequest)
+ return;
+
+ switch (pRequest->wIndex)
+ {
+ #if (APP_INTERFACE == APP_INTERFACE_VCP)
+ case NUMBER_OF_FIRST_INTERFACE:
+ vcpRequestHandler(data);
+ break;
+ #endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+ /* MSC commands */
+ #if (MSD_SUPPORT == 1)
+ #if (APP_INTERFACE == APP_INTERFACE_VCP)
+ case NUMBER_OF_THIRD_INTERFACE:
+ #else
+ case NUMBER_OF_FIRST_INTERFACE:
+ #endif
+ msdRequestHandler(data);
+ break;
+ #endif // (MSD_SUPPORT == 1)
+ #if (DFU_SUPPORT == 1)
+ #if (APP_INTERFACE == APP_INTERFACE_VCP)
+ #if (MSD_SUPPORT == 1)
+ case NUMBER_OF_FOURTH_INTERFACE:
+ #else
+ case NUMBER_OF_THIRD_INTERFACE:
+ #endif
+ #else
+ case NUMBER_OF_SECOND_INTERFACE:
+ #endif // (APP_INTERFACE == APP_INTERFACE_VCP)
+ dfuRequestHandler(data);
+ break;
+ #endif // (DFU_SUPPORT == 1)
+ default:
+ HAL_Stall(0);
+ break;
+ }
+}
+
+// eof usbSetupProcess.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBFIFO/include/usbFifoVirtualUsart.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBFIFO/include/usbFifoVirtualUsart.h
new file mode 100644
index 00000000..7b000818
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBFIFO/include/usbFifoVirtualUsart.h
@@ -0,0 +1,69 @@
+/**************************************************************************//**
+\file usbFifoVirtualUsart.h
+
+\brief The declaration of interfunction interface.
+
+\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:
+ 15.07.11 A. Khromykh - Created
+*******************************************************************************/
+#ifndef _USBFIFOVIRTUALUSART_H
+#define _USBFIFOVIRTUALUSART_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <gpio.h>
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+#if defined(ATMEGA128RFA1)
+
+// the macros for the manipulation by PC6 for binary decoder
+HAL_ASSIGN_PIN(PC6, D, 6);
+// the macros for the manipulation by PC7 for binary decoder
+HAL_ASSIGN_PIN(PC7, D, 7);
+// the macros for the manipulation by RD
+HAL_ASSIGN_PIN(RD, E, 5);
+// the macros for the manipulation by WR
+HAL_ASSIGN_PIN(WR, E, 4);
+
+#elif defined(ATMEGA1281) || defined(ATMEGA2561)
+
+// the macros for the manipulation by PC6 for binary decoder
+HAL_ASSIGN_PIN(PC6, C, 6);
+// the macros for the manipulation by PC7 for binary decoder
+HAL_ASSIGN_PIN(PC7, C, 7);
+// the macros for the manipulation by RD
+HAL_ASSIGN_PIN(RD, G, 1);
+// the macros for the manipulation by WR
+HAL_ASSIGN_PIN(WR, G, 0);
+
+#else
+ #error 'USB FIFO is not supported for this mcu.'
+#endif
+
+/**************************************************************************//**
+\brief Startup initialization.
+******************************************************************************/
+void usbfifoInit(void);
+
+/**************************************************************************//**
+\brief Clear startup initialization parameters
+******************************************************************************/
+void usbfifoUnInit(void);
+
+/**************************************************************************//**
+\brief USB FIFO driver task handler.
+******************************************************************************/
+void usbfifoHandler(void);
+
+#endif /* _USBFIFOVIRTUALUSART_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBFIFO/src/usbFifoFT245RL.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBFIFO/src/usbFifoFT245RL.c
new file mode 100644
index 00000000..8ba0d9c5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBFIFO/src/usbFifoFT245RL.c
@@ -0,0 +1,290 @@
+/**************************************************************************//**
+\file usbFifoFT245RL.c
+
+\brief Implementation of FT245RL driver.
+
+\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:
+ 12.07.11 A. Khromykh - Created
+*******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <usbFifoVirtualUsart.h>
+#include <usart.h>
+#include <atomic.h>
+#include <irq.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#if defined(ATMEGA128RFA1)
+// data port
+#define USB_DATA_PORT PORTB
+#define USB_DATA_DDR DDRB
+#define USB_DATA_PIN PINB
+
+#elif defined(ATMEGA1281) || defined(ATMEGA2561)
+// data port
+#define USB_DATA_PORT PORTA
+#define USB_DATA_DDR DDRA
+#define USB_DATA_PIN PINA
+
+#endif
+
+#define HANDLERS_GET(A, I) memcpy_P(A, &usbfifoHandlers[I], sizeof(UsbfifoTask_t))
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef volatile uint8_t UsbfifoTaskBitMask_t;
+typedef void (* UsbfifoTask_t)(void);
+
+// USB FIFO task IDs.
+typedef enum
+{
+ USB_FIFO_TASK_RX,
+ USB_FIFO_TASK_TX,
+ USB_FIFO_TASKS_NUMBER
+} UsbfifoTaskId_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+static void usbfifoRxBufferFiller(void);
+static void usbfifoTxBufferCleaner(void);
+static void usbfifoPostTask(UsbfifoTaskId_t taskId);
+static void usbfifoTxComplete(void);
+static void usbfifoRxComplete(void);
+
+/******************************************************************************
+ External global variables section
+******************************************************************************/
+// pointer to application uart descriptor
+extern HAL_UsartDescriptor_t *usbfifoPointDescrip;
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+static volatile UsbfifoTaskBitMask_t usbfifoTaskBitMask = 0; // USB FIFO tasks' bit mask.
+static const UsbfifoTask_t PROGMEM_DECLARE(usbfifoHandlers[USB_FIFO_TASKS_NUMBER]) =
+{
+ usbfifoRxComplete,
+ usbfifoTxComplete
+}; // List Of possible USB FIFO tasks.
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Startup initialization.
+******************************************************************************/
+void usbfifoInit(void)
+{
+ // init decoder input pins
+ GPIO_PC6_make_out();
+ GPIO_PC7_make_out();
+ // set pins to zero to select usb FIFO
+ GPIO_PC6_clr();
+ GPIO_PC7_clr();
+
+ // setup default value
+ GPIO_RD_set();
+ GPIO_WR_set();
+ // init R\W pins
+ GPIO_RD_make_out();
+ GPIO_WR_make_out();
+
+ // register RXF interrupt
+ HAL_RegisterIrq(IRQ_7, IRQ_LOW_LEVEL, usbfifoRxBufferFiller);
+ // register TXE interrupt
+ HAL_RegisterIrq(IRQ_6, IRQ_LOW_LEVEL, usbfifoTxBufferCleaner);
+
+ USB_DATA_DDR = 0;
+}
+
+/**************************************************************************//**
+\brief Clear startup initialization parameters
+******************************************************************************/
+void usbfifoUnInit(void)
+{
+ GPIO_PC6_make_in();
+ GPIO_PC7_make_in();
+
+ GPIO_RD_make_in();
+ GPIO_WR_make_in();
+
+ HAL_DisableIrq(IRQ_7);
+ HAL_UnregisterIrq(IRQ_7);
+
+ HAL_DisableIrq(IRQ_6);
+ HAL_UnregisterIrq(IRQ_6);
+}
+
+/**************************************************************************//**
+\brief Puts the byte received to the cyclic buffer.
+******************************************************************************/
+static void usbfifoRxBufferFiller(void)
+{
+ uint16_t old;
+ uint16_t poW;
+ uint16_t poR;
+ uint8_t *buffer;
+ HalUsartService_t *control;
+
+ if (!usbfifoPointDescrip)
+ { // unregistered intrrupt is occurred
+ HAL_DisableIrq(IRQ_7);
+ return;
+ }
+
+ control = &usbfifoPointDescrip->service;
+ poW = control->rxPointOfWrite;
+ poR = control->rxPointOfRead;
+ buffer = usbfifoPointDescrip->rxBuffer;
+
+ if (!buffer)
+ {
+ HAL_DisableIrq(IRQ_7);
+ return;
+ }
+
+ old = poW;
+
+ if (++poW == usbfifoPointDescrip->rxBufferLength)
+ poW = 0;
+
+ if (poW == poR)
+ { // Buffer full.
+ HAL_DisableIrq(IRQ_7);
+ return;
+ } // Buffer full.
+
+ control->rxPointOfWrite = poW;
+ GPIO_RD_clr();
+ NOP;
+ buffer[old] = USB_DATA_PIN;
+ GPIO_RD_set();
+ control->rxBytesInBuffer++;
+ usbfifoPostTask(USB_FIFO_TASK_RX);
+}
+
+/**************************************************************************//**
+\brief Reads byte from tx buffer and sends it to fifo.
+******************************************************************************/
+static void usbfifoTxBufferCleaner(void)
+{
+ HalUsartService_t *control;
+ uint16_t poW;
+ uint16_t poR;
+
+ if (!usbfifoPointDescrip)
+ { // unregistered intrrupt is occurred
+ HAL_DisableIrq(IRQ_6);
+ return;
+ }
+
+ control = &usbfifoPointDescrip->service;
+ poW = control->txPointOfWrite;
+ poR = control->txPointOfRead;
+
+ if (poW != poR)
+ {
+ // set port as output
+ USB_DATA_DDR = 0xFF;
+ NOP;
+ USB_DATA_PORT = usbfifoPointDescrip->txBuffer[poR++];
+ GPIO_WR_clr();
+ GPIO_WR_set();
+ USB_DATA_DDR = 0;
+
+ if (poR == usbfifoPointDescrip->txBufferLength)
+ poR = 0;
+
+ control->txPointOfRead = poR;
+ }
+ else
+ { // tx buffer is empty
+ HAL_DisableIrq(IRQ_6);
+ usbfifoPostTask(USB_FIFO_TASK_TX);
+ }
+}
+
+/**************************************************************************//**
+\brief Transmitting complete handler
+******************************************************************************/
+static void usbfifoTxComplete(void)
+{
+ if (NULL == usbfifoPointDescrip)
+ return;
+
+ if (0 == usbfifoPointDescrip->txBufferLength)
+ usbfifoPointDescrip->txBuffer = NULL; // nulling pointer for callback mode
+
+ if (usbfifoPointDescrip->txCallback)
+ usbfifoPointDescrip->txCallback();
+}
+
+/**************************************************************************//**
+\brief Byte is received handler
+******************************************************************************/
+static void usbfifoRxComplete(void)
+{
+ HalUsartService_t *control;
+ uint16_t number;
+
+ if (NULL == usbfifoPointDescrip)
+ return;
+
+ control = &usbfifoPointDescrip->service;
+ ATOMIC_SECTION_ENTER
+ number = control->rxBytesInBuffer;
+ ATOMIC_SECTION_LEAVE
+
+ if (number)
+ if (NULL != usbfifoPointDescrip->rxCallback)
+ usbfifoPointDescrip->rxCallback(number);
+}
+
+/**************************************************************************//**
+\brief USB FIFO driver task handler.
+******************************************************************************/
+void usbfifoHandler(void)
+{
+ UsbfifoTask_t handler;
+ uint8_t mask = 1;
+ UsbfifoTaskId_t index = 0;
+
+ for ( ; index < USB_FIFO_TASKS_NUMBER; index++, mask <<= 1)
+ {
+ if (usbfifoTaskBitMask & mask)
+ {
+ ATOMIC_SECTION_ENTER
+ usbfifoTaskBitMask ^= mask;
+ ATOMIC_SECTION_LEAVE
+ HANDLERS_GET(&handler, index);
+ handler();
+ }
+ }
+}
+
+/**************************************************************************//**
+\brief Posts specific USART task.
+
+\param[in]
+ taskId - unique identifier of the task to be posted.
+******************************************************************************/
+static void usbfifoPostTask(UsbfifoTaskId_t taskId)
+{
+ usbfifoTaskBitMask |= (UsbfifoTaskBitMask_t)1 << taskId;
+ halPostTask4(HAL_EXT_HANDLER);
+}
+
+// eof usbFifoFT245RL.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBFIFO/src/usbFifoVirtualUsart.c b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBFIFO/src/usbFifoVirtualUsart.c
new file mode 100644
index 00000000..1a909d38
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/USBFIFO/src/usbFifoVirtualUsart.c
@@ -0,0 +1,250 @@
+/****************************************************************************//**
+ \file usbFifoVirtualUart.c
+
+ \brief Implementation of virtual uart API.
+
+ \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:
+ 11/09/08 A. Khromykh - Created
+*******************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <usbFifoVirtualUsart.h>
+#include <usbFifoUsart.h>
+#include <atomic.h>
+#include <irq.h>
+
+/******************************************************************************
+ External global variables section
+******************************************************************************/
+extern void (* extHandler)(void);
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+// pointer to application uart descriptor
+HAL_UsartDescriptor_t *usbfifoPointDescrip = NULL;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+Open virtual com port and register uart's event handlers.
+
+Parameters:
+ descriptor - pointer to HAL_UartDescriptor_t structure
+
+Returns:
+ Returns positive uart descriptor on success or -1 in cases:
+ - bad uart channel;
+ - there are not enough resources;
+ - receiving buffer is less bulk endpoint size;
+******************************************************************************/
+int USBFIFO_OpenUsart(HAL_UsartDescriptor_t *descriptor)
+{
+ if (NULL == descriptor)
+ return -1;
+
+ if (USART_CHANNEL_USBFIFO != descriptor->tty)
+ return -1;
+
+ if (NULL != usbfifoPointDescrip)
+ return -1; /* source was opened */
+
+ extHandler = usbfifoHandler;
+ usbfifoPointDescrip = descriptor;
+
+ usbfifoPointDescrip->service.rxPointOfRead = 0;
+ usbfifoPointDescrip->service.rxPointOfWrite = 0;
+ usbfifoPointDescrip->service.txPointOfRead = 0;
+ usbfifoPointDescrip->service.txPointOfWrite = 0;
+ usbfifoInit();
+ // enable receiver
+ HAL_EnableIrq(IRQ_7);
+
+ return (int)descriptor->tty;
+}
+
+/******************************************************************************
+Frees the virtual uart channel.
+Parameters:
+ descriptor - the uart descriptor.
+Returns:
+ Returns 0 on success or -1 if bad descriptor.
+******************************************************************************/
+int USBFIFO_CloseUsart(HAL_UsartDescriptor_t *descriptor)
+{
+ if (NULL == descriptor)
+ return -1;
+
+ if (usbfifoPointDescrip != descriptor)
+ return -1;
+
+ usbfifoPointDescrip = NULL;
+ extHandler = NULL;
+ usbfifoUnInit();
+
+ return 0;
+}
+
+/******************************************************************************
+Writes a number of bytes to a virtual uart channel.
+txCallback function will be used to notify when the transmission is finished.
+Parameters:
+ descriptor - pointer to HAL_UartDescriptor_t structure;
+ buffer - pointer to the application data buffer;
+ length - number of bytes to transfer;
+Returns:
+ -1 - bad descriptor;
+ Number of bytes placed to the buffer - success.
+******************************************************************************/
+int USBFIFO_WriteUsart(HAL_UsartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length)
+{
+ uint16_t poW;
+ uint16_t poR;
+ uint16_t old;
+ uint16_t wasWrote = 0;
+ HalUsartService_t *control;
+
+ if (NULL == descriptor)
+ return -1;
+
+ if (usbfifoPointDescrip != descriptor)
+ return -1;
+
+ if (!buffer || !length)
+ return -1;
+
+ control = &descriptor->service;
+ ATOMIC_SECTION_ENTER
+ poW = control->txPointOfWrite;
+ poR = control->txPointOfRead;
+ ATOMIC_SECTION_LEAVE
+
+ if (0 == descriptor->txBufferLength)
+ { // Callback mode
+ if (poW != poR)
+ return -1; // there is unsent data
+ descriptor->txBuffer = buffer;
+ control->txPointOfWrite = length;
+ control->txPointOfRead = 0;
+ wasWrote = length;
+ } // Callback mode.
+ else
+ { // Polling mode.
+ while (wasWrote < length)
+ {
+ old = poW;
+
+ if (++poW == descriptor->txBufferLength)
+ poW = 0;
+
+ if (poW == poR)
+ { // Buffer full.
+ poW = old;
+ break;
+ } // Buffer full.
+
+ descriptor->txBuffer[old] = buffer[wasWrote++];
+ }
+
+ ATOMIC_SECTION_ENTER
+ control->txPointOfWrite = poW;
+ ATOMIC_SECTION_LEAVE
+ } // Polling mode
+
+ HAL_EnableIrq(IRQ_6);
+
+ return wasWrote;
+}
+
+/*****************************************************************************
+Reads length bytes from uart and places ones to buffer.
+Parameters:
+ descriptor - uart descriptor;
+ buffer - pointer to a application buffer;
+ length - the number of bytes which should be placed to buffer
+Returns:
+ -1 - bad descriptor, bad number to read;
+ number of bytes that were placed to buffer.
+*****************************************************************************/
+int USBFIFO_ReadUsart(HAL_UsartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length)
+{
+ uint16_t wasRead = 0;
+ uint16_t poW;
+ uint16_t poR;
+ HalUsartService_t *control;
+
+ if (NULL == descriptor)
+ return -1;
+
+ if (!buffer || !length)
+ return -1;
+
+ if (descriptor != usbfifoPointDescrip)
+ return -1; // Channel is not opened.
+
+ control = &usbfifoPointDescrip->service;
+ ATOMIC_SECTION_ENTER
+ poW = control->rxPointOfWrite;
+ poR = control->rxPointOfRead;
+ ATOMIC_SECTION_LEAVE
+
+ while ((poR != poW) && (wasRead < length))
+ {
+ buffer[wasRead] = descriptor->rxBuffer[poR];
+ if (++poR == descriptor->rxBufferLength)
+ poR = 0;
+ wasRead++;
+ }
+
+ ATOMIC_SECTION_ENTER
+ control->rxPointOfRead = poR;
+ control->rxBytesInBuffer -= wasRead;
+ ATOMIC_SECTION_LEAVE
+
+ HAL_EnableIrq(IRQ_7);
+
+ return wasRead;
+}
+
+/**************************************************************************//**
+\brief Checks the status of tx buffer.
+
+\param[in] descriptor - pointer to HAL_UsartDescriptor_t structure;
+\return -1 - bad descriptor, no tx buffer; \n
+ 1 - tx buffer is empty; \n
+ 0 - tx buffer is not empty;
+******************************************************************************/
+int USBFIFO_IsTxEmpty(HAL_UsartDescriptor_t *descriptor)
+{
+ HalUsartService_t *control;
+ uint16_t poW;
+ uint16_t poR;
+
+ if (NULL == descriptor)
+ return -1;
+
+ if (descriptor != usbfifoPointDescrip)
+ return -1; // Channel is not opened.
+
+ control = &usbfifoPointDescrip->service;
+ ATOMIC_SECTION_ENTER
+ poW = control->txPointOfWrite;
+ poR = control->txPointOfRead;
+ ATOMIC_SECTION_LEAVE
+ if (poW == poR)
+ return 1;
+
+ return 0;
+}
+
+// eof usbFifoVirtualUart.c
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/isdImageStorage.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/isdImageStorage.h
new file mode 100644
index 00000000..c5631189
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/isdImageStorage.h
@@ -0,0 +1,89 @@
+/**************************************************************************//**
+\file isdImageStorage.h
+
+\brief The public API of image storage driver.
+
+\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:
+ 25.05.11 A. Khromykh - Created
+*******************************************************************************/
+
+#ifndef _ISDIMAGESTORAGE_H
+#define _ISDIMAGESTORAGE_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <zclOTAUCluster.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** \brief Status which is returned by driver */
+typedef enum
+{
+ ISD_SUCCESS,
+ ISD_HARDWARE_FAULT,
+ ISD_COMMUNICATION_LOST
+} ISD_Status_t;
+
+typedef void (* IsdOpenCb_t)(ISD_Status_t);
+typedef void (* IsdQueryNextImageCb_t)(ZCL_OtauQueryNextImageResp_t *);
+typedef void (* IsdImageBlockCb_t)(ZCL_OtauImageBlockResp_t *);
+typedef void (* IsdUpgradeEndCb_t)(ZCL_OtauUpgradeEndResp_t *);
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Open image storage driver
+
+\param[in] cb - callback about driver actions
+******************************************************************************/
+void ISD_Open(IsdOpenCb_t cb);
+
+/**************************************************************************//**
+\brief Close image storage driver
+******************************************************************************/
+void ISD_Close(void);
+
+/**************************************************************************//**
+\brief Send query next image request to storage system
+
+\param[in] addressing - pointer to structure that include client network information; \n
+\param[in] data - data payload; \n
+\param[in] cd - callback about response receiving from storage system.
+******************************************************************************/
+void ISD_QueryNextImageReq(ZCL_Addressing_t *addressing, ZCL_OtauQueryNextImageReq_t *data, IsdQueryNextImageCb_t cb);
+
+/**************************************************************************//**
+\brief Send image block request to storage system
+
+\param[in] addressing - pointer to structure that include client network information; \n
+\param[in] data - data payload; \n
+\param[in] cd - callback about response receiving from storage system.
+******************************************************************************/
+void ISD_ImageBlockReq(ZCL_Addressing_t *addressing, ZCL_OtauImageBlockReq_t *data, IsdImageBlockCb_t cb);
+
+/**************************************************************************//**
+\brief Send upgrade end request to storage system
+
+\param[in] addressing - pointer to structure that include client network information; \n
+\param[in] data - data payload; \n
+\param[in] cd - callback about response receiving from storage system.
+******************************************************************************/
+void ISD_UpgradeEndReq(ZCL_Addressing_t *addressing, ZCL_OtauUpgradeEndReq_t *data, IsdUpgradeEndCb_t cb);
+
+#endif /* _ISDIMAGESTORAGE_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/massStorageDevice.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/massStorageDevice.h
new file mode 100644
index 00000000..f8957a90
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/massStorageDevice.h
@@ -0,0 +1,71 @@
+/****************************************************************************//**
+ \file massStorageDevice.h
+
+ \brief The header file describes the interface of the mass storage device
+
+ \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:
+ 29/08/11 N. Fomin - Created
+*******************************************************************************/
+#ifndef _MASSSTORAGEDEVICE_H
+#define _MASSSTORAGEDEVICE_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define MSD_TRANSMIT_PIPE 5
+#define MSD_RECEIVE_PIPE 6
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** \brief Status messages for upper layer about msd status */
+typedef enum
+{
+ MSD_STATUS_SUCCESS = 0,
+ MSD_INTERFACE_BUSY,
+ MSD_MEMORY_INIT_ERROR,
+ MSD_READ_CAPACITY_ERROR,
+ MSD_READ_ERROR,
+ MSD_WRITE_ERROR
+} MSD_Status_t;
+
+typedef void (* MSD_Callback_t)(MSD_Status_t);
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Opens mass storage device.
+\param[in]
+ callback - pointer to function to notify about MSD errors and transactions;
+ responseBuffer - pointer to hsmci command response buffer; it should have
+ a size of four;
+ buffer - pointer to buffer for hsmci data transfer; it should be
+ a multiplier of 512;
+ length - length of buffer for data transfer.
+\return
+ nothing
+******************************************************************************/
+void MSD_Open(MSD_Callback_t callback, uint32_t *responseBuffer, uint8_t *buffer, uint32_t length);
+
+/**************************************************************************//**
+\brief Closes mass storage device.
+\return
+ nothing
+******************************************************************************/
+void MSD_Close(void);
+
+#endif /* _MASSSTORAGEDEVICE_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/ofdExtMemory.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/ofdExtMemory.h
new file mode 100644
index 00000000..e15ed8fd
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/ofdExtMemory.h
@@ -0,0 +1,175 @@
+/**************************************************************************//**
+\file ofdExtMemory.h
+
+\brief The public API of external flash driver.
+
+\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:
+ 31/07/09 A. Khromykh - Created
+*******************************************************************************/
+
+#ifndef _OFDEXTMEMORY_H
+#define _OFDEXTMEMORY_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+/** \brief Size of memory block for internal ofd algorithms */
+#define OFD_BLOCK_FOR_CHECK_CRC 64
+#define OFD_BLOCK_SIZE OFD_BLOCK_FOR_CHECK_CRC
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** \brief Status messages for upper component about ofd state */
+typedef enum
+{
+ OFD_STATUS_SUCCESS = 0,
+ OFD_STATUS_SERIAL_BUSY,
+ OFD_STATUS_UNKNOWN_EXTERNAL_FLASH_TYPE,
+ OFD_STATUS_INCORRECT_API_PARAMETER,
+ OFD_STATUS_INCORRECT_EEPROM_PARAMETER,
+ OFD_SERIAL_INTERFACE_BUSY
+} OFD_Status_t ;
+
+/** \brief Number of position for image in the external flash */
+typedef enum
+{
+ OFD_POSITION_1,
+ OFD_POSITION_2,
+ OFD_POSITION_MAX
+} OFD_Position_t;
+
+/** \brief Source type which was been initiator of image saving. */
+typedef enum
+{
+ OFD_IMAGE_WAS_SAVED_FROM_MCU,
+ OFD_IMAGE_WAS_WRITTEN_THROUGH_API,
+} OFD_ImageSource_t;
+
+/** \brief Parameters for access to external memory \n
+ offset - offset from start address \n
+ data - pointer to mcu ram area with\for data for\from external memory \n
+ length - size of mcu ram area with\for data. */
+typedef struct
+{
+ uint32_t offset;
+ uint8_t *data;
+ uint32_t length;
+} OFD_MemoryAccessParam_t;
+
+/** \brief image crc */
+typedef uint8_t OFD_Crc_t;
+
+/** \brief Image information. Crc and image type. */
+typedef struct
+{
+ OFD_ImageSource_t type;
+ OFD_Crc_t crc;
+} OFD_ImageInfo_t;
+
+/** \brief callback methods for OFD API. \n
+ ATTENTION!!!! Callback functions must not call public OFD API directly.
+ */
+typedef void (* OFD_Callback_t)(OFD_Status_t);
+typedef void (* OFD_InfoCallback_t)(OFD_Status_t, OFD_ImageInfo_t *);
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Opens serial interface and checks memory type.
+
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_Open(OFD_Callback_t cb);
+
+/**************************************************************************//**
+\brief Closes serial interface.
+******************************************************************************/
+void OFD_Close(void);
+
+/**************************************************************************//**
+\brief Erases image in the external memory.
+
+\param[in]
+ pos - image position in the external memory
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_EraseImage(OFD_Position_t pos, OFD_Callback_t cb);
+
+/**************************************************************************//**
+\brief Writes data to the external memory.
+
+\param[in]
+ pos - image position for new data
+\param[in]
+ accessParam - pointer to the access structure
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_Write(OFD_Position_t pos, OFD_MemoryAccessParam_t *accessParam, OFD_Callback_t cb);
+
+/**************************************************************************//**
+\brief Flushes data from internal buffer, checks image crc and saves it to
+the external memory.
+
+\param[in]
+ pos - image position for new data
+\param[in]
+ countBuff - pointer to the memory for internal data (memory size must be OFD_BLOCK_FOR_CHECK_CRC)
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_FlushAndCheckCrc(OFD_Position_t pos, uint8_t *countBuff, OFD_InfoCallback_t cb);
+
+/**************************************************************************//**
+\brief Saves current mcu flash and eeprom to the external memory, checks crc for its
+and set command for bootloader.
+
+\param[in]
+ whereToSave - image position for current mcu flash and eeprom
+\param[in]
+ from - new image position
+\param[in]
+ copyBuff - pointer to the memory for internal data (memory size must be OFD_BLOCK_FOR_CHECK_CRC)
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_SwitchToNewImage(OFD_Position_t whereToSave, OFD_Position_t from, uint8_t *copyBuff, OFD_Callback_t cb);
+
+/**************************************************************************//**
+\brief Sets command for bootloader.
+
+\param[in]
+ from - image position
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_ChangeImage(OFD_Position_t from, OFD_Callback_t cb);
+
+/**************************************************************************//**
+\brief Reads image informations.
+
+\param[in]
+ pos - image position
+\param[in]
+ cb - pointer to callback
+******************************************************************************/
+void OFD_ReadImageInfo(OFD_Position_t pos, OFD_InfoCallback_t cb);
+
+#endif /* _OFDEXTMEMORY_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/usbFifoUsart.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/usbFifoUsart.h
new file mode 100644
index 00000000..8725d322
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/usbFifoUsart.h
@@ -0,0 +1,109 @@
+/**************************************************************************//**
+\file usbFifoUsart.h
+
+\brief The public API of usb fifo vitual COM port driver based on FTDI FT245RL.
+
+\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:
+ 12.07.11 A. Khromykh - Created
+*******************************************************************************/
+#ifndef _USBFIFOUSART_H
+#define _USBFIFOUSART_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <usart.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define USART_CHANNEL_USBFIFO ((UsartChannel_t)6)
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Opens driver and registers event handlers.
+
+\param[in]
+ descriptor - pointer to HAL_UartDescriptor_t structure
+
+\return
+ Returns positive uart descriptor on success or -1 in cases: \n
+ - bad uart channel; \n
+ - there are not enough resources; \n
+ - receiving buffer is less bulk endpoint size;
+******************************************************************************/
+int USBFIFO_OpenUsart(HAL_UsartDescriptor_t *descriptor);
+
+/*************************************************************************//**
+\brief Releases the driver.
+
+\param[in]
+ descriptor - pointer to HAL_UartDescriptor_t structure
+
+\return
+ -1 - bad descriptor; \n
+ 0 - success.
+*****************************************************************************/
+int USBFIFO_CloseUsart(HAL_UsartDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Writes a number of bytes to driver.
+txCallback function will be used to notify when the transmission is finished.
+
+\param[in]
+ descriptor - pointer to HAL_UartDescriptor_t structure;
+
+\param[in]
+ buffer - pointer to the application data buffer;
+
+\param[in]
+ length - number of bytes to transfer;
+
+\return
+ -1 - bad descriptor; \n
+ Number of bytes placed to the buffer - success.
+******************************************************************************/
+int USBFIFO_WriteUsart(HAL_UsartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);
+
+/*************************************************************************//**
+\brief Reads a number of bytes from driver and places them to the buffer.
+
+\param[in]
+ descriptor - pointer to HAL_UartDescriptor_t structure;
+
+\param[in]
+ buffer - pointer to the application buffer;
+
+\param[in]
+ length - number of bytes to be placed to the buffer;
+
+\return
+ -1 - bad descriptor, or bad number of bytes to read; \n
+ Number of bytes placed to the buffer - success.
+*****************************************************************************/
+int USBFIFO_ReadUsart(HAL_UsartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);
+
+/**************************************************************************//**
+\brief Checks the status of tx buffer (for polling mode).
+
+\param[in]
+ descriptor - pointer to HAL_UsartDescriptor_t structure;
+\return
+ -1 - bad descriptor, no tx buffer; \n
+ 1 - tx buffer is empty; \n
+ 0 - tx buffer is not empty;
+******************************************************************************/
+int USBFIFO_IsTxEmpty(HAL_UsartDescriptor_t *descriptor);
+
+#endif /* _USBFIFOUSART_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/vcpVirtualUsart.h b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/vcpVirtualUsart.h
new file mode 100644
index 00000000..0c54d8d1
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/drivers/include/vcpVirtualUsart.h
@@ -0,0 +1,111 @@
+/****************************************************************************//**
+ \file vcpVirtualUsart.h
+
+ \brief The header file describes the interface of the virtual uart based on USB
+
+ \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:
+ 05/09/08 A. Khromykh - Created
+*******************************************************************************/
+#ifndef _VCPVIRTUALUART_H
+#define _VCPVIRTUALUART_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <usart.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define USART_CHANNEL_VCP ((UsartChannel_t)5)
+#define VCP_TRANSMIT_PIPE 2
+#define VCP_RECEIVE_PIPE 1
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Registers uart's event handlers.
+
+\param[in]
+ descriptor - pointer to HAL_UartDescriptor_t structure
+
+\return
+ Returns positive uart descriptor on success or -1 in cases: \n
+ - bad uart channel; \n
+ - there are not enough resources; \n
+ - receiving buffer is less bulk endpoint size;
+******************************************************************************/
+int VCP_OpenUsart(HAL_UsartDescriptor_t *descriptor);
+
+/*************************************************************************//**
+\brief Releases the uart channel.
+
+\param[in]
+ descriptor - pointer to HAL_UartDescriptor_t structure
+
+\return
+ -1 - bad descriptor; \n
+ 0 - success.
+*****************************************************************************/
+int VCP_CloseUsart(HAL_UsartDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Writes a number of bytes to uart channel.
+txCallback function will be used to notify when the transmission is finished.
+
+\param[in]
+ descriptor - pointer to HAL_UartDescriptor_t structure;
+
+\param[in]
+ buffer - pointer to the application data buffer;
+
+\param[in]
+ length - number of bytes to transfer;
+
+\return
+ -1 - bad descriptor; \n
+ Number of bytes placed to the buffer - success.
+******************************************************************************/
+int VCP_WriteUsart(HAL_UsartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);
+
+/*************************************************************************//**
+\brief Reads a number of bytes from uart and places them to the buffer.
+
+\param[in]
+ descriptor - pointer to HAL_UartDescriptor_t structure;
+
+\param[in]
+ buffer - pointer to the application buffer;
+
+\param[in]
+ length - number of bytes to be placed to the buffer;
+
+\return
+ -1 - bad descriptor, or bad number of bytes to read; \n
+ Number of bytes placed to the buffer - success.
+*****************************************************************************/
+int VCP_ReadUsart(HAL_UsartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);
+
+/**************************************************************************//**
+\brief Checks the status of tx buffer (for polling mode).
+
+\param[in]
+ descriptor - pointer to HAL_UsartDescriptor_t structure;
+\return
+ -1 - bad descriptor, no tx buffer; \n
+ 1 - tx buffer is empty; \n
+ 0 - tx buffer is not empty;
+******************************************************************************/
+int VCP_IsTxEmpty(HAL_UsartDescriptor_t *descriptor);
+
+#endif /* _VCPVIRTUALUART_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/adc.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/adc.h
new file mode 100644
index 00000000..fddde028
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/adc.h
@@ -0,0 +1,229 @@
+/**************************************************************************//**
+ \file adc.h
+
+ \brief The header file describes the ADC interface
+
+ \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:
+ 22.11.07 A. Khromykh - Created.
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _ADC_H
+#define _ADC_H
+
+// \cond
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+// \endcond
+
+/** \brief adc resolution */
+#define RESOLUTION_8_BIT 0
+#define RESOLUTION_10_BIT 1
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/**************************************************************************//**
+\brief adc sample rate
+******************************************************************************/
+#if defined(AT91SAM7X256)
+ typedef enum
+ {
+ ADC_533KSPS,
+ ADC_429KSPS,
+ ADC_369KSPS,
+ ADC_250KSPS,
+ ADC_136KSPS,
+ ADC_68KSPS,
+ ADC_34KSPS
+ } HAL_AdcSampleRate_t;
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) || defined(ATMEGA128RFA1)
+ typedef enum
+ {
+ ADC_77KSPS,
+ ADC_39KSPS,
+ ADC_19200SPS,
+ ADC_9600SPS,
+ ADC_4800SPS
+ } HAL_AdcSampleRate_t;
+#endif
+
+/**************************************************************************//**
+\brief adc voltage reference
+******************************************************************************/
+typedef enum
+{
+ /** \brief AREF, Internal Vref turned off. \n
+ If 10x or 200x gain is selected, only 2.56 V should be used as Internal Voltage Reference. \n
+ For differential conversion, only 1.1V cannot be used as internal voltage reference. */
+ AREF = (0 << 6),
+ /** \brief AVCC with external capacitor at AREF pin */
+ AVCC = (1 << 6),
+ /** \brief Internal 1.1V Voltage Reference with external capacitor at AREF pin */
+ INTERNAL_1d1V = (2 << 6),
+ /** \brief Internal 2.56V Voltage Reference with external capacitor at AREF pin */
+ INTERNAL_2d56V = (3 << 6)
+} HAL_AdcVoltageReference_t;
+
+/**************************************************************************//**
+\brief adc structure of parameters
+******************************************************************************/
+typedef struct
+{
+ /** \brief conversion resolution */
+ uint8_t resolution;
+ /** \brief adc sample rate */
+ HAL_AdcSampleRate_t sampleRate;
+ /** \brief adc voltage reference selections (only for avr) */
+ HAL_AdcVoltageReference_t voltageReference;
+ /** \brief pointer to the application data */
+ void *bufferPointer;
+ /** \brief amount of samples (buffer cells) */
+ uint16_t selectionsAmount;
+ /** \brief pointer to callback method */
+ void (*callback)();
+} HAL_AdcParams_t;
+
+/**************************************************************************//**
+\brief channel number. \n
+Note for avr:
+If 10x gain is used, 8 bit resolution can be expected. \n
+If 200x gain is used, 7 bit resolution can be expected. \n
+If the user wants to perform a quick polarity check of the result, \n
+it is sufficient to read the MSB of the result. If the bit is one, \n
+the result is negative, and if this bit is zero, the result is positive. \n
+To reach the given accuracy, 10x or 200x Gain should not be used \n
+for operating voltage below 2.7V.
+******************************************************************************/
+#if defined(AT91SAM7X256)
+ typedef enum
+ {
+ HAL_ADC_CHANNEL0 = (1 << 0),
+ HAL_ADC_CHANNEL1 = (1 << 1),
+ HAL_ADC_CHANNEL2 = (1 << 2),
+ HAL_ADC_CHANNEL3 = (1 << 3),
+ HAL_ADC_CHANNEL4 = (1 << 4),
+ HAL_ADC_CHANNEL5 = (1 << 5),
+ HAL_ADC_CHANNEL6 = (1 << 6),
+ HAL_ADC_CHANNEL7 = (1 << 7)
+ } HAL_AdcChannelNumber_t;
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) || defined(ATMEGA128RFA1)
+ typedef enum
+ {
+ /** \brief channel ADC0 */
+ HAL_ADC_CHANNEL0 = 0,
+ /** \brief channel ADC1 */
+ HAL_ADC_CHANNEL1 = 1,
+ /** \brief channel ADC2 */
+ HAL_ADC_CHANNEL2 = 2,
+ /** \brief channel ADC3 */
+ HAL_ADC_CHANNEL3 = 3,
+ /** \brief ADC0 - ADC0 with gain 10x */
+ HAL_ADC_DIFF_CHANNEL0 = 8,
+ /** \brief ADC1 - ADC0 with gain 10x */
+ HAL_ADC_DIFF_CHANNEL1 = 9,
+ /** \brief ADC0 - ADC0 with gain 200x */
+ HAL_ADC_DIFF_CHANNEL2 = 10,
+ /** \brief ADC1 - ADC0 with gain 200x */
+ HAL_ADC_DIFF_CHANNEL3 = 11,
+ /** \brief ADC2 - ADC2 with gain 10x */
+ HAL_ADC_DIFF_CHANNEL4 = 12,
+ /** \brief ADC3 - ADC2 with gain 10x */
+ HAL_ADC_DIFF_CHANNEL5 = 13,
+ /** \brief ADC2 - ADC2 with gain 200x */
+ HAL_ADC_DIFF_CHANNEL6 = 14,
+ /** \brief ADC3 - ADC2 with gain 200x */
+ HAL_ADC_DIFF_CHANNEL7 = 15
+ } HAL_AdcChannelNumber_t;
+#endif
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Opens the ADC to make the measurement on the ADC channel.
+
+ \param[in] param - address of HAL_AdcParams_t structure. \n
+ fields of structure set by user: \n
+ resolution - conversion resolution. Must be chosen from: \n
+ RESOLUTION_8_BIT \n
+ RESOLUTION_10_BIT \n
+ sampleRate - sample rate. Must be chosen from: \n
+ for avr hardware platform \n
+ ADC_77KSPS \n
+ ADC_39KSPS \n
+ ADC_19200SPS \n
+ ADC_9600SPS \n
+ ADC_4800SPS \n
+ for arm hardware platform \n
+ ADC_533KSPS \n
+ ADC_429KSPS \n
+ ADC_369KSPS \n
+ ADC_250KSPS \n
+ ADC_136KSPS \n
+ ADC_68KSPS \n
+ ADC_34KSPS \n
+ bufferPointer - pointer to the application data buffer. \n
+ Buffer cell is one byte for 8-bit resolution. \n
+ Buffer cell is two bytes for 10-bit resolution. \n
+ selectionsAmount - amount of samples (buffer cells). \n
+ callback - pointer to the function that will notify about measurement completion.
+\return
+ -1 - unsupported parameter or ADC is busy. \n
+ 0 - success.
+******************************************************************************/
+int HAL_OpenAdc(HAL_AdcParams_t *param);
+
+/**************************************************************************//**
+\brief Starts ADC with the parameters defined in HAL_OpenAdc.
+
+ \param[in] channel - number of ADC channel. Must be chosen from:\n
+ HAL_ADC_CHANNEL0 \n
+ HAL_ADC_CHANNEL1 \n
+ HAL_ADC_CHANNEL2 \n
+ HAL_ADC_CHANNEL3 \n
+ next four channels only for arm hardware platform \n
+ HAL_ADC_CHANNEL4 \n
+ HAL_ADC_CHANNEL5 \n
+ HAL_ADC_CHANNEL6 \n
+ HAL_ADC_CHANNEL7 \n
+ next eight channels only for avr hardware platform \n
+ HAL_ADC_DIFF_CHANNEL0 \n
+ HAL_ADC_DIFF_CHANNEL1 \n
+ HAL_ADC_DIFF_CHANNEL2 \n
+ HAL_ADC_DIFF_CHANNEL3 \n
+ HAL_ADC_DIFF_CHANNEL4 \n
+ HAL_ADC_DIFF_CHANNEL5 \n
+ HAL_ADC_DIFF_CHANNEL6 \n
+ HAL_ADC_DIFF_CHANNEL7 \n
+
+\return
+ -1 - unable to open ADC (unsupported channel number). \n
+ 0 - success.
+******************************************************************************/
+int HAL_ReadAdc(HAL_AdcChannelNumber_t channel);
+
+/**************************************************************************//**
+\brief Closes the ADC.
+
+\return
+ -1 - the module was not open. \n
+ 0 - success.
+******************************************************************************/
+int HAL_CloseAdc(void);
+
+#endif /* _ADC_H */
+// eof adc.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/appTimer.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/appTimer.h
new file mode 100644
index 00000000..9c241ab6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/appTimer.h
@@ -0,0 +1,81 @@
+/***************************************************************************//**
+ \file appTimer.h
+
+ \brief The header file describes the appTimer interface.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _APPTIMER_H
+#define _APPTIMER_H
+
+// \cond
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <bcTimer.h>
+#include <halAppClock.h>
+// \endcond
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** \brief fields of structure: \n
+ uint32_t interval - timer firing interval. Interval must be more than 10 ms (set by user) \n
+ TimerMode_t mode - timer work mode (set by user). Must be chosen from: \n
+ TIMER_REPEAT_MODE \n
+ TIMER_ONE_SHOT_MODE \n
+ void (*callback)(void) - pointer to timer callback function (set by user). */
+typedef Timer_t HAL_AppTimer_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Starts to count an interval (starts user timer).
+
+\param[in]
+ appTimer - pointer to the timer structure (HAL_AppTimer_t is typedef Timer_t)
+
+\return
+ -1 - pointer is NULL
+ 0 - success
+******************************************************************************/
+int HAL_StartAppTimer(HAL_AppTimer_t *appTimer);
+
+/**************************************************************************//**
+\brief Stops the user timer.
+
+\param[in]
+ appTimer - pointer to the timer structure.
+
+\return
+ -1 - there is no appTimer started or pointer is NULL
+ 0 - success
+******************************************************************************/
+int HAL_StopAppTimer(HAL_AppTimer_t *appTimer);
+
+/**************************************************************************//**
+\brief Gets system time.
+
+\return
+ time since power up in milliseconds(8 bytes).
+******************************************************************************/
+BcTime_t HAL_GetSystemTime(void);
+
+#endif /*_APPTIMER_H*/
+//eof appTimer.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/atomic.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/atomic.h
new file mode 100644
index 00000000..ada41d9c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/atomic.h
@@ -0,0 +1,72 @@
+/**************************************************************************//**
+ \file atomic.h
+
+ \brief The header file describes the atomic sections
+
+ \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:
+ 20/08/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _ATOMIC_H
+#define _ATOMIC_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#if defined(AT91SAM7X256) || defined(AT32UC3A0512) || defined(AT91SAM3S4C)
+ #include <inttypes.h>
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) \
+ || defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3) || defined(ATMEGA128RFA1)
+ #include <halAtomic.h>
+#endif
+
+#if defined(AT91SAM7X256) || defined(AT32UC3A0512) || defined(AT91SAM3S4C)
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef uint32_t atomic_t;
+
+/******************************************************************************
+ Inline static functions section
+******************************************************************************/
+/******************************************************************************
+ Disables global interrupt. Enter atomic section.
+******************************************************************************/
+void halStartAtomic(atomic_t volatile *pAtomic);
+
+/******************************************************************************
+ Exit atomic section
+******************************************************************************/
+void halEndAtomic(atomic_t volatile *pAtomic);
+ /** \brief Marks the begin of atomic section */
+ #define ATOMIC_SECTION_ENTER {volatile atomic_t __atomic; halStartAtomic(&__atomic);
+ /** \brief Marks the end of atomic section */
+ #define ATOMIC_SECTION_LEAVE halEndAtomic(&__atomic);}
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) \
+ || defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3) || defined(ATMEGA128RFA1)
+ /** \brief Marks the begin of atomic section */
+ #define ATOMIC_SECTION_ENTER {atomic_t __atomic = halStartAtomic();
+ /** \brief Marks the end of atomic section */
+ #define ATOMIC_SECTION_LEAVE halEndAtomic(__atomic);}
+#elif defined(SIMULATOR)
+ /** \brief Marks the begin of atomic section */
+ #define ATOMIC_SECTION_ENTER do {} while (0);
+ /** \brief Marks the end of atomic section */
+ #define ATOMIC_SECTION_LEAVE do {} while (0);
+#endif
+
+#endif // _ATOMIC_H
+
+// eof atomic.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/bcTimer.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/bcTimer.h
new file mode 100644
index 00000000..88ce15c8
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/bcTimer.h
@@ -0,0 +1,98 @@
+/**************************************************************************//**
+ \file bcTimer.h
+
+ \brief Declaration of timer queue interface, hardware-independent module.
+
+ \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:
+ 7/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _MNHALTIMER_H
+#define _MNHALTIMER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** \brief mode of timers */
+typedef enum
+{
+ TIMER_REPEAT_MODE,
+ TIMER_ONE_SHOT_MODE
+} TimerMode_t;
+
+/** \brief fields of structure: \n
+ uint32_t interval - timer firing interval (set by user) \n
+ TimerMode_t mode - timer work mode (set by user). Must be chosen from: \n
+ TIMER_REPEAT_MODE \n
+ TIMER_ONE_SHOT_MODE \n
+ void (*callback)(void) - pointer to timer callback function (set by user). \n
+ next - pointer to next cell of list \n
+ intervalLeft - absolute fired time */
+typedef struct _Timer_t
+{
+ struct
+ {
+ struct _Timer_t *next;
+ uint32_t sysTimeLabel;
+ } service;
+ uint32_t interval;
+ TimerMode_t mode;
+ void (*callback)(void);
+} Timer_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Adds timer to the timer's list. Timers sorted by remaining time.
+\param[in]
+ head - address of pointer to head of the timers list.
+\param[in]
+ timer - address of timer that must be added to the list.
+\param[in]
+ sysTime - current time, used for sorting.
+******************************************************************************/
+void halAddTimer(Timer_t **head, Timer_t *timer, uint32_t sysTime);
+
+/**************************************************************************//**
+\brief Removes timer from the timers list.
+\param[in]
+ head - address of pointer to head of the timers list.
+\param[in]
+ prev - address of the timer before the timer that must be removed from the list.
+\param[in]
+ p - address of timer that must be removed from the list.
+
+\return pointer to next cell or pointer to head if deleting is head
+******************************************************************************/
+Timer_t* halRemoveTimer(Timer_t **head, Timer_t *prev, Timer_t *p);
+
+/**************************************************************************//**
+\brief The search of the timer in the timers list before one.
+\param[in]
+ head - address of pointer to head of the timers list.
+
+\return pointer to saerching timer
+******************************************************************************/
+Timer_t *halFindPrevTimer(Timer_t **head, Timer_t *p);
+
+#endif /* _MNHALTIMER_H */
+
+// eof bcTimer.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/calibration.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/calibration.h
new file mode 100644
index 00000000..3bfca393
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/calibration.h
@@ -0,0 +1,31 @@
+/**************************************************************************//**
+ \file calibration.h
+
+ \brief Interface to calibrate the internal RC generator.
+
+ \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:
+ 29/06/07 E. Ivanov - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _CALIBRATION_H
+#define _CALIBRATION_H
+/**************************************************************************//**
+\brief Performs calibration of the main clock generator \n
+(only for AVR and internal RC oscillator).
+******************************************************************************/
+void HAL_CalibrateMainClock(void);
+
+#endif /* _CALIBRATION_H */
+// eof calibration.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/dbgu.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/dbgu.h
new file mode 100644
index 00000000..44f76ca4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/dbgu.h
@@ -0,0 +1,41 @@
+/**************************************************************************//**
+ \file dbgu.h
+
+ \brief Declarations of debug message interface (feature only for atmel arm).
+
+ \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:
+ 11/11/08 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _DBGU_H
+#define _DBGU_H
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Open dbgu port (115200 baud, 8N1 format).
+******************************************************************************/
+void HAL_OpenDbgu(void);
+
+/**************************************************************************//**
+\brief Send string trough dbgu port.
+
+\param[in]
+ buffer - pointer to the string
+******************************************************************************/
+void HAL_SendDbguMessage(const char *buffer);
+
+#endif /* _DBGU_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/eeprom.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/eeprom.h
new file mode 100644
index 00000000..a4a21966
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/eeprom.h
@@ -0,0 +1,113 @@
+/**************************************************************************//**
+ \file eeprom.h
+
+ \brief The header file describes the EEPROM interface.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _EEPROM_H
+#define _EEPROM_H
+
+// \cond
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#if defined(AT91SAM7X256)
+ #define EEPROM_DATA_MEMORY_SIZE 0x400u
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) \
+ || defined(ATXMEGA256A3) || defined(ATXMEGA256D3) || defined(ATMEGA128RFA1) \
+ || defined(AT91SAM3S4C)
+ #define EEPROM_DATA_MEMORY_SIZE 0x1000u
+#elif defined(ATXMEGA128A1)
+ #define EEPROM_DATA_MEMORY_SIZE 0x800u
+#endif
+// \endcond
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/**************************************************************************//**
+\brief eeprom access control structure
+******************************************************************************/
+typedef struct
+{
+ /** \brief EEPROM address */
+ uint16_t address;
+ /** \brief pointer to data memory */
+ uint8_t *data;
+ /** \brief number of bytes */
+ uint16_t length;
+} HAL_EepromParams_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+\brief Reads a number of bytes defined by HAL_EepromParams_t from the EEPROM.
+\param[in]
+ param - address of HAL_EepromParams_t structure. \n
+ fields of structure set by user: \n
+ address - eeprom address \n
+ data - pointer to data memory \n
+ length - number of bytes
+\param[in]
+ readDone - pointer to the function that will notify about reading completion.
+\return
+ 0 - success, \n
+ -1 - the number of bytes to read is too large, \n
+ -2 - the previous EEPROM request is not completed yet.
+******************************************************************************/
+int HAL_ReadEeprom(HAL_EepromParams_t *params, void (*readDone)());
+
+/******************************************************************************
+\brief Writes a number of bytes defined by HAL_EepromParams_t to EEPROM.
+By writeDone parameter user can control if write operation will be asynchronous
+or synchronous.
+\param[in]
+ param - address of HAL_EepromParams_t structure. \n
+ fields of structure set by user: \n
+ address - eeprom address \n
+ data - pointer to data memory \n
+ length - number of bytes
+\param[in]
+ writeDone - pointer to the function that will notify about writing completion. \n
+ Only for avr: \n
+ if writeDone is NULL write operation will be synchronous.
+\return
+ 0 - success, \n
+ -1 - the number of bytes to write is too large, \n
+ -2 - the previous EEPROM request is not completed yet.
+******************************************************************************/
+int HAL_WriteEeprom(HAL_EepromParams_t *params, void (*writeDone)());
+
+/**************************************************************************//**
+\brief Checks the eeprom state.
+
+\return
+ true - eeprom is busy; \n
+ false - eeprom is free;
+******************************************************************************/
+bool HAL_IsEepromBusy(void);
+
+#endif /*_EEPROM_H*/
+
+//eof eeprom.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/halInit.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/halInit.h
new file mode 100644
index 00000000..765df7d4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/halInit.h
@@ -0,0 +1,31 @@
+/**************************************************************************//**
+ \file halInit.h
+
+ \brief HAL start up module interface.
+
+ \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:
+ 29/06/07 E. Ivanov - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALINIT_H
+#define _HALINIT_H
+
+/**************************************************************************//**
+\brief Performs start up HAL initialization.
+******************************************************************************/
+void HAL_Init(void);
+
+#endif /* _HALINIT_H */
+// eof halInit.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/halTaskManager.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/halTaskManager.h
new file mode 100644
index 00000000..48738c9a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/halTaskManager.h
@@ -0,0 +1,335 @@
+/**************************************************************************//**
+ \file halTaskManager.h
+
+ \brief Declarations of enums and functions of HAL task manager.
+
+ \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:
+ 10/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _HALTASKHANDLER_H
+#define _HALTASKHANDLER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <taskManager.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#if defined(AT91SAM7X256)
+/*! \brief task ID for hal task manager. HAL_FIRST_X are free ID. */
+enum
+{
+ HAL_USB_ENDPOINTS = 1ul << 0,
+ HAL_USB_SUSPEND = 1ul << 1,
+ HAL_USB_RESUME = 1ul << 2,
+ HAL_USB_BUS_RESET = 1ul << 3,
+ HAL_TASK_USART = 1ul << 4,
+ HAL_TIMER4_COMPA = 1ul << 5, /** timer interrupt is happened */
+ HAL_TWI = 1ul << 6, /** twi bus interrupt is happened */
+ HAL_SPI0_TXBUFE = 1ul << 7, /** spi0 dma buffer is empty */
+ HAL_SPI0_RXBUFF = 1ul << 8, /** spi0 dma buffer is full */
+ HAL_SPI1_TXBUFE = 1ul << 9, /** spi1 dma buffer is empty */
+ HAL_SPI1_RXBUFF = 1ul << 10, /** timer interrupt is happened */
+ HAL_ADC = 1ul << 11, /** adc measurement is ready */
+ HAL_FIRST_12 = 1ul << 12,
+ HAL_FIRST_13 = 1ul << 13,
+ HAL_FIRST_14 = 1ul << 14,
+ HAL_FIRST_15 = 1ul << 15,
+ HAL_FIRST_16 = 1ul << 16,
+ HAL_FIRST_17 = 1ul << 17,
+ HAL_FIRST_18 = 1ul << 18,
+ HAL_FIRST_19 = 1ul << 19,
+ HAL_FIRST_20 = 1ul << 20,
+ HAL_FIRST_21 = 1ul << 21,
+ HAL_FIRST_22 = 1ul << 22,
+ HAL_FIRST_23 = 1ul << 23,
+ HAL_FIRST_24 = 1ul << 24,
+ HAL_FIRST_25 = 1ul << 25,
+ HAL_FIRST_26 = 1ul << 26,
+ HAL_FIRST_27 = 1ul << 27,
+ HAL_FIRST_28 = 1ul << 28,
+ HAL_FIRST_29 = 1ul << 29,
+ HAL_FIRST_30 = 1ul << 30,
+ HAL_FIRST_31 = 1ul << 31
+};
+
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) \
+ || defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3) || defined(ATMEGA128RFA1)
+/**************************************************************************//**
+ \brief halTaskFlags0 flags definitions.
+******************************************************************************/
+enum
+{
+ HAL_ASYNC_TIMER = (uint8_t)1 << 0,
+ HAL_SYNC_SLEEP_TIME = (uint8_t)1 << 1,
+ HAL_EMPTY_TASK_0_2 = (uint8_t)1 << 2,
+ HAL_EMPTY_TASK_0_3 = (uint8_t)1 << 3,
+ HAL_EMPTY_TASK_0_4 = (uint8_t)1 << 4,
+ HAL_EMPTY_TASK_0_5 = (uint8_t)1 << 5,
+ HAL_EMPTY_TASK_0_6 = (uint8_t)1 << 6,
+ HAL_EMPTY_TASK_0_7 = (uint8_t)1 << 7
+};
+
+/**************************************************************************//**
+ \brief halTaskFlags1 flags definitions.
+******************************************************************************/
+enum
+{
+ HAL_EMPTY_TASK_1_0 = (uint8_t)1 << 0,
+ HAL_EMPTY_TASK_1_1 = (uint8_t)1 << 1,
+ HAL_EMPTY_TASK_1_2 = (uint8_t)1 << 2,
+ HAL_EMPTY_TASK_1_3 = (uint8_t)1 << 3,
+ HAL_EMPTY_TASK_1_4 = (uint8_t)1 << 4,
+ HAL_EMPTY_TASK_1_5 = (uint8_t)1 << 5,
+ HAL_EMPTY_TASK_1_6 = (uint8_t)1 << 6,
+ HAL_EMPTY_TASK_1_7 = (uint8_t)1 << 7
+};
+
+/**************************************************************************//**
+ \brief halTaskFlags2 flags definitions.
+******************************************************************************/
+enum
+{
+ HAL_EMPTY_TASK_2_0 = (uint8_t)1 << 0,
+ HAL_EMPTY_TASK_2_1 = (uint8_t)1 << 1,
+ HAL_EMPTY_TASK_2_2 = (uint8_t)1 << 2,
+ HAL_EMPTY_TASK_2_3 = (uint8_t)1 << 3,
+ HAL_EMPTY_TASK_2_4 = (uint8_t)1 << 4,
+ HAL_EMPTY_TASK_2_5 = (uint8_t)1 << 5,
+ HAL_TASK_SPI = (uint8_t)1 << 6,
+ HAL_TASK_USART = (uint8_t)1 << 7
+};
+
+/**************************************************************************//**
+ \brief halTaskFlags3 flags definitions.
+******************************************************************************/
+enum
+{
+ HAL_SM_REQ = (uint8_t)1 << 0,
+ HAL_ADC = (uint8_t)1 << 1,
+ HAL_EE_READY = (uint8_t)1 << 2,
+ HAL_USB_ENDPOINTS = (uint8_t)1 << 3,
+ HAL_USB_SUSPEND = (uint8_t)1 << 4,
+ HAL_USB_RESUME = (uint8_t)1 << 5,
+ HAL_USB_BUS_RESET = (uint8_t)1 << 6,
+ HAL_EMPTY_TASK_3_7 = (uint8_t)1 << 7
+};
+
+/**************************************************************************//**
+ \brief halTaskFlags4 flags definitions.
+******************************************************************************/
+enum
+{
+ HAL_WAKEUP = (uint8_t)1 << 0,
+ HAL_TWI = (uint8_t)1 << 1,
+ HAL_TIMER4_COMPA = (uint8_t)1 << 2,
+ HAL_SLEEP = (uint8_t)1 << 3,
+ HAL_EXT_HANDLER = (uint8_t)1 << 4,
+ HAL_EMPTY_TASK_4_4 = (uint8_t)1 << 5,
+ HAL_EMPTY_TASK_4_6 = (uint8_t)1 << 6,
+ HAL_EMPTY_TASK_4_7 = (uint8_t)1 << 7
+};
+
+#elif defined(AT32UC3A0512)
+/*! \brief task ID for hal task manager. HAL_FIRST_X are free ID. */
+enum
+{
+ HAL_APPTIMER = 1ul << 0,
+ HAL_TASK_USART = 1ul << 1,
+ HAL_FIRST_2 = 1ul << 2,
+ HAL_FIRST_3 = 1ul << 3,
+ HAL_FIRST_4 = 1ul << 4,
+ HAL_FIRST_5 = 1ul << 5,
+ HAL_FIRST_6 = 1ul << 6,
+ HAL_FIRST_7 = 1ul << 7,
+ HAL_FIRST_8 = 1ul << 8,
+ HAL_FIRST_9 = 1ul << 9,
+ HAL_FIRST_10 = 1ul << 10,
+ HAL_FIRST_11 = 1ul << 11,
+ HAL_FIRST_12 = 1ul << 12,
+ HAL_FIRST_13 = 1ul << 13,
+ HAL_FIRST_14 = 1ul << 14,
+ HAL_FIRST_15 = 1ul << 15,
+ HAL_FIRST_16 = 1ul << 16,
+ HAL_FIRST_17 = 1ul << 17,
+ HAL_FIRST_18 = 1ul << 18,
+ HAL_FIRST_19 = 1ul << 19,
+ HAL_FIRST_20 = 1ul << 20,
+ HAL_FIRST_21 = 1ul << 21,
+ HAL_FIRST_22 = 1ul << 22,
+ HAL_FIRST_23 = 1ul << 23,
+ HAL_FIRST_24 = 1ul << 24,
+ HAL_FIRST_25 = 1ul << 25,
+ HAL_FIRST_26 = 1ul << 26,
+ HAL_FIRST_27 = 1ul << 27,
+ HAL_FIRST_28 = 1ul << 28,
+ HAL_FIRST_29 = 1ul << 29,
+ HAL_FIRST_30 = 1ul << 30,
+ HAL_FIRST_31 = 1ul << 31
+};
+
+#elif defined(AT91SAM3S4C)
+/*! \brief task ID for hal task manager. HAL_FIRST_X are free ID. */
+enum
+{
+ HAL_APPTIMER = 1ul << 0,
+ HAL_TASK_USART = 1ul << 1,
+ HAL_USB_ENDPOINTS = 1ul << 2,
+ HAL_USB_SUSPEND = 1ul << 3,
+ HAL_USB_RESUME = 1ul << 4,
+ HAL_USB_BUS_RESET = 1ul << 5,
+ HAL_TASK_UART = 1ul << 6,
+ HAL_EE_READY = 1ul << 7,
+ HAL_HSMCI = 1ul << 8,
+ HAL_ASYNC_TIMER = 1ul << 9,
+ HAL_WAKEUP = 1ul << 10,
+ HAL_SLEEP = 1ul << 11,
+ HAL_FIRST_12 = 1ul << 12,
+ HAL_FIRST_13 = 1ul << 13,
+ HAL_FIRST_14 = 1ul << 14,
+ HAL_FIRST_15 = 1ul << 15,
+ HAL_FIRST_16 = 1ul << 16,
+ HAL_FIRST_17 = 1ul << 17,
+ HAL_FIRST_18 = 1ul << 18,
+ HAL_FIRST_19 = 1ul << 19,
+ HAL_FIRST_20 = 1ul << 20,
+ HAL_FIRST_21 = 1ul << 21,
+ HAL_FIRST_22 = 1ul << 22,
+ HAL_FIRST_23 = 1ul << 23,
+ HAL_FIRST_24 = 1ul << 24,
+ HAL_FIRST_25 = 1ul << 25,
+ HAL_FIRST_26 = 1ul << 26,
+ HAL_FIRST_27 = 1ul << 27,
+ HAL_FIRST_28 = 1ul << 28,
+ HAL_FIRST_29 = 1ul << 29,
+ HAL_FIRST_30 = 1ul << 30,
+ HAL_FIRST_31 = 1ul << 31
+};
+#endif
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+#if defined(AT91SAM7X256)
+extern volatile uint32_t halTaskFlags;
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) \
+ || defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3) || defined(ATMEGA128RFA1)
+extern volatile uint8_t halTaskFlags0;
+extern volatile uint8_t halTaskFlags1;
+extern volatile uint8_t halTaskFlags2;
+extern volatile uint8_t halTaskFlags3;
+extern volatile uint8_t halTaskFlags4;
+#elif defined(AT32UC3A0512) || defined(AT91SAM3S4C)
+extern volatile uint32_t halTaskFlags;
+#endif
+
+/******************************************************************************
+ Inline static functions section
+******************************************************************************/
+#if defined(AT91SAM7X256)
+/**************************************************************************//**
+\brief Set task for task manager.
+
+\param[in]
+ flag task for task mask
+******************************************************************************/
+INLINE void halPostTask(uint32_t flag)
+{
+ halTaskFlags |= flag;
+ SYS_PostTask(HAL_TASK_ID);
+}
+
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) \
+ || defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3) || defined(ATMEGA128RFA1)
+/**************************************************************************//**
+\brief Set task for task manager.
+
+\param[in]
+ flag task for task mask 0
+******************************************************************************/
+INLINE void halPostTask0(uint8_t flag)
+{
+ halTaskFlags0 |= flag;
+ SYS_PostTask(HAL_TASK_ID);
+}
+
+/**************************************************************************//**
+\brief Set task for task manager.
+
+\param[in]
+ flag task for task mask 1
+******************************************************************************/
+INLINE void halPostTask1(uint8_t flag)
+{
+ halTaskFlags1 |= flag;
+ SYS_PostTask(HAL_TASK_ID);
+}
+
+/**************************************************************************//**
+\brief Set task for task manager.
+
+\param[in]
+ flag task for task mask 2
+******************************************************************************/
+INLINE void halPostTask2(uint8_t flag)
+{
+ halTaskFlags2 |= flag;
+ SYS_PostTask(HAL_TASK_ID);
+}
+
+/**************************************************************************//**
+\brief Set task for task manager.
+
+\param[in]
+ flag task for task mask 3
+******************************************************************************/
+INLINE void halPostTask3(uint8_t flag)
+{
+ halTaskFlags3 |= flag;
+ SYS_PostTask(HAL_TASK_ID);
+}
+
+/**************************************************************************//**
+\brief Set task for task manager.
+
+\param[in]
+ flag task for task mask 4
+******************************************************************************/
+INLINE void halPostTask4(uint8_t flag)
+{
+ halTaskFlags4 |= flag;
+ SYS_PostTask(HAL_TASK_ID);
+}
+
+#elif defined(AT32UC3A0512) || defined(AT91SAM3S4C)
+/**************************************************************************//**
+\brief Set task for task manager.
+
+\param[in]
+ flag task for task mask
+******************************************************************************/
+INLINE void halPostTask(uint32_t flag)
+{
+ halTaskFlags |= flag;
+ SYS_PostTask(HAL_TASK_ID);
+}
+#endif
+
+#endif /*_HALTASKHANDLER_H*/
+
+// eof halTaskManager.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/hsmci.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/hsmci.h
new file mode 100644
index 00000000..6e9dd2ea
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/hsmci.h
@@ -0,0 +1,142 @@
+/****************************************************************************//**
+ \file hsmci.h
+
+ \brief The header file describes the HSMCI interface.
+
+ \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:
+ 24/08/11 N. Fomin - Created
+ ******************************************************************************/
+#ifndef _HSMCI_H
+#define _HSMCI_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halHsmci.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** \brief Hsmci descriptor */
+typedef struct
+{
+ /** \brief HSMCI bus clock rate. */
+ HsmciClockRate_t clockRate;
+ /** \brief HSMCI bus width. */
+ HsmciBusWidth_t busWidth;
+ /** \brief HSMCI high speed mode. */
+ bool highSpeedMode;
+ /** \brief HSMCI command desciptor.
+ Take a look into halHsmci.h platform specific file fore more details. */
+ HAL_HsmciCommandDescriptor_t *commandDescriptor;
+ /** \brief HSMCI data transfer descriptor.
+ Take a look into halHsmci.h platform specific file fore more details. */
+ HAL_HsmciDataTransferDescriptor_t *dataTransferDescriptor;
+ /** \brief Address of the function to notify the upper layer when
+ a transfer was completed. */
+ void (*callback)(void);
+} HAL_HsmciDescriptor_t;
+
+/**************************************************************************//**
+\brief Open the HSMCI interface and configure pins.
+\param[in]
+ descriptor - pointer to the hsmci descriptor.
+\return
+ -1 - there are no free resources;
+ 0 - HSMCI is ready.
+******************************************************************************/
+int HAL_OpenHsmci(HAL_HsmciDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Close the HSMCI interface.
+\param[in]
+ descriptor - pointer to the hsmci descriptor.
+\return
+ Returns 0 on success or -1 if interface was not opened.
+******************************************************************************/
+int HAL_CloseHsmci(HAL_HsmciDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Sends HSMCI command.
+ Callback function will be used to notify about the finishing transmitting.
+\param[in]
+ descriptor - pointer to hsmci descriptor.
+\return
+ -1 - hsmci interface was not opened, there is unsent data,
+ or command response buffer is zero;
+ 0 - on succes.
+******************************************************************************/
+int HAL_WriteHsmciCommand(HAL_HsmciDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Writes data to the HSMCI.
+ Callback function will be used to notify about the finishing transmitting.
+\param[in]
+ descriptor - pointer to hsmci descriptor.
+\return
+ -1 - hsmci interface was not opened, there is unsent data, pointer to the data,
+ the length are zero or command response buffer is zero;
+ 0 - on success.
+******************************************************************************/
+int HAL_WriteHsmci(HAL_HsmciDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Reads data from the HSMCI.
+ Callback function will be used to notify about the finishing transmitting.
+\param[in]
+ descriptor - pointer to hsmci descriptor.
+\return
+ -1 - hsmci module was not opened, there is unsent data, pointer to the data,
+ the interface are zero or command response buffer is zero;
+ 0 - on success.
+******************************************************************************/
+int HAL_ReadHsmci(HAL_HsmciDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Sets HSMCI bus speed.
+\param[in]
+ descriptor - pointer to hsmci descriptor.
+\return
+ -1 - hsmci interface was not opened or there is unsent data;
+ 0 - on success.
+******************************************************************************/
+int HAL_SetHsmciSpeed(HAL_HsmciDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Sets HSMCI bus width.
+\param[in]
+ descriptor - pointer to hsmci descriptor.
+\return
+ -1 - hsmci interface was not opened or there is unsent data;
+ 0 - on success.
+******************************************************************************/
+int HAL_SetHsmciBusWidth(HAL_HsmciDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Sets HSMCI high speed mode.
+\param[in]
+ descriptor - pointer to hsmci descriptor.
+\return
+ -1 - hsmci interface was not opened or there is unsent data;
+ 0 - on success.
+******************************************************************************/
+int HAL_SetHsmciHighSpeedMode(HAL_HsmciDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Checks if HSMCI interface is free and ready.
+\return
+ false - hsmci interface was not opened or there is unsent data;
+ true - hsmci interface is ready.
+******************************************************************************/
+bool HAL_HsmciCheckReady(void);
+
+#endif /* _HSMCI_H */
+// eof hsmci.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/i2cPacket.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/i2cPacket.h
new file mode 100644
index 00000000..102f2cd6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/i2cPacket.h
@@ -0,0 +1,165 @@
+/**************************************************************************//**
+ \file i2cPacket.h
+
+ \brief The header file describes the i2cPacket interface.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _I2CPACKET_H
+#define _I2CPACKET_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+// \cond
+#include <halClkCtrl.h>
+#include <types.h>
+// \endcond
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+/** \brief i2c bus prescaler */
+#define HAL_I2C_PRESCALER 0ul
+// \cond
+/** \brief internal address size */
+#if defined(AT91SAM7X256)
+ /* AT91C_TWI_IADRSZ_NO */
+ #define HAL_NO_INTERNAL_ADDRESS (0x0 << 8)
+ /* AT91C_TWI_IADRSZ_1_BYTE */
+ #define HAL_ONE_BYTE_SIZE (0x1 << 8)
+ /* AT91C_TWI_IADRSZ_2_BYTE */
+ #define HAL_TWO_BYTE_SIZE (0x2 << 8)
+ /* AT91C_TWI_IADRSZ_3_BYTE */
+ #define HAL_THREE_BYTE_SIZE (0x3 << 8)
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) || defined(ATMEGA128RFA1)
+ #define HAL_NO_INTERNAL_ADDRESS 0x0
+ #define HAL_ONE_BYTE_SIZE 0x1
+ #define HAL_TWO_BYTE_SIZE 0x2
+ #define HAL_THREE_BYTE_SIZE 0x3
+#endif
+// \endcond
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** \brief i2c baud rate */
+#if defined(AT91SAM7X256)
+ typedef enum
+ {
+ I2C_CLOCK_RATE_250 = F_CPU/(2*250000) - 3, // 200 Kb/s clock rate
+ I2C_CLOCK_RATE_125 = F_CPU/(2*125000) - 3, // 125 Kb/s clock rate
+ I2C_CLOCK_RATE_100 = F_CPU/(2*100000) - 3, // 100 Kb/s clock rate
+ I2C_CLOCK_RATE_62 = F_CPU/(2*62500) - 3 // 62.5 Kb/s clock rate
+ } I2cClockRate_t;
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) || defined(ATMEGA128RFA1)
+ typedef enum
+ {
+ I2C_CLOCK_RATE_250 = ((F_CPU/250000ul) - 16ul)/(2ul * (1ul << HAL_I2C_PRESCALER) * (1ul << HAL_I2C_PRESCALER)), // 250 Kb/s clock rate
+ I2C_CLOCK_RATE_125 = ((F_CPU/125000ul) - 16ul)/(2ul * (1ul << HAL_I2C_PRESCALER) * (1ul << HAL_I2C_PRESCALER)), // 125 Kb/s clock rate
+ I2C_CLOCK_RATE_62 = ((F_CPU/62500ul) - 16ul)/(2ul * (1ul << HAL_I2C_PRESCALER) * (1ul << HAL_I2C_PRESCALER)) // 62.5 Kb/s clock rate
+ } I2cClockRate_t;
+#endif
+
+/** \brief TWI clock rate */
+typedef struct
+{
+ I2cClockRate_t clockrate; // clock rate
+} HAL_i2cMode_t;
+
+/**************************************************************************//**
+\brief i2c access control structure
+******************************************************************************/
+typedef struct
+{
+ /** \brief slave address */
+ uint8_t id;
+ /** \brief number of bytes to be written to the bus */
+ uint16_t length;
+ /** \brief pointer to the data */
+ uint8_t *data;
+ /** \brief internal device address size conditions:
+ HAL_NO_INTERNAL_ADDRESS - byte command condition \n
+ HAL_ONE_BYTE_SIZE \n
+ HAL_TWO_BYTE_SIZE \n
+ HAL_THREE_BYTE_SIZE */
+#if defined(AT91SAM7X256)
+ uint32_t lengthAddr;
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) || defined(ATMEGA128RFA1)
+ uint8_t lengthAddr;
+#endif
+ /** \brief internal device address */
+ uint32_t internalAddr;
+ /** \brief callback function */
+ void (*f)(bool result);
+} HAL_I2cParams_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Opens twi resource.\n
+field of i2cMode structure \n
+i2cClockRate_t clockrate (set by user). Must be chosen from:\n
+ I2C_CLOCK_RATE_250 - 250 Kb/s clock rate \n
+ I2C_CLOCK_RATE_125 - 125 Kb/s clock rate \n
+ I2C_CLOCK_RATE_62 - 62.5 Kb/s clock rate \n
+
+\param[in]
+ i2cMode - pointer to the mode structure.
+
+\return
+ -1 - resource was already open or pointer is NULL. \n
+ 0 - success.
+******************************************************************************/
+int HAL_OpenI2cPacket(HAL_i2cMode_t *i2cMode);
+
+/**************************************************************************//**
+\brief Closes resource.
+
+\return
+ -1 - resource was not open. \n
+ 0 - success.
+******************************************************************************/
+int HAL_CloseI2cPacket(void);
+
+/**************************************************************************//**
+\brief Writes a series of bytes out to the TWI bus. Operation result will be
+sent to the callback function of the HAL_I2cParams_t structure.
+
+\param[in]
+ param - pointer to HAL_I2cParams_t structure
+\return
+ 0 - the bus is free and the request is accepted. \n
+ -1 - otherwise.
+******************************************************************************/
+int HAL_WriteI2cPacket(HAL_I2cParams_t *param);
+
+/**************************************************************************//**
+\brief Reads the series of bytes from the TWI bus. Operation result will be
+sent to the callback function of the HAL_I2cParams_t structure.
+
+\param[in]
+ param - pointer to HAL_I2cParams_t structure
+\return
+ 0 - the bus is free and the request is accepted. \n
+ -1 - otherwise.
+******************************************************************************/
+int HAL_ReadI2cPacket(HAL_I2cParams_t *param);
+
+#endif /* _I2CPACKET_H */
+// eof i2cPacket.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/irq.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/irq.h
new file mode 100644
index 00000000..bc2a36df
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/irq.h
@@ -0,0 +1,203 @@
+/**************************************************************************//**
+ \file irq.h
+
+ \brief The header file describes the IRQ interface.
+
+ \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:
+ 5/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _IRQ_H
+#define _IRQ_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+/** \brief The low level generates an interrupt request. */
+#define IRQ_LOW_LEVEL 0
+/** \brief The high level generates an interrupt request (valid only for arm and avr32). */
+#define IRQ_HIGH_LEVEL 1
+/** \brief Any edge generates an interrupt request (valid only for avr and xmega). */
+#define IRQ_ANY_EDGE 2
+/** \brief Falling edge generates an interrupt request. */
+#define IRQ_FALLING_EDGE 3
+/** \brief Rising edge generates an interrupt request. */
+#define IRQ_RISING_EDGE 4
+/** \brief interrupt is disabled. (valid only for xmega)*/
+#define IRQ_IS_DISABLED 5
+/** \brief interrupt is not changed previous state. (valid only for xmega)*/
+#define IRQ_IS_NOT_CHANGED 6
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** \brief numbers of possible interrupt. */
+typedef enum
+{
+#if defined(AT91SAM7X256) || defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || \
+ defined(AT90USB1287) || defined(ATMEGA128RFA1) || defined(AT32UC3A0512)
+/** \brief number of valid interrupt for arm and avr32. */
+ IRQ_0 = 0,
+/** \brief number of valid interrupt for arm and avr32. */
+ IRQ_1 = 1,
+/** \brief number of valid interrupt for avr32. */
+ IRQ_2 = 2,
+/** \brief number of valid interrupt for avr32. */
+ IRQ_3 = 3,
+/** \brief number of valid interrupt for avr32. */
+ IRQ_4 = 4,
+/** \brief number of valid interrupt for avr(only rcb platform) and avr32. */
+ IRQ_5 = 5,
+/** \brief number of valid interrupt for avr and avr32. */
+ IRQ_6 = 6,
+/** \brief number of valid interrupt for avr and avr32. */
+ IRQ_7 = 7,
+#endif
+#if defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3)
+ IRQ_A0,
+ IRQ_A1,
+ IRQ_B0,
+ IRQ_B1,
+ IRQ_C0,
+ IRQ_C1,
+ IRQ_D0,
+ IRQ_D1,
+ IRQ_E0,
+ IRQ_E1,
+ IRQ_F0,
+ IRQ_F1,
+#if defined(ATXMEGA128A1)
+ IRQ_H0,
+ IRQ_H1,
+ IRQ_J0,
+ IRQ_J1,
+ IRQ_K0,
+ IRQ_K1,
+#endif
+#endif
+#if defined(AT91SAM3S4C)
+ IRQ_PORT_A,
+ IRQ_PORT_B,
+ IRQ_PORT_C,
+#endif
+ IRQ_LIMIT
+} HAL_IrqNumber_t;
+
+#if defined(AT91SAM7X256) || defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || \
+ defined(AT90USB1287) || defined(ATMEGA128RFA1) || defined(AT32UC3A0512)
+/** \brief interrupt activation condition. */
+typedef uint8_t HAL_IrqMode_t;
+#endif
+#if defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3)
+/** \brief interrupt activation condition. */
+typedef struct
+{
+ uint32_t pin0 : 3;
+ uint32_t pin1 : 3;
+ uint32_t pin2 : 3;
+ uint32_t pin3 : 3;
+ uint32_t pin4 : 3;
+ uint32_t pin5 : 3;
+ uint32_t pin6 : 3;
+ uint32_t pin7 : 3;
+} HAL_IrqMode_t;
+#endif
+#if defined(AT91SAM3S4C)
+typedef uint8_t HAL_IrqMode_t[32];
+#endif
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Registers the user's irqNumber external interrupt
+
+\param[in]
+ irqNumber - IRQ number. Must be chosen from: \n
+ IRQ_0 (for arm and avr32) \n
+ IRQ_1 (for arm and avr32) \n
+ IRQ_2 (for avr32) \n
+ IRQ_3 (for avr32) \n
+ IRQ_4 (for avr32) \n
+ IRQ_5 (for avr (only rcb platform) and avr32) \n
+ IRQ_6 (for avr and avr32) \n
+ IRQ_7 (for avr and avr32) \n
+ IRQ_PC (for xmega. P - port name, C - interrupt number. For example: IRQ_D1) \n
+ IRQ_PORT_x (for cortex m3, x stands for port name) \n
+\param[in]
+ irqMode - Controls the sort of interrupt. For avr and arm must be chosen from: \n
+ IRQ_LOW_LEVEL // The low level generates an interrupt request. \n
+ IRQ_HIGH_LEVEL // The high level generates an interrupt request (valid for arm, avr32, cortex m3). \n
+ IRQ_ANY_EDGE // Any edge generates an interrupt request (valid for avr and cortex m3). \n
+ IRQ_FALLING_EDGE // Falling edge generates an interrupt request. \n
+ IRQ_RISING_EDGE // Rising edge generates an interrupt request. \n
+
+ irqMode is bit field for xmega . Bit field includes members pinX (X - pin number of selected port). \n
+ All members that bit field must have value:
+
+ IRQ_LOW_LEVEL // The low level generates an interrupt request. \n
+ IRQ_ANY_EDGE // Any edge generates an interrupt request. \n
+ IRQ_FALLING_EDGE // Falling edge generates an interrupt request. \n
+ IRQ_RISING_EDGE // Rising edge generates an interrupt request. \n
+ IRQ_IS_DISABLED // Pin is disabled for interrupt request. \n
+ IRQ_IS_NOT_CHANGED // Pin is not changed previous state.
+
+\param[in]
+ f - user's interrupt handler. Handler must be executed less than 100 us.
+\return
+ -1 - if irqNumber is out of range, \n
+ not valid irq mode, \n
+ such interrupt has been already registered. \n
+ 0 - otherwise.
+******************************************************************************/
+int HAL_RegisterIrq(HAL_IrqNumber_t irqNumber, HAL_IrqMode_t irqMode, void (*f)(void));
+
+/**************************************************************************//**
+\brief Enables the irqNumber interrupt.
+\param[in]
+ irqNumber - IRQ number
+\return
+ -1 - if irqNumber is out of range or has not been registered yet. \n
+ 0 - otherwise.
+******************************************************************************/
+int HAL_EnableIrq(HAL_IrqNumber_t irqNumber);
+
+/**************************************************************************//**
+\brief Disables the irqNumber interrupt.
+\param[in]
+ irqNumber - IRQ number
+\return
+ -1 - if irqNumber is out of range or has not been registered yet. \n
+ 0 - otherwise.
+******************************************************************************/
+int HAL_DisableIrq(HAL_IrqNumber_t irqNumber);
+
+/**************************************************************************//**
+\brief Unregisters the user's irqNumber interrupt
+\param[in]
+ irqNumber - IRQ number
+\return
+ -1 - if irqNumber is out of range or has not been registered yet. \n
+ 0 - otherwise.
+******************************************************************************/
+int HAL_UnregisterIrq(HAL_IrqNumber_t irqNumber);
+
+#endif /* _IRQ_H */
+//eof irq.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/pwm.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/pwm.h
new file mode 100644
index 00000000..d2b18cff
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/pwm.h
@@ -0,0 +1,193 @@
+/**************************************************************************//**
+ \file pwm.h
+
+ \brief Description of the PWM interface
+
+ \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:
+ 10/11/08 A. Taradov - Created
+ 5/04/11 A.Razinkov - Refactored
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _PWM_H
+#define _PWM_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <atomic.h>
+#include <mnUtils.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+#define TCCRnA(pwmUnit) MMIO_BYTE(pwmUnit)
+#define TCCRnB(pwmUnit) MMIO_BYTE(pwmUnit + 1U)
+#define TCCRnC(pwmUnit) MMIO_BYTE(pwmUnit + 2U)
+#define TCNTn(pwmUnit) MMIO_WORD(pwmUnit + 4U)
+#define ICRn(pwmUnit) MMIO_WORD(pwmUnit + 6U)
+#define OCRnA(pwmUnit) MMIO_WORD(pwmUnit + 8U)
+#define OCRnB(pwmUnit) MMIO_WORD(pwmUnit + 10U)
+#define OCRnC(pwmUnit) MMIO_WORD(pwmUnit + 12U)
+
+#define PWM_SUCCESS_STATUS 0
+#define PWM_INVALID_UNIT_STATUS -1
+#define PWM_INVALID_CHANNEL_STATUS -2
+#define PWM_INVALID_PRESCALER_STATUS -3
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/**************************************************************************//**
+\brief PWM prescaler
+******************************************************************************/
+typedef enum
+{
+ PWM_STOPPED,
+ PWM_PRESCALER_1,
+ PWM_PRESCALER_8,
+ PWM_PRESCALER_64,
+ PWM_PRESCALER_256,
+ PWM_PRESCALER_1024,
+ PWM_PRESCALER_EXT_CLOCK_ON_FALLING_EDGE,
+ PWM_PRESCALER_EXT_CLOCK_ON_RISING_EDGE,
+ PWM_PRESCALER_INVALID
+} HAL_PwmPrescaler_t;
+
+/**************************************************************************//**
+\brief PWM channel
+******************************************************************************/
+typedef enum
+{
+ PWM_CHANNEL_0,
+ PWM_CHANNEL_1,
+#ifndef ATMEGA1284
+ PWM_CHANNEL_2,
+#endif /* ATMEGA1284 */
+ PWM_INVALID_CHANNEL
+} HAL_PwmChannel_t;
+
+/**************************************************************************//**
+\brief PWM impulse polarity
+******************************************************************************/
+typedef enum
+{
+ /** \brief PWM output is low when duty cycle = 0% */
+ PWM_POLARITY_NON_INVERTED,
+ /** \brief PWM output is high when duty cycle = 0% */
+ PWM_POLARITY_INVERTED
+} HAL_PwmPolarity_t;
+
+/**************************************************************************//**
+\brief PWM unit number. Relative to corresponding Timer/Counter.
+******************************************************************************/
+typedef enum
+{
+ /* Base address of T/C1 PWM related registers */
+ PWM_UNIT_1 = 0x80,
+ /* Base address of T/C3 PWM related registers */
+ PWM_UNIT_3 = 0x90
+} HAL_PwmUnit_t;
+
+/**************************************************************************//**
+\brief PWM module descriptor
+******************************************************************************/
+typedef struct _HAL_PwmDescriptor_t
+{
+ /* Service fields for internal use. */
+ struct
+ {
+ /* Pointer to Data Direction Register. PWM port dependent. */
+ volatile uint8_t *DDRn;
+ /* PWN channel pin number. PWM port dependent. */
+ uint8_t pwmBaseChannelPin;
+ /* Compare Output Mode low bit position. PWM channel dependent. */
+ uint8_t COMnx0;
+ /* Output Compare Register. PWM channel dependent. */
+ volatile uint16_t *OCRnx;
+ } service;
+ /* PWM unit number. Equal to ID of Timer/Counter witch serves PWM module. */
+ HAL_PwmUnit_t unit;
+ /* PWM channel */
+ HAL_PwmChannel_t channel;
+ /* PWM polarity */
+ HAL_PwmPolarity_t polarity;
+} HAL_PwmDescriptor_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Initializes the PWM.
+
+\param [in] pwmUnit - PWM unit number.
+ Equal to ID of Timer/Counter witch serves PWM module.
+
+\return operation status
+******************************************************************************/
+int HAL_OpenPwm(HAL_PwmUnit_t pwmUnit);
+
+/**************************************************************************//**
+\brief Starts PWM on specified channel.
+
+\param [in] descriptor - PWM channel descriptor.
+
+\return operation status
+******************************************************************************/
+int HAL_StartPwm(HAL_PwmDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Stops PWM on specified channel.
+
+\param [in] descriptor - PWM channel descriptor.
+
+\return operation status
+******************************************************************************/
+int HAL_StopPwm(HAL_PwmDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Sets base frequency of module. Common for all module channels.
+
+\param [in] pwmUnit - PWM unit number. Equal to corresponding Timer/Counter ID.
+\param [in] top - value for the TOP register.
+\param [in] prescaler - clock prescaler.
+
+\return operation status
+******************************************************************************/
+int HAL_SetPwmFrequency(HAL_PwmUnit_t pwmUnit, uint16_t top, HAL_PwmPrescaler_t prescaler);
+
+
+/**************************************************************************//**
+\brief Sets compare value for the PWM channel.
+
+\param [in] descriptor - PWM channel descriptor.
+
+\return operation status
+******************************************************************************/
+int HAL_SetPwmCompareValue(HAL_PwmDescriptor_t *descriptor, uint16_t cmpValue);
+
+/**************************************************************************//**
+\brief Closes the PWM.
+
+\param [in] pwmUnit - PWM unit number.
+ Equal to ID of Timer/Counter witch serves PWM module.
+
+\return operation status
+******************************************************************************/
+int HAL_ClosePwm(HAL_PwmUnit_t pwmUnit);
+
+#endif /* _PWM_H */
+
+// eof pwm.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/reducePower.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/reducePower.h
new file mode 100644
index 00000000..b531f963
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/reducePower.h
@@ -0,0 +1,33 @@
+/**************************************************************************//**
+ \file reducePower.h
+
+ \brief The header file describes the power reducing interface.
+
+ \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:
+ 6/10/09 A. Khromykh - Created.
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+#ifndef _REDUCEPOWER_H
+#define _REDUCEPOWER_H
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+\brief Stops the clock to all peripherals, which are not used by BitCloud. \n
+(implemented only for atxmega128a1 & atxmega256a3).
+******************************************************************************/
+void HAL_SwitchOffPeripherals(void);
+
+#endif /* _REDUCEPOWER_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/resetReason.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/resetReason.h
new file mode 100644
index 00000000..25311296
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/resetReason.h
@@ -0,0 +1,153 @@
+/**************************************************************************//**
+ \file resetReason.h
+
+ \brief The header file describes the the reset reason interface.
+
+ \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:
+ 5/12/07 A. Khromykh - Created.
+ 2/09/09 M. Gekk - Platform XMega is supported.
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _RESETREASON_H
+#define _RESETREASON_H
+
+/* \cond */
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define TEMP_WARM_RESET 0x12
+/* \endcond */
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** \brief The reset reason types. */
+#if defined(AT91SAM7X256)
+ typedef enum
+ {
+ /** \brief VDDCORE rising */
+ POWER_ON_RESET = 0x00,
+ /** \brief Watchdog fault occurred */
+ WDT_RESET = 0x02,
+ /** \brief Processor reset required by the software */
+ WARM_RESET = 0x03,
+ /** \brief NRST pin detected low */
+ EXTERNAL_RESET = 0x04,
+ /** \brief BrownOut reset occurred */
+ BROWN_OUT_RESET = 0x05
+ } HAL_ResetReason_t;
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) || defined(ATMEGA128RFA1)
+ typedef enum
+ {
+ /** \brief jump to the NULL pointer was issued. */
+ NULL_PTR_DEREF_RESET = 0x0,
+ /** \brief the supply voltage was below reset threshold. */
+ POWER_ON_RESET = 0x1,
+ /** \brief a low level was present on RESET pin. */
+ EXTERNAL_RESET = 0x2,
+ /** \brief the supply voltage was below Brown-out reset threshold. Set by fuses.*/
+ BROWN_OUT_RESET = 0x4,
+ /** \brief Watch Dog Timer period expired. */
+ WDT_RESET = 0x8,
+ /** \brief MCU was reset by JTAG. */
+ JTAG_RESET = 0x10,
+ /** \brief software reset. */
+ WARM_RESET = 0x11
+ } HAL_ResetReason_t;
+#elif defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3)
+ typedef enum
+ {
+ /** \brief jump to the NULL pointer was issued. */
+ NULL_PTR_DEREF_RESET = 0x00,
+ /** \brief Power-on reset is released when the VCC stops rising or when
+ * the VCC level has reached the Power-on Threshold Voltage (VPOT) level. */
+ POWER_ON_RESET = (1U << 0),
+ /** \brief The external reset will trigger when the RESET pin is driven
+ * below the RESET pin threshold voltage, VRST. */
+ EXTERNAL_RESET = (1U << 1),
+ /** \brief The VCC level falls bellow the trigger level for a minimum time. */
+ BROWN_OUT_RESET = (1U << 2),
+ /** \brief Watchdog reset will be given if the WDT is not reset from t
+ * he software within a programmable timout period, */
+ WATCHDOG_RESET = (1U << 3),
+ /** \brief The Program and Debug Interface reset contains a separate reset source
+ * that is used to reset the device during external programming and debugging. */
+ DEBUG_RESET = (1U << 4),
+ /** \brief The Software reset makes it possible to issue a system reset from
+ * software by writing to the Software Reset bit in the Reset Control Register. */
+ WARM_RESET = (1U << 5)
+ } HAL_ResetReason_t;
+#elif defined(AT32UC3A0512)
+ typedef enum
+ {
+ /** \brief The CPU was reset due to the supply voltage
+ * being lower than the power-on threshold level. */
+ POWER_ON_RESET = (1U << 0),
+ /** \brief The CPU was reset due to the supply voltage
+ * being lower than the brown-out threshold level. */
+ BROWN_OUT_RESET = (1U << 1),
+ /** \brief The CPU was reset due to the RESET pin being asserted. */
+ EXTERNAL_RESET = (1U << 2),
+ /** \brief CPU reset caused by watchdog. */
+ WDT_RESET = (1U << 3),
+ /** \brief The CPU was reset by setting the bit RC_CPU in the JTAG reset register. */
+ DEBUG_RESET = (1U << 4),
+ /** \brief The CPU was reset because it had detected an illegal access. */
+ CPUERR_RESET = (1U << 7),
+ /** \brief The CPU was reset because the RES strobe in
+ * the OCD Development Control register has been written to one. */
+ OCDRST_RESET = (1U << 8),
+ /** \brief The chip was reset by setting the bit RC_OCD in the
+ * JTAG reset register or by using the JTAG HALT instruction.*/
+ JTAGHARD_RESET = (1U << 9),
+ /** \brief CPU reset caused by call to halSoftwareReset. */
+ WARM_RESET = (1U << 10),
+ } HAL_ResetReason_t;
+#elif defined(AT91SAM3S4C)
+ typedef enum
+ {
+ /** \brief A general reset occurs when a Power-on-reset is detected,
+ a Brownout or a Voltage regulation loss is detected by the Supply controller. */
+ GENERAL_RESET = 0x00,
+ /** \brief A Backup reset occurs when the chip returns from Backup mode.
+ The core_backup_reset signal is asserted by the Supply Controller when a Backup reset occurs. */
+ BACKUP_RESET = 0x01,
+ /** \brief CPU reset caused by watchdog. */
+ WDT_RESET = 0x02,
+ /** \brief CPU reset caused by call to halSoftwareReset. */
+ WARM_RESET = 0x03,
+ /** \brief The CPU was reset due to the RESET pin being asserted. */
+ EXTERNAL_RESET = 0x04
+ } HAL_ResetReason_t;
+#else
+ #error 'unsupported cpu'
+#endif
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/******************************************************************************
+ \brief Returns the reset reason.
+ \return The reason of reset.
+ ******************************************************************************/
+HAL_ResetReason_t HAL_ReadResetReason(void);
+
+/**************************************************************************//**
+ \brief Software reset.
+ ******************************************************************************/
+void HAL_WarmReset(void);
+
+#endif /* _RESETREASON_H */
+/* resetReason.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/sleep.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/sleep.h
new file mode 100644
index 00000000..dc5c55b1
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/sleep.h
@@ -0,0 +1,71 @@
+/**************************************************************************//**
+ \file sleep.h
+
+ \brief The header file describes the sleep interface.
+
+ \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:
+ 1/12/09 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+#ifndef _SLEEP_H
+#define _SLEEP_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef void (* HAL_WakeUpCallback_t)(void);
+
+/** \brief fields of structure \n
+ \brief uint32_t sleepTime - time of mcu+radio sleeping \n
+ \brief HAL_WakeUpCallback_t callback - pointer to wake up callback function */
+typedef struct
+{
+ uint32_t sleepTime;
+ HAL_WakeUpCallback_t callback;
+} HAL_Sleep_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Starts sleep timer and HAL sleep. When system is wake up send callback
+\param[in]
+ sleepParam - pointer to sleep structure.
+\return
+ -1 - bad parameters, \n
+ -2 - sleep timer busy, \n
+ -3 - sleep system has been started.
+ 0 - success.
+******************************************************************************/
+int HAL_StartSystemSleep(HAL_Sleep_t *sleepParam);
+
+/**************************************************************************//**
+\brief Prepares mcu for power-save, power-down.
+ Power-down the mode is possible only when internal RC is used
+\return
+ -1 - there is no possibility to sleep.
+******************************************************************************/
+int HAL_Sleep(void);
+
+/***************************************************************************//**
+\brief Makes MCU enter Idle mode.
+*******************************************************************************/
+void HAL_IdleMode(void);
+
+#endif /* _SLEEP_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/sleepTimer.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/sleepTimer.h
new file mode 100644
index 00000000..87c29632
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/sleepTimer.h
@@ -0,0 +1,69 @@
+/**************************************************************************//**
+ \file sleepTimer.h
+
+ \brief The header file describes the sleepTimer interface.
+
+ \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:
+ 29/05/07 E. Ivanov - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _SLEEPTIMER_H
+#define _SLEEPTIMER_H
+
+// \cond
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <bcTimer.h>
+// \endcond
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** \brief fields of structure \n
+ \brief uint32_t interval - timer firing interval (set by user) \n
+ \brief TimerMode_t mode - timer work mode (set by user). Must be chosen from: \n
+ TIMER_REPEAT_MODE \n
+ TIMER_ONE_SHOT_MODE \n
+ \brief void (*callback)() - pointer to the timer callback function (set by user) \n */
+typedef Timer_t HAL_SleepTimer_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Starts sleep timer. Interval must be greater one time of sleep timer tick.
+\param[in]
+ sleepTimer - pointer to sleep timer structure.
+\return
+ -1 - NULL pointer, \n
+ -2 - interval can not be counted out, \n
+ -3 - sleep timer has already started, \n
+ 0 - otherwise.
+******************************************************************************/
+int HAL_StartSleepTimer(HAL_SleepTimer_t *sleepTimer);
+
+/**************************************************************************//**
+\brief Removes timer.
+\param[in]
+ sleepTimer - address of the timer to be removed from the list
+\return
+ -1 - there is no active sleep timer, \n
+ 0 - otherwise.
+******************************************************************************/
+int HAL_StopSleepTimer(HAL_SleepTimer_t *sleepTimer);
+
+#endif /* _SLEEPTIMER_H */
+// eof sleepTimer.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/spi.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/spi.h
new file mode 100644
index 00000000..c34f5dcd
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/spi.h
@@ -0,0 +1,173 @@
+/****************************************************************************//**
+ \file spi.h
+
+ \brief The header file describes the USART SPI mode (for avr) and SPI1 bus (for arm).
+
+ \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:
+ 29/05/08 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _SPI_H
+#define _SPI_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#if defined(AT91SAM7X256)
+ #include <halMemSpi.h>
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || \
+ defined(AT90USB1287) || defined(ATMEGA128RFA1) || defined(ATXMEGA128A1) || \
+ defined(ATXMEGA256A3) || defined(ATXMEGA256D3)
+ #include <halSpi.h>
+#endif
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** \brief Spi descriptor */
+typedef struct
+{
+ /** \brief tty - SPI_CHANNEL_n to be used. "n" range depends on the platform.
+ Take a look into halSpi.h platform specific file fore more details. */
+ SpiChannel_t tty;
+ /** \brief SpiClockMode_t clockMode - spi clock mode (set by user). Must be chosen from: \n
+ SPI_CLOCK_MODE0 \n
+ SPI_CLOCK_MODE1 \n
+ SPI_CLOCK_MODE2 \n
+ SPI_CLOCK_MODE3 \n */
+ SpiClockMode_t clockMode;
+#if defined(AT91SAM7X256)
+ /** \brief parameters are valid only for arm: */
+ /** \brief symbol size (bits) (set by user). Must be set: \n
+ SPI_8BITS_SYMBOL \n
+ SPI_9BITS_SYMBOL \n
+ SPI_10BITS_SYMBOL \n
+ SPI_11BITS_SYMBOL \n
+ SPI_12BITS_SYMBOL \n
+ SPI_13BITS_SYMBOL \n
+ SPI_14BITS_SYMBOL \n
+ SPI_15BITS_SYMBOL \n
+ SPI_16BITS_SYMBOL \n */
+ SpiSymbolSize_t symbolSize;
+ /** \brief Must be use macros HAL_SPI_PACK_PARAMETER(freq_value, valid_delay_value, cons_delay_value). \n
+ Where is: \n
+ freq_value - spi frequency (Hz) \n
+ valid_delay_value - delay between setting CS and clock start (sec) \n
+ cons_delay_value - delay between consecutive transfers (sec) \n */
+ uint32_t pack_parameter;
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) || \
+ defined(ATMEGA128RFA1) || defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3)
+ /** \brief parameters are valid only for avr:*/
+ /** \brief spi data order (set by user). Must be chosen from: \n
+ SPI_DATA_MSB_FIRST \n
+ SPI_DATA_LSB_FIRST \n */
+ SpiDataOrder_t dataOrder;
+ /** \brief spi clock rate (set by user). Must be chosen from: \n
+ for atmega \n
+ SPI_CLOCK_RATE_62 \n
+ SPI_CLOCK_RATE_125 \n
+ SPI_CLOCK_RATE_250 \n
+ SPI_CLOCK_RATE_500 \n
+
+ for xmega mcu clock \n
+ SPI_CLOCK_RATE_125 (4 MHz) \n
+ SPI_CLOCK_RATE_250 (4, 8 MHz) \n
+ SPI_CLOCK_RATE_500 (4, 8, 16 MHz) \n
+ SPI_CLOCK_RATE_750 (12 MHz ) \n
+ SPI_CLOCK_RATE_1000 (4, 8, 16, 32 MHz) \n
+ SPI_CLOCK_RATE_1500 (12 MHz) \n
+ SPI_CLOCK_RATE_2000 (4, 8, 16, 32 MHz) \n
+ SPI_CLOCK_RATE_3000 (12 MHz) \n
+ SPI_CLOCK_RATE_4000 (8, 16, 32 MHz) \n
+ SPI_CLOCK_RATE_6000 (12 MHz) \n
+ SPI_CLOCK_RATE_8000 (16, 32 MHz) \n
+ SPI_CLOCK_RATE_16000 (32 MHz) */
+ SpiBaudRate_t baudRate;
+ /** \brief HAL USART service field - contains variables for HAL USART module
+ internal needs */
+ HAL_UsartDescriptor_t spiDescriptor;
+#endif
+ union
+ {
+ /** \brief address of the function to notify the application when a transmission was completed. \n
+ When the synchronous method is used, callback must be NULL. \n */
+ void (* callback)(void);
+ /** \brief address of the function to notify the application when a byte was received. \n
+ Slave mode uses only asynchronous method. \n */
+ void (* slave_callback)(uint16_t);
+ };
+} HAL_SpiDescriptor_t;
+
+/**************************************************************************//**
+\brief Open the SPI interface and configure pins.
+\param[in]
+ descriptor - pointer to the spi descriptor.
+\return
+ -1 - there not are free resources.
+ 0 - SPI channel is ready.
+******************************************************************************/
+int HAL_OpenSpi(HAL_SpiDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Close the SPI channel and pins.
+\param[in]
+ descriptor - pointer to the spi descriptor.
+\return
+ Returns 0 on success or -1 if channel was not opened.
+******************************************************************************/
+int HAL_CloseSpi(HAL_SpiDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Writes a length bytes to the SPI. \n
+ Callback function will be used to notify about the finishing transmitting.
+ (only for master spi)
+\param[in]
+ descriptor - pointer to spi descriptor
+\param[in]
+ buffer - pointer to application data buffer;
+\param[in]
+ length - number bytes for transfer;
+\return
+ -1 - spi module was not opened, there is unsent data, pointer to the data or
+ the length are zero; \n
+ 0 - on success or a number; \n
+ Number of written bytes if the synchronous method is used(callback is NULL), \n
+ only for master spi.
+******************************************************************************/
+int HAL_WriteSpi(HAL_SpiDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);
+
+/**************************************************************************//**
+\brief For master : writes a number of bytes to the spi.\n
+ Callback function will be used to notify when the activity is finished.\n
+ The read data is placed to the buffer. \n
+ For slave: reads a number of bytes from internal spi buffer and writes them \n
+ to application buffer.
+\param[in]
+ descriptor - pointer to HAL_SpiDescriptor_t structure
+\param[in]
+ buffer - pointer to the application data buffer
+\param[in]
+ length - number of bytes to transfer
+\return
+ -1 - spi module was not opened, or there is unsent data, or the pointer to
+ data or the length are NULL; \n
+ 0 - success for master; \n
+ Number of written bytes if the synchronous method is used(callback is NULL) for master \n
+ or number of read bytes from internal buffer to the application buffer for slave.
+******************************************************************************/
+int HAL_ReadSpi(HAL_SpiDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);
+
+#endif /* _SPI_H */
+// eof spi.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/uart.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/uart.h
new file mode 100644
index 00000000..a2a52d38
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/uart.h
@@ -0,0 +1,118 @@
+/************************************************************************//**
+ \file uart.h
+
+ \brief
+ UART interface
+
+ \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:
+ 17.11.2010 D. Loskutnikov - Created.
+******************************************************************************/
+#ifndef _UART_H
+#define _UART_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <usart.h>
+#include <halUart.h>
+
+/******************************************************************************
+ Functions prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Open UART
+
+\param[in] desc UART descriptor
+\return 1 if success, -1 if error
+******************************************************************************/
+int HAL_OpenUart(HAL_UartDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Close UART
+
+\param[in] desc UART descriptor
+\return
+******************************************************************************/
+int HAL_CloseUart(HAL_UartDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Send contents of buffer over UART
+
+\param[in] desc UART descriptor
+\param[in] buffer buffer to be sent
+\param[in] length buffer length
+\return number of sent bytes or -1 if error
+******************************************************************************/
+int HAL_WriteUart(HAL_UartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);
+
+/**************************************************************************//**
+\brief Copy received by UART bytes to user-supplied buffer
+
+\param[in] desc UART descriptor
+\param[in] buffer buffer to store data
+\param[in] length maximum length of buffer
+\return number of actually copied bytes or -1 if error
+******************************************************************************/
+int HAL_ReadUart(HAL_UartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);
+
+/**************************************************************************//**
+\brief Check if any bytes are pending for transmission over UART
+
+\param[in] desc descriptor
+\return -1 if error, 0 if not, 1 if yes
+******************************************************************************/
+int HAL_IsUartTxEmpty(HAL_UartDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Store UART error conditions
+
+\param[in] desc UART descriptor
+\param[in] err error condition
+******************************************************************************/
+void halUartStoreError(HAL_UartDescriptor_t *desc, uint8_t err);
+
+/**************************************************************************//**
+\brief Send byte from FIFO over UART
+
+\param[in] desc UART descriptor
+******************************************************************************/
+void halUartTx(HAL_UartDescriptor_t *desc);
+
+/**************************************************************************//**
+\brief Store received byte to FIFO
+
+\param[in] desc UART descriptor
+******************************************************************************/
+void halUartStoreRx(HAL_UartDescriptor_t *desc);
+
+/**************************************************************************//**
+\brief UART transmission complete handler
+
+\param[in] desc UART descriptor
+******************************************************************************/
+void halSigUartTransmissionComplete(HAL_UartDescriptor_t *desc);
+
+/**************************************************************************//**
+\brief UART reception complete handler
+
+\param[in] desc UART descriptor
+******************************************************************************/
+void halSigUartReceptionComplete(HAL_UartDescriptor_t *desc);
+
+/**************************************************************************//**
+\brief UART error handler
+
+\param[in] desc UART descriptor
+******************************************************************************/
+void halSigUartErrorOccurred(HAL_UartDescriptor_t *desc);
+
+#endif /* _UART_H */
+// eof uart.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/uid.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/uid.h
new file mode 100644
index 00000000..1adbaeb6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/uid.h
@@ -0,0 +1,48 @@
+/**************************************************************************//**
+ \file uid.h
+
+ \brief The header file describes the UID interface.
+
+ \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:
+ 7/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _UID_H
+#define _UID_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+// \cond
+#include <types.h>
+// \endcond
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/************************************************************//**
+\brief UID discovery.
+\param[in]
+ id - UID buffer pointer. \n
+ Attention! Memory size must equal <i> (Number of devices) * 8 bytes </i>
+\return
+ 0 - if UID of DS2411 has been found successfully; \n
+ -1 - if some error occured during UID discovery.
+****************************************************************/
+int HAL_ReadUid(uint64_t *id);
+
+#endif /* _UID_H */
+
+// eof uid.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/usart.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/usart.h
new file mode 100644
index 00000000..f81a5de7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/usart.h
@@ -0,0 +1,289 @@
+/****************************************************************************//**
+ \file usart.h
+
+ \brief The header file describes the usart interface.
+
+ \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:
+ 22/08/07 A. Khromykh - Created
+*******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+#ifndef _USART_H
+#define _USART_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+// \cond
+#include <halUsart.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define USART_FLOW_CONTROL_NONE 0
+#define USART_FLOW_CONTROL_HARDWARE (1 << 0)
+#define USART_DTR_CONTROL (1 << 1)
+
+#if defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || \
+ defined(AT90USB1287) || defined(ATMEGA128RFA1) || defined(ATXMEGA128A1) || \
+ defined(ATXMEGA256A3) || defined(ATXMEGA256D3)
+ // this define is used only by HAL.
+ #define USART_SPI_READ_MODE (1 << 4)
+ #define USART_SPI_WRITE_MODE (1 << 3)
+#endif
+// \endcond
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** \brief Usart descriptor*/
+typedef struct
+{
+ /** \brief HAL USART service field - contains variables for HAL USART module
+ internal needs */
+ HalUsartService_t service;
+ /** \brief tty - USART_CHANNEL_n to be used. "n" range depends on the platform.
+ Take a look into halUsart.h platform specific file fore more details. */
+ UsartChannel_t tty;
+ /** \brief Sets synchronous or asynchronous routine. \n
+ Must be chosen from: \n
+ USART_MODE_ASYNC \n
+ USART_MODE_RS485 (only for arm)\n
+ USART_MODE_SYNC \n */
+ UsartMode_t mode;
+ /** \brief baudrate - USART baud rate. Must be chosen from: \n
+ USART_BAUDRATE_1200 \n
+ USART_BAUDRATE_2400 \n
+ USART_BAUDRATE_4800 \n
+ USART_BAUDRATE_9600 \n
+ USART_BAUDRATE_19200 \n
+ USART_BAUDRATE_38400 \n
+ USART_SYNC_BAUDRATE_1200 \n
+ USART_SYNC_BAUDRATE_2400 \n
+ USART_SYNC_BAUDRATE_4800 \n
+ USART_SYNC_BAUDRATE_9600 \n
+ USART_SYNC_BAUDRATE_38400 \n
+ USART_SYNC_BAUDRATE_57600 \n
+ USART_SYNC_BAUDRATE_115200 \n */
+ UsartBaudRate_t baudrate;
+ /** \brief data - USART data length. Must be chosen from: \n
+ USART_DATA5 \n
+ USART_DATA6 \n
+ USART_DATA7 \n
+ USART_DATA8 \n */
+ UsartData_t dataLength;
+ /** \brief parity - USART parity mode. Must be chosen from: \n
+ USART_PARITY_NONE \n
+ USART_PARITY_EVEN \n
+ USART_PARITY_ODD \n */
+ UsartParity_t parity;
+ /** \brief stopbits - USART stop bits number. Must be chosen from: \n
+ USART_STOPBIT_1 \n
+ USART_STOPBIT_2 \n */
+ UsartStopBits_t stopbits;
+ /** \brief edge - data received edge (only for usart). Must be chosen from: \n
+ USART_EDGE_MODE_FALLING \n
+ USART_EDGE_MODE_RISING \n */
+ UsartEdgeMode_t edge;
+ /** \brief master or slave on usart (only for usart). Must be chosen from:
+ USART_CLK_MODE_MASTER \n
+ USART_CLK_MODE_SLAVE \n */
+ UsartClkMode_t syncMode;
+ /** \brief It's pointer to receive buffer. \n
+ If rxBuffer is NULL then transactions are discarded. \n
+ Size of buffer depends on user application. */
+ uint8_t *rxBuffer;
+ /** \brief length of receive buffer */
+ uint16_t rxBufferLength;
+ /** \brief It's pointer to transmit buffer. \n
+ If txBuffer is NULL then callback method is used. \n
+ If txBuffer isn't NULL then polling method is used. */
+ uint8_t *txBuffer;
+ /** \brief length of transmit buffer */
+ uint16_t txBufferLength;
+ /** \brief It's receive usart callback. \n
+ If rxCallback is NULL then polling method is used. \n
+ If rxCallback isn't NULL then callback method is used.*/
+ void (*rxCallback)(uint16_t);
+ /** \brief It's transmitting was completed usart callback. \n
+ If txBuffer isn't NULL then txCallback notify about end of bytes sending. */
+ void (*txCallback)(void);
+ #if defined(_USE_USART_ERROR_EVENT_)
+ /** \brief It's error was occurred usart callback. \n
+ If receiver error is issued then errCallback notify about issue with reason. \n
+ Reason must be: \n
+ FRAME_ERROR \n
+ DATA_OVERRUN \n
+ PARITY_ERROR */
+ void (*errCallback)(UsartErrorReason_t);
+ #endif
+ /** \brief flow control of usart. One of the defines \n
+ USART_FLOW_CONTROL_NONE, \n
+ USART_FLOW_CONTROL_HARDWARE, USART_DTR_CONTROL, it is possible to combine by logical OR. \n
+ RS485 mode needs for USART_FLOW_CONTROL_NONE. \n
+ The RTS pin is driven high when the transmitter is operating. */
+ uint8_t flowControl;
+} HAL_UsartDescriptor_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Registers usart's event handlers. Performs configuration
+of usart registers. Performs configuration of RTS, CTS and DTR pins.
+
+\param[in]
+ descriptor - pointer to HAL_UsartDescriptor_t structure
+
+\return
+ Returns positive usart descriptor on success or -1 in cases: \n
+ - bad usart channel; \n
+ - there are not enough resources; \n
+******************************************************************************/
+int HAL_OpenUsart(HAL_UsartDescriptor_t *descriptor);
+
+/*************************************************************************//**
+\brief Releases the usart channel and pins, if hardware flow control was used.
+
+\param[in]
+ descriptor - pointer to HAL_UsartDescriptor_t structure
+
+\return
+ -1 - bad descriptor or channel is already closed; \n
+ 0 - success.
+*****************************************************************************/
+int HAL_CloseUsart(HAL_UsartDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Writes a number of bytes to usart channel.
+txCallback function will be used to notify when the transmission is finished.
+If hardware flow control is used for transmitting then RTS and DTR pins will
+be tested during transmission.
+
+\param[in]
+ descriptor - pointer to HAL_UsartDescriptor_t structure;
+
+\param[in]
+ buffer - pointer to the application data buffer;
+
+\param[in]
+ length - number of bytes to transfer;
+
+\return
+ -1 - bad descriptor; \n
+ Number of bytes placed to the buffer - success.
+******************************************************************************/
+int HAL_WriteUsart(HAL_UsartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);
+
+/*************************************************************************//**
+\brief Reads a number of bytes from usart and places them to the buffer.
+
+\param[in]
+ descriptor - pointer to HAL_UsartDescriptor_t structure;
+
+\param[in]
+ buffer - pointer to the application buffer;
+
+\param[in]
+ length - number of bytes to be placed to the buffer;
+
+\return
+ -1 - bad descriptor, or bad number of bytes to read; \n
+ Number of bytes placed to the buffer - success.
+*****************************************************************************/
+int HAL_ReadUsart(HAL_UsartDescriptor_t *descriptor, uint8_t *buffer, uint16_t length);
+
+/**************************************************************************//**
+\brief Forbids the host to transmit data.
+Only USART_CHANNEL_1 can be used for hardware flow control for avr.
+
+\param[in]
+ descriptor - pointer to HAL_UsartDescriptor_t structure;
+
+\return
+ -1 - bad descriptor, bad usart, or unsupported mode; \n
+ 0 - success.
+******************************************************************************/
+int HAL_OnUsartCts(HAL_UsartDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Allows the host to transmit data.
+Only USART_CHANNEL_1 can be used for hardware flow control for avr.
+
+\param[in]
+ descriptor - pointer to HAL_UsartDescriptor_t structure;
+
+\return
+ -1 - bad descriptor, bad usart, or unsupported mode; \n
+ 0 - success.
+******************************************************************************/
+int HAL_OffUsartCts(HAL_UsartDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Reads RTS pin state.
+Only USART_CHANNEL_1 can be used for hardware flow control for avr.
+
+\param[in]
+ descriptor - pointer to HAL_UsartDescriptor_t structure;
+
+\return
+ -1 - bad descriptor, bad usart, or unsupported mode; \n
+ 0 - RTS is low level; \n
+ 1 - RTS is high level;
+******************************************************************************/
+int HAL_ReadUsartRts(HAL_UsartDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Reads DTR pin state.
+Only USART_CHANNEL_1 can be used for hardware flow control for avr.
+
+\param[in]
+ descriptor - pointer to HAL_UsartDescriptor_t structure;
+
+\return
+ -1 - bad descriptor, bad usart, or unsupported mode; \n
+ 0 - DTR is low level; \n
+ 1 - DTR is high level;
+******************************************************************************/
+int HAL_ReadUsartDtr(HAL_UsartDescriptor_t *descriptor);
+
+/**************************************************************************//**
+\brief Checks the status of tx buffer.
+
+\param[in]
+ descriptor - pointer to HAL_UsartDescriptor_t structure;
+
+\return
+ -1 - bad descriptor, no tx buffer; \n
+ 1 - tx buffer is empty; \n
+ 0 - tx buffer is not empty;
+******************************************************************************/
+int HAL_IsTxEmpty(HAL_UsartDescriptor_t *descriptor);
+
+#if defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) || defined(ATMEGA128RFA1)
+/**************************************************************************//**
+\brief Enables DTR wake up.
+
+\param[in]
+ callback - pointer to callback method;
+******************************************************************************/
+void HAL_EnableDtrWakeUp(void (* callback)(void));
+
+/**************************************************************************//**
+\brief Disables DTR wake up.
+******************************************************************************/
+void HAL_DisableDtrWakeUp(void);
+#endif
+
+#endif /* _USART_H */
+// eof usart.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/usb.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/usb.h
new file mode 100644
index 00000000..d561d8b5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/usb.h
@@ -0,0 +1,245 @@
+/**************************************************************************//**
+ \file usb.h
+
+ \brief The header file describes the usb interface
+
+ \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:
+ 17/07/08 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _USB_H
+#define _USB_H
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+// \cond
+// USB device API return values
+// Indicates the operation was successful
+#define STATUS_SUCCESS 0
+// Endpoint/device is already busy
+#define STATUS_BUSY 1
+// Operation has been aborted
+#define STATUS_ABORTED 2
+// Operation has been aborted because the device was configured
+#define STATUS_RESET 3
+
+// USB device states
+// The device is currently suspended
+#define DEVICE_SUSPENDED 0
+// USB cable is plugged into the device
+#define DEVICE_ATTACHED 1
+// Host is providing +5V through the USB cable
+#define DEVICE_POWERED 2
+// Device has been reset
+#define DEVICE_DEFAULT 3
+// The device has been given an address on the bus
+#define DEVICE_ADDRESS 5
+// A valid configuration has been selected
+#define DEVICE_CONFIGURED 6
+// \endcond
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+// transaction callback type
+typedef void (* TransferCallback_t)(void *pArg, uint8_t status, uint16_t transferred, uint16_t remaining);
+
+BEGIN_PACK
+// Usb endpoint descriptor
+typedef struct PACK
+{
+ uint8_t bLength; // Size of the descriptor in bytes
+ uint8_t bDescriptorType; // Descriptor type
+ uint8_t bEndpointAddress; // Address and direction of the endpoint
+ uint8_t bmAttributes; // Endpoint type and additional characteristics (for isochronous endpoints)
+ uint16_t wMaxPacketSize; // Maximum packet size (in bytes) of the endpoint
+ uint8_t bInterval; // Polling rate of the endpoint
+} HAL_UsbEndPointDescptr_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+\brief Registers user's request handler
+
+\param[in]
+ f - pointer to user's callback
+******************************************************************************/
+void HAL_RegisterRequestHandler(void (* f)(uint8_t *req));
+
+/**************************************************************************//**
+\brief Registers user's end of bus reset handler
+
+\param[in]
+ f - pointer to user's callback
+******************************************************************************/
+void HAL_RegisterEndOfBusResetHandler(void (* f)(void));
+
+/**************************************************************************//**
+\brief Registers user's resume handler
+
+\param[in]
+ f - pointer to user's callback
+******************************************************************************/
+void HAL_RegisterResumeHandler(void (* f)(void));
+
+/**************************************************************************//**
+\brief Registers user's suspend handler
+
+\param[in]
+ f - pointer to user's callback
+******************************************************************************/
+void HAL_RegisterSuspendHandler(void (* f)(void));
+
+/**************************************************************************//**
+\brief Configures an endpoint according to its Endpoint Descriptor.
+
+\param[in]
+ descriptor - Pointer to an Endpoint descriptor.
+******************************************************************************/
+void HAL_ConfigureEndpoint(HAL_UsbEndPointDescptr_t *descriptor);
+
+/**************************************************************************//**
+\brief Sends data through a USB endpoint. Sets up the transfer descriptor,
+writes one or two data payloads (depending on the number of FIFO bank
+for the endpoint) and then starts the actual transfer. The operation is
+complete when all the data has been sent.
+
+*If the size of the buffer is greater than the size of the endpoint
+(or twice the size if the endpoint has two FIFO banks), then the buffer
+must be kept allocated until the transfer is finished*. This means that
+it is not possible to declare it on the stack (i.e. as a local variable
+of a function which returns after starting a transfer).
+
+\param[in]
+ eptnum - Endpoint number.
+\param[in]
+ data - Pointer to a buffer with the data to send.
+\param[in]
+ size - Size of the data buffer.
+\param[in]
+ callback - Optional callback function to invoke when the transfer is complete.
+\param[in]
+ argument - Optional argument to the callback function.
+
+\return
+ STATUS_SUCCESS if the transfer has been started; otherwise, the
+ corresponding error status code.
+******************************************************************************/
+uint8_t HAL_UsbWrite(uint8_t eptnum, void *data, uint32_t size, TransferCallback_t callback, void *argument);
+
+/**************************************************************************//**
+\brief Reads incoming data on an USB endpoint This methods sets the transfer
+descriptor and activate the endpoint interrupt. The actual transfer is
+then carried out by the endpoint interrupt handler. The Read operation
+finishes either when the buffer is full, or a short packet (inferior to
+endpoint maximum size) is received.
+
+*The buffer must be kept allocated until the transfer is finished*.
+
+\param[in]
+ eptnum - Endpoint number.
+\param[in]
+ data - Pointer to a data buffer.
+\param[in]
+ size - Size of the data buffer in bytes.
+\param[in]
+ callback - Optional end-of-transfer callback function.
+\param[in]
+ argument - Optional argument to the callback function.
+
+\return
+ STATUS_SUCCESS if the read operation has been started; otherwise,
+ the corresponding error code.
+******************************************************************************/
+uint8_t HAL_UsbRead(uint8_t eptnum, void *data, uint32_t size, TransferCallback_t callback, void *argument);
+
+/**************************************************************************//**
+\brief Sets the HALT feature on the given endpoint (if not already in this state).
+
+\param[in]
+ eptnum - Endpoint number.
+******************************************************************************/
+void HAL_Halt(uint8_t eptnum);
+
+/**************************************************************************//**
+\brief Clears the Halt feature on the given endpoint.
+
+\param[in]
+ eptnum - Endpoint number.
+******************************************************************************/
+void HAL_Unhalt(uint8_t eptnum);
+
+/**************************************************************************//**
+\brief Returns the current Halt status of an endpoint.
+
+\param[in]
+ eptnum - Endpoint number.
+
+\return
+ 1 - if the endpoint is currently halted;
+ 0 - otherwise.
+******************************************************************************/
+uint8_t HAL_IsHalted(uint8_t eptnum);
+
+/**************************************************************************//**
+\brief Causes the given endpoint to acknowledge the next packet it receives with
+a STALL handshake.
+
+\param[in]
+ eptnum - Endpoint number.
+
+\return
+ STATUS_SUCCESS or STATUS_BUSY.
+******************************************************************************/
+uint8_t HAL_Stall(uint8_t eptnum);
+
+/**************************************************************************//**
+\brief Sets the device address to the given value.
+
+\param[in]
+ address - New device address.
+******************************************************************************/
+void HAL_SetAddress(uint8_t *address);
+
+/**************************************************************************//**
+\brief Sets the current device configuration.
+
+\param[in]
+ cfgnum - Configuration number to set.
+******************************************************************************/
+void HAL_SetConfiguration(uint8_t cfgnum);
+
+/**************************************************************************//**
+\brief Initializes the USB driver. This function must be called before host
+bus reset and after pull up is connected to D+. After pull up was connected
+to D+ host resets device with 100ms delay.
+
+\param[in]
+ reqMem - Memory for usb request. Memory is allocated by user.
+******************************************************************************/
+void HAL_UsbInit(uint8_t *reqMem);
+
+/**************************************************************************//**
+\brief Returns the current state of the USB device.
+
+\return
+ Device current state.
+******************************************************************************/
+uint8_t HAL_GetState(void);
+
+#endif /* _USB_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/w1.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/w1.h
new file mode 100644
index 00000000..7f26d39c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/w1.h
@@ -0,0 +1,109 @@
+/**************************************************************************//**
+ \file w1.h
+
+ \brief The header file describes the 1-Wire interface.
+
+ \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:
+ 10/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _W1_H
+#define _W1_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halW1.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define W1_ANY_FAMILY 0x00
+#define DS2411 0x01
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/*************************************************************************//**
+\brief 1-Wire search procedure with search ROM command only
+\param[in]
+ family - 8-bit family code.
+\param[in]
+ data - pointer of SRAM where the 8-bytes ROM codes returned by the
+ devices are stored. \n
+ Attention! Memory size must be equal to (Number of devices) * 8 bytes
+\param[in]
+ count - number of devices we wish to find.
+\param[in]
+ actCount - number of devices actually found.
+\return
+ W1_SUCCESS_STATUS - if at least one device has been found. \n
+ W1_NO_DEVICE_STATUS - if there are no any devices presented
+ on the bus with specified family code. \n
+ W1_INVALID_CRC - if an invalid CRC has been read during the search and
+ no devices with specified family code was found.
+******************************************************************************/
+W1Status_t HAL_SearchW1Device(uint8_t family,
+ uint8_t *data,
+ uint8_t count,
+ uint8_t *actCount);
+
+/**************************************************************************//**
+\brief 1-Wire search procedure with alarm search command only
+\param[in]
+ family - 8-bit family code.
+\param[in]
+ data - pointer of SRAM where the 8-bytes ROM codes returned by the
+ devices are stored. \n
+\param[in]
+ count - number of devices we wish to find.
+\param[in]
+ actCount - number of devices actually found.
+\return
+ W1_SUCCESS_STATUS - if at least one device has been found. \n
+ W1_NO_DEVICE_STATUS - if there are no any devices presented
+ on the bus with specified family code. \n
+ W1_INVALID_CRC - if an invalid CRC has been read during the search and
+ no devices with specified family code was found.
+******************************************************************************/
+W1Status_t HAL_AlarmSearchW1Device(uint8_t family,
+ uint8_t *data,
+ uint8_t count,
+ uint8_t *actCount);
+
+/***************************************************************************//**
+\brief Resets all devices connected to the bus.
+\return
+ 0 - there are some devices at the bus. \n
+ 1 - there are no devices at the bus.
+*******************************************************************************/
+uint8_t HAL_ResetW1(void);
+
+/***************************************************************************//**
+\brief Writes a single byte to the bus
+\param[in]
+ value - byte to write.
+*******************************************************************************/
+void HAL_WriteW1(uint8_t value);
+
+/***************************************************************************//**
+\brief Reads a single byte from the bus.
+\return
+ byte read from the bus.
+*******************************************************************************/
+uint8_t HAL_ReadW1(void);
+
+#endif /* _W1_H */
+// eof w1.h
diff --git a/digital/zigbit/bitcloud/stack/Components/HAL/include/wdtCtrl.h b/digital/zigbit/bitcloud/stack/Components/HAL/include/wdtCtrl.h
new file mode 100644
index 00000000..06d259ae
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/HAL/include/wdtCtrl.h
@@ -0,0 +1,122 @@
+/**************************************************************************//**
+ \file wdtCtrl.h
+
+ \brief The header file describes the WDT interface.
+
+ \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:
+ 10/12/07 A. Khromykh - Created
+ ******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifndef _WDTCTRL_H
+#define _WDTCTRL_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <halWdt.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+// \cond
+// an interval before WDT will expire
+#if defined(AT91SAM7X256)
+ typedef enum
+ {
+ WDT_INTERVAL_4 = 0xFFE, // 4 ms
+ WDT_INTERVAL_16 = 0xFFB, // 16 ms
+ WDT_INTERVAL_32 = 0xFF9, // 32 ms
+ WDT_INTERVAL_64 = 0xFEF, // 64 ms
+ WDT_INTERVAL_125 = 0xFDF, // 125 ms
+ WDT_INTERVAL_250 = 0xFBF, // 250 ms
+ WDT_INTERVAL_500 = 0xF7F, // 500 ms
+ WDT_INTERVAL_1000 = 0xEFF, // 1 second
+ WDT_INTERVAL_2000 = 0xDFF, // 2 seconds
+ WDT_INTERVAL_4000 = 0xBFF, // 4 seconds
+ WDT_INTERVAL_8000 = 0x7FF // 8 seconds
+ } HAL_WdtInterval_t;
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) || defined(ATMEGA128RFA1)
+ typedef enum
+ {
+ WDT_INTERVAL_16 = 0x00, // 16 ms
+ WDT_INTERVAL_32 = 0x01, // 32 ms
+ WDT_INTERVAL_64 = 0x02, // 64 ms
+ WDT_INTERVAL_125 = 0x03, // 125 ms
+ WDT_INTERVAL_250 = 0x04, // 250 ms
+ WDT_INTERVAL_500 = 0x05, // 500 ms
+ WDT_INTERVAL_1000 = 0x06, // 1 second
+ WDT_INTERVAL_2000 = 0x07, // 2 seconds
+ WDT_INTERVAL_4000 = 0x20, // 4 seconds
+ WDT_INTERVAL_8000 = 0x21 // 8 seconds
+ }HAL_WdtInterval_t;
+#endif
+// \endcond
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/***************************************************************************//**
+\brief Starts WDT within a given interval.
+
+\param[in]
+ interval - interval. Must be chosen from: \n
+ WDT_INTERVAL_16 // 16 ms \n
+ WDT_INTERVAL_32 // 32 ms \n
+ WDT_INTERVAL_64 // 64 ms \n
+ WDT_INTERVAL_125 // 125 ms \n
+ WDT_INTERVAL_250 // 250 ms \n
+ WDT_INTERVAL_500 // 500 ms \n
+ WDT_INTERVAL_1000 // 1 second \n
+ WDT_INTERVAL_2000 // 2 seconds \n
+ WDT_INTERVAL_4000 // 4 seconds \n
+ WDT_INTERVAL_8000 // 8 seconds \n
+*******************************************************************************/
+void HAL_StartWdt(HAL_WdtInterval_t interval);
+
+/***************************************************************************//**
+\brief Registers WDT fired callback.
+
+\param[in]
+ wdtCallback - pointer to the callback function.
+*******************************************************************************/
+void HAL_RegisterWdtCallback(void (*wdtCallback)(void));
+
+/******************************************************************************
+ Inline static functions section
+******************************************************************************/
+#if defined(AT91SAM7X256)
+/**************************************************************************//**
+\brief reset and reload wdt counter
+******************************************************************************/
+INLINE void HAL_ResetWdt(void)
+{
+ halResetWdt();
+}
+
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) || defined(ATMEGA128RFA1)
+/*******************************************************************//**
+\brief stops the WDT
+***********************************************************************/
+#define HAL_StopWdt() wdt_disable()
+
+/*******************************************************************//**
+\brief resets the WDT
+***********************************************************************/
+#define HAL_ResetWdt() wdt_reset()
+#endif
+
+#endif /*_WDTCTRL_H*/
+
+// eof wdtCtrl.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_ENV/include/macenvMem.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_ENV/include/macenvMem.h
new file mode 100644
index 00000000..fcc8da32
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_ENV/include/macenvMem.h
@@ -0,0 +1,114 @@
+/**************************************************************************//**
+ \file macenvMem.h
+
+ \brief MAC and PHY PIB memory.
+
+ \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:
+ 23/04/08 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _MACENVMEM_H
+#define _MACENVMEM_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <phy.h>
+#include <macAddr.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+//! PHY PIB attributes.
+typedef struct
+{
+ uint8_t channel;
+ uint32_t channelsSupported; // Just one row for current page.
+ int8_t transmitPower;
+ PHY_CcaMode_t ccaMode;
+ uint8_t currentPage;
+ uint16_t maxFrameDuration;
+ uint8_t shrDuration;
+ uint8_t symbolsPerOctet;
+} PhyPibAttr_t;
+
+//! MAC PIB attributes.
+typedef struct
+{
+ uint32_t ackWaitDuration;
+ bool associatedPanCoord;
+#ifdef _FFD_
+ bool associationPermit;
+#endif // _FFD_
+ bool autoRequest;
+ //bool battLifeExt;
+ //uint8_t battLifeExtPeriods;
+#ifdef _FFD_
+ uint8_t *beaconPayload;
+ uint8_t beaconPayloadLength;
+ //uint8_t beaconOrder;
+ //uint32_t beaconTxTime;
+ uint8_t bsn;
+#endif // _FFD_
+ ExtAddr_t coordExtAddr;
+ ShortAddr_t coordShortAddr;
+ uint8_t dsn;
+ //bool gtsPermit;
+ uint8_t maxBe;
+ uint8_t maxCsmaBackoffs;
+ //uint8_t maxFrameTotalWaitTime;
+ uint8_t maxFrameRetries;
+ uint8_t minBe;
+ //uint8_t minLifsPeriod;
+ //uint8_t minSifsPeriod;
+ PanId_t panId;
+#ifdef _FFD_
+ //bool promiscuousMode;
+#endif // _FFD_
+ uint8_t responseWaitTime;
+ bool rxOnWhenIdle;
+ bool securityEnabled;
+ ShortAddr_t shortAddr;
+#ifdef _FFD_
+ //uint8_t superframeOrder;
+ //uint8_t syncSymbolOffset;
+#endif // _FFD_
+ //bool timestampSupported;
+#ifdef _FFD_
+ //uint16_t transactionPersistenceTime;
+#endif // _FFD_
+ /************************************************************/
+ // Additional attributes. NOT described in the standard.
+ ExtAddr_t extAddr; // Device own extended address.
+ bool panCoordinator;
+ // For PanServer needs.
+#ifdef _FFD_
+ bool beaconTxEnable;
+#endif //_FFD_
+/** Duration in milliseconds of maximum length frame transferring. */
+ uint8_t maxFrameTransmissionTime;
+} MacPibAttr_t;
+
+//! MAC and PHY PIB attributes.
+typedef struct
+{
+ MacPibAttr_t macAttr;
+ PhyPibAttr_t phyAttr;
+} PIB_t;
+
+#endif /*_MACENVMEM_H*/
+
+// eof macphyPibMem.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_ENV/include/macenvPib.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_ENV/include/macenvPib.h
new file mode 100644
index 00000000..e1d9e2a9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_ENV/include/macenvPib.h
@@ -0,0 +1,444 @@
+/**************************************************************************//**
+ \file macenvPib.h
+
+ \brief MAC and PHY PIB access function prototypes.
+
+ \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:
+ 28/09/07 A. Mandychev - Created macphyPibServer.h.
+ 10/06/08 A. Mandychev - Renamed to macenvPib.h.
+ 22/12/10 A. Razinkov - Merged with macenvPibOldCs.h
+******************************************************************************/
+
+#ifndef _MACENVPIB_H
+#define _MACENVPIB_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <macphyPib.h>
+#include <macCommon.h>
+#include <macMem.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define MS_1000 1000U /* Divider from us to ms. */
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+//! PIB request's descriptor.
+typedef struct
+{
+ MACPHY_PibId_t id;
+ MACPHY_PibAttr_t attr;
+} MacPhyPibReq_t;
+
+/******************************************************************************
+ Constants section
+******************************************************************************/
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+extern PIB_t csPIB;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief Resets MACPHY PIB.
+ \param none.
+ \return none.
+******************************************************************************/
+void macenvResetPib(void);
+
+/**************************************************************************//**
+ \brief Sets MAC or PHY attribute to PIB.
+ \param[in] pibAttr - pointer to attribute structure.
+ \return SUCCESS, READ_ONLY, UNSUPPORTED_ATTRIBUTE or INVALID_PARAMETER.
+******************************************************************************/
+MAC_Status_t macenvSetPibAttr(const MacPhyPibReq_t *pibAttr);
+
+/**************************************************************************//**
+ \brief Gets MAC or PHY attribute from PIB.
+ \param[inout] pibAttr - pointer to attribute structure.
+ \return SUCCESS or UNSUPPORTED_ATTRIBUTE.
+******************************************************************************/
+MAC_Status_t macenvGetPibAttr(MacPhyPibReq_t *pibAttr);
+
+/**************************************************************************//**
+ \brief Calculates maximum frame total wait time.
+ \return maximum frame total wait time.
+******************************************************************************/
+uint32_t macenvCalculateMaxFrameTotalWaitTimeInMs(void);
+
+/******************************************************************************
+ Calculates MAC response wait time (IEEE standart: macResponseWaitTime).
+ Parameters:
+ none.
+ Return:
+ MAC response wait time.
+******************************************************************************/
+uint32_t macenvCalculateResponceWaitTimeInMs(void);
+
+/**************************************************************************//**
+ \brief Detects PHY symbol duration.
+ \param none;
+ \return PHY symbol duration.
+******************************************************************************/
+uint8_t macenvGetPhySymbolDuration(void);
+
+#ifdef _FFD_
+/**************************************************************************//**
+ \brief Calculates MAC transaction persistence time im ms.
+
+ \param[in] MAC transaction persistence time in unit periods.
+ IEEE802.15.4_2006, 7.4.2, Table 86, page 166.
+ \return time calculated (milliseconds).
+******************************************************************************/
+uint32_t macenvConvertTransPersistTimeFromUnitsToMs(uint16_t transPersTimeInUnits);
+#endif // _FFD_
+
+/**************************************************************************//**
+ \brief Gets current value for dsn parameter of PHY&MAC PIB and then increments it.
+ \return current dsn value.
+******************************************************************************/
+INLINE uint8_t macenvGetAndIncDsn(void)
+{
+ return csPIB.macAttr.dsn++;
+}
+
+/**************************************************************************//**
+ \brief Gets current value for bsn parameter of PHY&MAC PIB and then increments it.
+ \return current bsn value.
+******************************************************************************/
+#ifdef _FFD_
+INLINE uint8_t macenvGetAndIncBsn(void)
+{
+ return csPIB.macAttr.bsn++;
+}
+#endif // _FFD_
+
+/**************************************************************************//**
+ \brief Gets channel.
+ \return current channel.
+******************************************************************************/
+INLINE uint8_t macenvGetChannel(void)
+{
+ return csPIB.phyAttr.channel;
+}
+
+/**************************************************************************//**
+ \brief Gets supported channels.
+ \return supported channels.
+******************************************************************************/
+INLINE uint32_t macenvGetChannelsSupported(void)
+{
+ return csPIB.phyAttr.channelsSupported;
+}
+
+/**************************************************************************//**
+ \brief Gets tx power.
+ \return current tx power.
+******************************************************************************/
+INLINE int8_t macenvGetTxPower(void)
+{
+ return csPIB.phyAttr.transmitPower;
+}
+
+/**************************************************************************//**
+ \brief Gets CCA mode.
+ \return current CCA mode.
+******************************************************************************/
+INLINE PHY_CcaMode_t macenvGetCcaMode(void)
+{
+ return csPIB.phyAttr.ccaMode;
+}
+
+/**************************************************************************//**
+ \brief Gets current page.
+ \return current page.
+******************************************************************************/
+INLINE uint8_t macenvGetCurrentPage(void)
+{
+ return csPIB.phyAttr.currentPage;
+}
+
+/**************************************************************************//**
+ \brief Gets max CSMA backoffs.
+ \return max CSMA backoffs.
+******************************************************************************/
+INLINE uint8_t macenvGetMaxCsmaBackoffs(void)
+{
+ return csPIB.macAttr.maxCsmaBackoffs;
+}
+
+/**************************************************************************//**
+ \brief Gets PAN ID.
+ \return PAN ID.
+******************************************************************************/
+INLINE PanId_t macenvGetPanId(void)
+{
+ return csPIB.macAttr.panId;
+}
+
+/**************************************************************************//**
+ \brief Gets short address.
+ \return short address.
+******************************************************************************/
+INLINE ShortAddr_t macenvGetShortAddr(void)
+{
+ return csPIB.macAttr.shortAddr;
+}
+
+/**************************************************************************//**
+ \brief Gets min BE.
+ \return min BE.
+******************************************************************************/
+INLINE uint8_t macenvGetMinBe(void)
+{
+ return csPIB.macAttr.minBe;
+}
+
+/**************************************************************************//**
+ \brief Gets max frame retries.
+ \return max frame retries.
+******************************************************************************/
+INLINE uint8_t macenvGetMaxFrameRetries(void)
+{
+ return csPIB.macAttr.maxFrameRetries;
+}
+
+/**************************************************************************//**
+ \brief Gets rx on when idle parameter.
+ \return rx on when idle parameter.
+******************************************************************************/
+INLINE bool macenvGetRxOnWhenIdle(void)
+{
+ return csPIB.macAttr.rxOnWhenIdle;
+}
+
+/**************************************************************************//**
+ \brief Gets coordinator short address.
+ \return coordinator short address.
+******************************************************************************/
+INLINE ShortAddr_t macenvGetCoordShortAddr(void)
+{
+ return csPIB.macAttr.coordShortAddr;
+}
+
+/**************************************************************************//**
+ \brief Gets pointer to coordinator extended address.
+ \return pointer to coordinator extended address.
+******************************************************************************/
+INLINE ExtAddr_t* macenvGetCoordExtAddr(void)
+{
+ return &csPIB.macAttr.coordExtAddr;
+}
+
+/**************************************************************************//**
+ \brief Gets response wait time.
+ \return response wait time.
+******************************************************************************/
+INLINE uint8_t macenvGetResponseWaitTime(void)
+{
+ return csPIB.macAttr.responseWaitTime;
+}
+
+/**************************************************************************//**
+ \brief Gets PAN coordinator parameter.
+ \return PAN coordinator parameter.
+******************************************************************************/
+INLINE bool macenvGetPanCoordinator(void)
+{
+ return csPIB.macAttr.panCoordinator;
+}
+
+/**************************************************************************//**
+ \brief Gets association permit parameter.
+ \return association permit parameter.
+******************************************************************************/
+#ifdef _FFD_
+INLINE bool macenvGetAssociationPermit(void)
+{
+ return csPIB.macAttr.associationPermit;
+}
+#endif
+
+/**************************************************************************//**
+ \brief Gets beacon payload pointer.
+ \return beacon payload pointer.
+******************************************************************************/
+#ifdef _FFD_
+INLINE uint8_t* macenvGetBeaconPayload(void)
+{
+ return csPIB.macAttr.beaconPayload;
+}
+#endif
+
+/**************************************************************************//**
+ \brief Gets beacon payload length.
+ \return beacon payload length.
+******************************************************************************/
+#ifdef _FFD_
+INLINE uint8_t macenvGetBeaconPayloadLength(void)
+{
+ return csPIB.macAttr.beaconPayloadLength;
+}
+#endif
+
+/**************************************************************************//**
+ \brief Gets beacon tx enable parameter.
+ \return beacon tx enable parameter.
+******************************************************************************/
+#ifdef _FFD_
+INLINE bool macenvGetBeaconTxEnable(void)
+{
+ return csPIB.macAttr.beaconTxEnable;
+}
+#endif
+
+/**************************************************************************//**
+ \brief Gets auto request parameter.
+ \return auto request parameter.
+******************************************************************************/
+INLINE bool macenvGetAutoRequest(void)
+{
+ return csPIB.macAttr.autoRequest;
+}
+
+/**************************************************************************//**
+ \brief Gets associated PAN coordinator parameter.
+ \return associated PAN coordinator parameter.
+******************************************************************************/
+INLINE bool macenvGetAssociatedPanCoord(void)
+{
+ return csPIB.macAttr.associatedPanCoord;
+}
+
+/**************************************************************************//**
+ \brief Sets channel.
+ \param channel - channel to set.
+ \return none.
+******************************************************************************/
+INLINE void macenvSetChannel(uint8_t channel)
+{
+ csPIB.phyAttr.channel = channel;
+}
+
+/**************************************************************************//**
+ \brief Sets short address.
+ \param shortAddr - short address.
+ \return none.
+******************************************************************************/
+INLINE void macenvSetShortAddr(ShortAddr_t shortAddr)
+{
+ csPIB.macAttr.shortAddr = shortAddr;
+}
+
+/**************************************************************************//**
+ \brief Sets associated pan coordinator parameter.
+ \param associatedPanCoord.
+ \return none.
+******************************************************************************/
+INLINE void macenvSetAssociatedPanCoord(bool associatedPanCoord)
+{
+ csPIB.macAttr.associatedPanCoord = associatedPanCoord;
+}
+
+/**************************************************************************//**
+ \brief Sets coordinator short address.
+ \param coordShortAddr - coordinator short address.
+ \return none.
+******************************************************************************/
+INLINE void macenvSetCoordShortAddr(ShortAddr_t coordShortAddr)
+{
+ csPIB.macAttr.coordShortAddr = coordShortAddr;
+}
+
+/**************************************************************************//**
+ \brief Sets coordinator ext address.
+ \param coordExtAddr - coordinator ext address.
+ \return none.
+******************************************************************************/
+INLINE void macenvSetCoordExtAddr(ExtAddr_t* coordExtAddr)
+{
+ COPY_EXT_ADDR(csPIB.macAttr.coordExtAddr, *coordExtAddr);
+}
+
+/**************************************************************************//**
+ \brief Sets PAN ID.
+ \param panId - PAN ID.
+ \return none.
+******************************************************************************/
+INLINE void macenvSetPanId(PanId_t panId)
+{
+ csPIB.macAttr.panId = panId;
+}
+
+/**************************************************************************//**
+ \brief Sets PAN coordinator parameter.
+ \param panCoordinator - PAN coordinator parameter.
+ \return none.
+******************************************************************************/
+INLINE void macenvSetPanCoordinator(bool panCoordinator)
+{
+ csPIB.macAttr.panCoordinator = panCoordinator;
+}
+
+/**************************************************************************//**
+ \brief Sets beacon payload length.
+ \param beaconTxEnable - beacon tx enable parameter.
+ \return none.
+******************************************************************************/
+#ifdef _FFD_
+INLINE void macenvSetBeaconTxEnable(bool beaconTxEnable)
+{
+ csPIB.macAttr.beaconTxEnable = beaconTxEnable;
+}
+#endif
+
+/******************************************************************************
+ \brief Converts time in Microseconds to time in Milliseconds.
+ \param[in] time in microseconds.
+ \return time in milliseconds
+******************************************************************************/
+INLINE uint32_t convertTimeFromUsToMs(uint32_t timeInUs)
+{
+ return (timeInUs / MS_1000);
+}
+
+/**************************************************************************//**
+ \brief Sets max frame transmission time attribute value.
+
+ \param[in] time - new max frame transmission time value.
+ \return None.
+ ******************************************************************************/
+INLINE void MAC_SetMaxFrameTransmissionTime(const uint8_t time)
+{
+ csPIB.macAttr.maxFrameTransmissionTime = time;
+}
+
+/**************************************************************************//**
+ \brief Gets max frame transmission time attribute value.
+
+ \return Max frame transmission time attribute value.
+ ******************************************************************************/
+INLINE uint8_t MAC_GetMaxFrameTransmissionTime(void)
+{
+ return csPIB.macAttr.maxFrameTransmissionTime;
+}
+
+#endif /* _MACENVPIB_H */
+
+// eof macenvPib.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwd.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwd.h
new file mode 100644
index 00000000..2e3c47cb
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwd.h
@@ -0,0 +1,34 @@
+/**************************************************************************//**
+ \file machwd.h
+
+ \brief IEEE 802.15.4-2006 (hardware dependent part) public headers files' union.
+
+ \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:
+ 24/05/07 A. Mandychev - Created.
+ 26/09/07 A. Mandychev - Redesigned.
+******************************************************************************/
+
+#ifndef _MACHWD_H
+#define _MACHWD_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <machwdService.h>
+#include <machwdData.h>
+#include <machwdSetTrx.h>
+#include <machwdSet.h>
+#include <machwdEd.h>
+#include <machwdReset.h>
+
+#endif /* _MACHWD_H */
+
+// eof machwd.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdBatMon.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdBatMon.h
new file mode 100644
index 00000000..240228f9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdBatMon.h
@@ -0,0 +1,50 @@
+/**************************************************************************//**
+ \file machwdBatMon.h
+
+ \brief Prototypes of battery monitor functions and corresponding types.
+
+ \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:
+ 16/04/08 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _MACHWDBATMON_H
+#define _MACHWDBATMON_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <rfBattery.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+//! Redefenition of battery request function name.
+#define MACHWD_BatMonReq RF_BatteryMonReq
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+//! Redefenition of battery request structure.
+typedef RF_BatteryMonReq_t MACHWD_BatMonReq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief Sets battery monitor voltage.
+ \param reqParams - request parameters structure pointer.
+ \return none.
+******************************************************************************/
+void MACHWD_BatMonReq(MACHWD_BatMonReq_t *reqParams);
+
+#endif /*_MACHWDBATMON_H*/
+
+// eof machwdBatMon.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdCalibration.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdCalibration.h
new file mode 100644
index 00000000..38e231c4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdCalibration.h
@@ -0,0 +1,52 @@
+/**************************************************************************//**
+ \file machwdCalib.h
+
+ \brief MACHWD interface for PLL calibration and filter tuning.
+
+ \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:
+ 2011-10-04 Max Gekk - Created.
+ Last change:
+ $Id: machwdCalibration.h 18970 2011-10-21 12:48:41Z mgekk $
+ ******************************************************************************/
+#if !defined _MACHWDCALIB_H
+#define _MACHWDCALIB_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <rfCalibration.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Redefenition of RF calibration request function name. **/
+#define MACHWD_CalibrationReq RF_CalibrationReq
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Redefenition of random generation request structure. **/
+typedef RF_CalibrationReq_t MACHWD_CalibrationReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Request to perform PLL and FTN calibration.
+
+ \param[in] reqParams - pointer to calibration parameters - callback and
+ confirmation status.
+ \return None.
+ ******************************************************************************/
+void MACHWD_CalibrationReq(MACHWD_CalibrationReq_t *reqParams);
+
+#endif /* _MACHWDCALIB_H */
+/** eof machwdCalib.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdData.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdData.h
new file mode 100644
index 00000000..fa4e1c86
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdData.h
@@ -0,0 +1,92 @@
+/*************************************************************************//**
+ \file machwdData.h
+
+ \brief MACHWD data types types and function prototypes.
+
+ \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:
+ 26/09/07 A. Mandychev - Created.
+*****************************************************************************/
+
+#ifndef _MACHWDDATA_H
+#define _MACHWDDATA_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <machwdService.h>
+#include <machwdSetTrx.h>
+#include <macFrame.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+//! Set of frame transmission statuses.
+typedef enum
+{
+ MACHWD_DATA_PENDING_DATA_STATUS,
+ MACHWD_CHANNEL_ACCESS_FAIL_DATA_STATUS,
+ MACHWD_NO_ACK_DATA_STATUS,
+ MACHWD_SUCCESS_DATA_STATUS,
+} MACHWD_DataStatus_t;
+
+//! MACHWD data confirm structure.
+typedef struct
+{
+ //! Frame transmission status.
+ MACHWD_DataStatus_t status;
+} MACHWD_DataConf_t;
+
+//! MACHWD data request structure.
+typedef struct
+{
+ //! Service field - for internal needs.
+ MACHWD_Service_t service;
+ //! Description of the frame to be transmitted.
+ MAC_FrameDescr_t frameDescr;
+ //! Command to set trx state after transmitting frame.
+ MACHWD_TrxCmd_t trxCmdToSetAfterTransmitTrxState;
+ //! MACHWD data transmission confirm callback function's pointer.
+ void (*MACHWD_DataConf)(MACHWD_DataConf_t *confParams);
+ //! MACHWD confirm structure.
+ MACHWD_DataConf_t confirm;
+} MACHWD_DataReq_t;
+
+//! MACHWD data indication structure.
+typedef struct
+{
+ //! Received frame description.
+ MAC_FrameDescr_t frameDescr;
+} MACHWD_DataInd_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief MACHWD data request primitive's prototype.
+ \param reqParams - MACHWD data request's parameters' structure pointer.
+ \return none.
+******************************************************************************/
+void MACHWD_DataReq(MACHWD_DataReq_t *reqParams);
+
+/**************************************************************************//**
+ \brief MACHWD data indication primitive's prototype.
+ \param indParams - MACHWD data indication parameters' structure pointer.
+ \return none.
+******************************************************************************/
+extern void MACHWD_DataInd(MACHWD_DataInd_t *indParams);
+
+#endif /* _MACHWDDATA_H */
+
+// eof machwdData.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdEd.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdEd.h
new file mode 100644
index 00000000..9cd339f7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdEd.h
@@ -0,0 +1,61 @@
+/**************************************************************************//**
+ \file machwdEd.h
+
+ \brief MACHWD energy detection types and function prototypes.
+
+ \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:
+ 24/05/07 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _MACHWDED_H
+#define _MACHWDED_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <machwdService.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+//! MACHWD energy detection confirm structure.
+typedef struct
+{
+ PHY_EnergyLevel_t energyLevel;
+} MACHWD_EdConf_t;
+
+//! MACHWD energy detection request structure.
+typedef struct
+{
+ MACHWD_Service_t service;
+ // Callback pointer.
+ void (*MACHWD_EdConf)(MACHWD_EdConf_t *confParams);
+ // Confirm parameters.
+ MACHWD_EdConf_t confirm;
+} MACHWD_EdReq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief Detects energy level on channel.
+ \param reqParams - MACHWD energy detection request structure pointer.
+ \return none.
+******************************************************************************/
+void MACHWD_EdReq(MACHWD_EdReq_t *reqParams);
+
+#endif /* _MACHWDED_H */
+
+// eof machwdEd.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdEncrypt.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdEncrypt.h
new file mode 100644
index 00000000..4da3710b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdEncrypt.h
@@ -0,0 +1,51 @@
+/**************************************************************************//**
+ \file machwdEncrypt.h
+
+ \brief Prototypes of ecnryption functions and corresponding types.
+ Note that encryption is supported only for RF231 and RF212.
+
+ \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:
+ 18/01/08 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _MACHWDENCRYPT_H
+#define _MACHWDENCRYPT_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <rfEncrypt.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+//! Redefenition of encryption request function name.
+#define MACHWD_EncryptReq RF_EncryptReq
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+//! Redefenition of encryption request structure.
+typedef RF_EncryptReq_t MACHWD_EncryptReq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief Executes AES command.
+ \param reqParams - request parameters structure pointer.
+ \return none.
+******************************************************************************/
+void MACHWD_EncryptReq(MACHWD_EncryptReq_t *reqParams);
+
+#endif /*_MACHWDENCRYPT_H*/
+
+// eof machwdEncrypt.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdMem.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdMem.h
new file mode 100644
index 00000000..f094f0c5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdMem.h
@@ -0,0 +1,41 @@
+/******************************************************************************
+ \file machwdMem.h
+
+ \brief MACHWD memory type.
+
+ \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).
+
+ \brief
+ History:
+ 24/04/08 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _MACHWDMEM_H
+#define _MACHWDMEM_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <macBuffers.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef struct
+{
+ FrameRxBufferState_t rxBufferState;
+} MachwdMem_t;
+
+#endif /*_MACHWDMEM_H*/
+
+// eof machwdMem.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdReset.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdReset.h
new file mode 100644
index 00000000..d403355a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdReset.h
@@ -0,0 +1,32 @@
+/**************************************************************************//**
+ \file machwdReset.h
+
+ \brief MACHWD reset types and function prototypes.
+
+ \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:
+ 26/09/07 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _MACHWDRESET_H
+#define _MACHWDRESET_H
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief Resets MAC_HWD_PHY layer.
+ \return none.
+******************************************************************************/
+void MACHWD_Reset(void);
+
+#endif /* _MACHWDRESET_H */
+
+// eof machwdReset.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdRnd.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdRnd.h
new file mode 100644
index 00000000..ab551e89
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdRnd.h
@@ -0,0 +1,58 @@
+/**************************************************************************//**
+ \file machwdRnd.h
+
+ \brief MACHWD random generation types and function prototypes.
+
+ \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:
+ 08/04/08 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _MACHWDRND_H
+#define _MACHWDRND_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <rfRandom.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+//! Redefenition of random generation request function name.
+#define MACHWD_RndReq RF_RandomReq
+//! Redefenition of random seq generation request function name .
+#define MACHWD_RndSeqReq RF_RandomSeqReq
+/******************************************************************************
+ Types section
+******************************************************************************/
+//! Redefenition of random generation request structure.
+typedef RF_RandomReq_t MACHWD_RndReq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief Requests random value.
+ \param reqParams - request parameters structure pointer.
+ \return none.
+******************************************************************************/
+void MACHWD_RndReq(MACHWD_RndReq_t *reqParams);
+
+/**************************************************************************//**
+ \brief Requests random seq.
+ \param reqParams - request parameters structure pointer.
+ \return none.
+******************************************************************************/
+void MACHWD_RndSeqReq(MACHWD_RndReq_t *reqParams);
+
+#endif /*_MACHWDRND_H*/
+
+// eof machwdRnd.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdService.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdService.h
new file mode 100644
index 00000000..76f96b46
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdService.h
@@ -0,0 +1,57 @@
+/**************************************************************************//**
+ \file machwdService.h
+
+ \brief Describes types' declarations for internal needs.
+
+ \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:
+ 30/05/07 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _MACHWDSERVISE_H
+#define _MACHWDSERVISE_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <macCommon.h>
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+//! Set of MACHWD request identifiers.
+enum
+{
+ MACHWD_TX_DATA_REQ_ID,
+ MACHWD_SET_TRX_STATE_REQ_ID,
+ MACHWD_SET_REQ_ID,
+ MACHWD_ED_REQ_ID,
+#ifdef _RF_AES_
+ MACHWD_ENCRYPT_REQ_ID,
+#endif
+#ifdef _RF_BAT_MON_
+ MACHWD_BAT_MON_REQ_ID,
+#endif
+#ifdef _RF_RND_
+ MACHWD_RND_REQ_ID,
+ MACHWD_RND_REQ_F_ID,
+#endif
+#ifdef _RF_CALIBRATION_
+ MACHWD_CALIBRATION_REQ_ID
+#endif
+};
+
+//! Inherited service structure.
+typedef MAC_Service_t MACHWD_Service_t;
+
+#endif /* _MACHWDSERVISE_H */
+
+// eof machwdService.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdSet.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdSet.h
new file mode 100644
index 00000000..7b1909e3
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdSet.h
@@ -0,0 +1,94 @@
+/**************************************************************************//**
+ \file machwdSet.h
+
+ \brief MACHWD set types and function prototypes.
+
+ \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:
+ 26/09/07 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _MACHWDSET_H
+#define _MACHWDSET_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <inttypes.h>
+#include <machwdService.h>
+#include <macphyPib.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+//! Start point for Atmel own identifier counting.
+#define MACHWD_ATMEL_RESERVED_ID 0xF0
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+//! MACHWD PIB identifiers.
+typedef enum
+{
+ // PHY id.
+ MACHWD_PIB_CURRENT_CHANNEL_ID = PHY_PIB_CURRENT_CHANNEL_ID,
+ MACHWD_PIB_TRANSMIT_POWER_ID = PHY_PIB_TRANSMIT_POWER_ID,
+ MACHWD_PIB_CCA_MODE_ID = PHY_PIB_CCA_MODE_ID,
+ MACHWD_PIB_CURRENT_PAGE_ID = PHY_PIB_CURRENT_PAGE_ID,
+ // MAC id.
+ MACHWD_PIB_MAX_CSMA_BACKOFFS_ID = MAC_PIB_MAX_CSMA_BACKOFFS_ID,
+ MACHWD_PIB_PANID_ID = MAC_PIB_PANID_ID,
+ MACHWD_PIB_SHORT_ADDR_ID = MAC_PIB_SHORT_ADDR_ID,
+ MACHWD_PIB_MIN_BE_ID = MAC_PIB_MIN_BE_ID,
+ MACHWD_PIB_MAX_FRAME_RETRIES_ID = MAC_PIB_MAX_FRAME_RETRIES_ID,
+ MACHWD_PIB_EXT_ADDR_ID = MAC_PIB_EXT_ADDR_ID,
+ // Additional id for software needs.
+ MACHWD_PIB_RF_IRQ_DISABLE_ID = MACHWD_ATMEL_RESERVED_ID,
+ MACHWD_PIB_BEACON_RX_MODE_ID = MACHWD_ATMEL_RESERVED_ID + 1,
+ // Additional id for hardware needs.
+ MACHWD_PIB_PAN_COORDINATOR_ID = MACHWD_ATMEL_RESERVED_ID + 2,
+} MACHWD_PibId_t;
+
+//! MACHWD PIB attribute type.
+typedef union
+{
+ MAC_PibAttr_t macPib;
+ PHY_PibAttr_t phyPib;
+ bool panCoordinator;
+ bool rfIrqDisable;
+ bool beaconRxMode;
+} MACHWD_PibAttr_t;
+
+//! MACHWD set request structure.
+typedef struct
+{
+ //! Service field - for internal needs.
+ MACHWD_Service_t service;
+ //! MACHWD PIB identifier.
+ MACHWD_PibId_t id;
+ //! MACHWD PIB attribute.
+ MACHWD_PibAttr_t attr;
+ // MACHWD set confirm callback function's pointer.
+ void (*MACHWD_SetConf)(void);
+} MACHWD_SetReq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief Sets MACHWD attributes.
+ \param reqParams - MACHWD set request structure pointer.
+ \return none.
+******************************************************************************/
+void MACHWD_SetReq(MACHWD_SetReq_t *reqParams);
+
+#endif /* _MACHWDSET_H */
+
+// eof machwdSet.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdSetTrx.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdSetTrx.h
new file mode 100644
index 00000000..7c0ac92c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWD_PHY/include/machwdSetTrx.h
@@ -0,0 +1,65 @@
+/**************************************************************************//**
+ \file machwdSetTrx.h
+
+ \brief MACHWD transcivier control types and function prototypes.
+
+ \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:
+ 26/09/07 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _MACHWDSETTRX_H
+#define _MACHWDSETTRX_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <machwdService.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+//! Set of commands to control radio transcivier.
+typedef enum
+{
+ MACHWD_TX_ON_CMD,
+ MACHWD_RX_ON_CMD,
+ MACHWD_TRX_OFF_CMD,
+} MACHWD_TrxCmd_t;
+
+//! Set TRX state request structure.
+typedef struct
+{
+ //! Service field - for internal needs.
+ MACHWD_Service_t service;
+ //! Command to chnage the trancivier current state.
+ MACHWD_TrxCmd_t trxCmd;
+ // MACHWD set trx state confirm callback function's pointer.
+ void (*MACHWD_SetTrxStateConf)(void);
+} MACHWD_SetTrxStateReq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief Set trx state.
+ \param reqParams - MACHWD set trx state request structure pointer.
+ \return none.
+******************************************************************************/
+void MACHWD_SetTrxStateReq(MACHWD_SetTrxStateReq_t *reqParams);
+
+#endif /* _MACHWDSETTRX_H */
+
+// eof machwdSetTrx.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiAssociateHandler.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiAssociateHandler.h
new file mode 100644
index 00000000..85c733e6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiAssociateHandler.h
@@ -0,0 +1,101 @@
+/******************************************************************************
+ \file machwiAssociateHandler.h
+
+ \brief machwiAssociateHandler header file.
+
+ \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:
+ 15/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACHWIASSOCIATEHANDLER_H
+#define _MACHWIASSOCIATEHANDLER_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <machwiManager.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum
+{
+ MACHWI_IDLE_ASSOCIATE_STATE,
+ MACHWI_SET_CHANNEL_ASSOCIATE_STATE,
+ MACHWI_SET_PAGE_ASSOCIATE_STATE,
+ MACHWI_SET_COORD_PAN_ID_ASSOCIATE_STATE,
+ MACHWI_SET_SHORT_ADDR_ASSOCIATE_STATE,
+ MACHWI_CLR_RX_ON_WHEN_IDLE_ASSOCIATE_STATE,
+ MACHWI_TX_ASSOCIATE_REQUEST_ASSOCIATE_STATE,
+ MACHWI_WAIT_TX_DATA_REQUEST_ASSOCIATE_STATE,
+ MACHWI_TX_DATA_REQUEST_ASSOCIATE_STATE,
+ MACHWI_WAIT_ASSOCIATE_RESP_FRAME_ASSOCIATE_STATE,
+ MACHWI_SET_TRX_OFF_ASSOCIATE_STATE,
+} MachwiAssociateState_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ Checks associate request parameters, sends associate and data request commands.
+ Waits for the responce.
+ Parameters:
+ none.
+ Returns:
+ current status of operation (success or "in progress").
+******************************************************************************/
+MachwiHandlerResult_t machwiAssociateReqHandler(void);
+
+#ifdef _FFD_
+/******************************************************************************
+ Checks associate responce parameters, and puts the responce to the transaction
+ queue.
+ Parameters:
+ none.
+ Returns:
+ current status of operation (success or "in progress").
+******************************************************************************/
+MachwiHandlerResult_t machwiAssociateRespHandler(void);
+#endif //_FFD_
+
+/******************************************************************************
+ Indicates, that associate response command frame was received.
+ Parameters:
+ associateRespDescr - associate response command frame description.
+ Returns:
+ none.
+******************************************************************************/
+void machwiAssociateRespInd(MAC_FrameDescr_t *associateRespDescr);
+
+#ifdef _FFD_
+/******************************************************************************
+ Indicates, that associate request command frame was received.
+ Parameters:
+ associateReqDescr - associate request command frame description.
+ Returns:
+ none.
+******************************************************************************/
+void machwiAssociateReqInd(MAC_FrameDescr_t *associateReqDescr);
+#endif //_FFD_
+
+/******************************************************************************
+ Resets associate handler.
+ Parameters:
+ none.
+ Returns:
+ none.
+******************************************************************************/
+void machwiResetAssociateHandler(void);
+
+
+#endif /* _MACHWIASSOCIATEHANDLER_H */
+
+// eof machwiAssociateHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiBeaconHandler.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiBeaconHandler.h
new file mode 100644
index 00000000..3f2372d1
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiBeaconHandler.h
@@ -0,0 +1,50 @@
+/******************************************************************************
+ \file machwiBeaconHandler.h
+
+ \brief Declares beacon routine functions.
+
+ \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).
+
+ \intrenal
+ History:
+ 01/07/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACHWIBEACONHANDLER_H
+#define _MACHWIBEACONHANDLER_H
+#ifdef _FFD_
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <macFrame.h>
+
+/******************************************************************************
+ Global variables.
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/******************************************************************************
+ Implementations section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief Forms and sends MAC Beacon frame.
+
+ \param none.
+ \return none.
+******************************************************************************/
+void machwiSendBeacon(void);
+
+#endif // _FFD_
+#endif //_MACHWIBEACONHANDLER_H
+
+// eof machwiBeaconHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiDataHandler.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiDataHandler.h
new file mode 100644
index 00000000..76b69564
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiDataHandler.h
@@ -0,0 +1,65 @@
+/******************************************************************************
+ \file machwiDataHandler.h
+
+ \brief machwiDataHandler header file.
+
+ \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:
+ 15/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACHWIDATAHANDLER_H
+#define _MACHWIDATAHANDLER_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <machwd.h>
+#include <machwiManager.h>
+#include <macCommon.h>
+#include <macData.h>
+
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ Checks data request parameters, fills frame descriptor and passes request
+ further.
+ Parameters:
+ none.
+ Returns:
+ current status of operation (success or "in progress").
+******************************************************************************/
+MachwiHandlerResult_t machwiDataReqHandler(void);
+
+/******************************************************************************
+ Converts hwd data transmission status to IEEE802.15.4 status.
+ Parameters:
+ status - hwd data transmission status.
+ Returns:
+ IEEE802.15.4 data transmission status.
+******************************************************************************/
+MAC_Status_t machwiConvertmachwdDataConfirmTypes(MACHWD_DataStatus_t hwdStatus);
+
+/******************************************************************************
+ Fiils data frame fields.
+ Parameters:
+ frameDescr - pointer to frme descriptor to be filled.
+ dataReq - pointer to data request params.
+ Returns:
+ none.
+******************************************************************************/
+void machwiPrepareDataFrame(MAC_FrameDescr_t *frameDescr, MAC_DataReq_t *dataReq);
+
+
+#endif /* _MACHWIDATAHANDLER_H */
+
+// eof machwiDataHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiDisassociateHandler.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiDisassociateHandler.h
new file mode 100644
index 00000000..fa04e5c7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiDisassociateHandler.h
@@ -0,0 +1,98 @@
+/******************************************************************************
+ \file machwiDisassociate.h
+
+ \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:
+ 14/08/07 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _MACHWIDISASSOCIATE_H
+#define _MACHWIDISASSOCIATE_H
+#ifdef _MAC_DISASSOCIATE_
+
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <macFrame.h>
+#include <macDisassociate.h>
+#include <machwiManager.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum
+{
+ MACHWI_IDLE_DISASSOCIATE_STATE,
+ MACHWI_SET_PAN_ID_DISASSOCIATE_STATE,
+ MACHWI_SET_SHORT_ADDR_DISASSOCIATE_STATE,
+} MachwiDisassociateState_t;
+
+/******************************************************************************
+ Constants section
+******************************************************************************/
+
+/******************************************************************************
+ External variables
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ Resets disassociate component.
+ Parameters:
+ none.
+ Returns:
+ none.
+******************************************************************************/
+void machwiResetDisassociateHandler(void);
+
+/******************************************************************************
+ Checks disassociation request parameters, sends disassociation notification
+ command.
+ Parameters:
+ none.
+ Returns:
+ current status of operation (success or "in progress").
+******************************************************************************/
+MachwiHandlerResult_t machwiDisassociateReqHandler(void);
+
+/******************************************************************************
+ Sets disassociation notification command fields.
+ Parameters:
+ frameDescr - pointer to frame descriptor which will be set.
+ disassociateReq - pointer to disassociation notification command
+ parameters.
+ Returns:
+ none.
+******************************************************************************/
+void machwiPrepareDisassociateNotifCmdFrame(
+ MAC_FrameDescr_t *frameDescr,
+ MAC_DisassociateReq_t *disassociateReq);
+
+/******************************************************************************
+ Indicates, that disassociation notification command frame was received.
+ Parameters:
+ frameDescr - frame description.
+ Returns:
+ none.
+******************************************************************************/
+void machwiDisassociateNotifInd(MAC_FrameDescr_t *frameDescr);
+
+#endif // _MAC_DISASSOCIATE_
+
+#endif /* _MACHWIDISASSOCIATE_H */
+
+// eof machwiDisassociate.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiHwdReqMemPool.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiHwdReqMemPool.h
new file mode 100644
index 00000000..4f3c9a22
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiHwdReqMemPool.h
@@ -0,0 +1,48 @@
+/******************************************************************************
+ \file machwiHwdReqMemPool.h
+
+ \brief Types and constants declaration for machwi memory management for machwd
+ requests.
+
+ \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:
+ 19/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACHWIHWDREQMEMPOOL_H
+#define _MACHWIHWDREQMEMPOOL_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <machwd.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/******************************************************************************
+ Union of possible request types for the requests to machwd module.
+******************************************************************************/
+typedef union
+{
+ MACHWD_DataReq_t data;
+ MACHWD_SetTrxStateReq_t setTrxState;
+ MACHWD_SetReq_t set;
+ MACHWD_EdReq_t ed;
+} MachwiHwdReqDescr_t;
+
+#endif //_MACHWIHWDREQMEMPOOL_H
+
+// eof machwiHwdReqMemPool.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiManager.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiManager.h
new file mode 100644
index 00000000..1c897c1a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiManager.h
@@ -0,0 +1,234 @@
+/******************************************************************************
+ \file machwiManager.h
+
+ \brief Main MAC layer requests' manager header file.
+
+ \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:
+ 15/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACHWIMANAGER_H
+#define _MACHWIMANAGER_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <macAssociate.h>
+#include <macOrphan.h>
+#include <macCommStatus.h>
+#include <macData.h>
+#include <macAssociate.h>
+#include <macDisassociate.h>
+#include <macPoll.h>
+#include <macPurge.h>
+#include <macReset.h>
+#include <macRxEnable.h>
+#include <macStart.h>
+#include <macScan.h>
+#include <macSync.h>
+#include <macSetGet.h>
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+/******************************************************************************
+ Status of current operation which could be returned from particular handler.
+******************************************************************************/
+typedef enum
+{
+ MACHWI_SUCCESS_HNDLR_RESULT,
+ MACHWI_IN_PROGRESS_HNDLR_RESULT,
+} MachwiHandlerResult_t;
+
+/******************************************************************************
+ Possible states of machwiManager.
+******************************************************************************/
+typedef enum // machwiManager possible states.
+{
+ MACHWI_IDLE_STATE,
+ MACHWI_SET_REQ_STATE,
+ MACHWI_GET_REQ_STATE,
+ MACHWI_HARD_RESET_REQ_STATE,
+ MACHWI_SOFT_RESET_REQ_STATE,
+ MACHWI_SCAN_REQ_STATE,
+#ifdef _FFD_
+ MACHWI_START_REQ_STATE,
+#endif //_FFD_
+ MACHWI_ASSOCIATE_REQ_STATE,
+#ifdef _FFD_
+ MACHWI_ASSOCIATE_RESP_STATE,
+#endif //_FFD_
+ MACHWI_DISASSOCIATE_REQ_STATE,
+ MACHWI_RX_ENABLE_REQ_STATE,
+#ifdef _FFD_
+ MACHWI_ORPHAN_RESP_STATE,
+#endif //_FFD_
+ MACHWI_POLL_REQ_STATE,
+ MACHWI_DATA_REQ_STATE,
+#ifdef _FFD_
+ MACHWI_PURGE_REQ_STATE,
+#endif //_FFD_
+ MACHWI_TRANSACTION_TX_STATE,
+ MACHWI_BEACON_TX_STATE,
+} MachwiState_t;
+
+/******************************************************************************
+ Types of possible requests to MAC_HWI.
+******************************************************************************/
+typedef enum // machwi possible requests' types.
+{
+ MACHWI_SET_REQ_ID = MACHWI_SET_REQ_STATE,
+ MACHWI_GET_REQ_ID = MACHWI_GET_REQ_STATE,
+ MACHWI_HARD_RESET_REQ_ID = MACHWI_HARD_RESET_REQ_STATE,
+ MACHWI_SOFT_RESET_REQ_ID = MACHWI_SOFT_RESET_REQ_STATE,
+ MACHWI_SCAN_REQ_ID = MACHWI_SCAN_REQ_STATE,
+#ifdef _FFD_
+ MACHWI_START_REQ_ID = MACHWI_START_REQ_STATE,
+#endif //_FFD_
+ MACHWI_ASSOCIATE_REQ_ID = MACHWI_ASSOCIATE_REQ_STATE,
+#ifdef _FFD_
+ MACHWI_ASSOCIATE_RESP_ID = MACHWI_ASSOCIATE_RESP_STATE,
+#endif //_FFD_
+ MACHWI_DISASSOCIATE_REQ_ID = MACHWI_DISASSOCIATE_REQ_STATE,
+ MACHWI_RX_ENABLE_REQ_ID = MACHWI_RX_ENABLE_REQ_STATE,
+#ifdef _FFD_
+ MACHWI_ORPHAN_RESP_ID = MACHWI_ORPHAN_RESP_STATE,
+#endif //_FFD_
+ MACHWI_POLL_REQ_ID = MACHWI_POLL_REQ_STATE,
+ MACHWI_DATA_REQ_ID = MACHWI_DATA_REQ_STATE,
+#ifdef _FFD_
+ MACHWI_PURGE_REQ_ID = MACHWI_PURGE_REQ_STATE,
+#endif //_FFD_
+ MACHWI_TRANSACTION_TX_REQ_ID = MACHWI_TRANSACTION_TX_STATE,
+ MACHWI_BEACON_TX_REQ_ID = MACHWI_BEACON_TX_STATE,
+} MachwiRequestId_t;
+
+/******************************************************************************
+ Types of possible postponed MAC_HWI actions.
+******************************************************************************/
+typedef enum
+{
+ MAC_HWI_POSTPONED_ACTION_TRANSACTION_TX = (1 << 0),
+ MAC_HWI_POSTPONED_ACTION_BEACON_TX = (1 << 1),
+} MachwiPostponedAction_t;
+
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+/******************************************************************************
+ Main system entry point.
+ Parameters:
+ none.
+ returns:
+ none.
+******************************************************************************/
+void MAC_HWI_TaskHandler(void);
+
+/******************************************************************************
+ Sends confirmation to the upper layer.
+ Parameters:
+ request - parameters of the request to be confirmed.
+ Returns:
+ none.
+******************************************************************************/
+void machwiSendConfToUpperLayer(void *request);
+
+#ifdef _FFD_
+/******************************************************************************
+ Sends MAC_AssociteInd to the upper layer.
+ Parameters:
+ associateInd - associate indication descriptor.
+ Returnes:
+ none.
+******************************************************************************/
+void machwiSendAssociateInd(MAC_AssociateInd_t *associateInd);
+#endif //_FFD_
+
+/******************************************************************************
+ Sends MAC_DataInd to the upper layer.
+ Parameters:
+ dataInd - data indication descriptor.
+ Returnes:
+ none.
+******************************************************************************/
+void machwiSendDataInd(MAC_DataInd_t *dataInd);
+
+/******************************************************************************
+ Sends MAC_DisassociteInd to the upper layer.
+ Parameters:
+ disassociateInd - disassociate indication descriptor.
+ Returnes:
+ none.
+******************************************************************************/
+void machwiSendDisassociateInd(MAC_DisassociateInd_t *disassociateInd);
+
+/******************************************************************************
+ Sends MAC_BeaconNotifyInd to the upper layer.
+ Parameters:
+ beaconInd - beacon notify indication descriptor.
+ Returnes:
+ none.
+******************************************************************************/
+void machwiSendBeaconNotifyInd(MAC_BeaconNotifyInd_t *beaconInd);
+
+/******************************************************************************
+ Sends MAC_SyncLossInd to the upper layer.
+ Parameters:
+ lossInd - sync loss notify indication descriptor.
+ Returnes:
+ none.
+******************************************************************************/
+void machwiSendSyncLossNotifyInd(MAC_SyncLossInd_t *syncLoss);
+
+#ifdef _FFD_
+/******************************************************************************
+ Sends MAC_OrphanInd to the upper layer.
+ Parameters:
+ orphanInd - orphan indication descriptor.
+ Returnes:
+ none.
+******************************************************************************/
+void machwiSendOrphanInd(MAC_OrphanInd_t *orphanInd);
+
+/******************************************************************************
+ Sends MAC_PollInd to the upper layer.
+ Parameters:
+ pollInd - poll indication descriptor.
+ Returnes:
+ none.
+******************************************************************************/
+void machwiSendPollInd(MAC_PollInd_t *pollInd);
+
+/******************************************************************************
+ \brief initiates transaction transmission if MAC is in IDLE state. If state
+ is not IDLE - postpones operation.
+******************************************************************************/
+void machwiTxTransactionReq(void);
+
+/******************************************************************************
+ \brief initiates beacon transmission if MAC is in IDLE state. If state
+ is not IDLE - postpones operation.
+******************************************************************************/
+void machwiTxBeaconReq(void);
+
+/**************************************************************************//**
+ \brief Checks if there are any active transactions on MAC layer.
+
+ \return true, if there are any active transactions on MAC layer,
+ false - otherwise
+ ******************************************************************************/
+bool MAC_IsActiveTransaction(void);
+
+#endif //_FFD_
+
+#endif //_MACHWIMANAGER_H
+
+// eof machwiManager.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiMem.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiMem.h
new file mode 100644
index 00000000..37d519ab
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiMem.h
@@ -0,0 +1,82 @@
+/******************************************************************************
+ \file machwiMem.h
+
+ \brief MACHWI variable's memory description.
+
+ \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:
+ 03/11/07 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _MACHWIMEM_H
+#define _MACHWIMEM_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <queue.h>
+#include <bcTimer.h>
+#include <machwiManager.h>
+#include <machwiHwdReqMemPool.h>
+#include <machwiAssociateHandler.h>
+#include <machwiDisassociateHandler.h>
+#include <machwiScanHandler.h>
+#include <machwiStartHandler.h>
+#include <machwiTransactionHandler.h>
+#include <machwiPollHandler.h>
+#include <macBanNode.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef struct
+{
+ union
+ {
+ MachwiAssociateState_t assoc;
+#ifdef _MAC_DISASSOCIATE_
+ MachwiDisassociateState_t disassoc;
+#endif // _MAC_DISASSOCIATE_
+ MachwiScanState_t scan;
+#ifdef _FFD_
+ MachwiStartState_t start;
+#endif // _FFD_
+ } state;
+ MachwiState_t managerState; // For the manager needs.
+ MachwiPollHandlerState_t pollState; // For the poll handler needs.
+ void *machwiReq; // Used by all modules which need to save requests' parameters.
+ Timer_t comAppTimer; // Used by all modules except machwiTransactionQueue.
+ QueueDescriptor_t reqQueueDescr;
+ bool txCoordRealigCmd; // For the start handler needs.
+ MAC_DisassociateInd_t disassociateInd; // For the disassociate handler needs.
+ MachwiHwdReqDescr_t machwdReq;
+#ifdef _FFD_
+ QueueDescriptor_t transactionQueueDescr; // For the transaction queue needs - transaction queue descriptor.
+ Timer_t transTimer; // For the transaction queue needs - transaction queue timer.
+ MachwiTransactionHandlerState_t transactionHandlerState; // For the transaction handler needs.
+ uint8_t activatedTransactionsCounter;
+ MachwiTransaction_t *currentTransaction;
+#endif //_FFD_
+ bool switchIsLocked; // For the switching Rx Control needs.
+ void (*sendSwitchConfirm)(void);
+ uint8_t nextChannel; // For the scan handler needs.
+ uint8_t postponedAction; // MAC postponed actions bit field.
+#ifdef _MAC_BAN_NODE_
+ MAC_BanTable_t banTable;
+#endif /* _MAC_BAN_NODE_ */
+} MachwiMem_t;
+
+#endif /* _MACHWIMEM_H */
+
+// eof machwiMem.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiMemAccess.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiMemAccess.h
new file mode 100644
index 00000000..ac75894f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiMemAccess.h
@@ -0,0 +1,88 @@
+/******************************************************************************
+ \file machwiMemAccess.h
+
+ \brief Provides access to MACHWI memory .
+
+ \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:
+ 11/07/08 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _MACHWIMEMACCESS_H
+#define _MACHWIMEMACCESS_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <macMem.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+/******************************************************************************
+ External variables.
+******************************************************************************/
+
+/******************************************************************************
+ Inline static functions prototypes section.
+******************************************************************************/
+/******************************************************************************
+ Gets address of MACHWI memory.
+ Parameters: none.
+ returns: Address of MACHWI memory.
+******************************************************************************/
+INLINE MachwiMem_t* machwiGetMem(void)
+{
+ return &macMem.hwi;
+}
+
+/******************************************************************************
+ Stores the pointer to the current request.
+ Parameters:
+ req - pointer to the current request.
+ returns:
+ none.
+******************************************************************************/
+INLINE void machwiStoreReqParams(void *req)
+{
+ machwiGetMem()->machwiReq = req;
+}
+
+/******************************************************************************
+ Gets the pointer to the current request.
+ Parameters:
+ none.
+ returns:
+ Pointer to the current request.
+******************************************************************************/
+INLINE void* machwiGetReqParams(void)
+{
+ return machwiGetMem()->machwiReq;
+}
+
+/**************************************************************************//**
+ \brief Allocates memory to execute request to MAC HWD sublayer.
+
+ \return none.
+******************************************************************************/
+INLINE MachwiHwdReqDescr_t* machwiGetHwdReqMem(void)
+{
+ return &machwiGetMem()->machwdReq;
+}
+
+#endif /* _MACHWIMEM_H */
+
+// eof machwiMemAccess.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiOrphanHandler.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiOrphanHandler.h
new file mode 100644
index 00000000..3c833acf
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiOrphanHandler.h
@@ -0,0 +1,61 @@
+/******************************************************************************
+ \file machwiOrphanHandler.h
+
+ \brief Header file of machwiOrphanHandler.c.
+
+ \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:
+ 17/08/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACHWIORPHANHANDLER_H
+#define _MACHWIORPHANHANDLER_H
+#ifdef _FFD_
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <machwd.h>
+#include <machwiManager.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ Checks orphan response parameters, fills frame descriptor and passes request
+ further if it is needed.
+ Parameters:
+ none.
+ Returns:
+ current status of operation ("success" or "in progress").
+******************************************************************************/
+MachwiHandlerResult_t machwiOrphanRespHandler(void);
+
+/******************************************************************************
+ Indicates tha orphan notification command was received.
+ Parameters:
+ none.
+ Returns:
+ none.
+******************************************************************************/
+void machwiOrphanNotificationInd(MAC_FrameDescr_t *orphanNotificationDescr);
+
+#endif // _FFD_
+#endif /* _MACHWIORPHANHANDLER_H */
+
+// eof machwiOrphanHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiPanIdConflictHandler.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiPanIdConflictHandler.h
new file mode 100644
index 00000000..2aa5e5d0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiPanIdConflictHandler.h
@@ -0,0 +1,41 @@
+/******************************************************************************
+ \file machwiPanIdConflictHandler.h
+
+ \brief PAN ID coflict service routine header file.
+
+ \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:
+ 19/10/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACHWIPANIDCONFLICTHANDLER_H
+#define _MACHWIPANIDCONFLICTHANDLER_H
+
+/******************************************************************************
+ Checks accordance between PAN ID and coordinator addresses.
+ Parameters:
+ beaconDescr - beacon frame description.
+ Return:
+ none.
+******************************************************************************/
+void machwiCheckPanIdConflict(MAC_FrameDescr_t *beaconDescr);
+
+/******************************************************************************
+ Indicates that PAN iD conflict notification command is received.
+ Parameters:
+ frameDescr - pointer to the command's frame descriptor.
+ Returns:
+ none.
+******************************************************************************/
+void machwiPanIdConflictNotifInd(MAC_FrameDescr_t *beaconDescr);
+
+#endif //_MACHWIPANIDCONFLICTHANDLER_H
+
+// eof machwiPollHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiPanServer.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiPanServer.h
new file mode 100644
index 00000000..909c3d3a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiPanServer.h
@@ -0,0 +1,67 @@
+/******************************************************************************
+ \file machwiPanServer.h
+
+ \brief machwiPanServer header file.
+
+ \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/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACHWIPANSERVER_H
+#define _MACHWIPANSERVER_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+#include <types.h>
+#include <machwd.h>
+
+/******************************************************************************
+ Indicates that frame was received.
+ Parameters:
+ indParams - parameters of indication.
+ Returns:
+ none.
+******************************************************************************/
+void MACHWD_DataInd(MACHWD_DataInd_t *indParams);
+
+#ifdef _FFD_
+/******************************************************************************
+ Enable beacon transmission on beacon request.
+ Parameters:
+ none.
+ Returns:
+ none.
+******************************************************************************/
+void machwiEnableBeaconTransmission(void);
+
+/******************************************************************************
+ Resets PanServer logic. MAC doesn't transmit beacon on beacon request after
+ resetting.
+ Parameters:
+ none.
+ Returns:
+ none.
+******************************************************************************/
+void machwiResetPanServer(void);
+#endif //_FFD_
+
+#endif //_MACHWIPANSERVER_H
+
+// eof machwiPanServer.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiPollHandler.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiPollHandler.h
new file mode 100644
index 00000000..10a04736
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiPollHandler.h
@@ -0,0 +1,82 @@
+/******************************************************************************
+ \file machwiPollHandler.h
+
+ \brief MAC poll routine header file.
+
+ \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:
+ 09/07/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACHWIPOLLHANDLER_H
+#define _MACHWIPOLLHANDLER_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <macFrame.h>
+#include <machwiManager.h>
+
+/******************************************************************************
+ Typesa definition section
+******************************************************************************/
+/******************************************************************************
+ MAC Hardware Independent part POLL handler possible states.
+******************************************************************************/
+typedef enum
+{
+ MACHWI_POLL_HANDLER_STATE_IDLE,
+ MACHWI_POLL_HANDLER_STATE_DATA_REQ_TRANSMISSION,
+ MACHWI_POLL_HANDLER_STATE_ANSWER_WAITING,
+ MACHWI_POLL_HANDLER_STATE_TRX_STATE_SETTING,
+} MachwiPollHandlerState_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ Resets poll handler.
+ Parameters:
+ none.
+ Returns:
+ none.
+******************************************************************************/
+void machwiResetPollHandler(void);
+
+/******************************************************************************
+ Indicates data reception to upper layer.
+ Parameters:
+ frameDescr - pointer to frame descriptor.
+ Returns:
+ none.
+******************************************************************************/
+void machwiDataIndication(MAC_FrameDescr_t *frameDescr);
+
+/******************************************************************************
+ Checks poll request parameters, sends data request commands.
+ Waits for the data.
+ Parameters:
+ none.
+ Returns:
+ current status of operation (success or "in progress").
+******************************************************************************/
+MachwiHandlerResult_t machwiPollReqHandler(void);
+
+/******************************************************************************
+ Indicates, that data request frame was received.
+ Parameters:
+ pollDescr - Poll description.
+ Returns:
+ none.
+******************************************************************************/
+void machwiPollInd(MAC_FrameDescr_t *frameDescr);
+
+#endif //_MACHWIPOLLHANDLER_H
+// eof machwiPollHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiPurgeHandler.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiPurgeHandler.h
new file mode 100644
index 00000000..1fb1ae4c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiPurgeHandler.h
@@ -0,0 +1,58 @@
+/******************************************************************************
+ \file machwiPurgeHandler.h
+
+ \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:
+ 28/08/07 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _MACHWIPURGEHANDLER_H
+#define _MACHWIPURGEHANDLER_H
+#ifdef _FFD_
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <macPurge.h>
+#include <machwiManager.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+/******************************************************************************
+ Constants section
+******************************************************************************/
+
+/******************************************************************************
+ External variables
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ Purges an MSDU from the transaction queue.
+ Parameters:
+ none.
+ Returns:
+ current status of operation (always success).
+******************************************************************************/
+MachwiHandlerResult_t machwiPurgeReqHandler(void);
+
+#endif //_FFD_
+#endif /* _MACHWIPURGEHANDLER_H */
+
+// eof machwiPurgeHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiResetHandler.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiResetHandler.h
new file mode 100644
index 00000000..83c3a9b5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiResetHandler.h
@@ -0,0 +1,41 @@
+/******************************************************************************
+ \file machwiResetHandler.h
+
+ \brief MAC reset routine header file.
+
+ \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:
+ 21/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACHWIRESETHANDLER_H
+#define _MACHWIRESETHANDLER_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <machwiManager.h>
+
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ TBD
+ Parameters:
+ none.
+ Returns:
+ none.
+******************************************************************************/
+MachwiHandlerResult_t machwiResetReqHandler(void);
+
+// eof machwiResetHandler.h
+
+#endif //_MACHWIRESETHANDLER_H
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiRxEnableHandler.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiRxEnableHandler.h
new file mode 100644
index 00000000..b79111cf
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiRxEnableHandler.h
@@ -0,0 +1,50 @@
+/******************************************************************************
+ \file machwiRxEnableHandler.h
+
+ \brief Header file of machwiRxEnableHandler.c.
+
+ \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:
+ 24/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACHWIRXENABLEHANDLER_H
+#define _MACHWIRXENABLEHANDLER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <machwiManager.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ TBD
+ Parameters:
+ TBD - TBD.
+ Returns:
+ TBD.
+******************************************************************************/
+MachwiHandlerResult_t machwiRxEnableReqHandler(void);
+
+#endif /* _MACHWIRXENABLEHANDLER_H */
+
+// eof machwiRxEnableHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiScanHandler.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiScanHandler.h
new file mode 100644
index 00000000..ab0304ae
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiScanHandler.h
@@ -0,0 +1,97 @@
+/******************************************************************************
+ \file machwiScanHandler.h
+
+ \brief Header file of machwiScanHandler.c.
+
+ \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:
+ 24/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACHWISCANHANDLER_H
+#define _MACHWISCANHANDLER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <machwd.h>
+#include <machwiManager.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum
+{
+ MACHWI_IDLE_SCAN_STATE,
+ MACHWI_SET_CHANNEL_SCAN_STATE,
+ MACHWI_SET_BEACON_RX_MODE_SCAN_STATE,
+ MACHWI_CLR_BEACON_RX_MODE_SCAN_STATE,
+ MACHWI_SET_PAGE_SCAN_STATE,
+ MACHWI_SET_TRX_STATE_TRX_OFF_SCAN_STATE,
+ MACHWI_SET_TRX_STATE_RX_ON_SCAN_STATE,
+ MACHWI_SET_RF_IRQ_DISABLE_SCAN_STATE,
+ MACHWI_SET_RF_IRQ_ENABLE_SCAN_STATE,
+ MACHWI_SET_SHORT_ADDR_SCAN_STATE,
+ MACHWI_SET_PANID_SCAN_STATE,
+ MACHWI_SET_CHANNEL_AFTER_ORPHAN_SCAN_STATE,
+ MACHWI_WAIT_SCAN_STATE,
+ MACHWI_SCAN_TIME_EXHAUSTED_SCAN_STATE,
+ MACHWI_SET_ACTIVE_CHANNEL_SCAN_STATE,
+ MACHWI_SET_PANID_BROADCAST_SCAN_STATE,
+ MACHWI_SET_PANID_ORIGINAL_SCAN_STATE
+} MachwiScanState_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ TBD
+ Parameters:
+ TBD - TBD.
+ Returns:
+ TBD.
+******************************************************************************/
+MachwiHandlerResult_t machwiScanReqHandler(void);
+
+
+/******************************************************************************
+ Indicates, that beacon frame was received.
+ Parameters:
+ beaconDescr - beacon description.
+ Returns:
+ none.
+******************************************************************************/
+void machwiBeaconInd(MAC_FrameDescr_t *beaconDescr);
+
+/******************************************************************************
+ Indicates, that coordinator realignment connamd was received.
+ Parameters:
+ realignmentDescr - realignment command description.
+ Returns:
+ none.
+******************************************************************************/
+void machwiCoordRealignmentCommandInd(MAC_FrameDescr_t *realignmentDescr);
+
+/******************************************************************************
+ Resets scan handler.
+ Parameters:
+ none.
+ Returns:
+ none.
+******************************************************************************/
+void machwiResetScanHandler(void);
+
+#endif /* _MACHWISCANHANDLER_H */
+
+// eof machwiScanHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiSetGetHandler.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiSetGetHandler.h
new file mode 100644
index 00000000..10866d27
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiSetGetHandler.h
@@ -0,0 +1,50 @@
+/******************************************************************************
+ \file machwiSetGetHandler.h
+
+ \brief machwiSetGetHandler header file.
+
+ \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:
+ 21/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACHWISETGETHANDLER_H
+#define _MACHWISETGETHANDLER_H
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <machwiManager.h>
+#include <macSetGet.h>
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ Gets request parameters from PIB.
+ Parameters:
+ none.
+ Returns:
+ current status of operation (always success).
+******************************************************************************/
+MachwiHandlerResult_t machwiGetReqHandler(void);
+
+/**************************************************************************
+ Sets request parameters to PIB and RF chip (if it is needed).
+ Parameters:
+ none.
+ Returns:
+ current status of operation (success or "in progress").
+******************************************************************************/
+MachwiHandlerResult_t machwiSetReqHandler(void);
+
+
+#endif //_MACHWISETGETHANDLER_H
+
+// eof machwiSetGetHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiStartHandler.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiStartHandler.h
new file mode 100644
index 00000000..c838988d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiStartHandler.h
@@ -0,0 +1,69 @@
+/******************************************************************************
+ \file machwiStartHandler.h
+
+ \brief Header file of machwiStartHandler.
+
+ \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:
+ 24/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACHWISTARTHANDLER_H
+#define _MACHWISTARTHANDLER_H
+#ifdef _FFD_
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <machwd.h>
+#include <machwiManager.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum
+{
+ MACHWI_IDLE_START_STATE,
+ MACHWI_SET_PAN_ID_START_STATE,
+ MACHWI_SET_PAN_COORDINATOR_START_STATE,
+ MACHWI_SET_PAGE_START_STATE,
+ MACHWI_SET_CHANNEL_START_STATE,
+ MACHWI_TX_COORD_REALIG_CMD_STATE,
+} MachwiStartState_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ TBD
+ Parameters:
+ TBD - TBD.
+ Returns:
+ TBD.
+******************************************************************************/
+MachwiHandlerResult_t machwiStartReqHandler(void);
+
+/******************************************************************************
+ Resets start handler.
+ Parameters:
+ none.
+ Returns:
+ none.
+******************************************************************************/
+void machwiResetStartHandler(void);
+
+#endif // _FFD_
+#endif /* _MACHWISTARTHANDLER_H */
+
+// eof machwiStartHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiSwitchRxCtrl.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiSwitchRxCtrl.h
new file mode 100644
index 00000000..6891b07c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiSwitchRxCtrl.h
@@ -0,0 +1,113 @@
+/******************************************************************************
+ \file machwiSwitchRxCtrl.h
+
+ \brief Implementation of switching receiver control.
+
+ \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:
+ 23/08/07 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _MACHWISWITCHRXCTRL_H
+#define _MACHWISWITCHRXCTRL_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <machwiMemAccess.h>
+#include <machwiHwdReqMemPool.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+/******************************************************************************
+ Constants section
+******************************************************************************/
+
+/******************************************************************************
+ External variables
+******************************************************************************/
+extern bool __switchIsLocked;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ Switches receiver to TRX OFF if RxOnWhenIdle parameter isn't set.
+ Parameters:
+ hwdReq - pointer to MACHWD request memory.
+ switchingCompleted - callback to indicate the end of switching receiver.
+ Returns:
+ none.
+******************************************************************************/
+void machwiSwitchRxAccordToRxOnWhenIdle(MachwiHwdReqDescr_t *hwdReq,
+ void (*switchingCompleted)(void));
+
+/******************************************************************************
+ Inline static functions section
+******************************************************************************/
+/******************************************************************************
+ Resets switching receiver control.
+ Parameters:
+ none.
+ Returns:
+ none.
+******************************************************************************/
+static inline void machwiResetSwitchingRxCtrl(void)
+{
+ machwiGetMem()->switchIsLocked = false;
+}
+
+/******************************************************************************
+ Locks switching receiver control.
+ Parameters:
+ none.
+ Returns:
+ none.
+******************************************************************************/
+static inline void machwiLockSwitchingRx(void)
+{
+ machwiGetMem()->switchIsLocked = true;
+}
+
+/******************************************************************************
+ Unlocks switching receiver control.
+ Parameters:
+ none.
+ Returns:
+ none.
+******************************************************************************/
+static inline void machwiUnlockSwitchingRx(void)
+{
+ machwiGetMem()->switchIsLocked = false;
+}
+
+/******************************************************************************
+ Tests switching receiver control state.
+ Parameters:
+ none.
+ Returns:
+ true - switching receiver is locked.
+ false - otherwise.
+******************************************************************************/
+static inline bool machwiIsSwitchingRxLocked(void)
+{
+ return machwiGetMem()->switchIsLocked;
+}
+
+#endif /* _MACHWISWITCHRXCTRL_H */
+
+// eof machwiSwitchRxCtrl.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiTransactionHandler.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiTransactionHandler.h
new file mode 100644
index 00000000..cd5d31a8
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiTransactionHandler.h
@@ -0,0 +1,85 @@
+/******************************************************************************
+ \file machwiTransactionHandler.h
+
+ \brief machwiTransactionHandler header file.
+
+ \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:
+ 28/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACHWITRANSACTIONHANDLER_H
+#define _MACHWITRANSACTIONHANDLER_H
+#ifdef _FFD_
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <machwiTransactionQueue.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum
+{
+ MACHWI_IDLE_TRANSACTION_HANDLER_STATE,
+ MACHWI_BUSY_ASSOCIATE_TRANSACTION_HANDLER_STATE,
+#ifdef _MAC_DISASSOCIATE_
+
+ MACHWI_BUSY_DISASSOCIATE_TRANSACTION_HANDLER_STATE,
+#endif //_MAC_DISASSOCIATE_
+
+ MACHWI_BUSY_DATA_TRANSACTION_HANDLER_STATE,
+#ifdef _PENDING_EMPTY_DATA_FRAME_
+ MACHWI_BUSY_EMPTY_DATA_HANDLER_STATE,
+#endif // _PENDING_EMPTY_DATA_FRAME_
+} MachwiTransactionHandlerState_t;
+
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+
+/******************************************************************************
+ Indicates, that transaction event happened (it was requested or just expired).
+ Parameters:
+ transaction - transaction descriptor.
+ event - type of the event (MAC_TRANSACTION_EXPIRED_EVENT or
+ MAC_TRANSACTION_READY_EVENT).
+ Returns:
+ true - activate the kicked transaction, false - otherwise.
+******************************************************************************/
+bool machwiSendTransactionEvent(MachwiTransaction_t *transaction, MachwiTransactionEvent_t event);
+
+
+/******************************************************************************
+ Resets transaction handler.
+ Parameters:
+ none.
+ Returns:
+ none.
+******************************************************************************/
+void machwiResetTransactionHandler(void);
+
+#ifdef _PENDING_EMPTY_DATA_FRAME_
+/******************************************************************************
+ Sends an empty data frame in reply to the data request.
+ Parameters:
+ frameDescr - data request frame description.
+ Returns:
+ none.
+******************************************************************************/
+void replyWithEmptyDataFrame(MAC_FrameDescr_t *frameDescr);
+#endif // _PENDING_EMPTY_DATA_FRAME_
+
+#endif //_FFD_
+#endif //_MACHWITRANSACTIONHANDLER_H
+
+// eof machwiTransactionHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiTransactionQueue.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiTransactionQueue.h
new file mode 100644
index 00000000..584924a0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/MAC_HWI/include/machwiTransactionQueue.h
@@ -0,0 +1,123 @@
+/******************************************************************************
+ \file machwiTransactionQueue.h
+
+ \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:
+ 25/06/07 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _MACHWITRANSACTIONQUEUE_H
+#define _MACHWITRANSACTIONQUEUE_H
+#ifdef _FFD_
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <macData.h>
+#include <macFrame.h>
+#include <macAssociate.h>
+#include <macDisassociate.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+// Transaction event.
+typedef enum
+{
+ MAC_TRANSACTION_EXPIRED_EVENT = MAC_TRANSACTION_EXPIRED_STATUS,
+ MAC_TRANSACTION_ACTIVATED_EVENT
+} MachwiTransactionEvent_t;
+
+// Transaction.
+typedef union
+{
+ MAC_DataReq_t dataReq;
+ MAC_AssociateResp_t associateResp;
+ MAC_DisassociateReq_t disassociateReq;
+} MachwiTransaction_t;
+
+/******************************************************************************
+ Constants section
+******************************************************************************/
+
+/******************************************************************************
+ External variables
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ TBD.
+******************************************************************************/
+void machwiPutTransactionToQueue(MachwiTransaction_t *transaction);
+
+/******************************************************************************
+ TBD.
+******************************************************************************/
+result_t machwiPurgeTransactionFromQueue(uint8_t msduHandle);
+
+/**************************************************************************//**
+ \brief Compares MAC Data Request command's parameters with transactions in the
+ transaction queue. If matched - transaction is marked as "activated".
+
+ \param frameDescr - Data Request MAC command descriptor.
+ \return true if transaction to be transmitted is found, false otherwise
+******************************************************************************/
+bool machwiTestAndKickQueueTransactions(MAC_FrameDescr_t *frameDescr);
+
+/**************************************************************************//**
+ \brief Finds trunsactions which were already activated.
+
+ \return Activated transaction pointer if found, NULL otherwise.
+******************************************************************************/
+MachwiTransaction_t *machwiGetActivatedTransactionFromQueue(void);
+
+/******************************************************************************
+ TBD.
+******************************************************************************/
+uint8_t* machwiFillPendingAddrSpecAndList(uint8_t *beaconPayload);
+
+/******************************************************************************
+ Resets transaction queue.
+ Parameters:
+ none.
+ Returns:
+ none.
+******************************************************************************/
+void machwiResetTransactionQueue(void);
+
+/******************************************************************************
+ Deletes transaction from queue.
+ Parameters:
+ transaction - pointer to transaction wich should be deleted.
+ Returns:
+ none.
+******************************************************************************/
+void machwiDeleteTransactionFromQueue(MachwiTransaction_t *transaction);
+
+/******************************************************************************
+ Checks if MAC transaction queue is empty
+ Parameters:
+ none
+ Returns:
+ true, if MAC transaction queue is empty, false otherwise.
+******************************************************************************/
+bool machwiTransactionQueueEmpty(void);
+
+#endif //_FFD_
+#endif /* _MACHWITRANSACTIONQUEUE_H */
+
+// eof machwiTransactionQueue.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/mac.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/mac.h
new file mode 100644
index 00000000..368c0d9a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/mac.h
@@ -0,0 +1,51 @@
+/**************************************************************************//**
+ \file mac.h
+
+ \brief IEEE 802.15.4-2006 public headers files' union.
+
+ \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:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+#ifndef _MAC_H
+#define _MAC_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <phy.h>
+#include <macAddr.h>
+#include <macAffix.h>
+#include <macAssociate.h>
+#include <macBeacon.h>
+#include <macCommon.h>
+#include <macData.h>
+#include <macDisassociate.h>
+#include <macOrphan.h>
+#include <macPoll.h>
+#include <macPurge.h>
+#include <macReset.h>
+#include <macRxEnable.h>
+#include <macScan.h>
+#include <macSetGet.h>
+#include <macStart.h>
+#include <macSync.h>
+#include <rfEncrypt.h>
+#include <rfBattery.h>
+#include <rfRandom.h>
+#include <rfCalibration.h>
+#include <macBanNode.h>
+#include <macenvPib.h>
+#include <macEnvironment.h>
+
+#endif //_MAC_H
+
+// eof mac.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macAddr.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macAddr.h
new file mode 100644
index 00000000..c9ff0ccb
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macAddr.h
@@ -0,0 +1,85 @@
+/**************************************************************************//**
+ \file macAddr.h
+
+ \brief MAC addressing types and constants.
+
+ \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:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACADDR_H
+#define _MACADDR_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Define(s) section.
+******************************************************************************/
+#define MAC_BROADCAST_PANID 0xFFFFU ///< Broadcast PANID.
+#define MAC_BROADCAST_SHORT_ADDR 0xFFFFU ///< Broadcast short address, no association.
+#define MAC_NO_SHORT_ADDR 0xFFFEU ///< After association no short address.
+#define MAC_NO_EXT_ADDR 0x00ULL
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+typedef uint16_t PanId_t; ///< PAN identifier type declaration.
+typedef uint16_t ShortAddr_t; ///< Short address type declaration.
+typedef uint64_t ExtAddr_t; ///< Extended address type declaration.
+
+/// Union of possible MAC address types.
+typedef union
+{
+ ShortAddr_t sh;
+ ExtAddr_t ext;
+} MAC_Addr_t;
+
+//! MAC address mode types (IEEE 802.15.4-2006 Table 80).
+ typedef enum
+{
+ MAC_NO_ADDR_MODE = 0x00,
+ MAC_RSRV_ADDR_MODE = 0x01,
+ MAC_SHORT_ADDR_MODE = 0x02,
+ MAC_EXT_ADDR_MODE = 0x03
+} MAC_AddrMode_t;
+
+/******************************************************************************
+ Definitions section.
+******************************************************************************/
+#if defined UINT64_MEMCMP
+ #define IS_EQ_EXT_ADDR(A, B) (0 == memcmp(&(A), &(B), sizeof(uint64_t)))
+ #define IS_CORRECT_EXT_ADDR(A) isCorrectExtAddr((const uint8_t *)&A)
+ #define COPY_EXT_ADDR(DST, SRC) __builtin_memcpy(&(DST), &(SRC), sizeof(uint64_t))
+#else
+ #define IS_EQ_EXT_ADDR(A, B) ((A) == (B))
+ #define IS_CORRECT_EXT_ADDR(A) (MAC_NO_EXT_ADDR != (A))
+ #define COPY_EXT_ADDR(DST, SRC) (DST) = (SRC)
+#endif
+
+/******************************************************************************
+ Inline static functions prototypes section
+******************************************************************************/
+INLINE bool isCorrectExtAddr(const uint8_t *extAddr)
+{
+ uint8_t i = 0U;
+
+ do
+ if (extAddr[i]) return true;
+ while (++i < sizeof(uint64_t));
+ return false;
+}
+
+#endif //_MACADDR_H
+
+// eof macAddr.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macAffix.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macAffix.h
new file mode 100644
index 00000000..3f5427ff
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macAffix.h
@@ -0,0 +1,48 @@
+/**************************************************************************//**
+ \file macAffix.h
+
+ \brief MAC frames' header and footer size constants.
+
+ \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:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACAFFIX_H
+#define _MACAFFIX_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <macphyPib.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+//! aMaxMACPayloadSize (IEEE 802.15.4-2006 Table 85).
+#define MAC_MAX_MSDU_SIZE (PHY_MAX_PACKET_SIZE - MAC_MAX_MPDU_UNSECURED_OVERHEAD)
+//! aMaxBeaconOverhead (IEEE 802.15.4-2006 Table 85).
+#define MAC_MAX_BEACON_HEADER_LENGTH MAC_MAX_BEACON_OVERHEAD
+//! aMaxMPDUUnsecuredOverhead (IEEE 802.15.4-2006 Table 85).
+#define MAC_MAX_DATA_FRAME_HEADER_LENGTH MAC_MAX_MPDU_UNSECURED_OVERHEAD
+/**
+ * \brief MAC footer length in common frame buffer.
+ * It has zero length becouse FCS is calculated by RF chip. MAC does't has to
+ * reserve bytes to allocate it's footer.
+ */
+#define MAC_MAX_DATA_FRAME_FOOTER_LENGTH 0U
+//! Offset in common frame buffer for allocating MPDU.
+#define MAC_MSDU_OFFSET MAC_MAX_MPDU_UNSECURED_OVERHEAD
+//! MAC affix.
+#define MAC_AFFIX_LENGTH (MAC_MAX_MPDU_UNSECURED_OVERHEAD + MAC_MAX_DATA_FRAME_FOOTER_LENGTH)
+
+#endif /* _MACAFFIX_H */
+
+// eof macAffix.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macAssociate.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macAssociate.h
new file mode 100644
index 00000000..68779d54
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macAssociate.h
@@ -0,0 +1,154 @@
+/**************************************************************************//**
+ \file macAssociate.h
+
+ \brief Types', constants' and functions' declarations for IEEE 802.15.4-2006
+ association primitives.
+
+ \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:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACASSOCIATE_H
+#define _MACASSOCIATE_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <bcEndian.h>
+#include <macAddr.h>
+#include <macCommon.h>
+#include <macCommStatus.h>
+
+/******************************************************************************
+ Definitions section.
+******************************************************************************/
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+/**
+ \brief MAC capability information field.
+ IEEE 802.15.4-2006 7.3.1.2 Capability Information field.
+*/
+BEGIN_PACK
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(7, (
+ uint8_t alternatePANCoordinator : 1,
+ uint8_t deviceType : 1,
+ uint8_t powerSource : 1,
+ uint8_t rxOnWhenIdle : 1,
+ uint8_t reserved : 2,
+ uint8_t securityCapability : 1,
+ uint8_t allocateAddress : 1
+ ))
+} MAC_CapabilityInf_t;
+END_PACK
+
+/**
+ \brief MLME-ASSOCIATE confirm primitive's parameters structure declaration.
+ IEEE 802.15.4-2006 7.1.3.4 MLME-ASSOCIATE.confirm.
+*/
+typedef struct
+{
+ //! The short device address allocated by the coordinator on successful association.
+ ShortAddr_t shortAddr;
+ //! The extended device address of coordinator wich allocated short address.
+ //! It's additional parameter, not included in IEEE 802.15.4.
+ ExtAddr_t extAddr;
+ //! The status of the association attempt.
+ MAC_Status_t status;
+} MAC_AssociateConf_t;
+
+/**
+ \brief MLME-ASSOCIATE request primitive's parameters structure declaration.
+ IEEE 802.15.4-2006 7.1.3.1 MLME-ASSOCIATE.request.
+*/
+typedef struct
+{
+ //! Service field - for internal needs.
+ MAC_Service_t service;
+ //! The logical channel on which to attempt association.
+ uint8_t channel;
+ //! The channel page on which to attempt association.
+ uint8_t page;
+ //! The coordinator addressing mode for this primitive.
+ MAC_AddrMode_t coordAddrMode;
+ //! The identifier of the PAN with which to associate.
+ PanId_t coordPANId;
+ //! The address of the coordinator with which to associate.
+ MAC_Addr_t coordAddr;
+ //! Specifies the operational capabilities of the associating device.
+ MAC_CapabilityInf_t capability;
+ //! MLME-ASSOCIATE confirm callback fubction's pointer.
+ void (*MAC_AssociateConf)(MAC_AssociateConf_t *conf);
+ //! MLME-ASSOCIATE confirm parameters' structure.
+ MAC_AssociateConf_t confirm;
+} MAC_AssociateReq_t;
+
+/**
+ \brief MLME-ASSOCIATE indication primitive's parameters.
+ IEEE 802.15.4-2006 7.1.3.2 MLME-ASSOCIATE.indication.
+*/
+typedef struct
+{
+ //! The address of the device requesting association.
+ ExtAddr_t extAddr;
+ //! The operational capabilities requesting association.
+ MAC_CapabilityInf_t capability;
+} MAC_AssociateInd_t;
+
+/**
+ \brief MLME-ASSOCIATE response pritive's parameters.
+ IEEE 802.15.4-2006 7.1.3.3 MLME-ASSOCIATE.response.
+*/
+typedef struct
+{
+ //! Service field - for internal needs.
+ MAC_ServiceTransaction_t service;
+ //! The address of the device requesting association.
+ ExtAddr_t extAddr;
+ //! The 16-bit short device address allocated by the coordinator on successful association.
+ ShortAddr_t shortAddr;
+ //! The status of the association attempt.
+ MAC_Status_t status;
+ //! MLME-COMM STATUS callback function's pointer.
+ void (*MAC_CommStatusInd)(MAC_CommStatusInd_t *commStat);
+ //! Comm staus parameters' structure.
+ MAC_CommStatusInd_t commStatus;
+} MAC_AssociateResp_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief MLME-ASSOCIATE request primitive's prototype.
+ \param reqParams - MLME-ASSOCIATE request parameters' structure pointer.
+ \return none.
+******************************************************************************/
+void MAC_AssociateReq(MAC_AssociateReq_t *reqParams);
+
+/**************************************************************************//**
+ \brief MLME-ASSOCIATE indication primitive's prototype.
+ \param indParams - MLME-ASSOCIATE indication parameters' structure pointer.
+ \return none.
+******************************************************************************/
+extern void MAC_AssociateInd(MAC_AssociateInd_t *indParams);
+
+/**************************************************************************//**
+ \brief MLME-ASSOCIATE response primitive's prototype.
+ \param respParams - MLME-ASSOCIATE response parameters' structure pointer.
+ \return none.
+******************************************************************************/
+void MAC_AssociateResp(MAC_AssociateResp_t *respParams);
+
+#endif //_MACASSOCIATE_H
+// eof macAssociate.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macBanNode.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macBanNode.h
new file mode 100644
index 00000000..e187792d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macBanNode.h
@@ -0,0 +1,121 @@
+/**************************************************************************//**
+ \file macBanNode.h
+
+ \brief Interface of the ban node functionality.
+
+ \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:
+ 29/03/10 M. Gekk - Created.
+ 18/05/10 A. Luzhetsky - link cost control is added
+ ******************************************************************************/
+#ifndef _MAC_BAN_NODE_H
+#define _MAC_BAN_NODE_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <macAddr.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+#define LINK_COST_VALUE_NODE_BANNED 0xFF
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Type of node ban table entry. */
+typedef struct _MAC_BanTableEntry_t
+{
+ /* Short address of the banned node. */
+ ShortAddr_t shortAddr;
+ /* IEEE address of the banned node. */
+ ExtAddr_t extAddr;
+ /* Link cost to be used for all messages from the node. */
+ /* Valid range to correct the link cost (not to ban the node): 1 - 7 */
+ /* Use link cost value LINK_COST_VALUE_NODE_BANNED to ban the node */
+ uint8_t cost;
+} MAC_BanTableEntry_t;
+
+/** Type of the ban table size. */
+typedef uint8_t MAC_BanTableSize_t;
+/** Type of a ban entry index. */
+typedef MAC_BanTableSize_t MAC_BanTableIndex_t;
+
+/** Type of the ban node table. */
+typedef struct _MAC_BanTable_t
+{
+ /* Current size of the ban node table. */
+ MAC_BanTableSize_t size;
+ /* Pointer to the first entry of the ban table. */
+ MAC_BanTableEntry_t *entry;
+ /* Index of the oldest banned node. */
+ MAC_BanTableIndex_t oldBannedNode;
+ /* Ban all nodes by default (true) or not (false). After reset this attribute
+ * is equal to false. */
+ bool banAll;
+} MAC_BanTable_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Ban any frame from the node or correct link cost for all the frames
+ from the node.
+
+ \param shortAddr - short address of the node affected.
+ If the short address of banned node is unknown then pass MAC_NO_SHORT_ADDR.
+ \param extAddr - extended address of the node affetced.
+ If the extended address of banned node is unknown then pass 0.
+ \param cost - link cost value for all the frames received from the node.
+ If node shall be baned - use link cost value LINK_COST_VALUE_NODE_BANNED.
+
+ \return None.
+ ******************************************************************************/
+void MAC_BanNode(const ShortAddr_t shortAddr, const ExtAddr_t extAddr,
+ const uint8_t cost);
+
+/**************************************************************************//**
+ \brief Set global flag banAll
+
+ \param banAll - ban all nodes by default or not.
+
+ \return None.
+ ******************************************************************************/
+void MAC_BanAllNodes(const bool banAll);
+
+/**************************************************************************//**
+ \brief Is given short address banned or not.
+
+ \param shortAddr - short address of the banned node.
+ \param lqi - frame lqi pointer to be corrected if it is needed.
+
+ \return 'true' if the node is banned otherwise return 'false'.
+ ******************************************************************************/
+bool MAC_IsBannedShortAddr(const ShortAddr_t shortAddr, uint8_t *const lqi);
+
+/**************************************************************************//**
+ \brief Is given extended addresss banned or not.
+
+ \param extAddr - extended address of the banned node.
+ \param lqi - frame lqi pointer to be corrected if it is needed.
+
+ \return 'true' if the node is banned otherwise return 'false'.
+ ******************************************************************************/
+bool MAC_IsBannedExtAddr(const ExtAddr_t extAddr, uint8_t *const lqi);
+
+/******************************************************************************
+ \brief Reload from the config server and reset the ban table.
+ ******************************************************************************/
+void MAC_ResetBanTable(void);
+
+#endif /* _MAC_BAN_NODE_H */
+/** eof macBanNode.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macBeacon.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macBeacon.h
new file mode 100644
index 00000000..457d301b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macBeacon.h
@@ -0,0 +1,108 @@
+/**************************************************************************//**
+ \file macBeacon.h
+
+ \brief Beacon specific types declarations and prototypes.
+
+ \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:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACBEACON_H
+#define _MACBEACON_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <bcEndian.h>
+#include <macSuperframe.h>
+
+/******************************************************************************
+ Definitions section.
+******************************************************************************/
+#define MAC_MAX_PENDING_ADDRESS_COUNT 7
+#define MAC_FINAL_CAP_SLOT 15
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+/**
+ \brief Pending address specification fields.
+ IEEE 802.15.4-2006 7.2.2.1.6 Pending Address Specification field.
+*/
+BEGIN_PACK
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(4, (
+ uint8_t shortAddrNum : 3,
+ uint8_t reserved1 : 1,
+ uint8_t extAddrNum : 3,
+ uint8_t reserved2 : 1
+ ))
+} MAC_PendingAddrSpec_t;
+END_PACK
+
+/**
+ \brief PAN descriptor.
+ IEEE 802.15.4-2006 Table 55.
+*/
+typedef struct
+{
+ MAC_AddrMode_t coordAddrMode;
+ PanId_t coordPANId;
+ MAC_Addr_t coordAddr;
+ uint8_t channel;
+ uint8_t page;
+ MAC_SuperframeSpec_t superframeSpec;
+ bool gtsPermit;
+ uint8_t quality;
+ int8_t rssi; // Additional parameter (NOT described in the standard)
+ // RSSI value while beacon frame receiving procedure.
+ uint32_t timeStamp;
+} MAC_PanDescriptor_t;
+
+/**
+ \brief Parameters of BEACON indication.
+ IEEE 802.15.4-2006 7.1.5.1 MLME-BEACON-NOTIFY.indication.
+*/
+typedef struct
+{
+ //! The beacon sequence number.
+ uint8_t bsn;
+ //! The PANDescriptor for the received beacon.
+ MAC_PanDescriptor_t panDescr;
+ //! The beacon pending address specification.
+ MAC_PendingAddrSpec_t pendAddrSpec;
+ //! List of short addresses.
+ ShortAddr_t (*shortPendAddrList)[];
+ //! List of extended addresses.
+ ExtAddr_t (*extPendAddrList)[];
+ //! The number of octets contained in the beacon payload of the beacon frame
+ //! received by the MAC sublayer.
+ uint8_t msduLength;
+ //! The set of octets comprising the beacon payload to be transferred from the
+ //! MAC sublayer entity to the next higher layer.
+ uint8_t *msdu;
+} MAC_BeaconNotifyInd_t;
+
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief MLME-BEACON_NOTIFY indication primitive's prototype.
+ \param indParams - MLME-BEACON_NOTIFY indication parameters' structure pointer.
+ \return none.
+******************************************************************************/
+extern void MAC_BeaconNotifyInd(MAC_BeaconNotifyInd_t *indParams);
+
+#endif //_MACBEACON_H
+
+// eof macBeacon.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macBuffers.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macBuffers.h
new file mode 100644
index 00000000..b05be87f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macBuffers.h
@@ -0,0 +1,54 @@
+/**************************************************************************//**
+ \file macBuffers.h
+
+ \brief MAC and PHY buffers' description.
+
+ \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:
+ 09/10/07 A. Luzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACBUFFERS_H
+#define _MACBUFFERS_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <inttypes.h>
+#include <types.h>
+#include <phy.h>
+#include <macphyPib.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+//! Size of internal reception buffer.
+#define FRAME_RX_BUFFER_SIZE (PHY_FRAME_LENGTH_FIELD_SIZE + \
+ PHY_MAX_PACKET_SIZE + \
+ PHY_LQI_FIELD_SIZE + \
+ PHY_RSSI_FIELD_SIZE)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+//! Rx frame buffer state descriptor.
+typedef struct
+{
+ uint8_t *buffer;
+ uint8_t *reserved;
+ uint8_t *gap1b;
+ uint8_t *gap1e;
+ uint8_t *gap2b;
+ uint8_t *gap2e;
+} FrameRxBufferState_t;
+
+#endif // _MACBUFFERS_H
+
+// eof macBuffers.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macCommStatus.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macCommStatus.h
new file mode 100644
index 00000000..770ab148
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macCommStatus.h
@@ -0,0 +1,64 @@
+/**************************************************************************//**
+ \file macCommStatus.h
+
+ \brief Types', constants' and functions' declarations for IEEE 802.15.4-2006
+ comm status primitives.
+
+ \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:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACCOMMSTATUS_H
+#define _MACCOMMSTATUS_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <macAddr.h>
+#include <macCommon.h>
+
+/******************************************************************************
+ Definitions section.
+******************************************************************************/
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+
+/**
+ * \brief MLME-COMM_STATUS indication primitive's parameters.
+ * IEEE 802.15.4-2006 7.1.12.1 MLME-COMM-STATUS.indication.
+*/
+typedef struct
+{
+ //! The 16-bit PAN identifier of the device from which the frame was received
+ //! or to which the frame was being sent.
+ PanId_t panId;
+ //! The source addressing mode for this primitive.
+ MAC_AddrMode_t srcAddrMode;
+ //! The individual device address of the entity from which the frame causing
+ //! the error originated.
+ MAC_Addr_t srcAddr;
+ //! The destination addressing mode for this primitive.
+ MAC_AddrMode_t dstAddrMode;
+ //! The individual device address of the device for which the frame was intended.
+ MAC_Addr_t dstAddr;
+ //! The communications status.
+ MAC_Status_t status;
+} MAC_CommStatusInd_t;
+
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+#endif //_MACCOMMSTATUS_H
+
+// eof macCommStatus.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macCommon.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macCommon.h
new file mode 100644
index 00000000..fecb1f6f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macCommon.h
@@ -0,0 +1,90 @@
+/**************************************************************************//**
+ \file macCommon.h
+
+ \brief Declarations of common MAC layer fields and types.
+
+ \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:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACCOMMON_H
+#define _MACCOMMON_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Definitions section.
+******************************************************************************/
+//! MAC primitives' return codes.
+typedef enum
+{
+ // IEEE802.15.4 table - 83.
+ MAC_PAN_AT_CAPACITY_STATUS = 0x01,
+ MAC_PAN_ACCESS_DENIED_STATUS = 0x02,
+ // IEEE802.15.4 table - 78.
+ MAC_SUCCESS_STATUS = 0x00,
+ MAC_BEACON_LOSS_STATUS = 0xE0,
+ MAC_CHANNEL_ACCESS_FAILURE_STATUS = 0xE1,
+ MAC_DENIED_STATUS = 0xE2,
+ MAC_DISABLE_TRX_FAILURE_STATUS = 0xE3,
+ MAC_FRAME_TOO_LONG_STATUS = 0xE5,
+ MAC_INVALID_GTS_STATUS = 0xE6,
+ MAC_INVALID_HANDLE_STATUS = 0xE7,
+ MAC_INVALID_PARAMETER_STATUS = 0xE8,
+ MAC_NO_ACK_STATUS = 0xE9,
+ MAC_NO_BEACON_STATUS = 0xEA,
+ MAC_NO_DATA_STATUS = 0xEB,
+ MAC_NO_SHORT_ADDRESS_STATUS = 0xEC,
+ MAC_PAN_ID_CONFLICT_STATUS = 0xEE,
+ MAC_REALIGNMENT_STATUS = 0xEF,
+ MAC_TRANSACTION_EXPIRED_STATUS = 0xF0,
+ MAC_TRANSACTION_OVERFLOW_STATUS = 0xF1,
+ MAC_TX_ACTIVE_STATUS = 0xF2,
+ MAC_UNSUPPORTED_ATTRIBUTE_STATUS = 0xF4,
+ MAC_INVALID_ADDRESS_STATUS = 0xF5,
+ MAC_INVALID_INDEX_STATUS = 0xF9,
+ MAC_LIMIT_REACHED_STATUS = 0xFA, ///< There are some unscanned channels yet, but there is no memory.
+ MAC_ON_TIME_TOO_LONG_STATUS = 0xF6,
+ MAC_PAST_TIME_STATUS = 0xF7,
+ MAC_READ_ONLY_STATUS = 0xFB,
+ MAC_SCAN_IN_PROGRESS_STATUS = 0xFC,
+ MAC_SUPERFRAME_OVERLAP_STATUS = 0xFD,
+ MAC_TRACKING_OFF_STATUS = 0xF8
+} MAC_Status_t;
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+//! Internal service fields which give us opportunity to compose requests' queue.
+typedef struct
+{
+ void *next;
+ uint8_t requestId;
+} MAC_Service_t;
+
+/**
+ * \brief Internal service fields which give us opportunity to compose and to serve
+ * transactions frame queue.
+*/
+typedef struct
+{
+ void *next;
+ uint8_t requestId;
+ uint32_t ttl;
+ bool activated;
+} MAC_ServiceTransaction_t;
+
+#endif //_MACCOMMON_H
+
+// eof macCommon.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macData.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macData.h
new file mode 100644
index 00000000..2110e04c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macData.h
@@ -0,0 +1,143 @@
+/**************************************************************************//**
+ \file macData.h
+
+ \brief Types', constants' and functions' declarations for IEEE 802.15.4-2006
+ data primitives.
+
+ \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:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACDATA_H
+#define _MACDATA_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <macAddr.h>
+#include <macCommon.h>
+
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/**
+ * \brief MAC data TxOptions.
+ * IEEE 802.15.4-2006 Table 41.
+*/
+typedef enum
+{
+ MAC_NO_TXOPTION = 0x00,
+ MAC_ACK_TXOPTION = 0x01,
+ MAC_GTS_TXOPTION = 0x02,
+ MAC_INDIRECT_TXOPTION = 0x04,
+ MAC_NO_PANID_COMPRESSION_TXOPTION = 0x08 //It is not from IEEE 802.15.4
+} MAC_TxOptions_t;
+
+/**
+ * \brief MCPS-DATA confirm primitive's parameters structure declaration.
+ * IEEE 802.15.4-2006 7.1.1.2 MCPS-DATA.confirm.
+*/
+typedef struct
+{
+ //! The handle associated with the MSDU being confirmed.
+ uint8_t msduHandle;
+ //! The status of the last MSDU transmission.
+ MAC_Status_t status;
+} MAC_DataConf_t;
+
+/**
+ * \brief MCPS-DATA request primitive's parameters structure declaration.
+ * IEEE 802.15.4-2006 7.1.1.1 MCPS-DATA.request.
+*/
+typedef struct
+{
+ //! Service field - for internal needs.
+ MAC_ServiceTransaction_t service;
+ //! The source addressing mode for this primitive and subsequent MPDU.
+ MAC_AddrMode_t srcAddrMode;
+ //! The destination addressing mode for this primitive and subsequent MPDU.
+ MAC_AddrMode_t dstAddrMode;
+ //! The 16-bit PAN identifier of the entity to which the MSDU is being transferred.
+ PanId_t dstPanId;
+ //! The individual device address of the entity to which the MSDU is being transferred.
+ MAC_Addr_t dstAddr;
+ //! The number of octets contained in the MSDU to be transmitted by the MAC sublayer entity.
+ uint8_t msduLength;
+ //! The set of octets pointer forming the MSDU to be transmitted by the MAC sublayer entity.
+ uint8_t *msdu;
+ //! The handle associated with the MSDU to be transmitted by the MAC sublayer entity.
+ uint8_t msduHandle;
+ //! The 3 bits indicate the transmission options for this MSDU.
+ MAC_TxOptions_t txOptions;
+ //! MCPS-DATA confirm callback function's pointer.
+ void (*MAC_DataConf)(MAC_DataConf_t *conf);
+ //! MCPS-DATA confirm parameters' structure.
+ MAC_DataConf_t confirm;
+} MAC_DataReq_t;
+
+
+/**
+ * \brief MCPS-DATA indication primitive's parameters.
+ * IEEE 802.15.4-2006 7.1.1.3 MCPS-DATA.indication.
+*/
+typedef struct
+{
+ //! The source addressing mode for this primitive corresponding to the received.
+ MAC_AddrMode_t srcAddrMode;
+ //! The 16-bit PAN identifier of the entity from which the MSDU was received.
+ PanId_t srcPANId;
+ //! The individual device address of the entity from which the MSDU was received.
+ MAC_Addr_t srcAddr;
+ //! The destination addressing mode for this primitive corresponding to the received MPDU.
+ MAC_AddrMode_t dstAddrMode;
+ //! The 16-bit PAN identifier of the entity to which the MSDU is being transferred.
+ PanId_t dstPANId;
+ //! The individual device address of the entity to which the MSDU is being transferred.
+ MAC_Addr_t dstAddr;
+ //! The number of octets contained in the MSDU being indicated by the MAC sublayer entity.
+ uint8_t msduLength;
+ //! The set of octets pointer forming the MSDU being indicated by the MAC sublayer entity.
+ uint8_t *msdu;
+ //! LQI value measured during reception of the MPDU.
+ uint8_t linkQuality;
+ //! The DSN of the received data frame.
+ uint8_t dsn;
+ //! RSSI value measured during reception of the MPDU. Non-standard addition.
+ int8_t rssi;
+} MAC_DataInd_t;
+
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief MCPS-DATA request primitive's prototype.
+ \param reqParams - MCPS-DATA request parameters' structure pointer.
+ \return none.
+******************************************************************************/
+void MAC_DataReq(MAC_DataReq_t *reqParams);
+
+/**************************************************************************//**
+ \brief MCPS-DATA indication primitive's prototype.
+ \param indParams - MCPS-DATA indication parameters' structure pointer.
+ \return none.
+******************************************************************************/
+extern void MAC_DataInd(MAC_DataInd_t *indParams);
+
+#endif /* _MACDATA_H */
+
+// eof macData.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macDbg.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macDbg.h
new file mode 100644
index 00000000..049fbbbf
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macDbg.h
@@ -0,0 +1,210 @@
+/*********************************************************************************
+ \file macDbg.h
+
+ \brief Assert's code are located here.
+
+ \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:
+ 09/11/07 A. Mandychev - Created.
+**********************************************************************************/
+#ifndef _MACDBG_H
+#define _MACDBG_H
+
+/*********************************************************************************
+ ASSERT is used for debugging wrong conditions
+
+ Types of messages:
+
+
+*********************************************************************************/
+
+/***************************************************************
+ Defines with 1 in the high-order bit should not be used as enum is signed int type
+***************************************************************/
+typedef enum
+{
+ /***********************************
+ MAC & PHY section. Range 0x1000 - 0x1FFFF
+ ***********************************/
+ // PHY asserts' ID.
+ PHYRFIRQDISPATCHER_RFINTERRUPTSUBROUTINE_0 = 0x1001,
+ PHYTXFRAME_DATAREQ_0 = 0x1002,
+ PHYPIB_PHYSETPIBPARAM_0 = 0x1003,
+ PHYPIB_PHYGETPIBPARAM_0 = 0x1004,
+ PHYTXFRAME_PHYDATAREQ_0 = 0x1005,
+ PHYRXFRAME_PHYDOWNLOADFRAME_0 = 0x1006,
+ MACPHYMACENV_GETSYMBOLPEROCTET_0 = 0x1007,
+ MACPHYMACENV_GETPHYSYMBOLDURATION_0 = 0x1008,
+ PHYSET_PHYSETREQ_0 = 0x1009,
+ PHYSETTRXSTATE_PHYSETTRXSTATEREQ_0 = 0x100A,
+ PHYRFSPIPROTO_PHYENCRYPTBYSPI_0 = 0x100B,
+ MACPHYPIBSERVER_STORETXPOWER_0 = 0x100C,
+ PHYSET_CONVERTTXPOWER_0 = 0x100D,
+ PHYSET_PHYSETREQ_1 = 0x100E,
+ MACPHYMACENV_SETPIBATTR_0 = 0x100F,
+ MACPHYMACENV_GETPIBATTR_0 = 0x1010,
+ HALMACISRC_DISPATHRTIMEREVENT_0 = 0x1011,
+ PHYRFTXRX_CANNOT_BE_ENABLED = 0x1012,
+ PHYRFTXRX_CANNOT_BE_DISABLED = 0x1013,
+ PHYRFIRQDISPATCHER_WRONGSTATE_0 = 0x1014,
+ PHYRFIRQDISPATCHER_WRONGSTATE_1 = 0x1015,
+ PHYSET_PHYSETREQ_2 = 0x1016,
+ PHYANTEXTSW_CANNOT_BE_ENABLED = 0x1017,
+ PHYANTEXTSW_CANNOT_BE_DISABLED = 0x1018,
+
+ PHYRFIRQ_UNREASONABLE_IRQ = 0x1019,
+ PHYRFIRQ_UNKNOWN_RX_STATUS = 0x101A,
+ PHYRFIRQ_UNKNOWN_TX_STATUS = 0x101B,
+ PHYRFIRQ_OTHER_IRQ = 0x101C,
+ PHYRF_EXTRA_RX_FRAME = 0x101D,
+
+ // MAC_HWD asserts' ID.
+ MACHWDFRAMEROUTINE_MACHWDCOMPOSEFRAME_0 = 0x1021,
+ MACHWDPIB_MACHWDGETPIBPARAM_0 = 0x1022,
+ MACHWDGETHANDLER_MACHWDGETREQHANDLER_0 = 0x1023,
+ MACHWDRXFRAMEHANDLER_GETCURRENTCHANNEL_0 = 0x1024,
+ MACHWDMANAGER_TASKHANDLER_0 = 0x1025,
+ MACHWDMANAGER_TASKHANDLER_1 = 0x1026,
+ MACHWDMANAGER_TASKHANDLER_2 = 0x1027,
+ MACHWDMANAGER_SENDREQTOHANDLER_0 = 0x1028,
+ MACHWDMANAGER_DISPATCHETASKTOHANDLER_0 = 0x1029,
+ MACHWDEDHNDLR_MACHWDEDHANDLER_0 = 0x102A,
+ MACHWDEDHNDLR_MACHWDEDHANDLER_1 = 0x102B,
+ MACHWDEDHNDLR_MACHWDEDTASKHANDLER_0 = 0x102C,
+ MACHWDTRXHANDLER_MACHWDTRXREQHANDLER_0 = 0x102D,
+ MACHWDTRXHANDLER_TRXTASKHANDLER_0 = 0x102E,
+ MACHWDSETHANDLER_MACHWDSETREQHANDLER_0 = 0x102F,
+ MACHWDSETHANDLER_MACHWDSETREQHANDLER_1 = 0x1030,
+ MACHWDSETHANDLER_MACHWDSETTASKHANDLER_0 = 0x1031,
+ MACHWDSETHANDLER_MACHWDSETTASKHANDLER_1 = 0x1032,
+ MACHWDSETHANDLER_EXECUTESETREQ_0 = 0x1033,
+ MACHWDSETHANDLER_EXECUTEPHYSETREQ_0 = 0x1034,
+ MACHWDSETHANDLER_SETRXONSTATE_0 = 0x1035,
+ MACHWDTXFRAMEHANDLER_MACHWDTXFRAMEREQHANDLER_0 = 0x1036,
+ MACHWDTXFRAMEHANDLER_MACHWDTXFRAMETASKHANDLER_0 = 0x1037,
+ MACHWDTXFRAMEHANDLER_EXECUTEPHYDATAREQ_0 = 0x1038,
+ MACHWDTXFRAMEHANDLER_SETRXONSTATE_0 = 0x1039,
+ MACHWDRESETHANDLER_MACHWDRESETREQHANDLER_0 = 0x1040,
+ MACHWDTXFRAMEHANDLER_EXECUTEDATAREQ_0 = 0x1041,
+ MACHWDTXFRAMEHANDLER_MACHWDTXFRAMETASKHANDLER_1 = 0x1042,
+ MACHWDGETHANDLER_MACHWDGETREQHANDLER_1 = 0x1043,
+ MACHWDSETHANDLER_MACHWDSETREQHANDLER_2 = 0x1044,
+ MACHWDTRXCTRL_GETPHYTRXCMD_0 = 0x1045,
+ MACHWDTRXCTRL_CONVERTTRXCMDTOTRXSTATE_0 = 0x1046,
+ MACHWDEDHANDLER_MACHWDEDREQHANDLER_2 = 0x1047,
+ MACHWDTXFRAMEHANDLER_GETDATASTATUS_0 = 0x1048,
+ MACHWDENCRYPTHANDLER_MACHWDENCRYPTREQHANDLER_0 = 0x1049,
+ MACHWDENCRYPTHANDLER_MACHWDENCRYPTREQHANDLER_1 = 0x104A,
+ MACHWDENCRYPTHANDLER_MACHWDENCRYPTTASKHANDLER_0 = 0x104B,
+ MACHWDRNDHANDLER_MACHWDRNDREQHANDLER_0 = 0x104C,
+ MACHWDRNDHANDLER_MACHWDRNDREQHANDLER_1 = 0x104D,
+ MACHWDRNDHANDLER_MACHWDRNDTASKHANDLER_0 = 0x104E,
+ MACHWDBATMONHANDLER_MACHWDBATMONREQHANDLER_0 = 0x104F,
+ MACHWDBATMONHANDLER_MACHWDBATMONREQHANDLER_1 = 0x1050,
+ MACHWDBATMONHANDLER_MACHWDBATMONTASKHANDLER_0 = 0x1051,
+ MACHWDBATMONHANDLER_MACHWDBATMONTASKHANDLER_1 = 0x1052,
+ MACHWDTRXCTRL_CONVERTTRXSTATETOTRXCMD_0 = 0x1053,
+ MACHWDRXBUFFER_CHECKBUFFERSPACE_0 = 0x1054,
+ MACHWDRXBUFFER_COMMITRXBUFFER_0 = 0x1055,
+ MACHWDRXBUFFER_ROLLBACKRXBUFFER_0 = 0x1056,
+ MACHWDRXBUFFER_GETBUFFER_0 = 0x1057,
+ MACHWDRXBUFFER_NEXTBUFFER_0 = 0x1058,
+ MACHWDRXBUFFER_NEXTBUFFER_1 = 0x1059,
+ MACHWDRNDHANDLER_MACHWDCALIBREQHANDLER_0 = 0x1060,
+ MACHWDRNDHANDLER_MACHWDCALIBREQHANDLER_1 = 0x1061,
+ MACHWDCALIBHANDLER_MACHWDCALIBTASKHANDLER_0 = 0x1062,
+
+ // MAC_HWI asserts' ID.
+ MACHWIDATAHANDLER_CONVERTMACHWDDATACONFIRMTYPES_0 = 0x1080,
+ MACHWIMANAGER_SENDREQTOHANDLER_0 = 0x1083,
+ MACHWIMANAGER_TASKHANDLER_0 = 0x1084,
+ MACHWIMANAGER_TASKHANDLER_1 = 0x1085,
+ MACHWISCANHANDLER_MACHWDSETCONFIRM_0 = 0x1086,
+ MACHWISCANHANDLER_MACHWDSETCONFIRM_1 = 0x1087,
+ MACHWISCANHANDLER_MACHWIBEACONINDICATION_0 = 0x1088,
+ MACHWIASSOCIATEHANDLER_MACHWDSETCONFIRM_0 = 0x1089,
+ MACHWIASSOCIATEHANDLER_MACHWDSETTRXSTATECONFIRM_0 = 0x108A,
+ MACHWIASSOCIATEHANDLER_MACHWDDATACONFIRM_0 = 0x108B,
+ MACHWIASSOCIATEHANDLER_MACHWDDATACONFIRM_1 = 0x108C,
+ MACHWIASSOCIATEHANDLER_MACHWDDATACONFIRM_2 = 0x108D,
+ MACHWIASSOCIATEHANDLER_ASSOCIATETIMERFIRED_0 = 0x108E,
+ MACHWITRANSACTIONQUEUE_GETDSTADDRINFO_0 = 0x108F,
+ MACHWITRANSACTIONQUEUE_GETDSTADDRINFO_1 = 0x1090,
+ MACHWITRANSACTIONHANDLER_MACHWDDATACONFIRM_0 = 0x1091,
+ MACHWITRANSACTIONHANDLER_MACHWDDATACONFIRM_1 = 0x1092,
+ MACHWITRANSACTIONHANDLER_SENDTRANSACTIONEVENT_0 = 0x1093,
+ MACHWITRANSACTIONHANDLER_SENDTRANSACTIONEVENT_1 = 0x1094,
+ MACHWITRANSACTIONQUEUE_GETACTIVATEDTRANSACTION_0 = 0x1095,
+ MACHWISTARTHANDLER_MACHWDSETCONFIRM_0 = 0x1096,
+ MACHWISTARTHANDLER_MACHWDSETCONFIRM_1 = 0x1097,
+ MACHWISCANHANDLER_MACHWDSETTRXSTATECONFIRM_0 = 0x1098,
+ MACHWIPOLLHANDLER_MACHWDDATACONFIRM_0 = 0x1099,
+ MACHWIPOLLHANDLER_ISITREQUESTEDDATA_0 = 0x109A,
+ MACHWISCANHANDLER_MACHWDSETTRXSTATECONFIRM_1 = 0x109B,
+ MACHWISCANHANDLER_MACHWDSETTRXSTATECONFIRM_2 = 0x109C,
+ MACHWISCANHANDLER_MACHWISCANREQHANDLER_0 = 0x109D,
+ MACHWISCANHANDLER_MACHWDSETCONFIRM_2 = 0x109E,
+ MACHWISCANHANDLER_MACHWDSETCONFIRM_3 = 0x109F,
+ MACHWISCANHANDLER_MACHWDSETCONFIRM_4 = 0x10A0,
+ MACHWIDISASSOCIATEHANDLER_MACHWDDATACONFIRM_0 = 0x10A1,
+ MACHWISWITCHRXCTRL_SWITCHRXONWHENIDLE_0 = 0x10A2,
+ MACHWIMANAGER_MACHWISENDCONFTOUPPERLAYER_0 = 0x10A3,
+ MACHWISETHANDLER_MACHWDSETCONFIRM_0 = 0x10A4,
+ MACHWIGETHANDLER_MACHWDGETCONFIRM_0 = 0x10A5,
+ MACHWISTARTHANDLER_MACHWISTARTREQHANDLER_0 = 0x10A6,
+ MACHWIRESETHANDLER_MACHWDSETCONFIRM_0 = 0x10A7,
+ MACHWIDISASSOCIATEHANDLER_MACHWDSETCONFIRM_0 = 0x10A8,
+ MACHWISTARTHANDLER_MACHWDDATACONFIRM_0 = 0x10A9,
+ MACHWIENCRYPTHANDLER_MACHWISETKEYREQ_0 = 0x10AA,
+ MACHWIENCRYPTHANDLER_MACHWDENCRYPTCONF_0 = 0x10AB,
+ MACHWIENCRYPTHANDLER_MACHWIENCRYPTREQHANDLER_0 = 0x10AC,
+ MACHWIASSOCIATEHANDLER_SETHANDLING_0 = 0x10AD,
+ MACHWIASSOCIATEHANDLER_MACHWDSETCONFIRM_1 = 0x10AE,
+ MACHWIASSOCIATEHANDLER_ASSOCIATETIMERFIRED_1 = 0x10AF,
+ MACHWIDISASSOCIATEHANDLER_SETHANDLING_0 = 0x10B0,
+ MACHWIRESETHANDLER_SETHANDLING_0 = 0x10B1,
+ MACHWISCANHANDLER_SETHANDLING_0 = 0x10B2,
+ MACHWISCANHANDLER_MACHWDEDCONFIRM_0 = 0x10B3,
+ MACHWISCANHANDLER_TRXSTATEHANDLING_0 = 0x10B4,
+ MACHWISTARTHANDLER_MACHWDSETCONFIRM_2 = 0x10B5,
+ MACHWISWITCHRXCTRL_SWITCHRXONWHENIDLE_1 = 0x10B6,
+ MACHWISTARTHANDLER_SETHANDLING_0 = 0x10B7,
+ MACHWISCANHANDLERC_MACHWDEDCONFIRM_0 = 0x10B8,
+ MACHWISCANHANDLERC_TRXSTATEHANDLING_0 = 0X10b9,
+ PHYRFIRQDISPATCHER_RFINTERRUPTSUBROUTINE_1 = 0x10ba,
+ MACHWITRANSACTIONQUEUE_TESTANDKICKQUEUETRANS_0 = 0x10bb,
+ MACHWIMANAGER_PROCEEDPOSTPONEDACTIONS_0 = 0x10bc,
+ MACHWITRANSACTIONHANDLER_SENDTRANSACTIONEVENT_2 = 0x10bd,
+ MACHWITRANSACTIONHANDLER_SENDTRANSACTIONEVENT_3 = 0x10be,
+ MACHWITRANSACTIONHANDLER_SENDTRANSACTIONEVENT_4 = 0x10bf,
+ MACHWIBANNODE_MACBANNODE0 = 0x10c0,
+
+ MACHWD_RX_RELEASE_BUFFER_LIMIT = 0x1ff9,
+ MACHWD_POST_TASK_TIME_LIMIT = 0x1ffa,
+ MACHWD_RESET_TIME_LIMIT = 0x1ffb,
+ MACHWD_SETHANDLER_ID_1_TIME_LIMIT = 0x1ffc,
+ MACHWD_SETHANDLER_ID_2_TIME_LIMIT = 0x1ffd,
+ MACHWD_SETHANDLER_ID_3_TIME_LIMIT = 0x1ffe,
+ MACHWD_SETHANDLER_ID_4_TIME_LIMIT = 0x1fff
+} MacDbgCode_t;
+
+typedef enum
+{
+ LOG_MAC_MAC_DATA_REQ,
+ LOG_MAC_SEND_REQ_TO_HANDLER,
+ LOG_MAC_SEND_CONF_TO_UPPER,
+ LOG_MAC_SEND_TRANSAC_EVENT,
+ LOG_MAC_SEND_TRANSAC_EVENT2
+} MacLogCodeId_t;
+
+#endif /* _MACDBG_H */
+
+//end of macDbg.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macDisassociate.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macDisassociate.h
new file mode 100644
index 00000000..81e22edf
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macDisassociate.h
@@ -0,0 +1,129 @@
+/**************************************************************************//**
+ \file macDisassociate.h
+
+ \brief Types', constants' and functions' declarations for IEEE 802.15.4-2006
+ disassociation primitives.
+
+ \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:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACDISASSOCIATE_H
+#define _MACDISASSOCIATE_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <macAddr.h>
+#include <macCommon.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/**************************************************************************//**
+ \brief Disassociation possible reasons.
+
+ IEEE 802.15.4-2006 7.3.3.2 Disassociation Reason field.
+******************************************************************************/
+typedef enum
+{
+ MAC_COORDINATOR_WISHES_DEVICE_LEAVE_PAN_REASON = 0x01,
+ MAC_DEVICE_WISHES_LEAVE_PAN_REASON = 0x02,
+} MAC_DeassociateReason_t;
+
+/**************************************************************************//**
+ \brief MLME-DISASSOCIATE confirm primitive's parameters structure declaration.
+
+ IEEE 802.15.4-2006 7.1.4.3 MLME-DISASSOCIATE.confirm.
+******************************************************************************/
+typedef struct
+{
+ //! The status of the disassociation attempt.
+ MAC_Status_t status;
+ //! The addressing mode of the device that has either requested
+ //! disassociation or been instructed to disassociate by its coordinator.
+ MAC_AddrMode_t deviceAddrMode;
+ //! The PAN identifier of the device that has either requested disassociation or
+ //! been instructed to disassociate by its coordinator.
+ PanId_t devicePanId;
+ //! The address of the device that has either requested disassociation or
+ //! been instructed to disassociate by its coordinator.
+ MAC_Addr_t deviceAddr;
+} MAC_DisassociateConf_t;
+
+/**************************************************************************//**
+ \brief MLME-DISASSOCIATE request primitive's parameters structure declaration.
+
+ IEEE 802.15.4-2006 7.1.4.3 MLME-DISASSOCIATE.confirm.
+******************************************************************************/
+typedef struct
+{
+ //! Service field - for internal needs.
+ MAC_ServiceTransaction_t service;
+ //! The addressing mode of the device to which to send the disassociation
+ //! notification command.
+ MAC_AddrMode_t deviceAddrMode;
+ //! The PAN identifier of the device to which to send the disassociation
+ //! notification command.
+ PanId_t devicePanId;
+ //! The address of the device to which to send the disassociation notification command.
+ MAC_Addr_t deviceAddr;
+ //! The reason for the disassociation.
+ MAC_DeassociateReason_t reason;
+ //! TRUE if the disassociation notification command is to be sent indirectly.
+ bool txIndirect;
+ //! MLME-DISASSOCIATE confirm callback fubction's pointer.
+ void (*MAC_DisassociateConf)(MAC_DisassociateConf_t *conf);
+ //! MLME-DISASSOCIATE confirm parameters' structure.
+ MAC_DisassociateConf_t confirm;
+} MAC_DisassociateReq_t;
+
+/*************************************************************************//**
+ \brief MLME-DISASSOCIATE indication primitive's parameters.
+
+ IEEE 802.15.4-2006 7.1.4.2 MLME-DISASSOCIATE.indication.
+*****************************************************************************/
+typedef struct
+{
+ //! The address of the device requesting disassociation.
+ ExtAddr_t extAddr;
+ //! The reason for the disassociation.
+ MAC_DeassociateReason_t reason;
+} MAC_DisassociateInd_t;
+
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief MLME-DISASSOCIATE request primitive's prototype.
+
+ \param reqParams - MLME-DISASSOCIATE request parameters' structure pointer.
+ \return none.
+******************************************************************************/
+void MAC_DisassociateReq(MAC_DisassociateReq_t *reqParams);
+
+/**************************************************************************//**
+ \brief MLME-DISASSOCIATE indication primitive's prototype.
+
+ \param indParams - MLME-DISASSOCIATE indication parameters' structure pointer.
+ \return none.
+******************************************************************************/
+extern void MAC_DisassociateInd(MAC_DisassociateInd_t *indParams);
+
+#endif /* _MACDISASSOCIATE_H */
+
+// eof macDisassociate.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macEnvironment.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macEnvironment.h
new file mode 100644
index 00000000..155f7983
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macEnvironment.h
@@ -0,0 +1,59 @@
+/**************************************************************************//**
+ \file macEnvironment.h
+
+ \brief Public interface of MAC Environment.
+
+ \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:
+ 22/02/11 M. Gekk - Created.
+ ******************************************************************************/
+#ifndef _MAC_ENVIRONMENT_H
+#define _MAC_ENVIRONMENT_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <macAddr.h>
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Gets pointer to extended address.
+ \return pointer to extended address.
+ ******************************************************************************/
+const ExtAddr_t* MAC_GetExtAddr(void);
+
+/**************************************************************************//**
+ \brief Sets extended address.
+ \param extAddr - extended address.
+
+ \return none.
+ ******************************************************************************/
+void MAC_SetExtAddr(const ExtAddr_t *const extAddr);
+
+/**************************************************************************//**
+ \brief Checks, if extended address is equal to our own one
+ \param extAddr - pointer to extended address to check
+
+ \return true, if extended address is equal to our own one; false - otherwise
+ ******************************************************************************/
+bool MAC_IsOwnExtAddr(const ExtAddr_t *const extAddr);
+
+/**************************************************************************//**
+ \brief Convert octet amount to transmit duration.
+ \param octets - number of octets.
+
+ \return Time of octets transmission in milliseconds.
+ ******************************************************************************/
+uint32_t MAC_GetOctetsTransmissionTimeInMs(const uint32_t octets);
+
+#endif /* _MAC_ENVIRONMENT_H */
+/** eof macEnvironment.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macFrame.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macFrame.h
new file mode 100644
index 00000000..21b0e62d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macFrame.h
@@ -0,0 +1,205 @@
+/**************************************************************************//**
+ \file macFrame.h
+
+ \brief MAC frame fields' declarations.
+
+ \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:
+ 19/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACFRAME_H
+#define _MACFRAME_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <bcEndian.h>
+#include <macBeacon.h>
+#include <macAssociate.h>
+#include <macDisassociate.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+//! Beacon frame type. IEEE 802.15.4-2006 Table 79.
+#define MAC_BEACON_FRAME_CODE 0x00
+//! Data frame type. IEEE 802.15.4-2006 Table 79.
+#define MAC_DATA_FRAME_CODE 0x01
+//! Ack frame type. IEEE 802.15.4-2006 Table 79.
+#define MAC_ACK_FRAME_CODE 0x02
+//! Command frame type. IEEE 802.15.4-2006 Table 79.
+#define MAC_CMD_FRAME_CODE 0x03
+
+//! IEEE 802.15.4-2003 standart frames.
+#define FRAME_VERSION_2003 0x00
+//! IEEE 802.15.4-2006 standart frames.
+#define FRAME_VERSION_2006 0x01
+
+#ifdef _MAC_IEEE_STD_2003_
+#define FRAME_VERSION FRAME_VERSION_2003
+#else
+#define FRAME_VERSION FRAME_VERSION_2006
+#endif
+
+#define MAC_FRAME_CONTROL_FIELD_SIZE 2
+#define MAC_SUPERFRAME_SPEC_FIELD_SIZE 2
+#define MAC_GTS_LIST_FIELD_SIZE 3 ///< See IEEE 802.15.4-2006 chart 7.2.2.1.5
+#define MAC_GTS_SPEC_FIELD_SIZE 1
+#define MAC_PEND_ADDR_SPEC_FIELD_SIZE 1
+#define MAC_CAPABILITY_INF_FIELD_SIZE 1
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+//! Set of possible frame types and commands.
+typedef enum
+{
+ MAC_UNKNOWN_FRAME_TYPE,
+ MAC_BEACON_FRAME_TYPE,
+ MAC_DATA_FRAME_TYPE,
+ MAC_ACK_FRAME_TYPE,
+ MAC_ASSOCIATE_REQ_CMD_FRAME_TYPE,
+ MAC_ASSOCIATE_RESP_CMD_FRAME_TYPE,
+ MAC_DISASSOCIATE_NOTIF_CMD_FRAME_TYPE,
+ MAC_DATA_REQ_CMD_FRAME_TYPE,
+ MAC_PANID_CONFLICT_NOTIF_CMD_FRAME_TYPE,
+ MAC_ORPHAN_NOTIF_CMD_FRAME_TYPE,
+ MAC_BEACON_REQ_CMD_FRAME_TYPE,
+ MAC_COORD_REALIG_CMD_FRAME_TYPE,
+ //MAC_GTS_REQ_CMD_FRAME_TYPE,
+} MAC_Frame_t;
+
+//! Frame contol field. IEEE 802.15.4-2006, Figure 42.
+BEGIN_PACK
+typedef struct PACK // Frame control.
+{
+ LITTLE_ENDIAN_OCTET(6, (
+ uint16_t type : 3,
+ uint16_t security : 1,
+ uint16_t framePending : 1,
+ uint16_t ack : 1,
+ uint16_t intraPAN : 1,
+ uint16_t reserved1 : 1
+ ))
+ LITTLE_ENDIAN_OCTET(4, (
+ uint16_t reserved2 : 2,
+ uint16_t dstAddrMode : 2,
+ uint16_t frameVersion : 2,
+ uint16_t srcAddrMode : 2
+ ))
+} MAC_FrameCtrl_t;
+END_PACK
+
+//! Associate request payload description.
+typedef struct
+{
+ //! See IEEE 802.15.4-2006, Figure 56.
+ MAC_CapabilityInf_t capability;
+} MAC_AssociateReqPldDescr_t;
+
+//! Beacon description.
+typedef struct
+{
+ //uint32_t timeStamp;
+ //! Channel on which beacon was received.
+ uint8_t channel;
+ //! Superframe specification field, IEEE 802.15.4-2006 Figure 47.
+ MAC_SuperframeSpec_t superframeSpec;
+ //! GTS specification field, IEEE 802.15.4-2006 Figure 48.
+ MAC_GtsSpec_t gtsSpec;
+ //! GTS direction field, IEEE 802.15.4-2006 Figure 49.
+ MAC_GtsDirection_t gtsDirection;
+ //! IEEE 802.15.4-2006, 7.2.2.1.5 GTS List field.
+ MAC_GtsDescr_t *gtsList[MAC_GTS_MAX];
+ //! IEEE 802.15.4-2006, 7.2.2.1.6 Pending Address Specification field
+ MAC_PendingAddrSpec_t pendAddrSpec;
+ //! Short addresses list pointer.
+ ShortAddr_t (*shortPendAddrList)[];
+ //! Extended addresses list pointer.
+ ExtAddr_t (*extPendAddrList)[];
+} MAC_BeaconPldDescr_t;
+
+//! Description of associate response command MAC payload.
+typedef struct
+{
+ //! Allocated short address (in case of successfull association).
+ ShortAddr_t shortAddr;
+ //! Result of association.
+ uint8_t status;
+} MAC_AssociateRespPldDescr_t;
+
+//! Description of diassociate notification command MAC payload.
+typedef struct
+{
+ //! Disassociation reason.
+ MAC_DeassociateReason_t reason;
+} MAC_DisassociateNotifPldDescr_t;
+
+//! Coordinator realignment command MAC payload. IEEE 802.15.4-2006, 7.3.8
+typedef struct
+{
+ //! PAN identifier that the coordinator intends to use for all future communications.
+ PanId_t panId;
+ //! The coordinator short address field shall contain the value of macShortAddress.
+ ShortAddr_t coordShortAddr;
+ //! The logical channel that the coordinator intends to use for all future communications.
+ uint8_t channel;
+ //! Short address allocated for the device in case of orphan scan procedure, 0xffff otherwise.
+ ShortAddr_t shortAddr;
+ uint8_t page;
+} MAC_CoordinatorRealignmentPldDescr_t;
+
+//! Frame descriptor.
+typedef struct
+{
+ //! Frame type.
+ MAC_Frame_t type;
+ //! Frame control field, IEEE 802.15.4-2006 Figure 42.
+ MAC_FrameCtrl_t frameControl;
+ //! Data sequense number field.
+ uint8_t dsn;
+ //! Frame's destination PAN identifire.
+ PanId_t dstPANId;
+
+ //! Frame's destination address.
+ MAC_Addr_t dstAddr;
+ //! Frame's source PAN identifire.
+ PanId_t srcPANId;
+ //! Frame's source address.
+ MAC_Addr_t srcAddr;
+ union
+ {
+ //! Beacon payload description.
+ MAC_BeaconPldDescr_t beacon;
+ //! Associate request command payload description.
+ MAC_AssociateReqPldDescr_t associateReq;
+ //! Associate response command payload description.
+ MAC_AssociateRespPldDescr_t associateResp;
+ //! Disassociate nofification command payload description.
+ MAC_DisassociateNotifPldDescr_t disassociateNotif;
+ //! Coordinator realignment command payload description.
+ MAC_CoordinatorRealignmentPldDescr_t coordRealig;
+ //! GTS characteristics.
+ MAC_GtsCharacteristics_t gtsCharacteristics;
+ } payload;
+ //! MSDU pointer.
+ uint8_t *msdu;
+ //! MSDU length.
+ uint8_t msduLength;
+ //! Incoming frame's link quality.
+ uint8_t quality;
+ //! Incoming frame's RSSI.
+ int8_t rssi;
+} MAC_FrameDescr_t;
+
+#endif // _MACFRAME_H
+
+// eof macFrame.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macMem.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macMem.h
new file mode 100644
index 00000000..01331ed4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macMem.h
@@ -0,0 +1,52 @@
+/******************************************************************************
+ \file macMem.h
+
+ \brief MAC memory type.
+
+ \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:
+ 23/04/08 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _MACMEM_H
+#define _MACMEM_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <machwiMem.h>
+#include <machwdMem.h>
+#include <macenvMem.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef struct
+{
+ MachwiMem_t hwi;
+ MachwdMem_t hwd;
+} MAC_Mem_t;
+
+/******************************************************************************
+ Extern variables section
+******************************************************************************/
+extern MAC_Mem_t macMem;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+#endif /*_MACMEM_H*/
+
+// eof macMem.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macOrphan.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macOrphan.h
new file mode 100644
index 00000000..a4dfa05b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macOrphan.h
@@ -0,0 +1,81 @@
+/**************************************************************************//**
+ \file macOrphan.h
+
+ \brief Types', constants' and functions' declarations for IEEE 802.15.4-2006
+ orphan primitives.
+
+ \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:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACORPHAN_H
+#define _MACORPHAN_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <macAddr.h>
+#include <macCommon.h>
+#include <macCommStatus.h>
+
+/******************************************************************************
+ Definitions section.
+******************************************************************************/
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+//! MLME-ORPHAN indication primitive's parameters. IEEE 802.15.4-2006 7.1.8.1
+typedef struct
+{
+ //! The address of the orphaned device.
+ ExtAddr_t extAddr;
+} MAC_OrphanInd_t;
+
+//! MLME-ORPHAN response pritive's parameters. IEEE 802.15.4-2006 7.1.8.2
+typedef struct
+{
+ //! Service field - for internal needs.
+ MAC_Service_t service;
+ //! The address of the orphaned device.
+ ExtAddr_t extAddr;
+ //! The 16-bit short address allocated to the orphaned device if it is
+ //! associated with this coordinator.
+ ShortAddr_t shortAddr;
+ //! TRUE if the orphaned device is associated with this coordinator or FALSE otherwise.
+ bool associate;
+ //! MLME-ORPHAN response callback function pointer.
+ void (*MAC_CommStatusInd)(MAC_CommStatusInd_t *commStat);
+ // MLME-COMM_STATUS parameters' structure.
+ MAC_CommStatusInd_t commStatus;
+} MAC_OrphanResp_t;
+
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief MLME-ORPHAN indication primitive's prototype.
+ \param indParams - MLME-ORPHAN indication parameters' structure pointer.
+ \return none.
+******************************************************************************/
+extern void MAC_OrphanInd(MAC_OrphanInd_t *indParams);
+
+/**************************************************************************//**
+ \brief MLME-ORPHAN response primitive's prototype.
+ \param respParams - MLME-ORPHAN response parameters' structure pointer.
+ \return none.
+******************************************************************************/
+void MAC_OrphanResp(MAC_OrphanResp_t *respParams);
+
+#endif // _MACORPHAN_H
+
+// eof macOrphan.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macPoll.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macPoll.h
new file mode 100644
index 00000000..b1581508
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macPoll.h
@@ -0,0 +1,105 @@
+/**************************************************************************//**
+ \file macPoll.h
+
+ \brief Types', constants' and functions' declarations for IEEE 802.15.4-2006
+ data requesting primitives.
+
+ \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:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACPOLL_H
+#define _MACPOLL_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <macAddr.h>
+#include <macCommon.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/**
+ * \brief MLME-POLL confirm primitive's parameters structure.
+ * IEEE 802.15.4-2006 7.1.16.2 MLME-POLL.confirm.
+ */
+typedef struct
+{
+ //! The status of the data request.
+ MAC_Status_t status;
+} MAC_PollConf_t;
+
+/**
+ * \brief MLME-POLL request primitive's parameters structure declaration.
+ * IEEE 802.15.4-2006 7.1.16.1 MLME-POLL.request.
+ */
+typedef struct
+{
+ //! Service field - for internal needs.
+ MAC_Service_t service;
+ //! The addressing mode of the coordinator to which the poll is intended.
+ MAC_AddrMode_t coordAddrMode;
+ //! The PAN identifier of the coordinator to which the poll is intended.
+ PanId_t coordPANId;
+ //! The address of the coordinator to which the poll is intended.
+ MAC_Addr_t coordAddr;
+ //! MLME-POLL callback function's pointer.
+ void (*MAC_PollConf)(MAC_PollConf_t *conf);
+ //! MLME-POLL confirm parameters' structure.
+ MAC_PollConf_t confirm;
+} MAC_PollReq_t;
+
+/**
+ * \brief MLME-POLL indication primitive's parameters.
+ * This primitive is not described in IEEE 802.15.4-2006. Non-standard addition.
+ */
+typedef struct
+{
+ //! The addressing mode of the device from which poll request is isued.
+ MAC_AddrMode_t srcAddrMode;
+ //! The PAN identifier of the device from which poll request is isued.
+ PanId_t srcPANId;
+ //! The address of the device from which poll request is isued.
+ MAC_Addr_t srcAddr;
+ //! LQI value measured during reception of the data request command.
+ uint8_t linkQuality;
+ //! The DSN of the received data request command
+ uint8_t dsn;
+ // RSSI value measured during reception of the data request command.
+ int8_t rssi;
+} MAC_PollInd_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief MLME-POLL indication primitive's prototype.
+ \param indParams - MLME-POLL indication parameters' structure pointer.
+ \return none.
+******************************************************************************/
+extern void MAC_PollInd(MAC_PollInd_t *indParams);
+
+/**************************************************************************//**
+ \brief MLME-POLL request primitive's prototype.
+ \param reqParams - MLME-POLL request parameters' structure pointer.
+ \return none.
+******************************************************************************/
+void MAC_PollReq(MAC_PollReq_t *reqParams);
+
+#endif /* _MACPOLL_H */
+
+// eof macPoll.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macPurge.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macPurge.h
new file mode 100644
index 00000000..dad169a3
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macPurge.h
@@ -0,0 +1,75 @@
+/**************************************************************************//**
+ \file macPurge.h
+
+ \brief Types', constants' and functions' declarations for IEEE 802.15.4-2006
+ purge primitives.
+
+ \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:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACPURGE_H
+#define _MACPURGE_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <macCommon.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/**
+ * \brief MCPS-PURGE confirm primitive's parameters structure declaration.
+ * IEEE 802.15.4-2006 7.1.1.5 MCPS-PURGE.confirm.
+ */
+typedef struct
+{
+ //! The handle of the MSDU requested to be purge from the transaction queue.
+ uint8_t msduHandle;
+ //! The status of the request to be purged an MSDU from the transaction queue.
+ MAC_Status_t status;
+} MAC_PurgeConf_t;
+
+/**
+ * \brief MCPS-PURGE request primitive's parameters structure declaration.
+ * IEEE 802.15.4-2006 7.1.1.4 MCPS-PURGE.request.
+ */
+typedef struct
+{
+ //! Service field - for internal needs.
+ MAC_Service_t service;
+ //! The handle of the MSDU to be purged from the transaction queue.
+ uint8_t msduHandle;
+ //! MCPS-PURGE confirm callback function pointer.
+ void (*MAC_PurgeConf)(MAC_PurgeConf_t *conf);
+ //! MCPS-PURGE confirm parameters' structure.
+ MAC_PurgeConf_t confirm;
+} MAC_PurgeReq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief MCPS-PURGE request primitive's prototype.
+ \param reqParams - MCPS-PURGE request parameters' structure pointer.
+ \return none.
+******************************************************************************/
+void MAC_PurgeReq(MAC_PurgeReq_t *reqParams);
+
+#endif /* _MACPURGE_H */
+
+// eof macPurge.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macReset.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macReset.h
new file mode 100644
index 00000000..6f1365ea
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macReset.h
@@ -0,0 +1,73 @@
+/**************************************************************************//**
+ \file macReset.h
+
+ \brief Types', constants' and functions' declarations for IEEE 802.15.4-2006
+ reset primitives.
+
+ \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:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACRESET_H
+#define _MACRESET_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <macAddr.h>
+#include <macCommon.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+/******************************************************************************
+ Types section
+******************************************************************************/
+/**
+ * \brief MLME-RESET confirm primitive's parameters structure declaration.
+ * IEEE 802.15.4-2006 7.1.9.2 MLME-RESET.confirm.
+ */
+typedef struct
+{
+ //! The result of the reset operation.
+ MAC_Status_t status;
+} MAC_ResetConf_t;
+
+/**
+ * \brief MLME-RESET request primitive's parameters structure declaration.
+ * IEEE 802.15.4-2006 7.1.9.1 MLME-RESET.request
+ */
+typedef struct
+{
+ //! Service field - for internal needs.
+ MAC_Service_t service;
+ //! If TRUE, the MAC sublayer is reset, and all MAC PIB attributes are set
+ //! to their default values. It resets radio chip also.
+ bool setDefaultPib;
+ // MLME-RESET confirm callback function's pointer.
+ void (*MAC_ResetConf)(MAC_ResetConf_t *conf);
+ // MLME-RESET confirm parameters structure.
+ MAC_ResetConf_t confirm;
+} MAC_ResetReq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief MLME-RESET request primitive's prototype.
+ \param reqParams - MLME-RESET request parameters' structure pointer.
+ \return none.
+******************************************************************************/
+void MAC_ResetReq(MAC_ResetReq_t *reqParams);
+
+#endif /* _MACRESET_H */
+
+// eof macReset.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macRxEnable.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macRxEnable.h
new file mode 100644
index 00000000..f8a8e65c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macRxEnable.h
@@ -0,0 +1,78 @@
+/**************************************************************************//**
+ \file macRxEnable.h
+
+ \brief Types', constants' and functions' declarations for IEEE 802.15.4-2006
+ rx enable primitives.
+
+ \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:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACRXENABLE_H
+#define _MACRXENABLE_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <macAddr.h>
+#include <macCommon.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/**
+ * \brief MLME-RX_ENABLE confirm primitive's parameters structure declaration.
+ * IEEE 802.15.4-2006 7.1.10.2 MLME-RX-ENABLE.confirm.
+ */
+typedef struct
+{
+ //! The result of the request to enable or disable the receiver.
+ MAC_Status_t status;
+} MAC_RxEnableConf_t;
+
+/**
+ * \brief MLME-RX_ENABLE request primitive's parameters structure declaration.
+ * IEEE 802.15.4-2006 7.1.10.1 MLME-RX-ENABLE.request.
+ * deferPermit and rxOnTime are NOT used - superframe functionality is not implemented.
+ * rxOnDuration behaviour is changed. Non-standard addition.
+ */
+typedef struct
+{
+ //! Service field - for internal needs.
+ MAC_Service_t service;
+ //! Behaviour is changed. If rxOnDuration == 0 the receiver is switched off.
+ //! If rxOnDuartion != 0 the receiver is switched on.
+ uint32_t rxOnDuration;
+ //! MLME-RX-ENABLE callback pointer.
+ void (*MAC_RxEnableConf)(MAC_RxEnableConf_t *conf);
+ //! MLME-RX-ENABLE confirm parameters' structure.
+ MAC_RxEnableConf_t confirm;
+} MAC_RxEnableReq_t;
+
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief MLME-RX_ENABLE request primitive's prototype.
+ \param reqParams - MLME-RX_ENABLE request parameters' structure pointer.
+ \return none.
+******************************************************************************/
+void MAC_RxEnableReq(MAC_RxEnableReq_t *reqParams);
+
+#endif /* _MACRXENABLE_H */
+
+// eof macRxEnable.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macScan.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macScan.h
new file mode 100644
index 00000000..e5ae53b9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macScan.h
@@ -0,0 +1,116 @@
+/**************************************************************************//**
+ \file macScan.h
+
+ \brief Types', constants' and functions' declarations for IEEE 802.15.4-2006
+ scanning primitives.
+
+ \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:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACSCAN_H
+#define _MACSCAN_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <phy.h>
+#include <macAddr.h>
+#include <macBeacon.h>
+#include <macCommon.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+//! Set of MAC scanning types. IEEE 802.15.4-2006 Table 67.
+typedef enum
+{
+ MAC_ED_SCAN = 0x00,
+ MAC_ACTIVE_SCAN = 0x01,
+ MAC_PASSIVE_SCAN = 0x02,
+ MAC_ORPHAN_SCAN = 0x03
+} MAC_ScanType_t;
+
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/**
+ * \brief Scanning results union. Contains results of energy scanning
+ * procedure and passive/active scan procedures.
+ */
+typedef union
+{
+ //! Energy scanning procedure results.
+ PHY_EnergyLevel_t (*energy)[];
+ //! Active/passive scanning procedure results.
+ MAC_PanDescriptor_t (*panDescr)[];
+} MAC_ScanResult_t;
+
+/**
+ * \brief MLME-SCAN confirm primitive's parameters structure declaration.
+ * IEEE 802.15.4-2006 7.1.11.2 MLME-SCAN.confirm
+ */
+typedef struct
+{
+ //! The status of the scan request.
+ MAC_Status_t status;
+ //! Indicates the type of scan performed:
+ MAC_ScanType_t type;
+ //! The channel page on which the scan was performed TBD
+ uint8_t page;
+ //! Indicates which channels given in the request were not scanned.
+ uint32_t unScannedChannels;
+ //! The number of elements returned in the appropriate result lists.
+ uint8_t resultSize;
+ //! EnergyDetectList and PANDescriptorList union. Non-standard addition.
+ MAC_ScanResult_t result;
+} MAC_ScanConf_t;
+
+/**
+ * \brief MLME-SCAN request primitive's parameters structure declaration.
+ * IEEE 802.15.4-2006 7.1.11.1 MLME-SCAN.request.
+ */
+typedef struct
+{
+ //! Service field - for internal needs.
+ MAC_Service_t service;
+ //! Indicates the type of scan performed.
+ MAC_ScanType_t type;
+ //! The 27 bits indicate which channels are to be scanned.
+ uint32_t channels;
+ //! A value used to calculate the length of time to spend scanning each channel
+ //! for ED, active, and passive scans. This parameter is ignored for orphan scans.
+ uint8_t duration;
+ //! The channel page on which to perform the scan.
+ uint8_t page;
+ //! Non-standard addition. Max number of scan results.
+ uint8_t maxResultSize;
+ // MLME-SCAN confirm callback function's pointer.
+ void (*MAC_ScanConf)(MAC_ScanConf_t *conf);
+ // MLME-SCAN confirm parameters structure.
+ MAC_ScanConf_t confirm;
+} MAC_ScanReq_t;
+
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief MLME-SCAN request primitive's prototype.
+ \param reqParams - MLME-SCAN request parameters' structure pointer.
+ \return none.
+******************************************************************************/
+void MAC_ScanReq(MAC_ScanReq_t *reqParams);
+
+#endif /* _MACSCAN_H */
+
+// eof macScan.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macSetGet.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macSetGet.h
new file mode 100644
index 00000000..71eaaa67
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macSetGet.h
@@ -0,0 +1,113 @@
+/**************************************************************************//**
+ \file macSetGet.h
+
+ \brief Types', constants' and functions' declarations for IEEE 802.15.4-2006
+ set and get primitives.
+
+ \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:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACSETGET_H
+#define _MACSETGET_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <macphyPib.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/**
+ * \brief MLME-SET confirm primitive's parameters structure declaration.
+ * IEEE 802.15.4-2006 7.1.13.2 MLME-SET.confirm.
+*/
+typedef struct
+{
+ //! The result of the request to write the PIB attribute.
+ MAC_Status_t status;
+ //! The identifier of the PIB attribute that was written.
+ MACPHY_PibId_t attrId;
+} MAC_SetConf_t;
+
+/**
+ * \brief MLME-SET request primitive's parameters structure declaration.
+ * IEEE 802.15.4-2006 7.1.13.1 MLME-SET.request.
+ */
+typedef struct
+{
+ //! Service field - for internal needs.
+ MAC_Service_t service;
+ //! The identifier of the PIB attribute to write.
+ MACPHY_PibId_t attrId;
+ //! The value to write to the indicated PIB attribute.
+ MACPHY_PibAttr_t attrValue;
+ //! MLME-SET confirm callback function's pointer.
+ void (*MAC_SetConf)(MAC_SetConf_t *conf);
+ //! MLME-SET confirm parameters' structure.
+ MAC_SetConf_t confirm;
+} MAC_SetReq_t;
+
+/**
+ * \brief MLME-GET confirm primitive's parameters structure declaration.
+ * IEEE 802.15.4-2006 7.1.6.2 MLME-GET.confirm.
+ */
+typedef struct
+{
+ //! The result of the request for PIB attribute information.
+ MAC_Status_t status;
+ //! The identifier of the PIB attribute that was read.
+ MACPHY_PibId_t attrId;
+ //! The value of the indicated PIB attribute that was read.
+ MACPHY_PibAttr_t attrValue;
+} MAC_GetConf_t;
+
+/**
+ * \brief MLME-GET request primitive's parameters structure declaration.
+ * IEEE 802.15.4-2006 7.1.6.1 MLME-GET.request.
+ */
+typedef struct
+{
+ //! Service field - for internal needs.
+ MAC_Service_t service;
+ //! The identifier of the PIB attribute to read.
+ MACPHY_PibId_t attrId;
+ //! MLME-GET confirm callback function's pointer.
+ void (*MAC_GetConf)(MAC_GetConf_t *conf);
+ //! MLME-GET confirm parameters' structure.
+ MAC_GetConf_t confirm;
+} MAC_GetReq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief MLME-SET request primitive's prototype.
+ \param reqParams - MLME-SET request parameters' structure pointer.
+ \return none.
+******************************************************************************/
+void MAC_SetReq(MAC_SetReq_t *reqParams);
+
+/**************************************************************************//**
+ \brief MLME-GET request primitive's prototype.
+ \param reqParams - MLME-GET request parameters' structure pointer.
+ \return none.
+******************************************************************************/
+void MAC_GetReq(MAC_GetReq_t *reqParams);
+
+#endif /* _MACSETGET_H */
+
+// eof macSetGet.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macStart.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macStart.h
new file mode 100644
index 00000000..62abc6ea
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macStart.h
@@ -0,0 +1,89 @@
+/**************************************************************************//**
+ \file macStart.h
+
+ \brief Types', constants' and functions' declarations for IEEE 802.15.4-2006
+ start primitives.
+
+ \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:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACSTART_H
+#define _MACSTART_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <macAddr.h>
+#include <macCommon.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/**
+ * \brief MLME-START confirm primitive's parameters structure declaration.
+ * IEEE 802.15.4-2006 7.1.14.2 MLME-START.confirm.
+ */
+typedef struct
+{
+ //! The result of the attempt to start using an updated superframe configuration.
+ MAC_Status_t status;
+} MAC_StartConf_t;
+
+/**
+ * \brief MLME-START request primitive's parameters structure declaration.
+ * IEEE 802.15.4-2006 7.1.14.1 MLME-START.request.
+ */
+typedef struct
+{
+ //! Service field - for internal needs.
+ MAC_Service_t service;
+ //! The PAN identifier to be used by the device.
+ PanId_t panId;
+ //! The logical channel on which to start using the new configuration.
+ uint8_t channel;
+ //! The channel page on which to begin using the new configuration.
+ uint8_t page;
+ // NOT used - superframe functionality is not implemented.
+ //uint8_t beaconOrder;
+ // NOT used - superframe functionality is not implemented.
+ //uint8_t superframeOrder;
+ //! If this value is TRUE, the device will become the PAN coordinator of a new PAN.
+ bool panCoordinator;
+ // NOT used - superframe functionality is not implemented.
+ //bool batteryLifeExt;
+ //! TRUE if a coordinator realignment command is to be transmitted prior to
+ //! changing the superframe configuration or FALSE otherwise. TBD.
+ bool coordRealignment;
+ //! MLME-START confirm callback fubction's pointer.
+ void (*MAC_StartConf)(MAC_StartConf_t *conf);
+ //! MLME-START confirm parameters' structure.
+ MAC_StartConf_t confirm;
+} MAC_StartReq_t;
+
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief MLME-START request primitive's prototype.
+ \param reqParams - MLME-START request parameters' structure pointer.
+ \return none.
+******************************************************************************/
+void MAC_StartReq(MAC_StartReq_t *reqParams);
+
+#endif /* _MACSTART_H */
+
+// eof macStart.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macSuperframe.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macSuperframe.h
new file mode 100644
index 00000000..7203deb5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macSuperframe.h
@@ -0,0 +1,104 @@
+/**************************************************************************//**
+ \file macSuperframe.h
+
+ \brief Superframe types' declarations.
+
+ \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:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACSUPERFRAME_H
+#define _MACSUPERFRAME_H
+
+/******************************************************************************
+ Include section.
+******************************************************************************/
+#include <types.h>
+#include <bcEndian.h>
+#include <macAddr.h>
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+//! MAC GTS characteristics. IEEE 802.15.4-2006 Figure 65.
+BEGIN_PACK
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(4, (
+ uint8_t length : 4,
+ uint8_t direction : 1,
+ uint8_t type : 1,
+ uint8_t reserved : 2
+ ))
+} MAC_GtsCharacteristics_t;
+END_PACK
+
+//! Superframe specification. IEEE 802.15.4-2006 Figure 47.
+BEGIN_PACK
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(2, (
+ uint16_t beaconOrder : 4,
+ uint16_t superframeOrder : 4
+ ))
+ LITTLE_ENDIAN_OCTET(5, (
+ uint16_t finalCapSlot : 4,
+ uint16_t battLifeExt : 1,
+ uint16_t reserved : 1,
+ uint16_t panCoordinator : 1,
+ uint16_t associationPermit : 1
+ ))
+} MAC_SuperframeSpec_t;
+END_PACK
+
+//! GTS specification field. IEEE 802.15.4-2006 Figure 48.
+BEGIN_PACK
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(3, (
+ uint8_t count : 3,
+ uint8_t reserved : 4,
+ uint8_t permit : 1
+ ))
+} MAC_GtsSpec_t;
+END_PACK
+
+//! GTS descriptor. IEEE 802.15.4-2006 Figure 50.
+BEGIN_PACK
+typedef struct PACK
+{
+ ShortAddr_t shortAddr;
+ struct
+ {
+ LITTLE_ENDIAN_OCTET(2, (
+ uint8_t startSlot : 4,
+ uint8_t length : 4
+ ))
+ } gts;
+} MAC_GtsDescr_t;
+END_PACK
+
+/******************************************************************************
+ Defines section.
+******************************************************************************/
+//! Max of GTS.
+#define MAC_GTS_MAX 7
+
+//! MAC GTS direction type. IEEE 802.15.4-2006 7.3.9.2 GTS Characteristics field.
+typedef enum
+{
+ MAC_GTS_DIRECTION_TRANSMIT = 0,
+ MAC_GTS_DIRECTION_RECEIVE = 1
+} MAC_GtsDirection_t;
+
+#endif // _MACSUPERFRAME_H
+
+// eof macSuperframe.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macSync.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macSync.h
new file mode 100644
index 00000000..a91a4fed
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macSync.h
@@ -0,0 +1,70 @@
+/**************************************************************************//**
+ \file macSync.h
+
+ \brief Types', constants' and functions' declarations for IEEE 802.15.4-2006
+ sync primitives.
+
+ \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:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACSYNC_H
+#define _MACSYNC_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+//! Set of loss indication reasons. IEEE 802.15.4-2006 Table 75.
+typedef enum
+{
+ MAC_PAN_ID_CONFLICT = 0,
+ MAC_REALIGNMENT = 1,
+ MAC_BEACON_LOSS = 2
+} MAC_SyncLossReason_t;
+
+//! MLME-SYNC_LOSS indication structure. IEEE 802.15.4-2006 7.1.15.2
+typedef struct
+{
+ //! The reason that synchronization was lost.
+ MAC_SyncLossReason_t reason;
+ //! The PAN identifier with which the device lost synchronization or to which
+ //! it was realigned.
+ PanId_t panId;
+ //! The logical channel on which the device lost synchronization or to which it
+ //! was realigned.
+ uint8_t logicalChannel;
+ //! The channel page on which the device lost synchronization or to which it
+ //! was realigned.
+ uint8_t channelPage;
+} MAC_SyncLossInd_t;
+
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief MLME-SYNC_LOSS indication primitive's prototype.
+ \param indParams - MLME-SYNC_LOSS indication parameters' structure pointer.
+ \return none.
+******************************************************************************/
+extern void MAC_SyncLossInd(MAC_SyncLossInd_t *indParams);
+
+#endif /* _MACSYNC_H */
+
+// eof macSync.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macphyPib.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macphyPib.h
new file mode 100644
index 00000000..36cb28b0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/macphyPib.h
@@ -0,0 +1,381 @@
+/**************************************************************************//**
+ \file macphyPib.h
+
+ \brief Types', constants' and functions' declarations for IEEE 802.15.4-2006
+ MAC and PHY PIB access.
+
+ \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:
+ 28/09/07 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _MACPHYPIB_H
+#define _MACPHYPIB_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <inttypes.h>
+#include <phy.h>
+#include <macAddr.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+/**
+ * \brief The maximum PSDU size (in octets) the PHY shall be able to receive/send.
+ * IEEE Std 802.15.4-2006. Table 22.
+*/
+#define PHY_MAX_PACKET_SIZE 127U
+
+//! RX-to-TX or TX-to-RX maximum turnaround time. IEEE Std 802.15.4-2006. Table 22.
+#define PHY_TURNARROUND_TIME 12
+
+/**
+ * \brief The number of symbols forming a superframe slot when the superframe
+ * order is equal to 0. IEEE Std 802.15.4-2006. Table 85.
+*/
+#define MAC_BASE_SLOT_DURATION 60
+
+//! The number of slots contained in any superframe. IEEE Std 802.15.4-2006. Table 85.
+#define MAC_NUM_SUPERFRAME_SLOTS 16
+
+/**
+ * \brief The number of symbols forming a superframe when the superframe
+ * order is equal to 0. IEEE Std 802.15.4-2006. Table 85.
+*/
+#define MAC_BASE_SUPERFRAME_DURATION (MAC_BASE_SLOT_DURATION * MAC_NUM_SUPERFRAME_SLOTS)
+
+/**
+ * \brief The number of superframes in which a GTS descriptor
+ * exists in the beacon frame of the PAN coordinator. IEEE Std 802.15.4-2006. Table 85.
+*/
+#define MAC_GTS_DESC_PERSISTENCE_TIME 4
+
+/**
+ * \brief The maximum number of octets added by the MAC
+ * sublayer to the MAC payload of a beacon frame. IEEE Std 802.15.4-2006. Table 85.
+*/
+#define MAC_MAX_BEACON_OVERHEAD 75
+
+/**
+ * \brief The maximum size, in octets, of a beacon payload.
+ * IEEE Std 802.15.4-2006. Table 85.
+ */
+#define MAC_MAX_BEACON_PAYLOAD_LENGTH (PHY_MAX_PACKET_SIZE - MAC_MAX_BEACON_OVERHEAD)
+
+/**
+ * \brief The number of consecutive lost beacons that will cause the MAC
+ * sublayer of a receiving device to declare a loss of synchronization.
+ * IEEE Std 802.15.4-2006. Table 85.
+ */
+#define MAC_MAX_LOST_BEACONS 4
+
+/**
+ * \brief The maximum number of octets added by the MAC sublayer to the PSDU
+ * without security. IEEE Std 802.15.4-2006. Table 85.
+*/
+/**
+ * \brief ZigBee Document 053474r17: D.4 aMaxMACFrameSize.
+ *
+*/
+
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+ #define MAC_MAX_MPDU_UNSECURED_OVERHEAD 25U
+#else
+ #define MAC_MAX_MPDU_UNSECURED_OVERHEAD 11U // 25 - 8*2(ext addr) + 2*2(short addr) - 2(dst panId)
+#endif // _IEEE_ZIGBEE_COMPLIANCE_
+
+/**************************************************************************//**
+ \brief The minimum number of octets added by the MAC sublayer to the PSDU.
+
+ IEEE Std 802.15.4-2006. Table 85.
+******************************************************************************/
+#define MAC_MIN_MPDU_OVERHEAD 9
+
+/**
+ * \brief The maximum number of octets that can be transmitted in the MAC Payload
+ * field of an unsecured MAC frame that will be guaranteed not to exceed aMaxPHYPacketSize.
+ * IEEE Std 802.15.4-2006. Table 85.
+ */
+#define MAC_MAX_SAFE_PAYLOAD_SIZE (PHY_MAX_PACKET_SIZE - MAC_MAX_MPDU_UNSECURED_OVERHEAD)
+
+/**
+ * \brief The maximum number of octets that can be transmitted in the MAC Payload field.
+ * IEEE Std 802.15.4-2006. Table 85.
+ */
+#define MAC_MAX_PAYLOAD_SIZE (PHY_MAX_PACKET_SIZE - MAC_MIN_MPDU_OVERHEAD)
+
+/**
+ * \brief The maximum size of an MPDU, in octets, that can be followed by a SIFS period.
+ * IEEE Std 802.15.4-2006. Table 85.
+ */
+#define MAC_MAX_SIFS_FRAME_SIZE 18
+
+//! The minimum number of symbols forming the CAP.IEEE Std 802.15.4-2006. Table 85.
+#define MAC_MIN_CAP_LENGTH 440
+
+/**
+ * \brief The number of symbols forming the basic time period used
+ * by the CSMA-CA algorithm.
+ * IEEE Std 802.15.4-2006. Table 85.
+ */
+#define MAC_UNIT_BACKOFF_PERIOD 20
+
+/** Bit mask of frequency bands that are supported by the underlying
+ * IEEE 802.15.4 radio. */
+#define PHY_FREQUENCY_BAND_868 0x01
+#define PHY_FREQUENCY_BAND_902 0x04
+#define PHY_FREQUENCY_BAND_2400 0x08
+
+/**************************************************************************//**
+ \def PHY_PIB_TRANSMIT_POWER_DEFAULT
+ \brief Default transmit power for the radio trancivier.
+******************************************************************************/
+/**************************************************************************//**
+ \def PHY_PIB_CURRENT_CHANNEL_DEFAULT
+ \brief Default channel to start for the radio trancivier.
+******************************************************************************/
+/**************************************************************************//**
+ \def PHY_PIB_CURRENT_PAGE_DEFAULT
+ \brief Default page to start for the radio trancivier.
+******************************************************************************/
+#ifdef AT86RF230
+ #define PHY_PIB_TRANSMIT_POWER_DEFAULT DBM_3
+ #define PHY_PIB_CURRENT_CHANNEL_DEFAULT 0x0B
+ #define PHY_PIB_CURRENT_PAGE_DEFAULT 0
+ #define PHY_FREQUENCY_BANDS PHY_FREQUENCY_BAND_2400
+#endif // AT86RF230
+#ifdef AT86RF230B
+ #define PHY_PIB_TRANSMIT_POWER_DEFAULT DBM_3
+ #define PHY_PIB_CURRENT_CHANNEL_DEFAULT 0x0B
+ #define PHY_PIB_CURRENT_PAGE_DEFAULT 0
+ #define PHY_FREQUENCY_BANDS PHY_FREQUENCY_BAND_2400
+#endif // AT86RF230B
+#ifdef AT86RF231
+ #define PHY_PIB_TRANSMIT_POWER_DEFAULT DBM_3
+ #define PHY_PIB_CURRENT_CHANNEL_DEFAULT 0x0B
+ #define PHY_PIB_CURRENT_PAGE_DEFAULT 0
+ #define PHY_FREQUENCY_BANDS PHY_FREQUENCY_BAND_2400
+#endif // AT86RF231
+#ifdef AT86RF212
+ #define PHY_PIB_TRANSMIT_POWER_DEFAULT DBM_3
+ #define PHY_PIB_CURRENT_CHANNEL_DEFAULT 0x05
+ #define PHY_PIB_CURRENT_PAGE_DEFAULT 0
+ #define PHY_FREQUENCY_BANDS (PHY_FREQUENCY_BAND_868 | PHY_FREQUENCY_BAND_902)
+#endif // AT86RF212
+#ifdef ATMEGA128RFA1
+ #define PHY_PIB_TRANSMIT_POWER_DEFAULT DBM_3
+ #define PHY_PIB_CURRENT_CHANNEL_DEFAULT 0x0B
+ #define PHY_PIB_CURRENT_PAGE_DEFAULT 0
+ #define PHY_FREQUENCY_BANDS PHY_FREQUENCY_BAND_2400
+#endif // ATMEGA128RFA1
+#ifdef CUSTOMRF3
+ #define PHY_PIB_TRANSMIT_POWER_DEFAULT DBM_0
+ #define PHY_PIB_CURRENT_CHANNEL_DEFAULT 0x05
+ #define PHY_PIB_CURRENT_PAGE_DEFAULT 0
+ #define PHY_FREQUENCY_BANDS (PHY_FREQUENCY_BAND_868 | PHY_FREQUENCY_BAND_902)
+#endif // CUSTOMRF3
+
+//! Default channel access mode.
+#define PHY_PIB_CCA_MODE_DEFAULT PHY_CCA_MODE_1
+
+// Default values of MAC PIB attributes.
+#ifdef AT86RF230
+# define MAC_PIB_ACK_WAIT_DURATION_DEFAULT 54
+#endif
+#ifdef AT86RF230B
+# define MAC_PIB_ACK_WAIT_DURATION_DEFAULT 54
+#endif
+#ifdef AT86RF231
+# define MAC_PIB_ACK_WAIT_DURATION_DEFAULT 54
+#endif
+#ifdef AT86RF212
+# if PHY_PIB_CURRENT_PAGE_DEFAULT == 0
+# define MAC_PIB_ACK_WAIT_DURATION_DEFAULT 120
+# endif
+#endif
+#ifdef CUSTOMRF3
+# define MAC_PIB_ACK_WAIT_DURATION_DEFAULT 120
+#endif
+#ifdef ATMEGA128RFA1
+# define MAC_PIB_ACK_WAIT_DURATION_DEFAULT 54
+#endif
+#define MAC_PIB_ASSOCIATION_PERMIT_DEFAULT false
+#define MAC_PIB_AUTO_REQUEST_DEFAULT true
+#define MAC_PIB_BATT_LIFE_EXT_DEFAULT false
+#define MAC_PIB_BEACON_PAYLOAD_DEFAULT NULL
+#define MAC_PIB_BEACON_PAYLOAD_LENGTH_DEFAULT 0
+#define MAC_PIB_BEACON_ORDER_DEFAULT 15
+#define MAC_PIB_BEACON_TX_TIME_DEFAULT 0
+#define MAC_PIB_COORD_SHORT_ADDR_DEFAULT 0xFFFF
+#define MAC_PIB_COORD_EXT_ADDR_DEFAULT 0xFFFFFFFFFFFFFFFFLL ///< Not defined in standard.
+#define MAC_PIB_GTS_PERMIT_DEFAULT true
+#define MAC_PIB_MAX_CSMA_BACKOFFS_DEFAULT 4
+#define MAC_PIB_MAX_BE_DEFAULT 5
+#define MAC_PIB_MIN_BE_DEFAULT 3
+#define MAC_PIB_PANID_DEFAULT 0xFFFF
+#define MAC_PIB_PROMISCUOUS_MODE_DEFAULT false
+#define MAC_PIB_RX_ON_WHEN_IDLE_DEFAULT false
+#define MAC_PIB_SHORT_ADDR_DEFAULT 0xFFFF
+#define MAC_PIB_SUPERFRAME_ORDER_DEFAULT 15
+#define MAC_PIB_TRANSACTION_PERSISTENCE_TIME_DEFAULT 0x01F4
+#define MAC_PIB_ASSOCIATED_PAN_COORD_DEFAULT false
+#define MAC_PIB_MAX_FRAME_RETRIES_DEFAULT 3
+#define MAC_PIB_RESPONSE_WAIT_TIME_DEFAULT 32
+#define MAC_PIB_SECURITY_ENABLED_DEFAULT false
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+//! PHY PIB attribute identifiers (IEEE Std 802.15.4-2006. - table 23).
+typedef enum
+{
+ PHY_PIB_CURRENT_CHANNEL_ID = 0x00,
+ PHY_PIB_CHANNELS_SUPPORTED_ID = 0x01, // Read-only
+ PHY_PIB_TRANSMIT_POWER_ID = 0x02,
+ PHY_PIB_CCA_MODE_ID = 0x03,
+ PHY_PIB_CURRENT_PAGE_ID = 0x04,
+ PHY_PIB_MAX_FRAME_DURATION_ID = 0x05, // Read-only
+ PHY_PIB_SHR_DURATION_ID = 0x06, // Read-only
+ PHY_PIB_SYMBOLS_PER_OCTET_ID = 0x07, // Read-only
+} PHY_PibId_t;
+
+//! PHY PIB attribute types (IEEE Std 802.15.4-2006. - table 23).
+typedef union
+{
+ uint8_t channel;
+ uint32_t channelsSupported;
+ int8_t transmitPower;
+ PHY_CcaMode_t ccaMode;
+ uint8_t currentPage;
+ uint16_t maxFrameDuration;
+ uint8_t shrDuration;
+ uint8_t symbolsPerOctet;
+} PHY_PibAttr_t;
+
+//! MAC PIB attribute ID type.
+typedef enum
+{
+ MAC_PIB_ACK_WAIT_DURATION_ID = 0x40,
+ MAC_PIB_ASSOCIATION_PERMIT_ID = 0x41,
+ MAC_PIB_AUTO_REQUEST_ID = 0x42,
+ MAC_PIB_BATT_LIFE_EXT_ID = 0x43,
+ MAC_PIB_BATT_LIFE_EXT_PERIODS_ID = 0x44,
+ MAC_PIB_BEACON_PAYLOAD_ID = 0x45,
+ MAC_PIB_BEACON_PAYLOAD_LENGTH_ID = 0x46,
+ MAC_PIB_BEACON_ORDER_ID = 0x47,
+ MAC_PIB_BEACON_TX_TIME_ID = 0x48,
+ MAC_PIB_BSN_ID = 0x49,
+ MAC_PIB_COORD_EXT_ADDR_ID = 0x4A,
+ MAC_PIB_COORD_SHORT_ADDR_ID = 0x4B,
+ MAC_PIB_DSN_ID = 0x4C,
+ MAC_PIB_GTS_PERMIT_ID = 0x4D,
+ MAC_PIB_MAX_CSMA_BACKOFFS_ID = 0x4E,
+ MAC_PIB_MIN_BE_ID = 0x4F,
+ MAC_PIB_PANID_ID = 0x50,
+ MAC_PIB_PROMISCUOUS_MODE_ID = 0x51,
+ MAC_PIB_RX_ON_WHEN_IDLE_ID = 0x52,
+ MAC_PIB_SHORT_ADDR_ID = 0x53,
+ MAC_PIB_SUPERFRAME_ORDER_ID = 0x54,
+ MAC_PIB_TRANSACTION_PERSISTENCE_TIME_ID = 0x55,
+ MAC_PIB_ASSOCIATED_PAN_COORD_ID = 0x56,
+ MAC_PIB_MAX_BE_ID = 0x57,
+ MAC_PIB_MAX_FRAME_TOTAL_WAIT_TIME_ID = 0x58,
+ MAC_PIB_MAX_FRAME_RETRIES_ID = 0x59,
+ MAC_PIB_RESPONSE_WAIT_TIME_ID = 0x5A, ///< There is in additional parameter exist in PIB - MAC_PIB_RESPONSE_WAIT_TIME_MS_ID. Time in ms.
+ MAC_PIB_SYNC_SYMBOL_OFFSET_ID = 0x5B,
+ MAC_PIB_TIMESTAMP_SUPPORTED_ID = 0x5C,
+ MAC_PIB_SECURITY_ENABLED_ID = 0x5D,
+
+ MAC_PIB_EXT_ADDR_ID = 0x6F,
+
+ MAC_PIB_KEY_TABLE_ID = 0x71,
+ MAC_PIB_KEY_TABLE_ENTRIES_ID = 0x72,
+ MAC_PIB_DEVICE_TABLE_ID = 0x73,
+ MAC_PIB_DEVICE_TABLE_ENTRIES_ID = 0x74,
+ MAC_PIB_SECURITY_LEVEL_TABLE_ID = 0x75,
+ MAC_PIB_SECUTITY_LEVEL_TABLE_ENTRIES_ID = 0x76,
+ MAC_PIB_FRAME_COUNTER_ID = 0x77,
+ MAC_PIB_AUTO_REQ_SECURITY_LEVEL_ID = 0x78,
+ MAC_PIB_AUTO_REQ_SECUTITY_KEY_ID_MODE_ID = 0x79,
+ MAC_PIB_AUTO_REQ_KEY_SOURCE_ID = 0x7A,
+ MAC_PIB_AUTO_REQUEST_KEY_INDEX_ID = 0x7B,
+ MAC_PIB_DEFAULT_KEY_SOURCE_ID = 0x7C,
+ MAC_PIB_PAN_COORD_EXT_ADDR_ID = 0x7D,
+ MAC_PIB_PAN_COORD_SHORT_ADDR_ID = 0x7E,
+
+ MAC_PIB_BEACON_TX_ENABLE_ID = 0x80, ///< Additional identifier. NOT described in the standard.
+ MAC_PIB_RESPONSE_WAIT_TIME_MS_ID = 0x81, ///< Additional identifier. NOT described in the standard. Time in ms. Read only.
+ MAC_PIB_TRANSACTION_PERSIST_TIME_MS_ID = 0x83, ///
+
+} MAC_PibId_t;
+
+//! MAC PIB attribute type.
+typedef union
+{
+ uint32_t ackWaitDuration;
+ bool associationPermit;
+ bool autoRequest;
+ //bool battLifeExt;
+ //uint8_t battLifeExtPeriods;
+ uint8_t *beaconPayload;
+ uint8_t beaconPayloadLength;
+ //uint8_t beaconOrder;
+ //uint32_t beaconTxTime;
+ uint8_t bsn;
+ ExtAddr_t coordExtAddr;
+ ShortAddr_t coordShortAddr;
+ uint8_t dsn;
+ bool gtsPermit;
+ uint8_t maxCsmaBackoffs;
+ uint8_t minBe;
+ PanId_t panId;
+ //bool promiscuousMode;
+ bool rxOnWhenIdle;
+ ShortAddr_t shortAddr;
+ ExtAddr_t extAddr; // Additional parameter. NOT described in the standard.
+ // This parameter replaces MAC_EXTENDED_ADDRESS constant.
+ // Device own extended address.
+ //uint8_t superframeOrder;
+ uint16_t transactionPersistenceTime;
+ uint32_t transactionPersistenceTimeInMs;
+ bool associatedPanCoord;
+ uint8_t maxBe;
+ //uint8_t maxFrameTotalWaitTime;
+ uint8_t maxFrameRetries;
+ uint8_t responseWaitTime;
+ bool timestampSupported;
+ bool securityEnabled;
+ bool beaconTxEnable;
+ uint32_t responseWaitTimeMs; // MAC response wait time in !!!milliseconds!!!.
+} MAC_PibAttr_t;
+
+//! Union of MAC and PHY PIB attributes.
+typedef union
+{
+ MAC_PibAttr_t macPibAttr;
+ PHY_PibAttr_t phyPibAttr;
+} MACPHY_PibAttr_t;
+
+//! Union of MAC and PHY PIB attributes IDs.
+typedef union
+{
+ MAC_PibId_t macPibId;
+ PHY_PibId_t phyPibId;
+} MACPHY_PibId_t;
+
+/******************************************************************************
+ Constants section
+******************************************************************************/
+
+#endif /* _MACPHYPIB_H */
+
+// eof macphyPib.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/phy.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/phy.h
new file mode 100644
index 00000000..24c87d81
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/phy.h
@@ -0,0 +1,163 @@
+/**************************************************************************//**
+ \file phy.h
+
+ \brief Types and constants declaration for IEEE std 802.15.4-2006
+ PHY implementation.
+
+ \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:
+ 18/05/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _PHY_H
+#define _PHY_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <inttypes.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define DBM_11 11
+#define DBM_10 10
+#define DBM_9 9
+#define DBM_8 8
+#define DBM_7 7
+#define DBM_6 6
+#define DBM_5 5
+#define DBM_4 4
+#define DBM_3 3
+#define DBM_2 2
+#define DBM_1 1
+#define DBM_0 0
+#define DBM_MIN_1 (-1)
+#define DBM_MIN_2 (-2)
+#define DBM_MIN_3 (-3)
+#define DBM_MIN_4 (-4)
+#define DBM_MIN_5 (-5)
+#define DBM_MIN_6 (-6)
+#define DBM_MIN_7 (-7)
+#define DBM_MIN_8 (-8)
+#define DBM_MIN_9 (-9)
+#define DBM_MIN_10 (-10)
+#define DBM_MIN_11 (-11)
+#define DBM_MIN_12 (-12)
+#define DBM_MIN_13 (-13)
+#define DBM_MIN_14 (-14)
+#define DBM_MIN_15 (-15)
+#define DBM_MIN_16 (-16)
+#define DBM_MIN_17 (-17)
+#define DBM_MIN_18 (-18)
+#define DBM_MIN_19 (-19)
+#define DBM_MIN_20 (-20)
+#define DBM_MIN_21 (-21)
+#define DBM_MIN_22 (-22)
+#define DBM_MIN_23 (-23)
+#define DBM_MIN_24 (-24)
+#define DBM_MIN_25 (-25)
+#define DBM_MIN_26 (-26)
+#define DBM_MIN_27 (-27)
+
+#define PHY_CHANNEL_0 0
+#define PHY_CHANNEL_1 1
+#define PHY_CHANNEL_2 2
+#define PHY_CHANNEL_3 3
+#define PHY_CHANNEL_4 4
+#define PHY_CHANNEL_5 5
+#define PHY_CHANNEL_6 6
+#define PHY_CHANNEL_7 7
+#define PHY_CHANNEL_8 8
+#define PHY_CHANNEL_9 9
+#define PHY_CHANNEL_10 10
+#define PHY_CHANNEL_11 11
+#define PHY_CHANNEL_12 12
+#define PHY_CHANNEL_13 13
+#define PHY_CHANNEL_14 14
+#define PHY_CHANNEL_15 15
+#define PHY_CHANNEL_16 16
+#define PHY_CHANNEL_17 17
+#define PHY_CHANNEL_18 18
+#define PHY_CHANNEL_19 19
+#define PHY_CHANNEL_20 20
+#define PHY_CHANNEL_21 21
+#define PHY_CHANNEL_22 22
+#define PHY_CHANNEL_23 23
+#define PHY_CHANNEL_24 24
+#define PHY_CHANNEL_25 25
+#define PHY_CHANNEL_26 26
+
+#define PHY_SYMBOL_DURATION_PAGE_0_CHANNELS_0 50 ///< Symbol duration for channel 0 and BPSK modulation.
+#define PHY_SYMBOL_DURATION_PAGE_0_CHANNELS_1_10 25 ///< Symbol duration for channels [1 - 10] and BPSK modulation.
+#define PHY_SYMBOL_DURATION_PAGE_0_CHANNELS_11_26 16 ///< Symbol duration for channels [11 - 26] and OQPSK modulation.
+#define PHY_SYMBOL_DURATION_PAGE_1_CHANNELS_0 80 ///< Symbol duration for channel 0 and ASK modulation.
+#define PHY_SYMBOL_DURATION_PAGE_1_CHANNELS_1_10 20 ///< Symbol duration for channels [1 - 10] and ASK modulation.
+#define PHY_SYMBOL_DURATION_PAGE_2_CHANNELS_0 40 ///< Symbol duration for channel 0 and OQPSK modulation.
+#define PHY_SYMBOL_DURATION_PAGE_2_CHANNELS_1_10 16 ///< Symbol duration for channels [1 - 10] and OQPSK modulation.
+//Chinese frequencies.
+#define PHY_SYMBOL_DURATION_PAGE_5_CHANNELS_0_3 16 ///< Symbol duration for channels [0 - 3] OQPSK modulation.
+//#define PHY_SYMBOL_DURATION_PAGE_5_CHANNELS_4_7 16 ///< Symbol duration for channels [4 - 7] MPSK modulation. Not supported.
+
+#define PHY_SYMBOL_DURATION_PAGE_20_CHANNELS_0_25 50 ///< Symbol duration for channels [0 - 25] and BPSK modulation.
+#define PHY_SYMBOL_DURATION_PAGE_22_CHANNELS_0_25 40 ///< Symbol duration for channels [0 - 25] and OQPSK modulation.
+
+// PHY PIB attribute read only parameters.
+#define PHY_SYMBOLS_PER_OCTET_PAGE_0_CHANNELS_0 8
+#define PHY_SYMBOLS_PER_OCTET_PAGE_0_CHANNELS_0_10 8
+#define PHY_SYMBOLS_PER_OCTET_PAGE_0_CHANNELS_11_26 2
+//#define PHY_SYMBOLS_PER_OCTET_PAGE_1_CHANNELS_0 (2/5)
+//#define PHY_SYMBOLS_PER_OCTET_PAGE_1_CHANNELS_1_10 (6/3.75)
+#define PHY_SYMBOLS_PER_OCTET_PAGE_2_CHANNELS_0 2
+#define PHY_SYMBOLS_PER_OCTET_PAGE_2_CHANNELS_0_10 2
+//Chinese frequencies.
+#define PHY_SYMBOLS_PER_OCTET_PAGE_5_CHANNELS_0_3 2
+//#define PHY_SYMBOLS_PER_OCTET_PAGE_5_CHANNELS_4_7 2 // Not supported.
+
+#define PHY_SYMBOLS_PER_OCTET_PAGE_20_CHANNELS_0_25 8
+#define PHY_SYMBOLS_PER_OCTET_PAGE_22_CHANNELS_0_25 2
+
+// Size of frame fields
+#define PHY_FRAME_LENGTH_FIELD_SIZE 1
+#define PHY_FCS_FIELD_SIZE 2
+#define PHY_SFD_FIELD_SIZE 1
+#define PHY_PREAMBLE_FIELD_SIZE 4
+#define PHY_LQI_FIELD_SIZE 1
+#define PHY_RSSI_FIELD_SIZE 1
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+//! CCA mode types. IEEE 802.15.4-2006 6.9.9 Clear channel assessment (CCA).
+typedef enum
+{
+ PHY_CCA_MODE_N = 0,
+ PHY_CCA_MODE_1 = 1,
+ PHY_CCA_MODE_2 = 2,
+ PHY_CCA_MODE_3 = 3
+} PHY_CcaMode_t;
+
+//! Energy level type.
+typedef uint8_t PHY_EnergyLevel_t;
+
+//! Evailible channel pages.
+enum
+{
+ CHANNEL_PAGE_0 = 0,
+ CHANNEL_PAGE_1 = 1,
+ CHANNEL_PAGE_2 = 2,
+ CHANNEL_PAGE_5 = 5,
+ CHANNEL_PAGE_20 = 20,
+ CHANNEL_PAGE_22 = 22,
+};
+
+#endif /* _PHY_H */
+
+// eof phy.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfBattery.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfBattery.h
new file mode 100644
index 00000000..2d1a65cb
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfBattery.h
@@ -0,0 +1,126 @@
+/**************************************************************************//**
+ \file rfBattery.h
+
+ \brief Prototypes of battery monitor functions and corresponding types.
+ Powered by RF chip.
+
+ \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:
+ 15/01/08 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _RFBATTERY_H
+#define _RFBATTERY_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <macCommon.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+//! Possible set of battery monitor values.
+typedef enum
+{
+ RF_1V70_BAT_VTG = 0x0,
+ RF_1V75_BAT_VTG = 0x1,
+ RF_1V80_BAT_VTG = 0x2,
+ RF_1V85_BAT_VTG = 0x3,
+ RF_1V90_BAT_VTG = 0x4,
+ RF_1V95_BAT_VTG = 0x5,
+ RF_2V00_BAT_VTG = 0x6,
+ RF_2V05_BAT_VTG = 0x7,
+ RF_2V10_BAT_VTG = 0x8,
+ RF_2V15_BAT_VTG = 0x9,
+ RF_2V20_BAT_VTG = 0xA,
+ RF_2V25_BAT_VTG = 0xB,
+ RF_2V30_BAT_VTG = 0xC,
+ RF_2V35_BAT_VTG = 0xD,
+ RF_2V40_BAT_VTG = 0xE,
+ RF_2V45_BAT_VTG = 0xF,
+ RF_2V550_BAT_VTG = 0x10 | 0x0,
+ RF_2V625_BAT_VTG = 0x10 | 0x1,
+ RF_2V700_BAT_VTG = 0x10 | 0x2,
+ RF_2V775_BAT_VTG = 0x10 | 0x3,
+ RF_2V850_BAT_VTG = 0x10 | 0x4,
+ RF_2V925_BAT_VTG = 0x10 | 0x5,
+ RF_3V000_BAT_VTG = 0x10 | 0x6,
+ RF_3V075_BAT_VTG = 0x10 | 0x7,
+ RF_3V150_BAT_VTG = 0x10 | 0x8,
+ RF_3V225_BAT_VTG = 0x10 | 0x9,
+ RF_3V300_BAT_VTG = 0x10 | 0xA,
+ RF_3V375_BAT_VTG = 0x10 | 0xB,
+ RF_3V450_BAT_VTG = 0x10 | 0xC,
+ RF_3V525_BAT_VTG = 0x10 | 0xD,
+ RF_3V600_BAT_VTG = 0x10 | 0xE,
+ RF_3V675_BAT_VTG = 0x10 | 0xF,
+} RF_BatteryMonVtg_t;
+
+/**
+ * \brief Battery monitor status type.
+* RF_SUCCESS_BAT_MON_STATUS means that voltage threshold has been
+* successfuly set. RF_BatteryMonInd() will appeared when supply voltage
+* is lower than voltage threshold.
+* RF_FAIL_BAT_MON_STATUS means that voltage threshold hasn't been
+* successfuly set. Because supply voltage is lower than voltage threshold.
+* RF_BatteryMonInd() wont appeared in this case.
+*/
+typedef enum
+{
+ RF_SUCCESS_BAT_MON_STATUS,
+ RF_FAIL_BAT_MON_STATUS,
+} RF_BatteryMonStatus_t;
+
+//! Battery monitor confirm structure.
+typedef struct
+{
+ //! Status of RF_BatteryMonReq.
+ RF_BatteryMonStatus_t status;
+} RF_BatteryMonConf_t;
+
+//! Battery monitor request structure.
+typedef struct
+{
+ //! Service field - for internal needs.
+ MAC_Service_t service;
+ //! Threshold voltage.
+ RF_BatteryMonVtg_t voltage;
+ //! Confirm structure on RF_BatteryMonReq.
+ RF_BatteryMonConf_t confirm;
+ //! Callback on RF_BatteryMonReq.
+ void (*RF_BatteryMonConf)(RF_BatteryMonConf_t *conf);
+} RF_BatteryMonReq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief Sets battery monitor voltage.
+ \param reqParams - request parameters structure pointer.
+ \return none.
+******************************************************************************/
+void RF_BatteryMonReq(RF_BatteryMonReq_t *reqParams);
+
+/**************************************************************************//**
+ \brief Inidicates that supply voltage drop below the configured threshold.
+ \return none.
+******************************************************************************/
+extern void RF_BatteryMonInd(void);
+
+#endif /*_RFBATTERY_H*/
+
+// eof rfBattery.h
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfCalibration.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfCalibration.h
new file mode 100644
index 00000000..b3e06d56
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfCalibration.h
@@ -0,0 +1,78 @@
+/**************************************************************************//**
+ \file rfCalibration.h
+
+ \brief Interface for PLL calibration and filter tuning.
+
+ \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:
+ 2011-10-04 Max Gekk - Created.
+ Last change:
+ $Id: rfCalibration.h 18970 2011-10-21 12:48:41Z mgekk $
+ ******************************************************************************/
+#if !defined _RFCALIBRATION_H
+#define _RFCALIBRATION_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <macCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**
+ * \brief RF calibration status type.
+ *
+ * - RF_CALIBRATION_SUCCESS_STATUS means that the calibration cycle has finished
+ * successfuly and the radio chip is ready to work.
+ * - RF_CALIBRATION_FAIL_STATUS - MAC hardware depended subsystem cannot preform
+ * the calibration at this time.
+ **/
+typedef enum _RF_CalibrationStatus_t
+{
+ RF_CALIBRATION_SUCCESS_STATUS,
+ RF_CALIBRATION_FAIL_STATUS
+} RF_CalibrationStatus_t;
+
+/**//**
+ * \brief The structure declaration of RF calibration confirmation parameters.
+ */
+typedef struct _RF_CalibrationConf_t
+{
+ RF_CalibrationStatus_t status;
+} RF_CalibrationConf_t;
+
+/**//**
+ * \brief Parameters of RF Calibration request.
+ */
+typedef struct _RF_CalibrationReq_t
+{
+ /*! Service field - for internal needs. */
+ MAC_Service_t service;
+
+ /** RF Calibration confirm callback function's pointer. */
+ void (*RF_CalibrationConf)(RF_CalibrationConf_t *conf);
+ /** Status of processing this request. */
+ RF_CalibrationConf_t confirm;
+} RF_CalibrationReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief initiates a calibration cycle.
+
+ \param[in] req - pointer to calibration parameters - callback and conf status.
+ \return None.
+ ******************************************************************************/
+void RF_CalibrationReq(RF_CalibrationReq_t *const req);
+
+#endif /* _RFCALIBRATION_H */
+/** eof rfCalibration.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfEncrypt.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfEncrypt.h
new file mode 100644
index 00000000..fa760078
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfEncrypt.h
@@ -0,0 +1,72 @@
+/**************************************************************************//**
+ \file rfEncrypt.h
+
+ \brief Prototypes of ecnryption functions and corresponding types.
+ Powered by RF chip.
+
+ \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:
+ 18/01/08 A. Mandychev - Created.
+ 24/03/08 A. Mandychev - Renamed to rfEncrypt.h
+******************************************************************************/
+
+#ifndef _RFECNRYPT_H
+#define _RFECNRYPT_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <macCommon.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+//! Set of AES command.
+typedef enum
+{
+ RF_SET_KEY_AES_CMD = 0,
+ RF_SET_INIT_VECT_AES_CMD,
+ RF_ECB_ENCRYPT_AES_CMD,
+ RF_CBC_ENCRYPT_AES_CMD,
+} RF_AesCmd_t;
+
+//! Encryption request structure.
+typedef struct
+{
+ //! Service field - for internal needs.
+ MAC_Service_t service;
+ //! AES command.
+ RF_AesCmd_t aesCmd;
+ //! Pointer to input data for AES command.
+ uint8_t *text;
+ //! Size of input data in blocks.
+ uint8_t blockCount; // Block is 128-bit data.
+ void (*RF_EncryptConf)(void);
+} RF_EncryptReq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief Executes AES command. Valid for RF231 and RF212.
+ \param reqParams - request parameters structure pointer.
+ \return none.
+******************************************************************************/
+void RF_EncryptReq(RF_EncryptReq_t *reqParams);
+
+#endif /*_RFECNRYPT_H*/
+
+// eof rfEncrypt.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfInit.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfInit.h
new file mode 100644
index 00000000..e1b4f127
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfInit.h
@@ -0,0 +1,45 @@
+/**************************************************************************//**
+ \file rfInit.h
+
+ \brief Prototype of RF init function.
+
+ \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:
+ 11/04/08 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _RFINIT_H
+#define _RFINIT_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief Initializes RF chip.
+ \return none.
+******************************************************************************/
+void RF_Init(void);
+
+#endif /*_RFINIT_H*/
+
+// eof rfInit.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfRandom.h b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfRandom.h
new file mode 100644
index 00000000..759944c7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/MAC_PHY/include/rfRandom.h
@@ -0,0 +1,73 @@
+/**************************************************************************//**
+ \file rfRandom.h
+
+ \brief Prototype of random generation function.
+
+ \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:
+ 08/04/08 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _RFRANDOM_H
+#define _RFRANDOM_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <macCommon.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+//! Random confirm structure.
+typedef struct
+{
+ uint8_t *buff;
+ uint16_t value;
+} RF_RandomConf_t;
+
+//! Random request structure.
+typedef struct
+{
+ //! Service field - for internal needs.
+ MAC_Service_t service;
+ //! Number of bytes to be generated
+ uint8_t numberOfBytes;
+ //! Confirm structure on RF_RandomReq.
+ RF_RandomConf_t confirm;
+ //! Callback on RF_RandomReq.
+ void (*RF_RandomConf)(RF_RandomConf_t *conf);
+} RF_RandomReq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief Requests random value from RF chip. Valid for RF231 and RF212.
+ \param reqParams - request parameters structure pointer.
+ \return none.
+******************************************************************************/
+void RF_RandomReq(RF_RandomReq_t *reqParams);
+
+/**************************************************************************//**
+ \brief Requests random value from RF chip. Valid for RF231 and RF212.
+ \param reqParams - request parameters structure pointer.
+ \return none.
+******************************************************************************/
+void RF_RandomSeqReq(RF_RandomReq_t *reqParams);
+
+#endif /*_RFRANDOM_H*/
+
+// eof rfRandom.h
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nldeData.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nldeData.h
new file mode 100644
index 00000000..8595e54e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nldeData.h
@@ -0,0 +1,402 @@
+/**************************************************************************//**
+ \file nldeData.h
+
+ \brief NLDE-DATA interface
+
+ \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:
+ 2009-04-13 Max Gekk - Created.
+ Last change:
+ $Id: nldeData.h 18405 2011-08-31 15:42:23Z mgekk $
+ ******************************************************************************/
+#if !defined _NLDE_DATA_H
+#define _NLDE_DATA_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+#include <appFramework.h>
+#include <mac.h>
+#include <nwkCommon.h>
+#include <nwkNeighbor.h>
+#include <nlmeRouteDiscovery.h>
+#if defined _SECURITY_
+#include <sspSfp.h>
+#endif /* _SECURITY_ */
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLDE-DATA confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.2 NLDE-DATA.confirm, page 264.
+ */
+typedef struct _NWK_DataConf_t
+{
+ /* Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem;
+ } service;
+
+ /** The status of the corresponding request. */
+ NWK_Status_t status;
+ /** The handle associated with the NSDU being confirmed. */
+ void *nsduHandle;
+ /** A time indication for the transmitted packet based on the local clock. */
+ uint32_t txTime;
+ /** Quantity (or approximate quantity, it depends on routing method) of hops between source and destination nodes */
+ NwkRadius_t hops;
+} NWK_DataConf_t;
+
+/** Transmission delay types. */
+typedef enum _NwkTxDelayType_t
+{
+ NWK_TX_DELAY_UNICAST_DATA = 0x00,
+ NWK_TX_DELAY_UNICAST_COMMAND = 0x01,
+ NWK_TX_DELAY_LINK_STATUS = 0x02,
+ NWK_TX_DELAY_INITIAL_ROUTE_REQUEST = 0x03,
+ NWK_TX_DELAY_INITIAL_MANYTOONE_ROUTE_REQUEST = 0x04,
+ NWK_TX_DELAY_ROUTE_REQUEST = 0x05,
+ NWK_TX_DELAY_MANYTOONE_ROUTE_REQUEST = 0x06,
+ NWK_TX_DELAY_BROADCAST = 0x07,
+ NWK_TX_DELAY_BROADCAST_SUCCESS = 0x08,
+ NWK_TX_DELAY_MULTICAST = 0x09,
+ NWK_TX_DELAY_MULTICAST_SUCCESS = 0x0A,
+ NWK_TX_DELAY_INITIAL_MULTICAST= 0x0B,
+ NWK_TX_DELAY_INITIAL_ROUTE_RECORD = 0x0C,
+ NWK_TX_DELAY_TRANSIT_DATA = 0x0D,
+ NWK_LAST_TX_DELAY
+} NwkTxDelayType_t;
+
+/** Further behavior after delay. */
+typedef enum _NwkTxDelayStatus_t
+{
+ NWK_TX_NOW = 0x0, /**< Immediately to send. */
+ NWK_TX_DONE = 0x1, /**< To complete transmission. */
+ NWK_TX_DELAY_REQUIRED = 0x2, /**< Delay before transmission. */
+ NWK_TX_INDIRECT = 0x3 /**< Indirect transmission to all children. */
+} NwkTxDelayStatus_t;
+
+/** Delay request's parameters. */
+typedef struct _NwkTxDelayReq_t
+{
+ /* Service fields - for internal needs. */
+ struct
+ { /** Link to a next output packet in queue. */
+ QueueElement_t qelem;
+ } service;
+
+ NwkTxDelayType_t type;
+ uint8_t attempt;
+ uint16_t delay;
+ NwkTxDelayStatus_t actionAfterDelay;
+} NwkTxDelayReq_t;
+
+/* Routing methods, used for data packet transmission. */
+typedef enum _NwkRoutingMethod_t
+{
+ NWK_ROUTING_UNKNOWN,
+ NWK_ROUTING_FAIL,
+ NWK_ROUTING_INDIRECT,
+ NWK_ROUTING_TO_PARENT,
+ NWK_ROUTING_TO_NEIGHBOR,
+ NWK_ROUTING_TREE,
+ NWK_ROUTING_MESH,
+ NWK_ROUTING_MANYTOONE,
+ NWK_ROUTING_BROADCAST,
+ NWK_ROUTING_DIRECT,
+ NWK_ROUTING_MANYTOONE_RECORD
+} NwkRoutingMethod_t;
+
+/* Information about routing method and quantity of hops to destination node */
+typedef struct _NwkRouting_t
+{
+ NwkRoutingMethod_t method;
+ NwkRadius_t hops;
+} NwkRouting_t;
+
+/**//**
+ * \brief Meta-information of output packet.
+ */
+typedef struct _NwkOutputPacket_t
+{
+ /* Service fields - for internal needs. */
+ struct
+ { /** Link to a next output packet in queue. */
+ QueueElement_t qelem;
+ } service;
+
+ /** Identifier of transmission request. */
+ uint8_t txId;
+ /** Transmission context. */
+ void *context;
+ /** pointer to the destination neighbor. */
+ NwkNeighbor_t *neighbor;
+ /** Used routing method for transmission and quantity of hops to destination node. */
+ NwkRouting_t routingInfo;
+ /** Address of node from which the packet has been received. */
+ ShortAddr_t prevHopAddr;
+ /** Flag indicates that secured packet must be decrypted or not. */
+ bool decryptRequired;
+ /** MCPS-DATA request primitive's parameters structure. */
+ MAC_DataReq_t macDataReq;
+ union
+ {
+ /** NLME-ROUTE-DISCOVERY request primitive's parameters structure. */
+ NWK_RouteDiscoveryReq_t routeDiscovery;
+ /** Transmission delay parameters. */
+ NwkTxDelayReq_t txDelay;
+#if defined _NWK_ROUTE_RECORD_
+ /** Internal variables of the route record component. */
+ struct
+ {/** Extended address of node from which an original packet
+ * has been received. */
+ ExtAddr_t from;
+ } routeRecord;
+#endif /* _NWK_ROUTE_RECORD_ */
+#if defined _SECURITY_
+ /** Encrypt Frame primitive's parameters structure. */
+ SSP_EncryptFrameReq_t encrypt;
+ /** Decrypt Frame primitive's parameters structure. */
+ SSP_DecryptFrameReq_t decrypt;
+#endif /* _SECURITY_ */
+ } req;
+#if defined _SYS_ASSERT_ON_
+ uint8_t state;
+#endif
+} NwkOutputPacket_t;
+
+/**//**
+ * \brief NLDE-DATA request primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.1 NLDE-DATA.request, page 261.
+ */
+typedef struct _NWK_DataReq_t
+{
+ /* Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ NwkOutputPacket_t outPkt;
+ } service;
+
+ /* Public fields. */
+ /** The type of destination address supplied by the DstAddr parameter. */
+ NWK_DstAddrMode_t dstAddrMode;
+ /** Destination address. */
+ ShortAddr_t dstAddr;
+ /** The number of octets comprising the NSDU to be transferred. */
+ NwkLength_t nsduLength;
+ /** The set of octets comprising the NSDU to be transferred. */
+ uint8_t *nsdu;
+ /** The handle associated with the NSDU to be transmitted by the NWK layer. */
+ void *nsduHandle;
+ /** The distance, in hops, that a frame will be allowed
+ * to travel through the network. */
+ NwkRadius_t radius;
+ /** The distance, in hops, that a multicast frame will be relayed by nodes
+ * not a member of the group. A value of 0x07 is treated as infinity.*/
+ NwkRadius_t nonmemberRadius;
+ /** The DiscoverRoute parameter may be used to control route discovery
+ * operations for the transit of this frame: false = suppress route discovery,
+ * true = enable route discovery */
+ bool discoverRoute;
+ /** Encrypt packet by network key before transmission. */
+ bool securityEnable;
+ /** Decrypt packet after transmission or not. This is recommendation for NWK layer.
+ * NWK layer may set this flag to 'true' if packet was decrypted. */
+ bool decryptRequired;
+ /** Send to self a) broadcast, if destination address is matched to device type,
+ * b) multicast, if device is in group or c) unicast, if destination address
+ * is short address of this device. If this flag is 'false' then NWK-layer never
+ * sends to self otherwise it sends to self only conditions a)-c) are true.
+ * Before call NWK_DataConf this flag is set to true if NWK_DataInd will be called.
+ * */
+ bool boomerang;
+ /** NLDE-DATA confirm callback function's pointer. */
+ void (*NWK_DataConf)(NWK_DataConf_t *conf);
+ NWK_DataConf_t confirm;
+} NWK_DataReq_t;
+
+/** Service information for an outgoing external packet. */
+typedef NWK_DataReq_t NwkExternPacket_t;
+
+/** Nonstandard NLDE-DATA.response */
+typedef struct _NWK_DataResp_t
+{
+ uint8_t status;
+} NWK_DataResp_t;
+
+/**//**
+ * \brief NLDE-DATA indication primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.3 NLDE-DATA.indication, page 266.
+ */
+typedef struct _NWK_DataInd_t
+{
+ /* Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+
+ /** The type of destination address supplied by the DstAddr parameter.
+ * This may have one of the following two values:
+ * - 0x01 = 16-bit multicast group address,
+ * - 0x02 = 16-bit network address of a device or a broadcast address. */
+ NWK_DstAddrMode_t dstAddrMode;
+ /** The destination address to which the NSDU was sent. */
+ ShortAddr_t dstAddr;
+ /** The individual device address from which the NSDU originated. */
+ ShortAddr_t srcAddr;
+ /** The short node address from which the NSDU received. */
+ ShortAddr_t prevHopAddr;
+ /** The number of octets comprising the NSDU being indicated. */
+ NwkLength_t nsduLength;
+ /** The set of octets comprising the NSDU being indicated. */
+ uint8_t *nsdu;
+ /** The link quality indication delivered by the MAC on receipt of this frame
+ * as a parameter of the MCPS-DATA.indication primitive. */
+ Lqi_t linkQuality;
+ /** RSSI delivered by the MAC on receipt of this frame as a parameter of
+ * the MCPS-DATA.indication primitive.*/
+ Rssi_t rssi;
+ /** A time indication for the received packet based on the local clock. */
+ uint32_t rxTime;
+ /** An indication of whether the received data frame is using security. */
+ bool securityUse;
+ /** The flag indicates that the packet was sent through the loop. */
+ bool boomerang;
+ /** NLDE-DATA response callback function's pointer. */
+ void (*NWK_DataResp)(NWK_DataResp_t *resp);
+ NWK_DataResp_t response;
+} NWK_DataInd_t;
+
+/**//**
+ * \brief Confirmation parameters of NWK Data allocation.
+ */
+typedef struct _NWK_AllocDataConf_t
+{
+ NWK_DataReq_t *nwkDataReq;
+} NWK_AllocDataConf_t;
+
+/**//**
+ * \brief Parameters of NWK Data allocation request.
+ */
+typedef struct _NWK_AllocDataReq_t
+{
+ /* Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+
+ /** The number of allocated octets in the NSDU. */
+ NwkLength_t nsduLength;
+ /** Pointer to confirm callback function. */
+ void (*NWK_AllocDataConf)(NWK_AllocDataConf_t *conf);
+ NWK_AllocDataConf_t confirm;
+} NWK_AllocDataReq_t;
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+/** Get length of output packet. */
+#define NWK_GET_OUTPKT_LEN(outPkt) ((outPkt)->macDataReq.msduLength)
+/** Set length of output packet. */
+#define NWK_SET_OUTPKT_LEN(outPkt, len) (outPkt)->macDataReq.msduLength = (len)
+#define NWK_SET_INVALID_OUTPKT_LEN(outPkt) \
+ NWK_SET_OUTPKT_LEN(outPkt, MAC_MAX_MSDU_SIZE + 1U)
+#define NWK_IS_VALID_OUTPKT_LEN(outPkt) \
+ (NWK_GET_OUTPKT_LEN(outPkt) <= MAC_MAX_MSDU_SIZE)
+/** Add value to length of output packet. */
+#define NWK_ADD_TO_OUTPKT_LEN(outPkt, value) \
+ (outPkt)->macDataReq.msduLength += (value)
+/** Subtract value from length of output packet. */
+#define NWK_SUB_FROM_OUTPKT_LEN(outPkt, value) \
+ (outPkt)->macDataReq.msduLength -= (value)
+/** Get pointer to data (NWK header + payload) of output packet. */
+#define NWK_GET_OUTPKT_DATA(outPkt) ((void *)((outPkt)->macDataReq.msdu))
+/** Initialize msdu pointer. */
+#define NWK_SET_OUTPKT_DATA(outPkt, ptr) \
+ (outPkt)->macDataReq.msdu = (uint8_t *)(ptr)
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLDE-DATA request primitive's prototype.
+
+ \param[in] req - NLDE-DATA request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_DataReq(NWK_DataReq_t *const req);
+
+/**************************************************************************//**
+ \brief NLDE-DATA indication primitive's prototype.
+
+ \param[in] ind - NLDE-DATA indication parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+extern void NWK_DataInd(NWK_DataInd_t *ind);
+
+/**************************************************************************//**
+ \brief The request to send own data packet to itself.
+
+ \param[in] req - pointer to parameters of NLDE-DATA.request primitive.
+ \return None.
+ ******************************************************************************/
+void NWK_LoopbackTxReq(NWK_DataReq_t *const req);
+
+#if defined _INTERPAN_
+/**************************************************************************//**
+ \brief INTRP-DATA.ind primitive handler.
+
+ It is intended to notify APS Layer about incoming Inter-PAN packet.
+
+ \param[in] ind - NLDE-DATA indication parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_IntrpDataInd(MAC_DataInd_t *ind);
+#endif /*_INTERPAN_*/
+#if defined _NWK_ALLOCATOR_
+/**************************************************************************//**
+ \brief Allocate memory for NWK_DataReq_t structure and MPDU.
+
+ \param[in] req - pointer to allocation parameters' structure.
+ \return None.
+ ******************************************************************************/
+void NWK_AllocDataReq(NWK_AllocDataReq_t *const req);
+
+/**************************************************************************//**
+ \brief Free memory which is allocated for NWK_DataReq_t structure and MPDU.
+
+ \param[in] req - NLDE-DATA request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_FreeDataReq(NWK_DataReq_t *const req);
+
+/**************************************************************************//**
+ \brief Transform pointer to NWK_DataInd_t to pointer to NWK_DataReq_t.
+
+ This function initializes nsdu and nsduLength by appropriate field
+ from NWK_DataInd_t structure.
+
+ \param[in] ind - NLDE-DATA indication parameters' structure pointer.
+ \param[in] secure - if 'true' then encryption on NWK will be used for
+ NLDE-DATA.request otherwise 'false'.
+ \return Pointer to NLDE-DATA.request's parameters.
+ ******************************************************************************/
+NWK_DataReq_t* NWK_DataTransformIndToReq(NWK_DataInd_t *ind, const bool secure);
+
+#endif /* _NWK_ALLOCATOR_ */
+#endif /* _NLDE_DATA_H */
+/** eof nldeData.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeDirectJoin.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeDirectJoin.h
new file mode 100644
index 00000000..1e2141a7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeDirectJoin.h
@@ -0,0 +1,76 @@
+/**************************************************************************//**
+ \file nlmeDirectJoin.h
+
+ \brief NLME-DIRECT-JOIN interface
+
+ \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:
+ 2009-04-12 Max Gekk - Created.
+ Last change:
+ $Id: nlmeDirectJoin.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_DIRECT_JOIN_H
+#define _NLME_DIRECT_JOIN_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-DIRECT-JOIN confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.15 NLME-DIRECT-JOIN.confirm, page 287.
+ */
+typedef struct _NWK_DirectJoinConf_t
+{
+ /** The status of the corresponding request. */
+ NWK_Status_t status;
+} NWK_DirectJoinConf_t;
+
+/**//**
+ * \brief NLME-DIRECT-JOIN request primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.14 NLME-DIRECT-JOIN.request, page 286.
+ */
+typedef struct _NWK_DirectJoinReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /** The IEEE address of the device to be directly joined.*/
+ ExtAddr_t deviceAddress;
+ /** Recommended network address. */
+ ShortAddr_t networkAddress;
+ /** The operating capabilities of the device being directly joined. */
+ MAC_CapabilityInf_t capabilityInformation;
+ /** NLME-DIRECT-JOIN confirm callback function's pointer. */
+ void (*NWK_DirectJoinConf)(NWK_DirectJoinConf_t *conf);
+ NWK_DirectJoinConf_t confirm;
+} NWK_DirectJoinReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-DIRECT-JOIN request primitive's prototype.
+
+ \param[in] req - NLME-DIRECT-JOIN request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_DirectJoinReq(NWK_DirectJoinReq_t *const req);
+
+#endif /* _NLME_DIRECT_JOIN_H */
+/** eof nlmeDirectJoin.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeEdScan.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeEdScan.h
new file mode 100644
index 00000000..0e5a09bc
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeEdScan.h
@@ -0,0 +1,88 @@
+/**************************************************************************//**
+ \file nlmeEdScan.h
+
+ \brief NLME-ED-SCAN interface
+
+ \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:
+ 2009-04-11 Max Gekk - Created.
+ Last change:
+ $Id: nlmeEdScan.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_ED_SCAN_H
+#define _NLME_ED_SCAN_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+/** Maximum number of channels which can be scanned for one request. */
+#define MAX_EDSCAN_CHANNEL_AMOUNT 16U
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-ED-SCAN confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.10 NLME-ED-SCAN.confirm
+ */
+typedef struct _NWK_EDScanConf_t
+{
+ /** The status of the request. */
+ NWK_Status_t status;
+ /** Indicates which channels given in the request were not scanned. */
+ ChannelsMask_t unScannedChannels;
+ /** Size of energyDetectList */
+ uint8_t energyDetectListSize;
+ /** The list of energy measurements */
+ PHY_EnergyLevel_t energyDetectList[MAX_EDSCAN_CHANNEL_AMOUNT];
+} NWK_EDScanConf_t;
+
+/**//**
+ * \brief NLME-ED-SCAN request primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.9 NLME-ED-SCAN.request.
+ */
+typedef struct _NWK_EDScanReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ MAC_ScanReq_t macScanReq;
+ } service;
+ /** Bitmask of channels are to be scanned */
+ ChannelsMask_t scanChannels;
+ /** A value used to calculate the length of time to spend
+ * scanning each channel. */
+ ScanDuration_t scanDuration;
+ /** NLME-ED-SCAN confirm callback function's pointer. */
+ void (*NWK_EDScanConf)(NWK_EDScanConf_t *conf);
+ NWK_EDScanConf_t confirm;
+} NWK_EDScanReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-ED-SCAN request primitive's prototype.
+
+ \param[in] req - NLME-ED-SCAN request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_EDScanReq(NWK_EDScanReq_t *const req);
+
+#endif /* _NLME_ED_SCAN_H */
+/** eof nlmeEdScan.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeJoin.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeJoin.h
new file mode 100644
index 00000000..d2331f28
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeJoin.h
@@ -0,0 +1,148 @@
+/**************************************************************************//**
+ \file nlmeJoin.h
+
+ \brief NLME-JOIN interface
+
+ \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:
+ 2009-04-11 Max Gekk - Created.
+ Last change:
+ $Id: nlmeJoin.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_JOIN_H
+#define _NLME_JOIN_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <mac.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-JOIN confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.13 NLME-JOIN.confirm, page 285.
+ */
+typedef struct _NWK_JoinConf_t
+{
+ /** The status of the corresponding request. Valid Range: NWK_SUCCESS_STATUS,
+ * NWK_NOT_PERMITTED_STATUS, NWK_NO_NETWORKS_STATUS or any status value
+ * returned from MLME-ASSOCIATE.confirm, MLME-SET.confirm, MLME-GET.confirm,
+ * MLME-RX-ENABLE.confirm, NLME-NETWORK-DISCOVERY.confirm. */
+ NWK_Status_t status;
+ /** The 16-bit network address that was allocated to this device. This parameter
+ * will be equal to 0xffff if the join attempt was unsuccessful. */
+ ShortAddr_t networkAddress;
+ /** The 64-bit extended PAN identifier for the network of which the device is
+ * now a member. */
+ ExtPanId_t extendedPANId;
+ /** The value of phyCurrentChannel attribute of the PHY PIB, which is equal to
+ * the current channel of the network that has been joined. */
+ Channel_t activeChannel;
+} NWK_JoinConf_t;
+
+/** The method of joining the network. */
+typedef enum _NWK_RejoinNetwork_t
+{
+ /** The device is requesting to join a network through association. */
+ NWK_REJOIN_ASSOCIATION = 0,
+ /** The device is joining directly or rejoining the network using
+ * the orphaning procedure. */
+ NWK_REJOIN_ORPHAN = 1,
+ /** The device is joining the network using the NWK rejoining procedure. */
+ NWK_REJOIN_NWK_REJOIN = 2,
+ /** The device is to change the operational network channel to that
+ * identified in the ScanChannels parameter. */
+ NWK_REJOIN_CHANGE_CHANNEL = 3,
+ /** The device is joining to a network with known parameters. Device's own
+ * parameters are also known. This rejoin won't be visible on the air. */
+ NWK_REJOIN_SILENT = 4,
+} NWK_RejoinNetwork_t;
+
+/**//**
+ * \brief NLME-JOIN request primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.11 NLME-JOIN.request, page 281.
+ */
+typedef struct _NWK_JoinReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /** The 64-bit PAN identifier of the network to join.*/
+ ExtPanId_t extendedPANId;
+ /** This parameter controls the method of joining the network. */
+ NWK_RejoinNetwork_t rejoinNetwork;
+ /** The 27 least significant bits (b0, b1,... b26) indicate which channels
+ * are to be scanned (1=scan, 0=do not scan) for each of the 27 valid channels.
+ **/
+ ChannelsMask_t scanChannels;
+ /** A value used to calculate the length of time to spend scanning each
+ * channel. The time spent scanning each channel is
+ * (aBaseSuperframeDuration * (2^n + 1)) symbols,
+ * where n is the value of the ScanDuration parameter. */
+ ScanDuration_t scanDuration;
+ /** The operating capabilities of the device being directly joined. */
+ /** This parameter should be set in NWK_ResetReq. */
+ /* MAC_CapabilityInf_t capabilityInformation; */
+ /** If the value of RejoinNetwork is 0x02 and this is TRUE than the device
+ * will try to rejoin securely. Otherwise, this is set to FALSE. */
+ bool securityEnable;
+ /** NLME-JOIN confirm callback function's pointer. */
+ void (*NWK_JoinConf)(NWK_JoinConf_t *conf);
+ NWK_JoinConf_t confirm;
+} NWK_JoinReq_t;
+
+/**//**
+ * \brief NLME-JOIN indication primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.12 NLME-JOIN.indication, page 283.
+ */
+typedef struct _NWK_JoinInd_t
+{
+ /** The network address of an entity that has been added to the network. */
+ ShortAddr_t networkAddress;
+ /** The 64-bit IEEE address of an entity that has been added to the network.*/
+ ExtAddr_t extendedAddress;
+ /** Specifies the operational capabilities of the joining device. */
+ MAC_CapabilityInf_t capabilityInformation;
+ /** The RejoinNetwork parameter indicating the method
+ * used to join the network. */
+ NWK_RejoinNetwork_t rejoinNetwork;
+ /** This parameter will be TRUE if the rejoin was performed in a secure manner.
+ * Otherwise, this parameter will be FALSE. */
+ bool secureJoin;
+ bool isRejoin;
+} NWK_JoinInd_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-JOIN request primitive's prototype.
+
+ \param[in] req - NLME-JOIN request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_JoinReq(NWK_JoinReq_t *const req);
+
+/**************************************************************************//**
+ \brief NLME-JOIN indication primitive's prototype.
+
+ \param[in] ind - NLME-JOIN indication parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+extern void NWK_JoinInd(NWK_JoinInd_t *ind);
+
+#endif /* _NLME_JOIN_H */
+/** eof nlmeJoin.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeLeave.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeLeave.h
new file mode 100644
index 00000000..071e9f0a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeLeave.h
@@ -0,0 +1,105 @@
+/**************************************************************************//**
+ \file nlmeLeave.h
+
+ \brief NLME-LEAVE interface
+
+ \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:
+ 2009-04-13 Max Gekk - Created.
+ Last change:
+ $Id: nlmeLeave.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_LEAVE_H
+#define _NLME_LEAVE_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-LEAVE confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.18 NLME-LEAVE.confirm, page 291.
+ */
+typedef struct _NWK_LeaveConf_t
+{
+ /** The status of the corresponding request.*/
+ NWK_Status_t status;
+} NWK_LeaveConf_t;
+
+/**//**
+ * \brief NLME-LEAVE request primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.16 NLME-LEAVE.request, page 288.
+ */
+typedef struct _NWK_LeaveReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /** The 64-bit IEEE address of the entity to be removed from the network
+ * or NULL if the device removes itself from the network. */
+ ExtAddr_t deviceAddress;
+ /** This parameter has a value of TRUE if the device being asked to leave the
+ * network is also being asked to remove its child devices, if any. Otherwise,
+ * it has a value of FALSE. */
+ bool removeChildren;
+ /** This parameter has a value of TRUE if the device being asked to leave from
+ * the current parent is requested to rejoin the network.
+ * Otherwise, the parameter has a value of FALSE. */
+ bool rejoin;
+ /** NLME-LEAVE confirm callback function's pointer. */
+ void (*NWK_LeaveConf)(NWK_LeaveConf_t *conf);
+ NWK_LeaveConf_t confirm;
+} NWK_LeaveReq_t;
+
+/**//**
+ * \brief NLME-LEAVE indication primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.17 NLME-LEAVE.indication, page 290.
+ */
+ typedef struct _NWK_LeaveInd_t
+{
+ /** The 64-bit IEEE address of an entity that has removed itself from
+ * the network or NULL in the case that the device issuing the primitive has
+ * been removed from the network by its parent. */
+ ExtAddr_t deviceAddress;
+ /** This parameter has a value of TRUE if the device being asked to leave the
+ * current parent is requested to rejoin the network. Otherwise, this parameter
+ * has a value of FALSE. */
+ bool rejoin;
+} NWK_LeaveInd_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-LEAVE request primitive's prototype.
+
+ \param[in] req - NLME-LEAVE request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_LeaveReq(NWK_LeaveReq_t *const req);
+
+/**************************************************************************//**
+ \brief NLME-LEAVE indication primitive's prototype.
+
+ \param[in] ind - NLME-LEAVE indication parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+extern void NWK_LeaveInd(NWK_LeaveInd_t *ind);
+
+#endif /* _NLME_LEAVE_H */
+/** eof nlmeLeave.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNetworkDiscovery.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNetworkDiscovery.h
new file mode 100644
index 00000000..b8d45646
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNetworkDiscovery.h
@@ -0,0 +1,122 @@
+/**************************************************************************//**
+ \file nlmeNetworkDiscovery.h
+
+ \brief NLME-NETWORK-DISCOVERY interface
+
+ \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:
+ 2009-04-11 Max Gekk - Created
+ Last change:
+ $Id: nlmeNetworkDiscovery.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_NETWORK_DISCOVERY_H
+#define _NLME_NETWORK_DISCOVERY_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+#include <mac.h>
+#include <nwkCommon.h>
+#include <appFramework.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief Network Descriptor Information Fields.
+ * */
+BEGIN_PACK
+typedef struct PACK _NWK_NetworkDescriptor_t
+{
+ /** The 64-bit PAN identifier of the network. */
+ ExtPanId_t extendedPANId;
+ /** The current logical channel occupied by the network. */
+ Channel_t logicalChannel;
+ /** A ZigBee stack profile identifier indicating the stack profile in use in
+ * the discovered network. */
+ StackProfile_t stackProfile;
+ /** The version of the ZigBee protocol in use in the discovered network. */
+ uint8_t zigBeeVersion;
+ /** This specifies how often the MAC sub-layer beacon is to be transmitted by
+ * a given device on the network. */
+ BeaconOrder_t beaconOrder;
+ /** For beacon-oriented networks, that is, beacon order < 15, this specifies
+ * the length of the active period of the superframe. */
+ BeaconOrder_t superframeOrder;
+ /** A value of '1' indicates that at least one ZigBee router on the network
+ * currently permits joining, i.e. its NWK has been issued an NLME-PERMIT-JOINING
+ * primitive and, the time limit if given, has not yet expired. */
+ bool permitJoining;
+ /** This value is set to '1' if the device s capable of accepting join
+ * requests from router-capable devices and set to '0' otherwise. */
+ bool routerCapacity;
+ /** This value is set to '1' if the device is capable of accepting join
+ * requests from end devices and set to '0' otherwise. */
+ bool endDeviceCapacity;
+} NWK_NetworkDescriptor_t;
+END_PACK
+
+/**//**
+ * \brief NLME-NETWORK-DISCOVERY confirm primitive's parameters structure.
+ * ZigBee Specification r17, 3.2.2.2, NLME-NETWORK-DISCOVERY.confirm
+ */
+typedef struct _NWK_NetworkDiscoveryConf_t
+{
+ /** The status of the request. Any status values returned with MLME-SCAN.confirm
+ * primitive or NWK_INVALID_REQUEST_STATUS, NWK_SUCCESS_STATUS. */
+ NWK_Status_t status;
+ /** The number of networks discovered by the search. */
+ uint8_t networkCount;
+ /** Size of networkDescriptors array. It must be initialized by user.
+ * Zero value is admissible. */
+ uint8_t maxNetworkDescr;
+ /** The array of descriptors, one for each of the networks discovered.
+ * It must be initialized by user. NULL pointer is admissible. */
+ NWK_NetworkDescriptor_t *networkDescriptors;
+} NWK_NetworkDiscoveryConf_t;
+
+/**//**
+ * \brief NLME-NETWORK-DISCOVERY request primitive's parameters structure.
+ * Zigbee Specification r17, 3.2.2.1 NLME-NETWORK-DISCOVERY.request.
+ */
+typedef struct _NWK_NetworkDiscoveryReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ MAC_ScanReq_t macScan;
+ } service;
+ /** A value used to calculate the length of time to spend scanning each channel. */
+ ScanDuration_t scanDuration;
+ /** The mask of channels that must be scanned. */
+ ChannelsMask_t scanChannels;
+ /** NLME-NETWORK-DISCOVERY confirm callback function's pointer. */
+ void (*NWK_NetworkDiscoveryConf)(NWK_NetworkDiscoveryConf_t *conf);
+ NWK_NetworkDiscoveryConf_t confirm;
+ /** Field that allows to keep entries in neighbor table during network discovery request called from application */
+ bool clearNeighborTable;
+} NWK_NetworkDiscoveryReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-NETWORK-DISCOVERY request primitive's prototype.
+
+ \param[in] req - NLME-NETWORK-DISCOVERY request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_NetworkDiscoveryReq(NWK_NetworkDiscoveryReq_t *const req);
+
+#endif /* _NLME_NETWORK_DISCOVERY_H */
+/** eof nlmeNetworkDiscovery.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNetworkFormation.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNetworkFormation.h
new file mode 100644
index 00000000..88b6ed4c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNetworkFormation.h
@@ -0,0 +1,95 @@
+/**************************************************************************//**
+ \file nlmeNetworkFormation.h
+
+ \brief NLME-NETWORK-FORMATION interface
+
+ \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:
+ 2009-04-11 Max Gekk - Created.
+ Last change:
+ $Id: nlmeNetworkFormation.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_NETWORK_FORMATION_H
+#define _NLME_NETWORK_FORMATION_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <mac.h>
+#include <nwkCommon.h>
+#include <nlmeEdScan.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-NETWORK-FORMATION confirm primitive's parameters structure.
+ * ZigBee Specification r17, 3.2.2.3, NLME-NETWORK-FORMATION.confirm
+ */
+typedef struct _NWK_NetworkFormationConf_t
+{
+ /** The status of the request. */
+ NWK_Status_t status;
+} NWK_NetworkFormationConf_t;
+
+/**//**
+ * \brief NLME-NETWORK-FORMATION request primitive's parameters structure.
+ * Zigbee Specification r17, 3.2.2.3 NLME-NETWORK-FORMATION.request.
+ */
+typedef struct _NWK_NetworkFormationReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ { /** Link to a next network formation request in queue. */
+ QueueElement_t qelem;
+ union
+ {
+ struct
+ {
+ MAC_ScanReq_t req;
+ PHY_EnergyLevel_t energyList[MAX_EDSCAN_CHANNEL_AMOUNT];
+ } scan;
+ MAC_SetReq_t setReq;
+ MAC_StartReq_t startReq;
+ MAC_RxEnableReq_t rxEnableReq;
+ } mac;
+ } service;
+ /** Channels are to be scanned in preparation for starting a network. */
+ ChannelsMask_t scanChannels;
+ /** The time spent scanning each channel is
+ * (aBaseSuperframeDuration * (2n + 1)) symbols,
+ * where n is the value of the ScanDuration parameter. */
+ ScanDuration_t scanDuration;
+ /** The beacon order of the network that the higher layers wish to form. */
+ /* NwkBeaconOrder_t beaconOrder; */
+ /* The superframe order of the network that the higher layers wish to form. */
+ /* NwkBeaconOrder_t superFrameOrder; */
+ /* Support battery life extension mode. This parameter is ignored if the
+ * BeaconOrder parameter has a value of 15. */
+ /* bool batteryLifeExtention; */
+ /** NLME-NETWORK-FORMATION confirm callback function's pointer. */
+ void (*NWK_NetworkFormationConf)(NWK_NetworkFormationConf_t *conf);
+ NWK_NetworkFormationConf_t confirm;
+} NWK_NetworkFormationReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-NETWORK-FORMATION request primitive's prototype.
+
+ \param[in] req - NLME-NETWORK-FORMATION request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_NetworkFormationReq(NWK_NetworkFormationReq_t *const req);
+
+#endif /* _NLME_NETWORK_FORMATION_H */
+/** eof nlmeNetworkFormation.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNwkStatus.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNwkStatus.h
new file mode 100644
index 00000000..3fa8cc37
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeNwkStatus.h
@@ -0,0 +1,122 @@
+/**************************************************************************//**
+ \file nlmeNwkStatus.h
+
+ \brief NLME-NWK-STATUS interface
+
+ \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:
+ 2009-04-12 Max Gekk - Created.
+ Last change:
+ $Id: nlmeNwkStatus.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_NWK_STATUS_H
+#define _NLME_NWK_STATUS_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+
+/** Status Codes for network status command frame. */
+typedef enum _NWK_StatusIndErrorCodes_t
+{
+ /** Route discovery and/or repair has been attempted and no route to
+ * the intended destination address has been discovered. */
+ NWK_NO_ROUTE_AVAILABLE = 0x00,
+ /** The routing failure occurred as a result of the failure of an attempt
+ * to route the frame along the tree. */
+ NWK_TREE_LINK_FAILURE = 0x01,
+ /** The routing failure did not occur as a result of an attempt to route along
+ * the tree. */
+ NWK_NON_TREE_LINK_FAILURE = 0x02,
+ /** The frame was not relayed because the relaying device was running low
+ * on battery power. */
+ NWK_LOW_BATTERY_LEVEL = 0x03,
+ /** The failure occurred because the relaying device has no routing capacity.
+ **/
+ NWK_NO_ROUTING_CAPACITY = 0x04,
+ /** The failure occurred as the result of an attempt to buffer
+ * a frame for a sleeping end device child and the relaying device
+ * had no buffer capacity to use. */
+ NWK_NO_INDIRECT_CAPACITY = 0x05,
+ /** A frame that was buffered on behalf of a sleeping end device child has
+ * been dropped as a result of a time-out. */
+ NWK_INDIRECT_TRANSACTION_EXPIRY = 0x06,
+ /** An end device child of the relaying device is for some reason unavailable.
+ **/
+ NWK_TARGET_DEVICE_UNAVAILABLE = 0x07,
+ /** The frame was addressed to a non-existent end device
+ * child of the relaying device. */
+ NWK_TARGET_ADDRESS_UNALLOCATED = 0x08,
+ /** The failure occurred as a result of a failure in the RF link to
+ * the device's parent. This status is only used locally on a device
+ * to indicate loss of communication with the parent. */
+ NWK_PARENT_LINK_FAILURE = 0x09,
+ /** The multicast route identified in the destination address
+ * field should be validated. */
+ NWK_VALIDATE_ROUTE = 0x0A,
+ /** Source routing has failed, probably indicating a link failure in one of
+ * the source route's links. */
+ NWK_SOURCE_ROUTE_FAILURE = 0x0B,
+ /** A route established as a result of a many-to-one route request has failed.
+ **/
+ NWK_MANY_TO_ONE_ROUTE_FAILURE = 0x0C,
+ /** The address in the destination address field has been determined to be
+ * in use by two or more devices. */
+ NWK_ADDRESS_CONFLICT = 0x0D,
+ /** The source device has the IEEE address in the Source IEEE address field
+ * and, if the Destination IEEE address field is present, the value it
+ * contains is the expected IEEE address of the destination. */
+ NWK_VERIFY_ADDRESSES = 0x0E,
+ /** The operational network PAN identifier of the device has been updated. */
+ NWK_PAN_IDENTIFIER_UPDATE = 0x0F,
+ /** The network address of the device has been updated. */
+ NWK_NETWORK_ADDRESS_UPDATE = 0x10,
+ /** A frame counter reported in a received frame had a value less than or
+ * equal to that stored in nwkSecurityMaterialSet. */
+ NWK_BAD_FRAME_COUNTER = 0x11,
+ /** The key sequence number reported in a received frame did not match
+ * that of nwkActiveKeySeqNumber. */
+ NWK_BAD_KEY_SEQUENCE_NUMBER = 0x12,
+ NWK_PARENT_LINK_SUCCESS = 0x13,
+ NWK_BAD_LINK = 0x14,
+ NWK_STATIC_ADDRESS_CONFLICT = 0x15
+} NWK_StatusIndErrorCodes_t;
+
+/**//**
+ * \brief NLME-NWK-STATUS indication primitive's parameters structure.
+ * Zigbee Specification r17, 3.2.2.30 NLME-NWK-STATUS.indication, page 302.
+ */
+typedef struct _NWK_NwkStatusInd_t
+{
+ /** The 16-bit network address of the device
+ * associated with the status information. */
+ ShortAddr_t shortAddress;
+ /** The error code associated with the failure. */
+ NWK_StatusIndErrorCodes_t status;
+} NWK_NwkStatusInd_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-NWK-STATUS indication primitive's prototype.
+
+ \return None.
+ ******************************************************************************/
+extern void NWK_NwkStatusInd(NWK_NwkStatusInd_t *ind);
+
+#endif /* _NLME_NWK_STATUS_H */
+/** eof nlmeNwkStatus.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmePermitJoining.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmePermitJoining.h
new file mode 100644
index 00000000..7729f1d4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmePermitJoining.h
@@ -0,0 +1,99 @@
+/**************************************************************************//**
+ \file nlmePermitJoining.h
+
+ \brief NLME-PERMIT-JOINING interface
+
+ \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:
+ 2009-04-12 Max Gekk - Created.
+ Last change:
+ $Id: nlmePermitJoining.h 18296 2011-08-19 12:29:05Z mgekk $
+ ******************************************************************************/
+#if !defined _NLME_PERMIT_JOINING_H
+#define _NLME_PERMIT_JOINING_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Permissions flags of network rejoin. */
+#define NWK_ALLOW_REJOIN 0U
+#define NWK_BAN_ED_REJOIN 1U /* End Devices can't rejoin to this device. */
+#define NWK_BAN_ROUTER_REJOIN 2U /* Routers can't rejoin to this device. */
+#define NWK_BAN_REJOIN \
+ ((NWK_RejoinPermit_t)(NWK_BAN_ED_REJOIN | NWK_BAN_ROUTER_REJOIN))
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-PERMIT-JOINING confirm primitive's parameters structure.
+ * ZigBee Specification r17, 3.2.2.6 NLME-PERMIT-JOINING.confirm, page 276.
+ */
+typedef struct _NWK_PermitJoiningConf_t
+{
+ /** The status of the corresponding request. Valid Range: NWK_SUCCESS_STATUS
+ * or any status returned from the MLME-SET.confirm primitive. */
+ NWK_Status_t status;
+} NWK_PermitJoiningConf_t;
+
+/**//**
+ * \brief NLME-PERMIT-JOINING request primitive's parameters structure.
+ * Zigbee Specification r17, 3.2.2.5 NLME-PERMIT-JOINING.request, page 274.
+ */
+typedef struct _NWK_PermitJoiningReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /** The length of time in seconds during which the ZigBee coordinator or
+ * router will allow associations. The value 0x00 and 0xff indicate that
+ * permission is disabled or enabled, respectively,
+ * without a specified time limit. */
+ uint8_t permitDuration;
+ /** NLME-PERMIT-JOINING confirm callback function's pointer. */
+ void (*NWK_PermitJoiningConf)(NWK_PermitJoiningConf_t *conf);
+ NWK_PermitJoiningConf_t confirm;
+} NWK_PermitJoiningReq_t;
+
+/** Type of rejoin permissions to the given devices. */
+typedef uint8_t NWK_RejoinPermit_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-PERMIT-JOINING request primitive's prototype.
+
+ \param[in] req - NLME-PERMIT-JOINING request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_PermitJoiningReq(NWK_PermitJoiningReq_t *const req);
+
+/**************************************************************************//**
+ \brief Enable or disable an end deivce or a router rejoin.
+
+ \param[in] permit - rejoin permissions, allow an end device rejoin only
+ if NWK_BAN_ED_REJOIN bit isn't set, and allow a router
+ rejoin only if NWK_BAN_ROUTER_REJOIN flag isn't set.
+ \return None.
+ ******************************************************************************/
+void NWK_SetRejoinPermit(const NWK_RejoinPermit_t permit);
+
+#endif /* _NLME_PERMIT_JOINING_H */
+/** eof nlmePermitJoining.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeReset.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeReset.h
new file mode 100644
index 00000000..2a1df8f6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeReset.h
@@ -0,0 +1,124 @@
+/**************************************************************************//**
+ \file nlmeReset.h
+
+ \brief NLME-RESET interface.
+
+ \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:
+ 2009-04-13 Max Gekk - Created.
+ Last change:
+ $Id: nlmeReset.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_RESET_H
+#define _NLME_RESET_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-RESET confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.20 NLME-RESET.confirm, page 293.
+ */
+typedef struct _NWK_ResetConf_t
+{
+ /** The result of the reset operation. */
+ NWK_Status_t status;
+} NWK_ResetConf_t;
+
+/**//**
+ * \brief Power failure status bitfield declaration.
+ */
+typedef struct _NWK_PowerFailureControl_t
+{
+ NwkBitField_t active : 1;
+ NwkBitField_t networkOperationsAccepted : 1;
+ NwkBitField_t reserved : 6;
+} NWK_PowerFailureControl_t;
+
+/**//**
+ * \brief NLME-RESET request primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.19 NLME-RESET.request, page 292.
+ */
+typedef struct _NWK_ResetReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /** To restore or not the saved parameters? */
+ NWK_PowerFailureControl_t powerFailureControl;
+ /** This field shall contain the device capability information.
+ * See ZigBee spec r18, Table 3.44, page 345. */
+ MAC_CapabilityInf_t capabilityInformation;
+ /** NLME-RESET confirm callback function's pointer. */
+ void (*NWK_ResetConf)(NWK_ResetConf_t *conf);
+ NWK_ResetConf_t confirm;
+} NWK_ResetReq_t;
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-RESET request primitive's prototype.
+
+ \param[in] req - NLME-RESET request parameters' structure pointer.
+ \return None.
+******************************************************************************/
+void NWK_ResetReq(NWK_ResetReq_t *const req);
+
+/**************************************************************************//**
+ \brief Check, if BitCloud was restored after power failure
+
+ \param[in] powerFailureControl - stack restoring after power failure control bitfield;
+ affects on initialization procedure.
+ \return True, if BitCloud was restored after power failure; false - otherwise
+******************************************************************************/
+INLINE bool NWK_StackRestoredAfterPowerFailure(NWK_PowerFailureControl_t powerFailureControl)
+{
+ return powerFailureControl.active && powerFailureControl.networkOperationsAccepted;
+}
+
+/**************************************************************************//**
+ \brief Retruns Power Failure control information default value.
+
+ \return Power Failure control default value.
+ ******************************************************************************/
+INLINE NWK_PowerFailureControl_t NWK_GetDefaultPowerFailureControl(void)
+{
+ NWK_PowerFailureControl_t powerFailureControl =
+ {
+ .active = 0U,
+ .networkOperationsAccepted = 0U,
+ .reserved = 0U
+ };
+
+ return powerFailureControl;
+}
+
+/**************************************************************************//**
+ \brief Gather Power Failure control information.
+
+ \return Power Failure control information.
+ ******************************************************************************/
+NWK_PowerFailureControl_t NWK_GatherPowerFailureInfo(void);
+
+#endif /* _NLME_RESET_H */
+/** eof nlmeReset.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeRouteDiscovery.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeRouteDiscovery.h
new file mode 100644
index 00000000..381dcb57
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeRouteDiscovery.h
@@ -0,0 +1,88 @@
+/**************************************************************************//**
+ \file nlmeRouteDiscovery.h
+
+ \brief NLME-ROUTE-DISCOVERY interface.
+
+ \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:
+ 2009-04-13 Max Gekk - Created.
+ Last change:
+ $Id: nlmeRouteDiscovery.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_ROUTE_DISCOVERY_H
+#define _NLME_ROUTE_DISCOVERY_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+#include <nlmeNwkStatus.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-ROUTE-DISCOVERY confirm primitive's parameters structure.
+ * ZigBee Specification r17, 3.2.2.32 NLME-NETWORK-FORMATION.confirm, page 306.
+ */
+typedef struct _NWK_RouteDiscoveryConf_t
+{
+ /** The status of an attempt to initiate route discovery. */
+ NWK_Status_t status;
+ /** In the case where the Status parameter has a value of ROUTE_ERROR,
+ * this code gives further information about the kind of error that occurred.
+ * Otherwise, it should be ignored. ZigBee spec r17, Table 3.35. */
+ NWK_StatusIndErrorCodes_t networkStatusCode;
+ ShortAddr_t nextHop;
+} NWK_RouteDiscoveryConf_t;
+
+/**//**
+ * \brief NLME-ROUTE-DISCOVERY request primitive's parameters structure.
+ * Zigbee Specification r17, 3.2.2.31 NLME-ROUTE-DISCOVERY.request.
+ */
+typedef struct _NWK_RouteDiscoveryReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /** A parameter specifying the kind of destination address provided. */
+ NWK_DstAddrMode_t dstAddrMode;
+ /** The destination of the route discovery. */
+ ShortAddr_t dstAddr;
+ /** This optional parameter describes the number of hops that the route
+ * request will travel through the network. */
+ NwkRadius_t radius;
+ /** In the case where DstAddrMode has a value of zero, indicating many-to-one
+ * route discovery, this flag determines whether the NWK should establish
+ * a route record table. TRUE = no route record table should be established,
+ * FALSE = establish a route record table */
+ bool noRouteCache;
+ /** NLME-ROUTE-DISCOVERY confirm callback function's pointer. */
+ void (*NWK_RouteDiscoveryConf)(NWK_RouteDiscoveryConf_t *conf);
+ NWK_RouteDiscoveryConf_t confirm;
+} NWK_RouteDiscoveryReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-ROUTE-DISCOVERY request primitive's prototype.
+
+ \param[in] req - NLME-ROUTE-DISCOVERY request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_RouteDiscoveryReq(NWK_RouteDiscoveryReq_t *const req);
+
+#endif /* _NLME_ROUTE_DISCOVERY_H */
+/** eof nlmeRouteDiscovery.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSetGet.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSetGet.h
new file mode 100644
index 00000000..d6c37e9b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSetGet.h
@@ -0,0 +1,299 @@
+/**************************************************************************//**
+ \file nlmeSetGet.h
+
+ \brief NLME-SET and NLME-GET interface
+
+ \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:
+ 2009-04-13 Max Gekk - Created.
+ Last change:
+ $Id: nlmeSetGet.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_SET_GET_H
+#define _NLME_SET_GET_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+#include <appFramework.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Identifiers of network information base attributes. ZigBee spec r17,
+ * Table 3.44. */
+typedef enum _NWK_NibId_t
+{
+ /** This NIB attribute have the same value as macPANId. */
+ NWK_NIB_PANID_ID = 0x80,
+ /** A sequence number used to identify outgoing frames. */
+ NWK_NIB_SEQUENCE_NUMBER_ID = 0x81,
+ /** The maximum time duration in milliseconds allowed for the parent and
+ * all child devices to retransmit a broadcast message.
+ * Valid range: 0-0x2710. */
+ NWK_NIB_PASSIVE_ACK_TIMEOUT_ID = 0x82,
+ /** The maximum number of retries allowed after a broadcast transmission
+ * failure. Valid range: 0-5. */
+ NWK_NIB_MAX_BROADCAST_RETRIES_ID = 0x83,
+ /** The number of children a device is allowed to have on its current network.
+ **/
+ NWK_NIB_MAX_CHILDREN_ID = 0x84,
+ /** The depth a device can have. */
+ NWK_NIB_MAX_DEPTH_ID = 0x85,
+ /** The number of routers any one device is allowed to have as children. */
+ NWK_NIB_MAX_ROUTERS_ID = 0x86,
+ /** The current set of neighbor table entries in the device. */
+ NWK_NIB_NEIGHBOR_TABLE_ID = 0x87,
+ /** Time duration in seconds that a broadcast message needs to encompass
+ * the entire network. */
+ NWK_NIB_NETWORK_BROADCAST_DELIVERY_TIME_ID = 0x88,
+ /** If this is set to 0, the NWK layer shall calculate link cost from
+ * all neighbor nodes using the LQI values reported by the MAC layer;
+ * otherwise, it shall report a constant value. */
+ NWK_NIB_REPORT_CONSTANT_COST_ID = 0x89,
+ /** The number of retries allowed after an unsuccessful route request. */
+ NWK_NIB_ROUTE_DISCOVERY_RETRIES_PERMITTED_ID = 0x8A,
+ /** The current set of routing table entries in the device. */
+ NWK_NIB_ROUTE_TABLE_ID = 0x8B,
+ /** A flag that determines if a time stamp indication is provided on incoming
+ * and outgoing packets.
+ * '1' - time indication provided.
+ * '0' - no time indication provided. */
+ NWK_NIB_TIME_STAMP_ID = 0x8C,
+ /** The current route symmetry setting. 'true' means that routes are considered
+ * to be comprised of symmetric links. Backward and forward routes are created
+ * during one-route discovery and they are identical. 'false' indicates that
+ * routes are not consider to be comprised of symmetric links. Only the forward
+ * route is stored during route discovery. */
+ NWK_NIB_SYM_LINK_ID = 0x8E,
+ /** This field shall contain the device capability information established at
+ * network joining time. */
+ NWK_NIB_CAPABILITY_INFORMATION_ID = 0x8F,
+ /** A value that determines the method used to assign addresses:
+ * - 0x00 = use distributed address allocation
+ * - 0x01 = reserved
+ * - 0x02 = use stochastic address allocation. */
+ NWK_NIB_ADDR_ALLOC_ID = 0x90,
+ /** A flag that determines whether the NWK layer should assume the ability
+ * to use hierarchical routing:
+ * - true = assume the ability to use hierarchical routing.
+ * - false = never use hierarchical routing. */
+ NWK_NIB_USE_TREE_ROUTING_ID = 0x91,
+ /** The address of the designated network channel manager function. */
+ NWK_NIB_MANAGER_ADDR_ID = 0x92,
+ /** The maximum number of hops in a source route. */
+ NWK_NIB_MAX_SOURCE_ROUTE_ID = 0x93,
+ /** The value identifying a snapshot of the network settings with
+ * which this node is operating with. */
+ NWK_NIB_UPDATE_ID = 0x94,
+ /** The maximum time (in superframe periods) that a transaction is stored by a
+ * coordinator and indicated in its beacon. */
+ NWK_NIB_TRANSACTION_PERSISTENCE_TIME_ID = 0x95,
+ /** The 16-bit address that the device uses to communicate with the PAN. */
+ NWK_NIB_NETWORK_ADDRESS_ID = 0x96,
+ /** The identifier of the ZigBee stack profile in use for this device. */
+ NWK_NIB_STACK_PROFILE_ID = 0x97,
+ /** The current set of broadcast transaction table entries in the device. */
+ NWK_NIB_BROADCAST_TRANSACTION_TABLE_ID = 0x98,
+ /** The Extended PAN Identifier for the PAN of which the device is a member.
+ * The value 0x0000000000000000 means the Extended PAN Identifier is unknown.
+ **/
+ NWK_NIB_EXTENDED_PANID_ID = 0x9A,
+ /** A flag determining the layer where multicast messaging occurs.
+ * - true = multicast occurs at the network layer.
+ * - false = multicast occurs at the APS layer and using the APS header.*/
+ NWK_NIB_USE_MULTICAST_ID = 0x9B,
+ /** The route record table. */
+ NWK_NIB_ROUTE_RECORD_TABLE_ID = 0x9C,
+ /** A flag determining if this device is a concentrator.
+ * - true = Device is a concentrator.
+ * - false = Device is not a concentrator.*/
+ NWK_NIB_IS_CONCENTRATOR_ID = 0x9D,
+ /** The hop count radius for concentrator route discoveries. */
+ NWK_NIB_CONCENTRATOR_RADIUS_ID = 0x9E,
+ /** The time in seconds between concentrator route discoveries.
+ * If set to 0x0000, the discoveries are done at start up and
+ * by the next higher layer only. */
+ NWK_NIB_CONCENTRATOR_DISCOVERY_TIME_ID = 0x9F,
+ /** The security level for outgoing and incoming NWK frames. */
+ NWK_NIB_SECURITY_LEVEL_ID = 0xA0,
+ /** Set of network security material descriptors capable of maintaining
+ * an active and alternate network key. */
+ NWK_NIB_SECURITY_MATERIAL_SET_ID = 0xA1,
+ /** The sequence number of the active network key in nwkSecurityMaterialSet.
+ **/
+ NWK_NIB_ACTIVE_KEY_SEQ_NUMBER_ID = 0xA2,
+ /** Indicates whether incoming NWK frames must be all checked for freshness
+ * when the memory for incoming frame counts is exceeded. */
+ NWK_NIB_ALL_FRESH_ID = 0xA3,
+ /** Indicates whether security shall be applied to incoming and outgoing NWK
+ * data frames.If set to 0x01, security processing shall be applied to all
+ * incoming and outgoing frames except data frames destined for the current
+ * device that have the security sub-field of the frame control field
+ * set to 0. If this attribute has a value of 0x01, the NWK layer shall not
+ * relay frames that have the security sub-field of the frame control field
+ * set to 0. The SecurityEnable parameter of the NLDE-DATA.request primitive
+ * shall override the setting of this attribute. */
+ NWK_NIB_SECURE_ALL_FRAMES_ID = 0xA5,
+ /** The time in seconds between link status command frames. */
+ NWK_NIB_LINK_STATUS_PERIOD_ID = 0xA6,
+ /** The number of missed link status command frames before resetting the link
+ * costs to zero. */
+ NWK_NIB_ROUTER_AGE_LIMIT_ID = 0xA7,
+ /** Use static addressing or not. */
+ NWK_NIB_UNIQUE_ADDR_ID = 0xA8,
+ /** The current set of 64-bit IEEE to 16-bit network address map. */
+ NWK_NIB_ADDRESS_MAP_ID = 0xA9,
+ /** Extra nib attributes. */
+ NWK_NIB_INT_LOGICAL_CHANNEL_ID = 0xF0,
+ NWK_NIB_INT_PARENT_SHORT_ID = 0xF1,
+ NWK_NIB_INT_TRANSMIT_COUNTER_ID = 0xF2,
+ NWK_NIB_INT_TRANSMIT_FAILURE_COUNTER_ID = 0xF3,
+ NWK_NIB_INT_DEPTH_ID = 0xF4,
+ NWK_NIB_INT_SECURITY_IB_ID = 0xF5,
+ NWK_NIB_INT_EXTENDED_ADDRESS_ID = 0xF6,
+ NWK_NIB_MAX_NEIGHBOR_ROUTE_COST_ID = 0xF7,
+ NWK_NIB_PREDEFINED_PANID_ID = 0xF8
+} NWK_NibId_t;
+
+/** NWK NIB attribute type. */
+typedef union _NWK_NibAttr_t
+{
+ PanId_t panId;
+ NwkSequenceNumber_t sequenceNumber;
+ uint16_t passiveAckTimeout;
+ uint8_t maxBroadcastRetries;
+ NwkChildCount_t maxChildren;
+ NwkDepth_t maxDepth;
+ NwkChildCount_t maxRouters;
+ void *neighborTable;
+ uint32_t networkBroadcastDeliveryTime;
+ uint8_t reportConstantCost;
+ uint8_t routeDiscoveryRetriesPermitted;
+ void *routeTable;
+ bool symLink;
+ MAC_CapabilityInf_t capabilityInformation;
+ uint8_t addrAlloc;
+ bool useTreeRouting;
+ ShortAddr_t managerAddr;
+ uint8_t maxSourceRoute;
+ NwkUpdateId_t updateId;
+ uint16_t transactionPersistenceTime;
+ ShortAddr_t networkAddress;
+ uint8_t stackProfile;
+ void *broadcastTransactionTable;
+ void *groupIDTable;
+ ExtPanId_t extendedPANID;
+ bool useMulticast;
+ void *routeRecordTable;
+ bool isConcentrator;
+ NwkRadius_t concentratorRadius;
+ uint8_t concentratorDiscoveryTime;
+ uint8_t linkStatusPeriod;
+ uint8_t routerAgeLimit;
+ bool uniqueAddr;
+ void *addressMap;
+ bool timeStamp;
+ uint16_t txTotal;
+ Channel_t logicalChannel;
+ ShortAddr_t parentShortAddr;
+ uint16_t transmitCounter;
+ uint16_t transmitFailureCounter;
+ NwkDepth_t depth;
+ void *securityIB;
+ ExtAddr_t extAddr;
+} NWK_NibAttr_t;
+
+/**//**
+ * \brief NLME-SET confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.29 NLME-GET.confirm, page 301.
+ */
+typedef struct _NWK_SetConf_t
+{
+ /** The result of the request to write the NIB attribute. */
+ NWK_Status_t status;
+ /** The identifier of the NIB attribute that was written. */
+ NWK_NibId_t attrId;
+} NWK_SetConf_t;
+
+typedef struct _NWK_SetReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ };
+ /** The identifier of the NIB attribute to write. */
+ NWK_NibId_t attrId;
+ /** The value to write to the indicated NIB attribute. */
+ NWK_NibAttr_t attrValue;
+ /** NLME-SET confirm callback function's pointer. */
+ void (*NWK_SetConf)(NWK_SetConf_t *conf);
+ /** NLME-SET confirm parameters' structure. */
+ NWK_SetConf_t confirm;
+} NWK_SetReq_t;
+
+/**//**
+ * \brief NLME-GET confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.27 NLME-GET.confirm, page 299.
+ */
+typedef struct _NWK_GetConf_t
+{
+ /** The results of the request to read a NIB attribute value. */
+ NWK_Status_t status;
+ /** The identifier of the NIB attribute that was read. */
+ NWK_NibId_t attrId;
+ /** The value of the indicated NIB attribute that was read. */
+ NWK_NibAttr_t attrValue;
+} NWK_GetConf_t;
+
+/**//**
+ * \brief NLME-GET request primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.26 NLME-SYNC.request, page 298.
+ */
+typedef struct _NWK_GetReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /** The identifier of the PIB attribute to read. */
+ NWK_NibId_t attrId;
+ /** NLME-GET confirm callback function's pointer. */
+ void (*NWK_GetConf)(NWK_GetConf_t *conf);
+ /** NLME-GET confirm parameters' structure. */
+ NWK_GetConf_t confirm;
+} NWK_GetReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-SET request primitive's prototype.
+
+ \param[in] req - NLME-SET request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_SetReq(NWK_SetReq_t *const req);
+
+/**************************************************************************//**
+ \brief NLME-GET request primitive's prototype.
+
+ \param[in] req - NLME-GET request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_GetReq(NWK_GetReq_t *const req);
+
+#endif /* _NLME_SET_GET_H */
+/** eof nlmeSetGet.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeStartRouter.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeStartRouter.h
new file mode 100644
index 00000000..d4de3afe
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeStartRouter.h
@@ -0,0 +1,81 @@
+/**************************************************************************//**
+ \file nlmeStartRouter.h
+
+ \brief NLME-START-ROUTER interface
+
+ \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:
+ 2009-04-11 Max Gekk - Created.
+ Last change:
+ $Id: nlmeStartRouter.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_START_ROUTER_H
+#define _NLME_START_ROUTER_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <mac.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-START-ROUTER confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.7 NLME-START-ROUTER.confirm
+ */
+typedef struct _NWK_StartRouterConf_t
+{
+ /** The result of the attempt to initialize a ZigBee router.
+ * Valid range: NWK_INVALID_REQUEST_STATUS or any status value returned from
+ * the MAC_StartConf callback.*/
+ NWK_Status_t status;
+} NWK_StartRouterConf_t;
+
+/**//**
+ * \brief NLME-START-ROUTER request primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.8 NLME-START-ROUTER.request.
+ */
+typedef struct _NWK_StartRouterReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ MAC_StartReq_t macStart;
+ } service;
+ /** The beacon order of the network that the higher layers wish to form. */
+ /* NwkBeaconOrder_t beaconOrder; */
+ /* The superframe order of the network that the higher layers wish to form. */
+ /* NwkBeaconOrder_t superFrameOrder; */
+ /* Supporting battery life extension mode. This parameter is ignored if the
+ * BeaconOrder parameter has a value of 15. */
+ /* bool batteryLifeExtention; */
+ /* NLME-START-ROUTER confirm callback function's pointer. */
+ void (*NWK_StartRouterConf)(NWK_StartRouterConf_t *conf);
+ /** NLME-START-ROUTER confirm primitive's parameters */
+ NWK_StartRouterConf_t confirm;
+} NWK_StartRouterReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-START-ROUTER request primitive's prototype.
+
+ \param[in] req - NLME-START-ROUTER request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_StartRouterReq(NWK_StartRouterReq_t *const req);
+
+#endif /* _NLME_START_ROUTER_H */
+/** eof nlmeStartRouter.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSync.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSync.h
new file mode 100644
index 00000000..b01eb4f2
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSync.h
@@ -0,0 +1,79 @@
+/**************************************************************************//**
+ \file nlmeSync.h
+
+ \brief NLME-SYNC interface
+
+ \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:
+ 2009-04-12 Max Gekk - Created.
+ Last change:
+ $Id: nlmeSync.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_SYNC_H
+#define _NLME_SYNC_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/**//**
+ * \brief NLME-SYNC confirm primitive's parameters structure declaration.
+ * ZigBee Specification r17, 3.2.2.24 NLME-SYNC.confirm, page 296.
+ */
+typedef struct _NWK_SyncConf_t
+{
+ /** The result of the request to synchronize with the ZigBee coordinator or
+ * router. Valid Range: NWK_SUCCESS_STATUS, NWK_INVALID_PARAMETER_STATUS,
+ * or any status value returned from the MLME_POLL.confirm primitive. */
+ NWK_Status_t status;
+} NWK_SyncConf_t;
+
+/**//**
+ * \brief NLME-SYNC request primitive's parameters structure declaration.
+ * Zigbee Specification r17, 3.2.2.22 NLME-SYNC.request, page 294.
+ */
+typedef struct _NWK_SyncReq_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /** Whether or not the synchronization should be maintained for future beacons.
+ **/
+ bool track;
+ /** NLME-SYNC confirm callback function's pointer. */
+ void (*NWK_SyncConf)(NWK_SyncConf_t *conf);
+ NWK_SyncConf_t confirm;
+} NWK_SyncReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-SYNC request primitive's prototype.
+
+ The function sends a data request to the parent polling for buffered data. The confirmation callback is raised with NWK_SUCCESS_STATUS, if the
+ request has been executed successfully and a response from the parents has been received. If the current node's parent is storing data frames
+ for the child, then after sending response to the polling request it starts sending the data. When the child receives the data the standard callback
+ idicating data frame reception is executed.
+
+ \param[in] req - NLME-SYNC request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+void NWK_SyncReq(NWK_SyncReq_t *const req);
+
+#endif /* _NLME_SYNC_H */
+/** eof nlmeSync.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSyncLoss.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSyncLoss.h
new file mode 100644
index 00000000..7e8d4353
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nlmeSyncLoss.h
@@ -0,0 +1,34 @@
+/**************************************************************************//**
+ \file nlmeSyncLoss.h
+
+ \brief NLME-SYNC-LOSS interface
+
+ \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:
+ 2009-04-12 Max Gekk - Created.
+ Last change:
+ $Id: nlmeSyncLoss.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NLME_SYNC_LOSS_H
+#define _NLME_SYNC_LOSS_H
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NLME-SYNC-LOSS indication primitive's prototype.
+
+ \return None.
+ ******************************************************************************/
+extern void NWK_SyncLossInd(void);
+
+#endif /* _NLME_SYNC_LOSS_H */
+/** eof nlmeSyncLoss.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwk.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwk.h
new file mode 100644
index 00000000..94f82a6c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwk.h
@@ -0,0 +1,87 @@
+/**************************************************************************//**
+ \file nwk.h
+
+ \brief Interface of NWK layer.
+
+ \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:
+ 2009-04-13 Max Gekk - Created.
+ Last change:
+ $Id: nwk.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_H
+#define _NWK_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkCommon.h>
+
+#include <nldeData.h>
+#include <nlmeDirectJoin.h>
+#include <nlmeEdScan.h>
+#include <nlmeJoin.h>
+#include <nlmeLeave.h>
+#include <nlmeNetworkDiscovery.h>
+#include <nlmeNetworkFormation.h>
+#include <nlmeNwkStatus.h>
+#include <nlmePermitJoining.h>
+#include <nlmeReset.h>
+#include <nlmeRouteDiscovery.h>
+#include <nlmeStartRouter.h>
+#include <nlmeSync.h>
+#include <nlmeSyncLoss.h>
+
+/** Extra network headers */
+#include <nwkAttributes.h>
+#include <nwkSecurity.h>
+#include <nwkAddressResolv.h>
+#include <nwkNeighbor.h>
+#include <nwkRouteInfo.h>
+#include <nwkGroup.h>
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief NWK_Init shall be called only by APS and only once at startup.
+
+ \return None.
+ ******************************************************************************/
+void NWK_Init(void);
+
+/**************************************************************************//**
+ \brief The stack don't sleep if this function return 'true'.
+
+ \return 'true' if the network layer if active otherwise 'false'.
+ ******************************************************************************/
+bool NWK_IsActiveTransaction(void);
+
+/**************************************************************************//**
+ \brief NWK layer activities launching
+ ******************************************************************************/
+void NWK_LaunchActivities(void);
+
+/**************************************************************************//**
+ \brief NWK layer activities stopping
+ ******************************************************************************/
+void NWK_StopActivities(void);
+
+/**************************************************************************//**
+ \brief Determine if node has all the parameters required to operate in network.
+
+ \return True, if node has all the parameters required to operate in network;
+ false - otherwise.
+ ******************************************************************************/
+bool NWK_DeviceIsAbleToOperateInNetwork(void);
+
+#endif /* _NWK_H */
+/** eof nwk.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkAddressResolv.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkAddressResolv.h
new file mode 100644
index 00000000..a89e439d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkAddressResolv.h
@@ -0,0 +1,67 @@
+/**************************************************************************//**
+ \file nwkAddressResolv.h
+
+ \brief Interface of address resolution.
+
+ \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:
+ 2010-07-04 Max Gekk - Created.
+ Last change:
+ $Id: nwkAddressResolv.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ADDRESS_RESOLV_H
+#define _NWK_ADDRESS_RESOLV_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Link short network and IEEE extended address.
+
+ \param[in] shortAddr - a short address.
+ \param[in] extAddr - an extended address.
+ \return 'true' if short and extended addresses are linked successfully
+ otherwise 'false'.
+ ******************************************************************************/
+bool NWK_LinkShortAndExtAddress(const ShortAddr_t shortAddr,
+ const ExtAddr_t extAddr);
+
+/**************************************************************************//**
+ \brief Remove the entry with given address from the address map.
+
+ \param[in] extAddr - pointer to a extended address.
+ \return None.
+ ******************************************************************************/
+void NWK_RemoveFromAddressMap(const ExtAddr_t *const extAddr);
+
+/**************************************************************************//**
+ \brief Searching a extended address by the short address.
+
+ \param[in] shortAddr - a short address.
+ \return Pointer to the extended address in the address map.
+ ******************************************************************************/
+const ExtAddr_t* NWK_GetExtByShortAddress(const ShortAddr_t shortAddr);
+
+/**************************************************************************//**
+ \brief Searching a short address by the extended address.
+
+ \param[in] extAddr - pointer to the extended address.
+ \return Pointer to the short address in the address map.
+ ******************************************************************************/
+const ShortAddr_t* NWK_GetShortByExtAddress(const ExtAddr_t *const extAddr);
+
+#endif /* _NWK_ADDRESS_RESOLV_H */
+/** eof nwkAddressResolv.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkAttributes.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkAttributes.h
new file mode 100644
index 00000000..1dad0c46
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkAttributes.h
@@ -0,0 +1,196 @@
+/**************************************************************************//**
+ \file nwkAttributes.h
+
+ \brief Interface of network attributes.
+
+ \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:
+ 2009-05-01 Max Gekk - Created
+ Last change:
+ $Id: nwkAttributes.h 18225 2011-08-12 14:02:16Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_ATTRIBUTES_H
+#define _NWK_ATTRIBUTES_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+#include <appFramework.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief This function return a short address that is allocated by parent.
+
+ \return Short address of this node or NWK_NO_SHORT_ADDR.
+ ******************************************************************************/
+ShortAddr_t NWK_GetShortAddr(void);
+
+/**************************************************************************//**
+ \brief Setting new short address of this device.
+
+ \param[in] shortAddr - new short (16-bit) address.
+ \param[in] silent - report (false) or not (true) to upper-layer.
+
+ \return NWK_SUCCESS_STATUS - if this request is valid
+ otherwise NWK_NOT_PERMITTED_STATUS.
+ ******************************************************************************/
+NWK_Status_t NWK_SetShortAddr(const ShortAddr_t shortAddr, const bool silent);
+
+/**************************************************************************//**
+ \brief This function return a short address of parent.
+
+ \return Short address of parent device or NWK_NO_SHORT_ADDR
+ ******************************************************************************/
+ShortAddr_t NWK_GetParentShortAddr(void);
+
+/**************************************************************************//**
+ \brief This function return a short panid of network.
+
+ \return short panid or 0xFFFF
+ ******************************************************************************/
+PanId_t NWK_GetPanId(void);
+
+/**************************************************************************//**
+ \brief This function return a extended panid of network.
+
+ \return extended panid or 0
+ ******************************************************************************/
+ExtPanId_t NWK_GetExtPanId(void);
+
+/**************************************************************************//**
+ \brief Set a NWK extended PAN ID parameter value.
+
+ \param[in] extPanId - pointer to new NWK extended PAN ID parameter value.
+ \return None.
+ ******************************************************************************/
+void NWK_SetExtPanId(const ExtPanId_t *extPanId);
+
+/**************************************************************************//**
+ \brief Current RF channel.
+ ******************************************************************************/
+Channel_t NWK_GetLogicalChannel(void);
+
+/**************************************************************************//**
+ \brief Setting a new RF channel.
+
+ \param[in] channel - the number of new channel.
+ ******************************************************************************/
+void NWK_SetLogicalChannel(const Channel_t channel);
+
+/**************************************************************************//**
+ \brief Maximum delivery time of broadcasting transmission on a network.
+
+ Distination nodes of broadcasting transmission are only full function devices.
+
+ \return Current value of broadcast delivery time in milliseconds.
+ ******************************************************************************/
+uint32_t NWK_GetBroadcastDeliveryTime(void);
+
+/**************************************************************************//**
+ \brief Medium delivery time of unicast packet to a sleep end device.
+
+ \return Current value of unicast delivery time in milliseconds.
+ ******************************************************************************/
+uint32_t NWK_GetUnicastDeliveryTime(void);
+
+/**************************************************************************//**
+ \brief Set a short address of the network manager.
+
+ \param[in] - short address of the network manager.
+ ******************************************************************************/
+void NWK_SetManagerAddr(const ShortAddr_t shortAddr);
+
+/**************************************************************************//**
+ \brief Getting network address of channel manager.
+
+ \return Network manager address.
+ ******************************************************************************/
+ShortAddr_t NWK_GetManagerAddr(void);
+
+/**************************************************************************//**
+ \brief Set an id of network snapshot.
+
+ \param[in] - new value of the update identifier.
+ ******************************************************************************/
+void NWK_SetUpdateId(const NwkUpdateId_t updateId);
+
+/**************************************************************************//**
+ \brief Getting an id of network snapshot.
+
+ \return Network snapshot id
+ ******************************************************************************/
+NwkUpdateId_t NWK_GetUpdateId(void);
+
+/**************************************************************************//**
+ \brief Sets symmetric link attribute value.
+
+ \param[in] symLink - new symmetric link attribute value.
+ \return None.
+ ******************************************************************************/
+void NWK_SetSymLink(const bool symLink);
+
+/**************************************************************************//**
+ \brief Changing the route fail order.
+
+ After 2^order failure attempts a route entry will be deleted.
+
+ \param[in] order - new order of route fail.
+ \return NWK_SUCCESS_STATUS if order is valid
+ otherwise NWK_INVALID_PARAMETER_STATUS.
+ ******************************************************************************/
+NWK_Status_t NWK_SetFailRouteOrder(const uint8_t order);
+
+/**************************************************************************//**
+ \brief Gets attribute value which specifies if static addressing mode is in use
+
+ \return True, if static addressing mode is in use; false - otherwise
+ ******************************************************************************/
+bool NWK_IsStaticAddressingMode(void);
+
+/**************************************************************************//**
+ \brief Gets protocol version attribute value.
+
+ \return Protocol version attribute value.
+ ******************************************************************************/
+uint8_t NWK_GetProtocolVersion(void);
+
+/**************************************************************************//**
+ \brief Getting the total number of transmissions
+
+ \return Value of total number of transmissions
+ ******************************************************************************/
+uint16_t NWK_GetTransmitCouner(void);
+
+/**************************************************************************//**
+ \brief Getting the transmission failures counter.
+
+ \return Value of transmission failures counter
+ ******************************************************************************/
+uint16_t NWK_GetTransmitFailureCounter(void);
+
+/**************************************************************************//**
+ \brief Resets the transmission failures counter and the total tx counter.
+ ******************************************************************************/
+void NWK_ResetTransmitCounters(void);
+
+/**************************************************************************//**
+ \brief Getting a device type parameter value.
+
+ \return device type parameter value.
+ ******************************************************************************/
+DeviceType_t NWK_GetDeviceType(void);
+
+#endif /* _NWK_ATTRIBUTES_H */
+/** eof nwkAttributes.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkCommon.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkCommon.h
new file mode 100644
index 00000000..e17fd64b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkCommon.h
@@ -0,0 +1,353 @@
+/**************************************************************************//**
+ \file nwkCommon.h
+
+ \brief Declarations of common NWK layer constants and types.
+
+ \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:
+ 2009-04-13 Max Gekk - Created.
+ Last change:
+ $Id: nwkCommon.h 17470 2011-06-10 11:31:00Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_COMMON_H
+#define _NWK_COMMON_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+#include <queue.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Base NWK header length of data packet:
+ * - frame control field (2 octets),
+ * - destination address (2 octets),
+ * - source address (2 octets),
+ * - radius (1 octet),
+ * - sequence number (1 octet),
+ * - multicast control field (1 octet). */
+#define NWK_DATA_FRAME_HEADER_LENGTH 9U
+/** Length of auxiliary frame header. See ZigBee spec r18, Figure 4.3. */
+#if defined _SECURITY_
+ #define NWK_AUXILIARY_HEADER_SIZE 14U
+ #define NWK_MAX_DATA_FRAME_FOOTER_LENGTH 4U
+#else
+ #define NWK_AUXILIARY_HEADER_SIZE 0U
+ #define NWK_MAX_DATA_FRAME_FOOTER_LENGTH 0U
+#endif /* _SECURITY_ */
+
+/** The hop count radius for concentrator route discoveries.
+ * ZigBee spec r18, Table 3.44, page 348. */
+#define NWK_CONCENTRATOR_RADIUS 8U /* hop */
+/** The maximum number of hops in a source route. ZigBee spec r18, Table 3.44.
+ **/
+#define NWK_MAX_SOURCE_ROUTE (NWK_CONCENTRATOR_RADIUS)
+/** Maximum length of the source route subframe:
+ * - relay count field (1 octet),
+ * - relay index field (1 octet),
+ * - relay list (NWK_MAX_SOURCE_ROUTE * size of short address).
+ * See ZigBee spec r18, 3.3.1.9, page 316. */
+#if defined _NWK_SOURCE_ROUTING_
+ #define NWK_MAX_SOURCE_ROUTE_SUBFRAME_LENGTH (2U+(2U*NWK_MAX_SOURCE_ROUTE))
+#else
+ #define NWK_MAX_SOURCE_ROUTE_SUBFRAME_LENGTH 0U
+#endif /* _NWK_SOURCE_ROUTING_ */
+
+/** Maximum lenght of NWK header. */
+#define NWK_MAX_UNSECURE_HEADER_LEHGTH \
+ (NWK_DATA_FRAME_HEADER_LENGTH + NWK_MAX_SOURCE_ROUTE_SUBFRAME_LENGTH)
+#define NWK_MAX_DATA_FRAME_HEADER_LEHGTH \
+ (NWK_MAX_UNSECURE_HEADER_LEHGTH + NWK_AUXILIARY_HEADER_SIZE)
+
+/** Length of the reserved part in the data frame. */
+#define NWK_AFFIX_LENGTH (MAC_AFFIX_LENGTH + \
+ NWK_MAX_DATA_FRAME_HEADER_LEHGTH + NWK_MAX_DATA_FRAME_FOOTER_LENGTH)
+
+/** Length of the reserved header in the data frame. */
+#define NWK_NSDU_OFFSET (MAC_MSDU_OFFSET + NWK_MAX_DATA_FRAME_HEADER_LEHGTH)
+
+/** Maximum lenght of NWK payload. */
+#define NWK_MAX_NSDU_SIZE (MAC_MAX_MSDU_SIZE \
+ - NWK_MAX_DATA_FRAME_HEADER_LEHGTH - NWK_MAX_DATA_FRAME_FOOTER_LENGTH)
+
+/** Valid broadcast addresses. See ZigBee spec r18, Table 3.54, page 411. */
+#define IS_BROADCAST_ADDR(A) (LE16_TO_CPU(A) >= 0xFFF8U)
+#define IS_CORRECT_SHORT_ADDR(A) (LE16_TO_CPU(A) < 0xFFF8U)
+
+/** Low power routers only. */
+#define LOW_POWER_ROUT_ADDR CCPU_TO_LE16(0xFFFBU)
+#define BROADCAST_ADDR_LOWPOWER_ROUTERS LOW_POWER_ROUT_ADDR
+
+/** All routers and coordinator in a network. */
+#define ALL_ROUT_AND_COORD_ADDR CCPU_TO_LE16(0xFFFCU)
+#define BROADCAST_ADDR_ROUTERS ALL_ROUT_AND_COORD_ADDR
+
+/** All devices with MAC attribute macRxOnWhenIdle = TRUE. */
+#define RX_ON_WHEN_IDLE_ADDR CCPU_TO_LE16(0xFFFDU)
+#define BROADCAST_ADDR_RX_ON_WHEN_IDLE RX_ON_WHEN_IDLE_ADDR
+
+/** All devices in PAN. */
+#define ALL_DEVICES_IN_PAN_ADDR 0xFFFFU
+#define BROADCAST_ADDR_ALL ALL_DEVICES_IN_PAN_ADDR
+
+/** The value of the nwkNetworkAddress attribute of its NIB has
+ * a value of 0xffff indicating that it is not currently joined to a network. */
+#define NWK_NO_SHORT_ADDR 0xFFFFU
+
+/** The maximum broadcast jitter time measured in number of octets.
+ * ZigBee spec r18, Table 3.43. */
+#define NWKC_MAX_BROADCAST_JITTER 2000U /*<! ~0x40 milliseconds in 2.4GHz */
+
+/* Maximum radius for non-member mode multicast frame. */
+#define NWK_MAX_NON_MEMBER_MULTICAST_RADIUS 7U
+
+/** The value of the extendedPanId attribute in NIB has
+ * a value of 0x0000000000000000 indicating that the device is not (or wasn't)
+ * currently joined to a network. */
+#define NWK_NO_EXT_PANID 0ULL
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** NWK primitives' return codes. ZigBee spec r17, 3.7, page 417. */
+typedef enum _NWK_Status
+{
+ /** A request has been executed successfully. */
+ NWK_SUCCESS_STATUS = 0x00,
+ /** The MAC requested operation was completed successfully. */
+ NWK_MAC_SUCCESS_STATUS = 0x00,
+ /** IEEE 802.15.4-2006, Table 83.
+ * Valid values of the Association Status field. */
+ NWK_MAC_PAN_AT_CAPACITY_STATUS = 0x01,
+ NWK_MAC_PAN_ACCESS_DENIED_STATUS = 0x02,
+ /** An invalid or out-of-range parameter has been passed to a primitive from
+ * the next higher layer. */
+ NWK_INVALID_PARAMETERS_STATUS = 0xC1,
+ /** The next higher layer has issued a request that is invalid or cannot be
+ * executed given the current state of the NWK layer. */
+ NWK_INVALID_REQUEST_STATUS = 0xC2,
+ /** An NLME-JOIN.request has been disallowed. */
+ NWK_NOT_PERMITTED_STATUS = 0xC3,
+ /** An NLME-NETWORK-FORMATION.request has failed to start a network. */
+ NWK_STARTUP_FAILURE_STATUS = 0xC4,
+ /** A device with the address supplied to the NLMEDIRECT-JOIN.request is
+ * already present in the neighbor table of the device on which
+ * the NLME-DIRECT-JOIN.request was issued. */
+ NWK_ALREADY_PRESENT_STATUS = 0xC5,
+ /** Used to indicate that an NLME-SYNC.request has failed at the MAC layer. */
+ NWK_SYNC_FAILURE_STATUS = 0xC6,
+ /** An NLME-JOIN-DIRECTLY.request has failed because there is no more room in
+ * the neighbor table. */
+ NWK_NEIGHBOR_TABLE_FULL_STATUS = 0xC7,
+ /** An NLME-LEAVE.request has failed because the device addressed in
+ * the parameter list is not in the neighbor table of the issuing device. */
+ NWK_UNKNOWN_DEVICE_STATUS = 0xC8,
+ /** An NLME-GET.request or NLME-SET.request has been issued with
+ * an unknown attribute identifier. */
+ NWK_UNSUPPORTED_ATTRIBUTE_STATUS = 0xC9,
+ /** An NLME-JOIN.request has been issued in an environment
+ * where no networks are detectable. */
+ NWK_NO_NETWORKS_STATUS = 0xCA,
+ /** Security processing has been attempted on an outgoing frame,
+ * and has failed because the frame counter has reached its maximum value. */
+ NWK_MAX_FRM_COUNTER_STATUS = 0xCC,
+ /** Security processing has been attempted on an outgoing frame,
+ * and has failed because no key was available with which to process it. */
+ NWK_NO_KEY_STATUS = 0xCD,
+ /** Security processing has been attempted on an outgoing frame,
+ * and has failed because the security engine produced erroneous output. */
+ NWK_BAD_CCM_OUTPUT_STATUS = 0xCE,
+ /** An attempt to discover a route has failed due to a lack of routing table
+ * or discovery table capacity. */
+ NWK_NO_ROUTING_CAPACITY_STATUS = 0xCF,
+ /** An attempt to discover a route has failed due to a reason other
+ * than a lack of routing capacity. */
+ NWK_ROUTE_DISCOVERY_FAILED_STATUS = 0xD0,
+ /** An NLDE-DATA.request has failed due to a routing
+ * failure on the sending device. */
+ NWK_ROUTE_ERROR_STATUS = 0xD1,
+ /** An attempt to send a broadcast frame or member mode multicast has failed
+ * due to the fact that there is no room in the BTT. */
+ NWK_BT_TABLE_FULL_STATUS = 0xD2,
+ /** An NLDE-DATA.request has failed due to insufficient buffering available.
+ **/
+ NWK_FRAME_NOT_BUFFERED_STATUS = 0xD3,
+ /** IEEE 802.15.4-2006, Table 78 MAC enumerations description. */
+ /** The frame counter purportedly applied by the originator of the
+ * received frame is invalid. */
+ NWK_MAC_COUNTER_ERROR_STATUS = 0xDB,
+ /** The key purportedly applied by the originator of the received frame is
+ * not allowed to be used with that frame type according to the key usage
+ * policy of the recipient. */
+ NWK_MAC_IMPROPER_KEY_TYPE_STATUS = 0xDC,
+ /** The security level purportedly applied by the originator of the received
+ * frame does not meet the minimum security level required/expected by
+ * the recipient for that frame type. */
+ NWK_MAC_IMPROPER_SECURITY_LEVEL_STATUS = 0xDD,
+ /** The received frame was purportedly secured using security based on
+ * IEEE Std 802.15.4-2003, and such security is not supported by this standard.
+ **/
+ NWK_MAC_UNSUPPORTED_LEGACY_STATUS = 0xDE,
+ /** The security purportedly applied by the originator of the received frame
+ * is not supported. */
+ NWK_MAC_UNSUPPORTED_SECURITY_STATUS = 0xDF,
+ /** The beacon was lost following a synchronization request. */
+ NWK_MAC_BEACON_LOSS_STATUS = 0xE0,
+ /** A transmission could not take place due to activity on the channel,
+ * i.e., the CSMA-CA mechanism has failed. */
+ NWK_MAC_CHANNEL_ACCESS_FAILURE_STATUS = 0xE1,
+ /** The GTS request has been denied by the PAN coordinator. */
+ NWK_MAC_DENIED_STATUS = 0xE2,
+ /** The attempt to disable the transceiver has failed. */
+ NWK_MAC_DISABLE_TRX_FAILURE_STATUS = 0xE3,
+ /** Either a frame resulting from processing has a length that is
+ * greater than aMaxPHYPacketSize or a requested transaction is
+ * too large to fit in the CAP or GTS. */
+ NWK_MAC_FRAME_TOO_LONG_STATUS = 0xE5,
+ /** The requested GTS transmission failed because the specified
+ * GTS either did not have a transmit GTS direction or was not defined. */
+ NWK_MAC_INVALID_GTS_STATUS = 0xE6,
+ /** A request to purge an MSDU from the transaction queue was made using
+ * an MSDU handle that was not found in the transaction table. */
+ NWK_MAC_INVALID_HANDLE_STATUS = 0xE7,
+ /** A parameter in the primitive is either not supported or is out of
+ * the valid range. */
+ NWK_MAC_INVALID_PARAMETER_STATUS = 0xE8,
+ /** No acknowledgment was received after macMaxFrameRetries. */
+ NWK_MAC_NO_ACK_STATUS = 0xE9,
+ /** A scan operation failed to find any network beacons. */
+ NWK_MAC_NO_BEACON_STATUS = 0xEA,
+ /** No response data were available following a request. */
+ NWK_MAC_NO_DATA_STATUS = 0xEB,
+ /** The operation failed because a 16-bit short address was not allocated. */
+ NWK_MAC_NO_SHORT_ADDRESS_STATUS = 0xEC,
+ /** A receiver enable request was unsuccessful because it could not be
+ * completed within the CAP. */
+ NWK_MAC_OUT_OF_CAP_STATUS = 0xED,
+ /** A PAN identifier conflict has been detected and communicated
+ * to the PAN coordinator. */
+ NWK_MAC_PAN_ID_CONFLICT_STATUS = 0xEE,
+ /** A coordinator realignment command has been received. */
+ NWK_MAC_REALIGNMENT_STATUS = 0xEF,
+ /** The transaction has expired and its information was discarded. */
+ NWK_MAC_TRANSACTION_EXPIRED_STATUS = 0xF0,
+ /** There is no capacity to store the transaction. */
+ NWK_MAC_TRANSACTION_OVERFLOW_STATUS = 0xF1,
+ /** The transceiver was in the transmitter enabled state when the receiver
+ * was requested to be enabled. */
+ NWK_MAC_TX_ACTIVE_STATUS = 0xF2,
+ /** The key purportedly used by the originator of the received frame is
+ * not available or, if available, the originating device is not known
+ * or is blacklisted with that particular key. */
+ NWK_MAC_UNAVAILABLE_KEY_STATUS = 0xF3,
+ /** A SET/GET request was issued with the identifier of a PIB
+ * attribute that is not supported. */
+ NWK_MAC_UNSUPPORTED_ATTRIBUTE_STATUS = 0xF4,
+ /** A request to send data was unsuccessful because neither the source address
+ * parameters nor the destination address parameters were present. */
+ NWK_MAC_INVALID_ADDRESS_STATUS = 0xF5,
+ /** A receiver enable request was unsuccessful because it specified a number
+ * of symbols that was longer than the beacon interval. */
+ NWK_MAC_ON_TIME_TOO_LONG_STATUS = 0xF6,
+ /** A receiver enable request was unsuccessful because it could not be
+ * completed within the current superframe and was not permitted to be
+ * deferred until the next superframe. */
+ NWK_MAC_PAST_TIME_STATUS = 0xF7,
+ /** The device was instructed to start sending beacons based on the
+ * timing of the beacon transmissions of its coordinator, but the device
+ * is not currently tracking the beacon of its coordinator. */
+ NWK_MAC_TRACKING_OFF_STATUS = 0xF8,
+ /** An attempt to write to a MAC PIB attribute that is in a table failed
+ * because the specified table index was out of range. */
+ NWK_MAC_INVALID_INDEX_STATUS = 0xF9,
+ /** There are some unscanned channels yet, but there is no memory */
+ NWK_MAC_LIMIT_REACHED_STATUS = 0xFA,
+ /** A SET/GET request was issued with the identifier of an attribute
+ * that is read only. */
+ NWK_MAC_READ_ONLY_STATUS = 0xFB,
+ /** A request to perform a scan operation failed because the MLME was
+ * in the process of performing a previously initiated scan operation. */
+ NWK_MAC_SCAN_IN_PROGRESS_STATUS = 0xFC,
+ /** The device was instructed to start sending beacons based on the timing of
+ * the beacon transmissions of its coordinator, but the instructed start time
+ * overlapped the transmission time of the beacon of its coordinator. */
+ NWK_MAC_SUPERFRAME_OVERLAP_STATUS = 0xFD
+} NWK_Status_t;
+
+/** Type of the 64-bit PAN identifier of the network.*/
+typedef uint64_t ExtPanId_t;
+
+/** Type of channels mask. */
+typedef uint32_t ChannelsMask_t;
+
+/** Type of MAC channel number. */
+typedef uint8_t Channel_t;
+
+/** Type of update identifier. The value identifying a snapshot of the network
+ * settings with which this node is operating with.*/
+typedef uint8_t NwkUpdateId_t;
+
+/** Type of sequence number of NWK packets. */
+typedef uint8_t NwkSequenceNumber_t;
+
+typedef uint8_t BeaconOrder_t;
+typedef BeaconOrder_t ScanDuration_t;
+
+/** Type of link quality indicator. */
+typedef uint8_t Lqi_t;
+/** Type of received signal strength indication. */
+typedef int8_t Rssi_t;
+
+/** Type of link cost. */
+typedef uint8_t NwkLinkCost_t;
+/** Type of route path cost. */
+typedef uint8_t NwkPathCost_t;
+
+/** Length of any NWK data: header, payload and etc. */
+typedef uint8_t NwkLength_t;
+
+/** Type of children counters. */
+typedef uint8_t NwkChildCount_t;
+
+typedef uint8_t NwkDepth_t;
+typedef NwkDepth_t NwkRadius_t;
+
+/** The kind of destination address*/
+typedef enum _NWK_DstAddrMode_t
+{
+ NWK_DSTADDRMODE_NOADDR = 0, /**< No destination address. */
+ /** 16-bit network address of a multicast group. */
+ NWK_DSTADDRMODE_MULTICAST = 1,
+ /** 16-bit network address of an individual device or a broadcast address. */
+ NWK_DSTADDRMODE_SHORT = 2
+} NWK_DstAddrMode_t;
+
+/** The method used to assign addresses. */
+typedef enum _NWK_AddrAlloc_t
+{
+ NWK_ADDR_ALLOC_DISTRIBUTED = 0, /**< Use distributed address allocation. */
+ NWK_ADDR_ALLOC_RESERVED = 1,
+ NWK_ADDR_ALLOC_STOCHASTIC = 2, /**< Use stochastic address allocation. */
+ NWK_ADDR_ALLOC_FROM_UID = 3 /**< Use 2 octet from IEEE extended address. */
+} NWK_AddrAlloc_t;
+
+/** Type of initial route request identifier. */
+typedef uint8_t NwkRouteRequestId_t;
+
+/** Global state of the network layer. */
+typedef uint8_t NwkState_t;
+
+typedef BitField_t NwkBitField_t;
+
+#endif /* _NWK_COMMON_H */
+/** eof nwkCommon.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkConfigServer.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkConfigServer.h
new file mode 100644
index 00000000..3a2f70c4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkConfigServer.h
@@ -0,0 +1,47 @@
+/**************************************************************************//**
+ \file nwkConfigServer.h
+
+ \brief The data types necessary for building of the ConfigServer.
+
+ \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:
+ 2009-04-13 Max Gekk - Created.
+ Last change:
+ $Id: nwkConfigServer.h 18049 2011-07-20 13:08:36Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_CONFIG_SERVER_H
+#define _NWK_CONFIG_SERVER_H
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+#ifndef NWK_PRIVATE
+ #define NWK_PRIVATE
+#endif /* #ifndef NWK_PRIVATE */
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkTx.h>
+#include <nwkPacket.h>
+#include <nwkJoinInd.h>
+#include <nwkRoutingTable.h>
+#include <nwkRouteDiscoveryTable.h>
+#include <nwkRouteDiscovery.h>
+#include <nwkAddressMap.h>
+#include <nwkBTT.h>
+#include <nwkRouteCache.h>
+#include <nwkGroup.h>
+#include <nwkIB.h>
+#include <nwkPassiveAck.h>
+
+#endif /* _NWK_CONFIG_SERVER_H */
+/** eof nwkConfigServer.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkGroup.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkGroup.h
new file mode 100644
index 00000000..160d1ca8
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkGroup.h
@@ -0,0 +1,144 @@
+/**************************************************************************//**
+ \file nwkGroup.h
+
+ \brief Interface of the group table.
+
+ \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:
+ 2010-07-20 Max Gekk - Created.
+ Last change:
+ $Id: nwkGroup.h 18320 2011-08-23 14:02:26Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_GROUP_H
+#define _NWK_GROUP_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+#include <nlmeReset.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Value that can not be used as a group data parameter. */
+#define NWK_INVALID_GROUP_DATA 0x00U
+/** Universal group data. It means any group data value. */
+#define NWK_ANY_GROUP_DATA 0xFFU
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Type of data linked to group. */
+typedef uint8_t NWK_GroupData_t;
+/** Type of group address. */
+typedef GroupAddr_t NWK_GroupAddr_t;
+
+/** Type of group table entry. */
+typedef struct _NWK_GroupTableEntry_t
+{
+ /** The data used by user, for example APS end point. */
+ NWK_GroupData_t data;
+ /** Address of group. */
+ NWK_GroupAddr_t addr;
+} NWK_GroupTableEntry_t;
+
+/** Type of size of the group table.*/
+typedef uint8_t NWK_GroupTableSize_t;
+
+/** Type of internal variables of group component. */
+typedef struct _NWK_GroupTable_t
+{
+ /** Pointer to first entry of the group table. */
+ NWK_GroupTableEntry_t *begin;
+ /** Pointer to memory after last entry of the group table. */
+ NWK_GroupTableEntry_t *end;
+} NWK_GroupTable_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _GROUP_TABLE_
+/**************************************************************************//**
+ \brief Add new entry to the group table.
+
+ \param[in] addr - address of group. Valid range 0x0000 - 0xffff.
+ \param[in] data - value linked to group. Valid range 0x01 - 0xfe.
+
+ \return 'true' if entry is added successfully otherwise 'false'.
+ ******************************************************************************/
+bool NWK_AddGroup(const NWK_GroupAddr_t addr, const NWK_GroupData_t data);
+
+/**************************************************************************//**
+ \brief Remove group entries from the group table.
+
+ \param[in] addr - address of group. Valid range 0x0000 - 0xffff.
+ \param[in] data - value linked to group. Valid range 0x01 - 0xff.
+ If data is equal to NWK_ANY_GROUP_DATA then remove
+ all entries with given group address.
+
+ \return 'true' if any entry is removed successfully otherwise 'false'.
+ ******************************************************************************/
+bool NWK_RemoveGroup(const NWK_GroupAddr_t addr, const NWK_GroupData_t data);
+
+/**************************************************************************//**
+ \brief Remove all group entries with given group data
+
+ \param[in] data - value linked to group. Valid range 0x01 - 0xff.
+ If data is equal to NWK_ANY_GROUP_DATA then remove
+ all entries from table.
+
+ \return 'true' if any entry is removed successfully otherwise 'false'.
+ ******************************************************************************/
+bool NWK_RemoveAllGroups(const NWK_GroupData_t data);
+
+/**************************************************************************//**
+ \brief Check group address and data in the group table.
+
+ \param[in] addr - address of group. Valid range 0x0000 - 0xffff.
+ \param[in] data - value linked to group. Valid range 0x01 - 0xff.
+ If data is equal to NWK_ANY_GROUP_DATA that means
+ any enties with given group address.
+
+ \return 'true' if pair addr and data is found in the group table
+ otherwise 'false'.
+ ******************************************************************************/
+bool NWK_IsGroupMember(const NWK_GroupAddr_t addr, const NWK_GroupData_t data);
+
+/**************************************************************************//**
+ \brief Get remaining groups capacity.
+
+ \return number of free entries in the group table.
+ ******************************************************************************/
+NWK_GroupTableSize_t NWK_GroupCapacity(void);
+
+/**************************************************************************//**
+ \brief Get first or next non-free entry from the groups table.
+
+ \param[in] entry - address of the current entry or NULL to get the first entry.
+
+ \return pointer to the next non-free entry or NULL if no more entries exist.
+ ******************************************************************************/
+NWK_GroupTableEntry_t* NWK_NextGroup(NWK_GroupTableEntry_t *entry);
+
+/**************************************************************************//**
+ \brief Allocate and initialize the group table.
+
+ \param[in] powerFailureControl - stack restoring after power failure control bitfield;
+ affects on initialization procedure.
+ ******************************************************************************/
+void NWK_ResetGroups(const NWK_PowerFailureControl_t powerFailureControl);
+
+#else
+#define NWK_ResetGroups(powerFailureControl) (void)0
+#endif /* _GROUP_TABLE_ */
+#endif /* _NWK_GROUP_H */
+/** eof nwkGroup.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkNeighbor.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkNeighbor.h
new file mode 100644
index 00000000..f30822c0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkNeighbor.h
@@ -0,0 +1,241 @@
+/**************************************************************************//**
+ \file nwkNeighbor.h
+
+ \brief Neighbor table interface.
+
+ \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:
+ 2009-04-14 Max Gekk - Created.
+ Last change:
+ $Id: nwkNeighbor.h 19021 2011-10-26 12:36:59Z mgekk $
+ ******************************************************************************/
+/**//**
+ * The neighbor table of a device shall contain information on every device
+ * within transmission range. ZigBee Spec r17, 3.6.1.5, page 366.
+ **/
+#if !defined _NWK_NEIGHBOR_H
+#define _NWK_NEIGHBOR_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+#include <appTimer.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** The relationship between the neighbor and the current device */
+typedef enum _Relationship_t
+{
+ RELATIONSHIP_PARENT = 0x00, /**< neighbor is the parent */
+ RELATIONSHIP_CHILD = 0x01, /**< neighbor is a child */
+ RELATIONSHIP_SIBLING = 0x02, /**< neighbor is a sibling */
+ RELATIONSHIP_NONE_OF_ABOVE = 0x03, /**< none of the above */
+ RELATIONSHIP_PREVIOUS_CHILD = 0x04, /**< previous child */
+ RELATIONSHIP_UNAUTHENTICATED_CHILD = 0x05, /**< unauthenticated child */
+ RELATIONSHIP_EMPTY
+} Relationship_t;
+
+/** The neighbor table item. */
+typedef struct _NwkNeighbor_t
+{
+ Relationship_t relationship;
+ /** The type of neighbor device. */
+ DeviceType_t deviceType;
+ /** IEEE 802.15.4-2006 7.3.1.2 Capability Information field. */
+ MAC_CapabilityInf_t capability;
+ /** The logical channel on which the network is operating. */
+ Channel_t logicalChannel;
+ /** The 16-bit network address of the neighboring device. */
+ ShortAddr_t networkAddr;
+ PanId_t panId;
+ /** 64-bit IEEE address that is unique to every device. */
+ ExtAddr_t extAddr;
+ /** The 64-bit unique identifier of the network to which the device belongs.*/
+ ExtPanId_t extPanId;
+ /** The tree depth of the neighbor device. */
+ NwkDepth_t depth;
+ /** The value identifying a snapshot of the network settings with which this
+ * node is operating with.*/
+ NwkUpdateId_t updateId;
+ /** Indicates if neighbor's receiver is enabled during idle periods. */
+ bool rxOnWhenIdle :1;
+ /** An indication of whether the device is accepting joining requests. */
+ bool permitJoining :1;
+ /** An indication of whether the device has been
+ * ruled out as a potential parent. */
+ bool potentialParent :1;
+ /** Network address of the neighbor is conflict with other address in network.
+ **/
+ bool isAddressConflict :1;
+ /** Upper layer knowns about this child (true) or not (false).*/
+ bool isKnownChild :1;
+ unsigned reserved1 :3;
+} NwkNeighbor_t;
+
+/** Type of life time of neighbors in ticks. */
+typedef uint16_t NwkLifeTime_t;
+/** The bit map of passive acks, each bit is matched to a broadcast that
+ * waits passive acknowledgements. */
+typedef uint8_t NwkPassiveAckMap_t;
+
+/** Mutable fields of a entry in the neighbor table. */
+typedef struct _NwkMutablePartOfNeighbor_t
+{
+ /** The time of life of a neighbor entry. */
+ NwkLifeTime_t lifeTime;
+ /** The estimated link quality for RF transmissions from this device. */
+ Lqi_t lqi;
+ Rssi_t rssi;
+ /** The cost of an outgoing link as measured by the neighbor. */
+ unsigned outgoingCost :3;
+ /** The cost of an incoming link as measured by this device. */
+ unsigned incomingCost :3;
+ /** Does the lqi field (and incomingCost) have a valid value. */
+ unsigned isLqiUnInit :1;
+ unsigned reserved1 :1;
+#if defined _NWK_PASSIVE_ACK_
+ NwkPassiveAckMap_t passiveAckMap;
+#endif /* _NWK_PASSIVE_ACK_ */
+} NwkMutablePartOfNeighbor_t;
+
+/** Type of size of the neighbor table. */
+typedef uint8_t NwkSizeOfNeighborTable_t;
+
+/** Type of the neighbor table. */
+typedef struct _NwkNeighborTable_t
+{
+ /** The array of a neighbor entry. */
+ NwkNeighbor_t *table;
+ /** Pointer to memory area after last entry of the neighbor table. */
+ NwkNeighbor_t *end;
+ /** The array of a mutable neighbor entry. */
+ NwkMutablePartOfNeighbor_t *mutableTable;
+ /** Current size of the neighbor table. */
+ NwkSizeOfNeighborTable_t size;
+#if defined _ROUTER_ || defined _COORDINATOR_
+ /** Timer for internal use. */
+ HAL_AppTimer_t ageTimer;
+#endif /* _ROUTER_ or _COORDINATOR_ */
+} NwkNeighborTable_t;
+
+/** For backward compatibility */
+typedef NwkNeighbor_t Neib_t;
+typedef NwkMutablePartOfNeighbor_t MutableNeib_t;
+typedef NwkNeighborTable_t NeibTable_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Access function to the neighbor table.
+
+ \return Pointer to the neighbor table.
+ ******************************************************************************/
+NwkNeighborTable_t* NWK_GetNeighborTable(void);
+
+/**************************************************************************//**
+ \brief Searching a neighbor entry by extended address.
+
+ \param[in] extAddr - extended IEEE address of neighbor.
+ \return NULL if no records found, or entry with extAddr otherwise
+ ******************************************************************************/
+NwkNeighbor_t* NWK_FindNeighborByExtAddr(const ExtAddr_t extAddr);
+
+/**************************************************************************//**
+ \brief Searching a neighbor entry by short address.
+
+ \param[in] shortAddr - network address of neighbor.
+ \return NULL if no records found, or entry with shortAddr otherwise
+ ******************************************************************************/
+NwkNeighbor_t* NWK_FindNeighborByShortAddr(const ShortAddr_t shortAddr);
+
+/**************************************************************************//**
+ \brief Remove a neighbor from the neighbor table with leave indication.
+
+ \param[in] neighbor - pointer to a entry in the neighbor table.
+ \param[in] cleanAddressMap - Remove records from address map if existed.
+ \return None.
+ ******************************************************************************/
+void NWK_RemoveNeighbor(NwkNeighbor_t *const neighbor, bool cleanAddressMap);
+
+/**************************************************************************//**
+ \brief Link quality indication for given neighbor.
+
+ \param[in] neighbor - pointer to a entry of neighbor in the neighbor table.
+ \return LQI of received frames from a neighbor
+ ******************************************************************************/
+Lqi_t NWK_GetNeighborsLqi(NwkNeighbor_t const *const neighbor);
+
+/**************************************************************************//**
+ \brief RSSI for given neighbor.
+
+ \param[in] neighbor - pointer to a entry of neighbor in the neighbor table.
+ \return RSSI of received frames from a neighbor
+ ******************************************************************************/
+Rssi_t NWK_GetNeighborsRssi(NwkNeighbor_t const *const neighbor);
+
+/**************************************************************************//**
+ \brief Is given neighbor known child.
+
+ \param[in] extAddr - extended address of child.
+ \param[in] setKnownFlag - change the known flag to 'true' if this parameter
+ is equal 'true'.
+
+ \return Current value of known flag.
+ ******************************************************************************/
+bool NWK_IsKnownChild(const ExtAddr_t extAddr, const bool setKnownFlag);
+
+/**************************************************************************//**
+ \brief Is given neighbor is child.
+
+ \param[in] neighbor - pointer to a entry of neighbor in the neighbor table.
+
+ \return True, given neighbor is child.; otherwise - false.
+ ******************************************************************************/
+INLINE bool NWK_IsChild(Neib_t const *const neighbor)
+{
+ return (RELATIONSHIP_CHILD == neighbor->relationship)
+ || (RELATIONSHIP_UNAUTHENTICATED_CHILD == neighbor->relationship);
+}
+
+/**************************************************************************//**
+ \brief Is given neighbor is unauthenticated child.
+
+ \param[in] neighbor - pointer to a entry of neighbor in the neighbor table.
+
+ \return True, given neighbor is unauthenticated child.; otherwise - false.
+ ******************************************************************************/
+INLINE bool NWK_IsUnauthenticatedChild(Neib_t const *const neighbor)
+{
+ return (RELATIONSHIP_UNAUTHENTICATED_CHILD == neighbor->relationship);
+}
+
+/**************************************************************************//**
+ \brief Authenticate a child node.
+
+ \param[in] extAddr - pointer to the extended address of child.
+ \return None.
+ ******************************************************************************/
+bool NWK_AuthenticateNeighbor(const ExtAddr_t *const extAddr);
+
+/*****************************************************************************
+ \brief This function adds neighbor table record for a known neighbor.
+
+ \param[in] nwkAddress - neighbor network address.
+ \return None.
+ *****************************************************************************/
+void NWK_AddKnownNeighbor(const ShortAddr_t nwkAddress);
+
+#endif /* _NWK_NEIGHBOR_H */
+/** eof nwkNeighbor.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkProfiler.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkProfiler.h
new file mode 100644
index 00000000..b1e40a96
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkProfiler.h
@@ -0,0 +1,68 @@
+/**************************************************************************//**
+ \file nwkProfiler.h
+
+ \brief Interface of NWK Profiler.
+
+ \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:
+ 2010-10-29 Max Gekk - Created
+ Last change:
+ $Id: nwkProfiler.h 18049 2011-07-20 13:08:36Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_PROFILER_H
+#define _NWK_PROFILER_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+
+#if defined _PROFILER_
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/* NWK Profiling information. */
+BEGIN_PACK
+typedef struct PACK _NWK_ProfilingInfo_t
+{
+ /** Maximum number of simultaneous join transaction. */
+ uint8_t maxJoinTrans;
+ /** Current number of processing join requests. */
+ uint8_t incomingJoinReq;
+ /** Current number of pending buffer for join response command. */
+ uint8_t pendingJoinRespBuffers;
+ /** Total NWK buffers. */
+ uint8_t nwkBuffersAmount;
+ /** Current number of busy output command buffers. */
+ uint8_t outCmdBuffers;
+ /** Total number of passive acks. */
+ uint8_t passiveAckAmount;
+ /** Used passive acks amount. */
+ uint8_t usedPassiveAcks;
+} NWK_ProfilingInfo_t;
+END_PACK
+
+/******************************************************************************
+ Global variables section
+ ******************************************************************************/
+extern NWK_ProfilingInfo_t nwkProfilingInfo;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Collect profiling information and update nwkProfInfo.
+ ******************************************************************************/
+void NWK_CollectProfilingInfo(void);
+
+#endif /* _PROFILER_ */
+#endif /* _NWK_PROFILER_H */
+/** eof nwkProfiler.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkRouteInfo.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkRouteInfo.h
new file mode 100644
index 00000000..679d393d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkRouteInfo.h
@@ -0,0 +1,124 @@
+/**************************************************************************//**
+ \file nwkRouteInfo.h
+
+ \brief Public route information.
+
+ \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:
+ 2010-05-07 Max Gekk - Created.
+ Last change:
+ $Id: nwkRouteInfo.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ROUTE_INFO_H
+#define _NWK_ROUTE_INFO_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/* Invalid concentrator descriptor. */
+#define NWK_INVALID_CONCENTRATOR (UINT8_MAX)
+/* Macro return true if concentrator descriptor is valid. */
+#define IS_VALID_CONCENTRATOR(descr) (NWK_INVALID_CONCENTRATOR != (descr))
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/* Type of concentrator descriptor. */
+typedef uint8_t NWK_Concentrator_t;
+
+/* Type of concentrator indication structure. */
+typedef struct _NWK_ConcentratorInd_t
+{
+ /** Service fields - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /* This function is called when new concentrator is found. */
+ void (* NWK_ConcentratorInd)(NWK_Concentrator_t concentrator);
+} NWK_ConcentratorInd_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief This function return the 16-bit network address of the next hop on
+ the way to the destination.
+
+ \return The network address of the next hop.
+ ******************************************************************************/
+ShortAddr_t NWK_GetNextHop(ShortAddr_t dstAddr);
+
+/**************************************************************************//**
+ \brief Get descriptor of next concentrator.
+
+ Example:
+ NWK_Concentrator_t c = NWK_INVALID_CONCENTRATOR;
+
+ while (IS_VALID_CONCENTRATOR(c = NWK_NextConcentrator(c)))
+ {
+ cAddr = NWK_ShortAddrOfConcentrator(c);
+ if (MASTER_CONCENTRATOR_ADDR == cAddr)
+ ...
+ ...
+ }
+
+ \param[in] prevConcentrator - descriptor of previous concentrator or
+ NWK_INVALID_CONCENTRATOR if it's initial call.
+
+ \return if next concentrator is found then return valid descriptor otherwise
+ return NWK_INVALID_CONCENTRATOR.
+ ******************************************************************************/
+NWK_Concentrator_t NWK_NextConcentrator(const NWK_Concentrator_t prevConcentrator);
+
+/**************************************************************************//**
+ \brief Get short address of given concentrator.
+
+ Note: Call this function and NWK_NextConcentrator() in same task.
+
+ \param[in] concentrator - descriptor of concentrator (see NWK_NextConcentrator).
+ \return Short address of concentrator.
+ ******************************************************************************/
+ShortAddr_t NWK_ShortAddrOfConcentrator(const NWK_Concentrator_t concentrator);
+
+/**************************************************************************//**
+ \brief Get short address of next hop node for given concentrator.
+
+ Note: Call this function and NWK_NextConcentrator() in same task.
+
+ \param[in] concentrator - descriptor of concentrator (see NWK_NextConcentrator).
+ \return Short address of next hop.
+ ******************************************************************************/
+ShortAddr_t NWK_NextHopToConcentrator(const NWK_Concentrator_t concentrator);
+
+/**************************************************************************//**
+ \brief Subscribe to indication about new concentrators.
+
+ \param[in] ind - pointer to concentrator indication structure.
+ \return None.
+ ******************************************************************************/
+void NWK_SubscribeToConcentratorInfo(NWK_ConcentratorInd_t *const ind);
+
+/**************************************************************************//**
+ \brief Unsubscribe from indication about new concentrators.
+
+ \param[in] ind - pointer to concentrator indication structure.
+ \return None.
+ ******************************************************************************/
+void NWK_UnsubscribeFromConcentratorInfo(NWK_ConcentratorInd_t *const ind);
+
+#endif /* _NWK_ROUTE_INFO_H */
+/** eof nwkRouteInfo.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkSecurity.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkSecurity.h
new file mode 100644
index 00000000..d06fa66a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/nwkSecurity.h
@@ -0,0 +1,270 @@
+/**************************************************************************//**
+ \file nwkSecurity.h
+
+ \brief Network security interface.
+
+ \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:
+ 2009-04-13 Max Gekk - Created.
+ 2009-08-15 Max Gekk - Refactoring.
+ 2011-01-29 Max Gekk - Redesign.
+ Last change:
+ $Id: nwkSecurity.h 18245 2011-08-16 09:23:15Z arazinkov $
+ ******************************************************************************/
+/**//**
+ * The NWK layer is responsible for the processing steps needed to securely
+ * transmit outgoing frames and securely receive incoming frames. Upper layers
+ * control the security processing operations by setting up the appropriate keys
+ * and frame counters and establishing which security level to use.
+ * ZigBee spec r17, 4.3, page 426.
+ **/
+#if !defined _NWK_SECURITY_H && defined _SECURITY_
+#define _NWK_SECURITY_H
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <sspCommon.h>
+#include <mac.h>
+#include <nlmeReset.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_PRECONFIGURED_NETWORK_KEY 0U
+#define NWK_NOT_PRECONFIGURED_NETWORK_KEY 3U
+
+/** Amount of incoming frame counters. */
+#define NWK_IN_FRAMES_MAX 4U
+/** Startup active network key sequence number */
+#define NWK_STARTUP_ACTIVE_KEY_SEQUENCE_NUMBER 0U
+/** Size of security counter in bytes */
+#define NWK_SIZE_OF_SECURITY_COUNTER 4U
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Type of NWK Key Sequence Number. */
+typedef uint8_t NWK_KeySeqNum_t;
+/** Type of NWK Key Index and amount. */
+typedef uint8_t NwkKeyAmount_t;
+typedef NwkKeyAmount_t NwkKeyIndex_t;
+
+/** Type of outgoing frame counter used for outgoing frames. */
+typedef uint32_t NwkOutFrameCounter_t;
+/** Type of incoming frame counter used for incoming frames. */
+typedef uint32_t NwkInFrameCounter_t;
+/** Type of outgoing frame counter higher bytes. */
+typedef uint16_t NwkOutFrameCounterTop_t;
+/** Type of outgoing frame counter lower bytes. */
+typedef uint16_t NwkOutFrameCounterLow_t;
+
+/** Outgoing security frame counter handle type. */
+BEGIN_PACK
+typedef union PACK
+{
+ NwkOutFrameCounter_t value;
+ struct
+ {
+ LITTLE_ENDIAN_OCTET(2,
+ (NwkOutFrameCounterLow_t low,
+ NwkOutFrameCounterTop_t top
+ ))
+ } part;
+} NwkOutFrameCounterHandle_t;
+END_PACK
+
+BEGIN_PACK
+typedef union PACK _NwkUnalignedInFrameCounter_t
+{
+ NwkInFrameCounter_t value;
+ uint8_t raw[sizeof(NwkInFrameCounter_t)];
+} NwkUnalignedInFrameCounter_t;
+END_PACK
+
+/** The Incoming Frame Counter Descriptor. */
+typedef struct _NWK_InFrameCounterSet_t
+{
+ bool isSet; /** Flag indicates busy status of entry. */
+ /** Extended device address. */
+ ExtAddr_t senderAddress;
+ /** Incoming frame counter used for incoming frames. */
+ NwkInFrameCounter_t value;
+} NWK_InFrameCounterSet_t;
+
+/** The Network Security Material Descriptor - key and key sequence number. */
+typedef struct _NWK_SecurityKey_t
+{
+ bool isSet; /** Flag indicates busy status of entry. */
+
+ /** A sequence number assigned to a network key by the Trust Center and used
+ * to distinguish network keys for purposes of key updates, and incoming
+ * frame security operations. */
+ NWK_KeySeqNum_t seqNum;
+ /** Outgoing frame counter higher bytes. */
+ NwkOutFrameCounterTop_t outCounterTop;
+ /** The actual value of the key. */
+ uint8_t value[SECURITY_KEY_SIZE];
+} NWK_SecurityKey_t;
+
+/** The Network Mutable Security Material Descriptor - incoming and outgoing
+ * frame counters. */
+typedef struct _NWK_SecurityFrameCounters_t
+{
+ /** Outgoing frame counter lower bytes. */
+ NwkOutFrameCounterLow_t outCounterLow;
+ /** Set of incoming frame counter values and corresponding device addresses. */
+ /* NWK_InFrameCounterSet_t inCounters[NWK_IN_FRAMES_MAX]; */
+} NWK_SecurityFrameCounters_t;
+
+/** Security-Related NIB Attributes. */
+typedef struct _NWK_SecurityIB_t
+{
+ /** Private field for internal use - the index of active key. */
+ NwkKeyIndex_t activeIndex;
+ /** The security level for outgoing and incoming NWK frames. */
+ uint8_t securityLevel;
+ /** Indicates whether security shall be applied to incoming
+ * and outgoing NWK data frames. */
+ bool secureAllFrames;
+ /** Total amount of NWK security keys. */
+ NwkKeyAmount_t keyAmount;
+ /** Set of network security material descriptors capable of maintaining
+ * an active and alternate network key. */
+ NWK_SecurityKey_t *key;
+ /** Pointer to set of security incoming and outgoing key frame counters.*/
+ NWK_SecurityFrameCounters_t *counter;
+} NWK_SecurityIB_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Get value of the nwkSecurityLevel attribute.
+
+ ZigBee spec r17, page 344, Table 3.44.
+
+ \return Current value of nwkSecurityLevel.
+ ******************************************************************************/
+uint8_t NWK_GetSecurityLevel(void);
+
+/**************************************************************************//**
+ \brief Getting value of nwkSecureAllFrames attribute.
+ ZigBee spec r17, page 344, Table 3.44.
+
+ \return Current value of nwkSecureAllFrames.
+ ******************************************************************************/
+bool NWK_GetSecureAllFrames(void);
+
+/**************************************************************************//**
+ \brief Set a new network key.
+
+ \param[in] key - a new network security key.
+ \param[in] keySeqNum - key sequence number.
+ \return 'true' if operation was completed successfully otherwise 'false'.
+ ******************************************************************************/
+bool NWK_SetKey(const uint8_t *const key, const NWK_KeySeqNum_t keySeqNum);
+
+/**************************************************************************//**
+ \brief Set NWK key as active.
+
+ \param[in] keySeqNum - key sequence number.
+ \return 'true' if operation was completed successfully otherwise 'false'.
+ ******************************************************************************/
+bool NWK_ActivateKey(const NWK_KeySeqNum_t keySeqNum);
+
+/**************************************************************************//**
+ \brief Check active network key.
+
+ \return 'true' if active NWK key is set otherwise 'false'.
+ ******************************************************************************/
+bool NWK_IsAnyKeyActivated(void);
+
+/**************************************************************************//**
+ \brief Get active network key.
+
+ \return Pointer to value of active network key.
+ ******************************************************************************/
+const uint8_t* NWK_GetActiveKey(void);
+
+/**************************************************************************//**
+ \brief Getting value of nwkActiveKeySeqNumber attribute.
+ ZigBee spec r17, page 344, Table 3.44.
+
+ \return Current value of nwkActiveKeySeqNumber.
+ ******************************************************************************/
+NWK_KeySeqNum_t NWK_GetActiveKeySeqNumber(void);
+
+/**************************************************************************//**
+ \brief Update outgoing security frame counter of active NWK key and return
+ it's value.
+
+ \return Outgoing frame counter in little-endian format.
+ ******************************************************************************/
+NwkOutFrameCounter_t NWK_GetUpdatedSecOutCounter(void);
+
+/**************************************************************************//**
+ \brief Return outgoing security frame counter value of active NWK key
+
+ \return Outgoing frame counter in little-endian format.
+ ******************************************************************************/
+NwkOutFrameCounter_t NWK_GetSecOutCounter(void);
+
+/**************************************************************************//**
+ \brief Update the incoming frame counter.
+
+ \param[in] srcExtAddr - an extended source address.
+ \param[in] newValue - a new value of the incoming frame counter.
+ \return None.
+ ******************************************************************************/
+void NWK_SetInFrameCounter(const ExtAddr_t srcExtAddr,
+ const NwkInFrameCounter_t counter);
+
+/**************************************************************************//**
+ \brief Deactivate current active NWK key.
+ ******************************************************************************/
+void NWK_DeactivateKey(void);
+
+/**************************************************************************//**
+ \brief Set all incoming and outgoing frame counters to zero.
+ ******************************************************************************/
+void NWK_ResetAllSecurityCounters(void);
+
+/**************************************************************************//**
+ \brief Reseting the network security subsystem.
+
+ \param[in] powerFailureControl - stack restoring after power failure control bitfield;
+ affects on initialization procedure.
+ \return None.
+ ******************************************************************************/
+void NWK_ResetSecurityIB(const NWK_PowerFailureControl_t powerFailureControl);
+
+/**************************************************************************//**
+ \brief Checks, if security services are provided by NWK.
+
+ \return True, if security services are provided by NWK, false - otherwise.
+ ******************************************************************************/
+bool NWK_IsSecurityProvided(void);
+
+#if defined _CERTIFICATION_
+/**************************************************************************//**
+ \brief Changes the maximum number of stored NWK security keys.
+
+ \param[in] keyAmount - new total amount of NWK keys.
+
+ \return NWK_SUCCESS_STATUS if keyAmount is changed successfuly otherwise
+ return NWK_INVALID_PARAMETERS_STATUS.
+ ******************************************************************************/
+NWK_Status_t NWK_SetKeyAmount(const uint8_t keyAmount);
+#endif /* _CERTIFICATION_ */
+
+#endif /* _NWK_SECURITY_H and _SECURITY_ */
+/** eof nwkSecurity.h */
+
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddress.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddress.h
new file mode 100644
index 00000000..b3516b86
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddress.h
@@ -0,0 +1,82 @@
+/**************************************************************************//**
+ \file nwkAddress.h
+
+ \brief Formation header file.
+
+ \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:
+ 2009-05-12 M. Gekk - Created.
+ Last change:
+ $Id: nwkAddress.h 17923 2011-07-08 14:13:30Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_ADDRESS_H
+#define _NWK_ADDRESS_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <types.h>
+#include <mac.h>
+#include <nwkCommon.h>
+#include <nwkSystem.h>
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _COORDINATOR_ || defined _ROUTER_
+/**************************************************************************//**
+ \brief Allocate short address.
+
+ \param[in] router - parameters is used if tree addressing is active.
+ \param[in] addrRequested - if rejoin is used, it is address device selects for
+ itself otherwise NWK_NO_SHORT_ADDR.
+ \param[in] extAddr - IEEE extended address of node.
+ \return Allocated address. addrRequested - is possible,
+ or address allocated in little endian.
+ ******************************************************************************/
+NWK_PRIVATE ShortAddr_t nwkAllocateShortAddr(const bool router,
+ const ShortAddr_t addrRequested, const ExtAddr_t extAddr);
+#endif /* _COORDINATOR_ or _ROUTER_ */
+
+#if defined _NWK_DISTRIBUTED_ADDRESSING_
+/**************************************************************************//**
+ \brief Computing the size of the address sub-block.
+
+ \param[in] depth - current depth of node in network tree topology.
+ \return cskip block in big endian format.
+ ******************************************************************************/
+NWK_PRIVATE NwkAddrRange_t nwkCSkip(const NwkDepth_t depth);
+#endif /* _NWK_DISTRIBUTED_ADDRESSING_ */
+
+/**************************************************************************//**
+ \brief Allocate non-conflict short address
+
+ \param[in] shortAddr - initial value of short address.
+ \param[in] extAddr - pointer to IEEE extended address of node for which is
+ allocated a short address.
+ \return Valid short address in little endian format.
+ ******************************************************************************/
+NWK_PRIVATE ShortAddr_t nwkAllocNonConflAddr(ShortAddr_t shortAddr,
+ const ExtAddr_t *const extAddr);
+
+/**************************************************************************//**
+ \brief Is received broadcast packet for this device or not?
+
+ \param[in] dstAddr - destination broadcast address.
+
+ \return 'true' if broadcast packet can be handled by this device
+ otherwise return 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkBroadcastForMe(const ShortAddr_t dstAddr);
+
+#endif /* _NWK_ADDRESS_H */
+/** eof nwkAddress.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddressConflict.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddressConflict.h
new file mode 100644
index 00000000..7b349907
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddressConflict.h
@@ -0,0 +1,105 @@
+/**************************************************************************//**
+ \file nwkAddressConflict.h
+
+ \brief Interface of address conflict resolver.
+
+ \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:
+ 2009-06-23 Max Gekk - Created.
+ 2010-07-04 Max Gekk - Redesign.
+ Last change:
+ $Id: nwkAddressConflict.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ADDRESS_CONFLICT_H
+#define _NWK_ADDRESS_CONFLICT_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <types.h>
+#include <queue.h>
+#include <mac.h>
+#include <nwkCommon.h>
+#include <nlmeJoin.h>
+#include <nwkStatusReq.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the address conflict component. */
+typedef enum _NwkAddrConflictState_t
+{
+ NWK_ADDR_CONFLICT_IDLE_STATE = 0xAA,
+ NWK_ADDR_CONFLICT_FIRST_STATE = 0x43,
+ NWK_ADDR_CONFLICT_BEGIN_STATE = NWK_ADDR_CONFLICT_FIRST_STATE,
+ NWK_ADDR_CONFLICT_MAC_SET_STATE = 0x44,
+ NWK_ADDR_CONFLICT_REJOIN_STATE = 0x45,
+ NWK_ADDR_CONFLICT_SEND_STATUS_STATE = 0x46,
+ NWK_ADDR_CONFLICT_LAST_STATE
+} NwkAddrConflictState_t;
+
+/** Internal variables of the network manager component. */
+typedef struct _NwkAddrConflict_t
+{
+ /** Finite-state machine */
+ NwkAddrConflictState_t state;
+ /** Current conflict address. */
+ ShortAddr_t shortAddr;
+ bool sendNwkStatus;
+ union
+ {
+ MAC_SetReq_t macSet;
+ NWK_JoinReq_t rejoin;
+ NwkStatusReq_t nwkStatus;
+ } req;
+} NwkAddrConflict_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _RESOLVE_ADDR_CONFLICT_
+/**************************************************************************//**
+ \brief Reset address conflict component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetAddressConflict(void);
+
+/**************************************************************************//**
+ \brief Main task handler of address conflict component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkAddressConflictTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Resolve address conflict for given short address.
+
+ \param[in] shortAddr - conflicted short address.
+ \return None.
+******************************************************************************/
+NWK_PRIVATE void nwkResolveAddressConflict(const ShortAddr_t shortAddr,
+ const bool sendNwkStatus);
+
+/******************************************************************************
+ \brief nwkAddressConflict idle checking.
+
+ \return true, if nwkAddressConflict performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkAddressConflictIsIdle(void);
+
+#else /* _RESOLVE_ADDR_CONFLICT_ */
+
+#define nwkResetAddressConflict() (void)0
+#define nwkAddressConflictTaskHandler NULL
+#define nwkAddressConflictIsIdle NULL
+#define nwkResolveAddressConflict(shortAddr, sendNwkStatus) ((void)0)
+
+#endif /* _RESOLVE_ADDR_CONFLICT_ */
+#endif /* _NWK_ADDRESS_CONFLICT_H */
+/** eof nwkAddressConflict.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddressMap.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddressMap.h
new file mode 100644
index 00000000..c6418f35
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddressMap.h
@@ -0,0 +1,117 @@
+/**************************************************************************//**
+ \file nwkAddressMap.h
+
+ \brief The access interface to the address map..
+
+ \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:
+ 2010-07-04 Max Gekk - Created.
+ Last change:
+ $Id: nwkAddressMap.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ADDRESS_MAP_H
+#define _NWK_ADDRESS_MAP_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appFramework.h>
+#include <nwkSystem.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Type of size of the address map. */
+typedef uint8_t NwkSizeOfAddressMap_t;
+
+/** Type of index of the address map. */
+typedef NwkSizeOfAddressMap_t NwkAddressMapIndex_t;
+
+/** Type of entry of the address map. */
+typedef struct _NwkAddressMapEntry_t
+{
+ /** The entry is busy (true) or not (false). */
+ bool busy : 1;
+ /** Conflict of short addresses is detected (true) or not (false). */
+ bool conflict : 1;
+ NwkBitField_t reserved : 6;
+ /** A network address (16-bit). */
+ ShortAddr_t shortAddr;
+ /** IEEE address (64-bit). */
+ ExtAddr_t extAddr;
+} NwkAddressMapEntry_t;
+
+/** Type of the address map. */
+typedef struct _NwkAddressMap_t
+{
+ /** Array of address map entries. */
+ NwkAddressMapEntry_t *table;
+ /** Pointer to memory area after last entry of the address map. */
+ NwkAddressMapEntry_t *end;
+ /** Current position for a new entry. */
+ NwkAddressMapEntry_t *current;
+} NwkAddressMap_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Add a short and extended addresses in the address map.
+
+ \param[in] shortAddr - a short address.
+ \param[in] extAddr - an extended address.
+ \param[in] isConflict - 'true' if shortAddr conflict with other short address
+ in the network otherwise 'false'.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkAddToAddressMap(const ShortAddr_t shortAddr,
+ const ExtAddr_t extAddr, const bool isConflict);
+
+/**************************************************************************//**
+ \brief Find entry in the address map by IEEE address.
+
+ \param[in] extAddr - pointer to IEEE extended 64-bit address.
+ \return Pointer to an entry in the address map.
+ ******************************************************************************/
+NWK_PRIVATE NwkAddressMapEntry_t*
+ nwkFindAddressMapEntryByExtAddr(const ExtAddr_t *const extAddr);
+
+/**************************************************************************//**
+ \brief Find entry in the address map by short address.
+
+ \param[in] shortAddr - a network short address.
+ \return Pointer to an entry in the address map.
+ ******************************************************************************/
+NWK_PRIVATE NwkAddressMapEntry_t*
+ nwkFindAddressMapEntryByShortAddr(const ShortAddr_t shortAddr);
+
+#if defined _RESOLVE_ADDR_CONFLICT_
+/**************************************************************************//**
+ \brief Find entry in the address map with conflicted short address.
+
+ \return Pointer to an entry in the address map.
+ ******************************************************************************/
+NWK_PRIVATE NwkAddressMapEntry_t* nwkFindAddrMapConflictEntry(void);
+#endif /* _RESOLVE_ADDR_CONFLICT_ */
+
+/**************************************************************************//**
+ \brief Get maximum size of NWK address map.
+ ******************************************************************************/
+NWK_PRIVATE NwkSizeOfAddressMap_t nwkAddrMapSize(void);
+
+/**************************************************************************//**
+ \brief Reset the address map.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetAddressMap(void);
+
+#endif /* _NWK_ADDRESS_MAP_H */
+/** eof nwkAddressMap.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkBTT.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkBTT.h
new file mode 100644
index 00000000..881b5576
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkBTT.h
@@ -0,0 +1,86 @@
+/**************************************************************************//**
+ \file nwkBTT.h
+
+ \brief Broadcast transaction table.
+
+ \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:
+ 2007-09-01 V. Panov - Created.
+ 2008-11-17 M. Gekk - Correct clearing of record in BTT. In case of overflow
+ of the table function nwkCheckBTT returns an error.
+ BTT moved in ConfigServer.
+ 2009-04-29 M. Gekk - Refactoring.
+ 2009-11-24 Igor Vagulin - reimplemented using sysDuplicateTable.
+ Last change:
+ $Id: nwkBTT.h 17946 2011-07-13 09:26:59Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_BTT_H
+#define _NWK_BTT_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <mac.h>
+#include <sysDuplicateTable.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Broadcast transaction table */
+typedef struct _NwkBTT_t
+{
+ /** Pointer to BTT sysDuplicateTable descriptor */
+ SYS_DuplicateTable_t btt;
+} NwkBTT_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Reseting of the broadcast transaction table.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetBTT(void);
+
+/**************************************************************************//**
+ \brief Check entry for short address and sequence number.
+
+ \param[in] shortAddr - source address of broadcast packet.
+ \param[in] sequenceNumber - a sequence number of broadcast packet.
+ ******************************************************************************/
+NWK_PRIVATE SysDuplicateTableAnswer_t nwkCheckBTT(const ShortAddr_t shortAddr,
+ const uint8_t sequenceNumber);
+
+/**************************************************************************//**
+ \brief Clear the existing entry in the broadcast transaction table.
+
+ \param[in] shortAddr - a short address of broadcast packet,
+ \param[in] sequenceNumber - a sequence number of broadcast packet.
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkClearBTR(const ShortAddr_t shortAddr,
+ const uint8_t sequenceNumber);
+
+/**************************************************************************//**
+ \brief Add new BTR to BTT with own address and given sequence number
+
+ \param[in] sequenceNumber - a sequence number of broadcast packet.
+ \return None.
+ ******************************************************************************/
+#if !defined NWK_ALWAYS_REJECT_OWN_BROADCAST
+NWK_PRIVATE void nwkAddOwnBTR(const uint8_t sequenceNumber);
+
+#else
+#define nwkAddOwnBTR(sequenceNumber) (void)0
+#endif /* NWK_ALWAYS_REJECT_OWN_BROADCAST */
+#endif /* _NWK_BTT_H */
+/** eof nwkBTT.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkCommands.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkCommands.h
new file mode 100644
index 00000000..a92c7da8
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkCommands.h
@@ -0,0 +1,86 @@
+/**************************************************************************//**
+ \file nwkCommands.h
+
+ \brief NWK commands header file.
+
+ \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:
+ 2007-06-20 V. Panov - Created.
+ 2009-04-28 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkCommands.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_COMMANDS_H
+#define _NWK_COMMANDS_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <types.h>
+#include <nwkFrame.h>
+#include <nwkTx.h>
+
+/******************************************************************************
+ Definition section
+ ******************************************************************************/
+/* Total number of command requests. */
+#define NWK_COMMAND_REQ_AMOUNT (NWK_MAX_COMMAND_TX_ID + 1U)
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Type of command request counter. */
+typedef uint8_t NwkCommandCount_t;
+
+/** Internal variables of the commands component. */
+typedef struct _NwkCommands_t
+{
+ NwkCommandCount_t reqCount[NWK_COMMAND_REQ_AMOUNT];
+} NwkCommands_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Request to perform outgoing command allocated in data buffer.
+
+ \param[in] txId - the transmission identifier of a command
+ which is requested to send.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkCommandReq(const NwkTxId_t txId);
+
+/**************************************************************************//**
+ \brief Action when any command received.
+
+ \param[in] payload - command payload (with ID)
+ \param[in] header - pointer to network frame header.
+ \param[in] parse - parsed header fields
+ \return 'true' if continue command processing otherwise 'false'.
+******************************************************************************/
+NWK_PRIVATE bool nwkCommandInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+/**************************************************************************//**
+ \brief The packet for NWK command has been released.
+
+ \return 'true' if free packet has been allocated otherwise return 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkCommandFreePacketInd(void);
+
+/**************************************************************************//**
+ \brief Reset the commands component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetCommands(void);
+
+#endif /* _NWK_COMMANDS_H */
+/** eof nwkCommands.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkConcentrator.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkConcentrator.h
new file mode 100644
index 00000000..65e5a4a0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkConcentrator.h
@@ -0,0 +1,83 @@
+/**************************************************************************//**
+ \file nwkConcentrator.h
+
+ \brief Interface of network concentrator.
+
+ \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:
+ 2009-09-14 Max Gekk - Created.
+ Last change:
+ $Id: nwkConcentrator.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_CONCENTRATOR_H
+#define _NWK_CONCENTRATOR_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <appTimer.h>
+#include <nlmeRouteDiscovery.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the network concentrator. */
+typedef enum _NwkConcentratorState_t
+{
+ NWK_CONCENTRATOR_IDLE_STATE = 0x89,
+ NWK_CONCENTRATOR_FIRST_STATE = 0x8A,
+ NWK_CONCENTRATOR_START_TIMER_STATE = NWK_CONCENTRATOR_FIRST_STATE,
+ NWK_CONCENTRATOR_ROUTE_DISCOVERY_STATE = 0x8B,
+ NWK_CONCENTRATOR_LAST_STATE
+} NwkConcentratorState_t;
+
+/** State and parameters of the network concentrator. */
+typedef struct _NwkConcentrator_t
+{
+ NwkConcentratorState_t state;
+ union
+ {
+ HAL_AppTimer_t timer;
+ NWK_RouteDiscoveryReq_t routeDiscovery;
+ } req;
+} NwkConcentrator_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _NWK_CONCENTRATOR_
+/**************************************************************************//**
+ \brief Start the network concentrator.
+
+ Periodic sending of route discovery commands.
+ ******************************************************************************/
+NWK_PRIVATE void nwkStartConcentrator(void);
+
+/**************************************************************************//**
+ \brief nwkReset module call this function when network layer is reseting.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetConcentrator(void);
+
+/**************************************************************************//**
+ \brief Check state of the concentrator and stop timer.
+ ******************************************************************************/
+NWK_PRIVATE void nwkStopConcentratorTimer(void);
+
+#else /* _NWK_CONCENTRATOR_ */
+
+#define nwkStartConcentrator() (void)0
+#define nwkStopConcentratorTimer() (void)0
+#define nwkResetConcentrator() (void)0
+
+#endif /* _NWK_CONCENTRATOR_ */
+#endif /* _NWK_CONCENTRATOR_H */
+/** eof nwkConcentrator.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkConfig.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkConfig.h
new file mode 100644
index 00000000..a66816d5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkConfig.h
@@ -0,0 +1,137 @@
+/**************************************************************************//**
+ \file nwkConfig.h
+
+ \brief Constant definition header file.
+
+ \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:
+ 2007-06-20 V. Panov - Created.
+ 2008-09-29 M. Gekk - Values of constants for a network from 60
+ nodes are increased.
+ Last change:
+ $Id: nwkConfig.h 19021 2011-10-26 12:36:59Z mgekk $
+******************************************************************************/
+#if !defined _NWK_CONFIG_H
+#define _NWK_CONFIG_H
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** A Boolean flag indicating whether the device is capable of becoming
+ * the ZigBee coordinator. ZigBee spec r17, page 338, table 3.43.
+ * */
+#if defined _COORDINATOR_
+ #define NWKC_COORDINATOR_CAPABLE true
+#else
+ #define NWKC_COORDINATOR_CAPABLE false
+#endif /* _COORDINATOR_ */
+
+/** Define for coordinator address */
+#define NWKC_COORD_ADDR 0x0000U
+
+/** North America */
+/* #define NWK_NO_WIFI_CHANNELS_MASK 0x610800 */
+/** Europe */
+#define NWK_NO_WIFI_CHANNELS_MASK 0x618000U
+
+#define NWK_FAVOURITE_CHANNELS_MASK (NWK_NO_WIFI_CHANNELS_MASK)
+
+#define NWKC_PROTOCOL_ID 0U
+
+#define NWKC_INITIAL_LINK_STATUS_PERIOD 15000UL /* msec*/
+
+#define NWK_MAX_CHANNEL 26
+
+#define NWK_MAX_LINK_STATUS_FAILURES 3U
+#define NWK_END_DEVICE_MAX_FAILURES 3U
+
+#define NWK_MAX_ED_LEVEL 0xCCU /* 255 * 0.8 */
+
+/** Support network realignment */
+/* #define NWK_COORD_REALIGNMENT */
+
+#if defined _NWK_NONSTANDARD_BEACON_FILTER_
+ /** Filter by extended pan id */
+ #define NWK_BEACON_FILTER_EXTENDED_PANID
+ /** If predefined short pan id then discard beacons with other pan id. */
+ #define NWK_BEACON_FILTER_PREDEFINED_PANID
+ /** Beacons with the end device capacity bit equal zero will discard. */
+ #define NWK_BEACON_FILTER_END_DEVICE_CAPACITY
+ /** Beacons with the router capacity bit equal zero will discard. */
+ #define NWK_BEACON_FILTER_ROUTER_CAPACITY
+#endif /* NWK_NONSTANDARD_BEACON_FILTER */
+
+/** Update the neighbor table only if our network address is presented in
+ * the received link status command. */
+/* #define NWK_LINK_STATUS_ONLY_IN_LIST */
+
+/** Duration of searching other networks on same channel.
+ * It is ~(2^NWK_REPORT_SCAN_DURATION)*960*16 (usec) - for 2.4MHz */
+#define NWK_SEARCH_NETWORKS_DURATION 8U /* ~4sec - 2.4MHz */
+
+#define NWK_SELECT_RANDOM_PARENT
+#define NWK_DELTA_LQI (255/10)
+
+#if defined _NWK_ROUTE_CACHE_
+ #define NWKC_NO_ROUTE_CACHE false
+#else
+ #define NWKC_NO_ROUTE_CACHE true
+#endif /* _NWK_ROUTE_CACHE_ */
+
+/** Maximum number of the many-to-one route requests after that the
+ * route record command must be transmitted if no source route packet has
+ * been received. */
+#define NWK_MAX_NO_SOURCE_ROUTE_PERIODS 3U
+
+#if defined _COORDINATOR_ || defined _ROUTER_
+ #define NWK_ROUTING_CAPACITY
+#endif /* _COORDINATOR_ or _ROUTER_ */
+
+/** The maximum time duration in milliseconds allowed for the parent and
+ * all child devices to retransmit a broadcast message. */
+#define NWK_PASSIVE_ACK_TIMEOUT 15625UL /* octets duration ~= 500 ms. in 2.4Ghz */
+
+/** Maximum data packet retransmission. The maximum number of retries allowed
+ * after a broadcast transmission failure.*/
+#define NWK_MAX_BROADCAST_RETRIES 3U
+
+/** Maximum value of a link cost metric. */
+#define NWK_MAX_LINK_COST 7U
+
+/** Time duration in milliseconds until a route discovery expires.
+ * ZigBee spec r18, Table 3.43, page 342. */
+#define NWKC_ROUTE_DISCOVERY_TIME 0x2710U
+
+#define NWK_ALWAYS_REJECT_OWN_BROADCAST
+
+#if !defined _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 0
+#endif
+
+#if defined _CERTIFICATION_
+/* Doesn't change relationship of router child. */
+#define NWK_TAKES_CARE_OF_CHILD_ROUTER
+
+#define NWK_LIFE_TIME_OF_RX_ON_END_DEVICE (65534UL * 2048UL) /* msec */
+
+#else /* not _CERTIFICATION_ */
+
+#define NWK_LIFE_TIME_OF_RX_ON_END_DEVICE (60U * 2048UL) /* msec */
+
+#endif /* _CERTIFICATION_ */
+
+#define NWK_MAX_DEPTH_IN_BEACON 0xf
+
+/** The cost of an outgoing link as measured by the neighbor. A value
+ * of 0 indicates no outgoing cost is available. See ZigBee Spec r19, Table 3.48. */
+#define NWK_NO_OUTGOING_COST 0U
+
+#endif /* _NWK_CONFIG_H */
+/** eof nwkConfig.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDataReq.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDataReq.h
new file mode 100644
index 00000000..e0fe02a7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDataReq.h
@@ -0,0 +1,92 @@
+/**************************************************************************//**
+ \file nwkDataReq.h
+
+ \brief Interface of the data request component.
+
+ \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:
+ 2009-08-29 M. Gekk - Created.
+ Last change:
+ $Id: nwkDataReq.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_DATA_REQ_H
+#define _NWK_DATA_REQ_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <nwkCommon.h>
+#include <nldeData.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+/** Transmission parameters of data packets. */
+#define NWK_UNICAST_DATA_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_DATA, NULL, nwkConfirmDataTx, false}
+#define NWK_BROADCAST_DATA_TX_PARAMETERS \
+ {NWK_TX_DELAY_BROADCAST, NULL, nwkConfirmDataTx, false}
+#define NWK_MULTICAST_MEMBER_TX_PARAMETERS \
+ {NWK_TX_DELAY_INITIAL_MULTICAST, NULL, nwkConfirmDataTx, false}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of data confirmation. */
+typedef enum _NwkDataConfState_t
+{
+ NWK_DATA_CONF_IDLE_STATE = 0x41,
+ NWK_DATA_CONF_FIRST_STATE = 0x03,
+ NWK_DATA_CONF_PROCESS_STATE = NWK_DATA_CONF_FIRST_STATE,
+ NWK_DATA_CONF_LAST_STATE
+} NwkDataConfState_t;
+
+/** Internal variables of this component. */
+typedef struct _NwkDataConf_t
+{
+ QueueDescriptor_t queue;
+ NwkDataConfState_t state;
+} NwkDataConf_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Reset the data request component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetDataConf(void);
+
+/**************************************************************************//**
+ \brief Main task handler of the data request component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkDataConfTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Confirmation of data transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of data transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmDataTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/******************************************************************************
+ \brief nwkDataReq idle checking.
+
+ \return true, if nwkDataReq performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkDataReqIsIdle(void);
+
+#endif /* _NWK_DATA_REQ_H */
+/** eof nwkDataReq.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDbg.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDbg.h
new file mode 100644
index 00000000..9e4cb22d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDbg.h
@@ -0,0 +1,473 @@
+/**************************************************************************//**
+ \file nwkDbg.h
+
+ \brief Constants for debugging and tracing
+
+ \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:
+ 2008-09-19 M. Gekk - New assert identifiers are added.
+ 2009-04-02 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkDbg.h 18296 2011-08-19 12:29:05Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_DBG_H
+#define _NWK_DBG_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <dbg.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+
+#if defined _SYS_ASSERT_ON_
+
+#define NWK_SET_STATE(obj, newState) (obj)->state = (newState)
+#define NWK_CHECK_STATE(obj, checkState, nameOfAssert) \
+ assert((checkState) == (obj)->state, nameOfAssert)
+
+#else /* _SYS_ASSERT_ON_ */
+
+#define NWK_SET_STATE(obj, newState)
+#define NWK_CHECK_STATE(obj, waitState, nameOfAssert)
+#if defined assert
+#undef assert
+#endif /* assert */
+#define assert(condition, dbgCode) (void)0
+
+#endif /* _SYS_ASSERT_ON_ */
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Network assert code. Range 0x3000 - 0x3FFF. */
+typedef enum _NwkDbgCode_t
+{
+ NWKIB_NWKRELOADNIBFROMCONFIGSERVER0 = 0x3001,
+ NWKADDRESS_MACSETCONF0 = 0x3005,
+ NWKADDRESS_NWKALLOCATESHORTADDR1 = 0x3006,
+ NWKJOINREQ_GETSUITABLEPARENT = 0x300B,
+ NWKJOINREQ_NWKASSOCIATE = 0x300C,
+ NWKJOINREQ_NWKJOINREQTASKHANDLER0 = 0x300D,
+ NWKJOINREQ_NWKJOINREQTASKHANDLER1 = 0x300E,
+ NWKJOINREQ_NWKJOINREQTASKHANDLER2 = 0x300F,
+ NWKJOINREQ_NWKJOINREQTASKHANDLER3 = 0x3010,
+ NWKJOINREQ_NWKJOINREQTASKHANDLER4 = 0x3011,
+ NWKJOINREQ_NWKNETWORKDISCOVERYCONF0 = 0x3012,
+ NWKJOINREQ_NWKNETWORKDISCOVERYCONF1 = 0x3013,
+ NWKJOINREQ_MACSETCONF0 = 0x3014,
+ NWKJOINREQ_MACSETCONF1 = 0x3015,
+ NWKJOINREQ_MACSETCONF2 = 0x3016,
+ NWKJOINREQ_MACSETCONF3 = 0x3017,
+ NWKJOINREQ_MACSETCONF4 = 0x3018,
+ NWKJOINREQ_MACRXENABLECONF0 = 0x3019,
+ NWKJOINREQ_MACRXENABLECONF1 = 0x301A,
+ NWKJOINREQ_MACGETCONF0 = 0x301B,
+ NWKJOINREQ_MACGETCONF1 = 0x301C,
+ NWKJOINREQ_NWKCONFIRMJOINREQTX0 = 0x301D,
+ NWKJOINREQ_NWKREJOINRESPONSEFRAMEIND0 = 0x301E,
+ NWKJOINREQ_RESPONSEWAITTIMERFIRED0 = 0x301F,
+ NWKJOINREQ_RESPONSEWAITTIMERFIRED1 = 0x3020,
+ NWKJOINREQ_RESPONSEWAITTIMERFIRED2 = 0x3021,
+ NWKJOINREQ_DECRYPTRESPONSEFIRED0 = 0x3022,
+ NWKJOINREQ_DECRYPTRESPONSEFIRED1 = 0x3023,
+ NWKJOINREQ_MACPOLLCONF0 = 0x3024,
+ NWKJOINREQ_MACPOLLCONF1 = 0x3025,
+ NWKJOINREQ_MACASSOCIATECONF0 = 0x3026,
+ NWKJOINREQ_MACRXENABLECONF2 = 0x3027,
+ NWKJOINREQ_NWKJOINREQ0 = 0x3028,
+ NWKJOINREQ_NWKJOINREQ1 = 0x3029,
+ NWKJOINREQ_NWKNETWORKDISCOVERYCONF2 = 0x302A,
+ NWK_RD_INVALID_STATE_IN_TIMER_CALLBACK = 0x3030,
+ NWK_ROUTEDISCOVERY_PROCESSROUTEDISCOVERYOBJ = 0x3031,
+ NWK_ROUTEDISCOVERY_NWKSETRREQTIMEOUTTIMER = 0x3032,
+ NWK_ROUTEDISCOVERY_NWKRREQTIMEOUTTIMERFIRED = 0x3033,
+ NWKJOININD_FINDFREEJOININDOBJ0 = 0x3040,
+ NWKJOININD_FREEJOININDOBJ0 = 0x3041,
+ NWKJOININD_NWKJOININDTASKHANDLER0 = 0x3042,
+ NWKJOININD_NWKPREPAREJOINRESPTX0 = 0x3043,
+ NWKJOININD_NWKJOININDISIDLE = 0x3044,
+ NWKJOININD_NWKCONFIRMJOINRESPTX0 = 0x3045,
+ NWKJOININD_MACCOMMSTATUSIND0 = 0x3046,
+ NWKJOININD_MACCOMMSTATUSIND1 = 0x3047,
+ NWKJOININD_NWKCONFIRMADDRCONFLICTJOINRESPTX0 = 0x3048,
+ NWKJOININD_NWKRESETJOININD0 = 0x3049,
+ NWKRESET_NWKRESETREQ0 = 0x3050,
+ NWKRESET_NWKRESETREQ1 = 0x3051,
+ NWKRESET_NWKRESETTASKHANDLER0 = 0x3052,
+ NWKRESET_NWKRESETTASKHANDLER1 = 0x3053,
+ NWKRESET_NWKRESETTASKHANDLER2 = 0x3054,
+ NWKRESET_NWKRESETCONF0 = 0x3055,
+ NWKRESET_MACRESETCONF0 = 0x3056,
+ NWKRESET_MACRESETCONF1 = 0x3057,
+ NWKRESET_MACRESETCONF2 = 0x3058,
+ NWKRESET_MACSETCONF1 = 0x3059,
+ NWKRESET_MACSETCONF0 = 0x305A,
+ NWKRESET_MACSTARTCONF0 = 0x305B,
+ NWKRESET_MACSTARTCONF1 = 0x305C,
+ NWKRESET_MACRXENABLECONF0 = 0x305D,
+ NWKRESET_MACRXENABLECONF1 = 0x305E,
+ NWKPERMITJOINING_NWKPERMITJOININGREQ1 = 0x3060,
+ NWKPERMITJOINING_NWKPERMITJOININGTASKHANDLER0 = 0x3061,
+ NWKPERMITJOINING_NWKPERMITJOININGTASKHANDLER1 = 0x3062,
+ NWKPERMITJOINING_NWKPERMITJOININGTASKHANDLER2 = 0x3063,
+ NWKPERMITJOINING_MACSETCONF0 = 0x3064,
+ NWKPERMITJOINING_MACSETCONF1 = 0x3065,
+ NWKPERMITJOINING_NWKPERMITJOININGREQ2 = 0x3069,
+ NWKPERMITJOINING_NWKSETREJOINPERMIT0 = 0x306A,
+ NWKSYNC_NWKSYNCREQ0 = 0x3070,
+ NWKSYNC_NWKSYNCPOLLREQ0 = 0x3071,
+ NWKSYNC_NWKSYNCPOLLREQ1 = 0x3072,
+ NWKSYNC_NWKSYNCTASKHANDLER0 = 0x3073,
+ NWKSYNC_NWKSYNCTASKHANDLER1 = 0x3074,
+ NWKSYNC_NWKSYNCTASKHANDLER2 = 0x3075,
+ NWKSYNC_NWKSYNCTASKHANDLER3 = 0x3076,
+ NWKSYNC_NWKSYNCTASKHANDLER4 = 0x3077,
+ NWKSYNC_NWKSYNCTASKHANDLER5 = 0x3078,
+ NWKSYNC_NWKSYNCMACPOLLCONF_0 = 0x3079,
+ NWKSYNC_NWKSYNCMACPOLLCONF_1 = 0x307A,
+ NWKSYNC_NWKSYNCREQ1 = 0x307B,
+ NWKSYNC_MACPOLLIND0 = 0x307C,
+ NWKEDSCAN_NWKEDSCANREQ0 = 0x3080,
+ NWKEDSCAN_NWKEDSCANTASKHANDLER0 = 0x3081,
+ NWKEDSCAN_NWKEDSCANTASKHANDLER1 = 0x3082,
+ NWKEDSCAN_NWKEDSCANTASKHANDLER2 = 0x3083,
+ NWKEDSCAN_NWKEDSCANTASKHANDLER3 = 0x3084,
+ NWKEDSCAN_NWKEDSCANTASKHANDLER4 = 0x3085,
+ NWKEDSCAN_NWKEDSCANTASKHANDLER5 = 0x3086,
+ NWKEDSCAN_MACEDSCANCONF0 = 0x3087,
+ NWKEDSCAN_MACEDSCANCONF1 = 0x3088,
+ NWKEDSCAN_MACEDSCANCONF2 = 0x3089,
+ NWKEDSCAN_NWKEDSCANREQ1 = 0x308A,
+ NWKSTARTROUTER_NWKSTARTROUTERREQ0 = 0x3090,
+ NWKSTARTROUTER_NWKSTARTROUTERTASKHANDLER0 = 0x3091,
+ NWKSTARTROUTER_NWKSTARTROUTERTASKHANDLER1 = 0x3092,
+ NWKSTARTROUTER_NWKSTARTROUTERTASKHANDLER2 = 0x3093,
+ NWKSTARTROUTER_NWKSTARTROUTERTASKHANDLER3 = 0x3094,
+ NWKSTARTROUTER_NWKSTARTROUTERTASKHANDLER4 = 0x3095,
+ NWKSTARTROUTER_NWKSTARTROUTERTASKHANDLER5 = 0x3096,
+ NWKSTARTROUTER_MACSTARTCONF0 = 0x3097,
+ NWKSTARTROUTER_MACSTARTCONF1 = 0x3098,
+ NWKSTARTROUTER_MACSTARTCONF2 = 0x3099,
+ NWKSTARTROUTER_NWKSTARTROUTERREQ1 = 0x309A,
+ NWKFORMATION_NWKNETWORKFORMATIONREQ0 = 0x30A0,
+ NWKFORMATION_NWKFORMATIONTASKHANDLER0 = 0x30A1,
+ NWKFORMATION_NWKFORMATIONTASKHANDLER1 = 0x30A2,
+ NWKFORMATION_NWKFORMATIONTASKHANDLER2 = 0x30A3,
+ NWKFORMATION_NWKFORMATIONTASKHANDLER3 = 0x30A4,
+ NWKFORMATION_MACSTARTREALIGNMENTCONF0 = 0x30A5,
+ NWKFORMATION_MACSTARTREALIGNMENTCONF1 = 0x30A6,
+ NWKFORMATION_MACSTARTREALIGNMENTCONF2 = 0x30A7,
+ NWKFORMATION_MACEDSCANCONF0 = 0x30A8,
+ NWKFORMATION_MACEDSCANCONF1 = 0x30A9,
+ NWKFORMATION_MACEDSCANCONF2 = 0x30AA,
+ NWKFORMATION_MACACTIVESCANCONFIRM0 = 0x30AB,
+ NWKFORMATION_MACACTIVESCANCONFIRM1 = 0x30AC,
+ NWKFORMATION_MACACTIVESCANCONFIRM2 = 0x30AD,
+ NWKFORMATION_MACSETCONF0 = 0x30AE,
+ NWKFORMATION_MACSETCONF1 = 0x30AF,
+ NWKFORMATION_MACSETCONF2 = 0x30B0,
+ NWKFORMATION_MACSTARTCONF0 = 0x30B1,
+ NWKFORMATION_MACSTARTCONF1 = 0x30B2,
+ NWKFORMATION_MACSTARTCONF2 = 0x30B3,
+ NWKFORMATION_MACRXENABLECONF0 = 0x30B4,
+ NWKFORMATION_MACRXENABLECONF1 = 0x30B5,
+ NWKFORMATION_MACRXENABLECONF2 = 0x30B6,
+ NWKFORMATION_FINDBESTCHANNEL0 = 0x30B7,
+ NWKFORMATION_FINDBESTCHANNEL1 = 0x30B8,
+ NWKFORMATION_MACACTIVESCANCONFIRM3 = 0x30B9,
+ NWKFORMATION_MACEDSCANCONF3 = 0x30BA,
+ NWKFORMATION_MACEDSCANCONF4 = 0x30BB,
+ NWKFORMATION_NWKNETWORKFORMATIONREQ1 = 0x30BC,
+ NWKSYNCLOSS_MACSYNCLOSSIND0 = 0x30C0,
+ NWKSYNCLOSS_MACSYNCLOSSIND1 = 0x30C1,
+ NWKSYNCLOSS_MACSYNCLOSSIND2 = 0x30C2,
+ NWKSYNCLOSS_MACSYNCLOSSIND3 = 0x30C3,
+ NWKSYNCLOSS_NWKSTARTROUTERCONF0 = 0x30C4,
+ NWKSYNCLOSS_NWKSTARTROUTERCONF1 = 0x30C5,
+ NWKSYNCLOSS_NWKRESETREALIGNMENT0 = 0x30C6,
+ NWKDISCOVERY_NWKNETWORKDISCOVERYREQ0 = 0x30D0,
+ NWKDISCOVERY_NWKNETWORKDISCOVERYREQ1 = 0x30D1,
+ NWKDISCOVERY_NWKDISCOVERYTASKHANDLER0 = 0x30D2,
+ NWKDISCOVERY_NWKDISCOVERYTASKHANDLER1 = 0x30D3,
+ NWKDISCOVERY_NWKDISCOVERYTASKHANDLER2 = 0x30D4,
+ NWKDISCOVERY_NWKDISCOVERYTASKHANDLER3 = 0x30D5,
+ NWKDISCOVERY_MACBEACONNOTIFYIND0 = 0x30D6,
+ NWKDISCOVERY_MACACTIVESCANCONFIRM0 = 0x30D7,
+ NWKDISCOVERY_MACACTIVESCANCONFIRM1 = 0x30D8,
+ NWKDISCOVERY_MACACTIVESCANCONFIRM2 = 0x30D9,
+ NWKDISCOVERY_NWKFILLPANDESCRIPTORS0 = 0x30DA,
+ NWKDISCOVERY_NWKFILLPANDESCRIPTORS1 = 0x30DB,
+ NWKLINKSTATUS_NWKLINKSTATUSTIMERFIRED0 = 0x30E0,
+ NWKLINKSTATUS_NWKCONFIRMLINKSTATUSTX0 = 0x30E1,
+ NWKLINKSTATUS_NWKSTARTLINKSTATUSTIMER0 = 0x30E2,
+ NWKLINKSTATUS_NWKPREPARELINKSTATUSTX0 = 0x30E3,
+ NWKLINKSTATUS_NWKPREPARELINKSTATUSTX1 = 0x30E4,
+ NWKLINKSTATUS_NWKSTOPLINKSTATUSTIMER = 0x30E5,
+ NWKLINKSTATUS_NWKCOPYCOSTINFOTOLINKSTATUSCMD0 = 0x30E7,
+ NWKNEIGHBORTABLE_NWKRESETNEIBTABLE0 = 0x30F0,
+ NWKNEIGHBORTABLE_NWKRESETNEIBTABLE1 = 0x30F1,
+ NWKNEIGHBORTABLE_NWKRESETNEIBTABLE2 = 0x30F2,
+ NWKNEIGHBORTABLE_NWKFREENEIGHBOR0 = 0x30F3,
+ NWKNEIGHBORTABLE_NWKSETLIFETIMEOFNEIGHBOR0 = 0x30F4,
+ NWKNEIGHBORTABLE_NEIGHBORTIMERFIRED0 = 0x30F5,
+ NWKNEIGHBORTABLE_NWKSTARTAGETIMEROFNEIGHBORTABLE0 = 0x30F6,
+ NWKNEIGHBORTABLE_NWKISKNOWNCHILD0 = 0x30F7,
+ NWKADDRESSMAP_NWKADDTOADDRESSMAP1 = 0x3110,
+ NWKADDRESSMAP_NWKGETSHORTBYEXTADDRESS0 = 0x3111,
+ NWKADDRESSMAP_NWKSTATUSCOMMANDCONF0 = 0x3112,
+ NWKADDRESSMAP_NWKSTATUSCOMMANDCONF1 = 0x3113,
+ NWKADDRESSMAP_NWKADDTOADDRESSMAP0 = 0x3114,
+ NWKADDRESSMAP_NWKRESETADDRESSMAP0 = 0x3115,
+ NWKLEAVE_NWKREMOVENEIGHBOR0 = 0x3120,
+ NWKLEAVE_NWKLEAVEREQ0 = 0x3121,
+ NWKLEAVE_NWKLEAVEREQ1 = 0x3122,
+ NWKLEAVE_NWKLEAVETASKHANDLER0 = 0x3123,
+ NWKLEAVE_NWKLEAVETASKHANDLER1 = 0x3124,
+ NWKLEAVE_NWKLEAVETASKHANDLER2 = 0x3125,
+ NWKLEAVE_NWKLEAVETASKHANDLER3 = 0x3126,
+ NWKLEAVE_NWKLEAVENEIGHBOR0 = 0x3127,
+ NWKLEAVE_NWKLEAVENEIGHBOR1 = 0x3128,
+ NWKLEAVE_NWKCONFIRMOFLEAVEITSELFCMD0 = 0x3129,
+ NWKLEAVE_NWKCONFIRMOFLEAVEITSELFCMD1 = 0x312A,
+ NWKLEAVE_MACRESETCONF0 = 0x312B,
+ NWKLEAVE_MACRESETCONF1 = 0x312C,
+ NWKLEAVE_MACRESETCONF2 = 0x312D,
+ NWKLEAVE_NWKCONFIRMOFLEAVECHILDCMD0 = 0x312E,
+ NWKLEAVE_NWKCONFIRMOFLEAVECHILDCMD1 = 0x312F,
+ NWKLEAVE_NWKCONFIRMOFLEAVECHILDCMD2 = 0x3130,
+ NWKLEAVE_NWKCONFIRMOFLEAVECHILDCMD3 = 0x3131,
+ NWKLEAVE_NWKPREPAREMACDATAOFLEAVEITSELFCMD0 = 0x3132,
+ NWKLEAVE_NWKPREPAREMACDATAOFLEAVEITSELFCMD1 = 0x3133,
+ NWKLEAVE_NWKPREPAREMACDATAOFLEAVECHILDCMD0 = 0x3135,
+ NWKLEAVEIND_NWKLEAVECONF0 = 0x3138,
+ NWKLEAVEIND_NWKLEAVECONF1 = 0x3139,
+ NWKLEAVE_NWKCONFIRMOFLEAVECHILDCMD4 = 0x313A,
+ NWKLEAVE_NWKCONFIRMOFLEAVEITSELFCMD2 = 0x313B,
+ NWKLEAVE_NWKCONFIRMOFLEAVECHILDCMD5 = 0x313C,
+ NWKREPORTCOMMAND_NWKDETECTPANIDCONFLICT0 = 0x3140,
+ NWKREPORTCOMMAND_NWKSEARCHOTHERNETWORKS0 = 0x3141,
+ NWKREPORTCOMMAND_MACACTIVESCANCONFIRM0 = 0x3142,
+ NWKREPORTCOMMAND_MACACTIVESCANCONFIRM1 = 0x3143,
+ NWKREPORTCOMMAND_NWKPREPAREREPORTTX0 = 0x3144,
+ NWKREPORTCOMMAND_NWKPREPAREREPORTTX1 = 0x3145,
+ NWKREPORTCOMMAND_NWKPREPAREREPORTTX2 = 0x3146,
+ NWKREPORTCOMMAND_NWKCONFIRMREPORTTX0 = 0x3148,
+ NWKUPDATECOMMAND_NWKUPDATEPANID0 = 0x3150,
+ NWKUPDATECOMMAND_NWKUPDATETIMERFIRED0 = 0x3151,
+ NWKUPDATECOMMAND_MACSETCONF0 = 0x3152,
+ NWKUPDATECOMMAND_MACSETCONF1 = 0x3153,
+ NWKMANAGER_NWKDETECTPANIDCONFLICTBYNWKMANAGER0 = 0x3160,
+ NWKMANAGER_NWKREPORTFRAMEIND0 = 0x3161,
+ NWKMANAGER_NWKCHOSEPANID0 = 0x3162,
+ NWKMANAGER_MACACTIVESCANCONF0 = 0x3163,
+ NWKMANAGER_MACACTIVESCANCONF1 = 0x3164,
+ NWKMANAGER_NWKPREPAREUPDATETX0 = 0x3165,
+ NWKMANAGER_NWKCONFIRMUPDATETX0 = 0x3167,
+ NWKMANAGER_NWKCONFIRMUPDATETX1 = 0x3168,
+ NWKMANAGER_NWKMANAGERSETPANIDDONE0 = 0x3169,
+ NWKMANAGER_MACACTIVESCANCONF2 = 0x316A,
+ NWKSTATUSIND_NWKADDRCONFLICTCONF0 = 0x3170,
+ NWKSTATUSREQ_NWKSTATUSREQ0 = 0x3171,
+ NWKSTATUSREQ_NWKSTATUSREQ1 = 0x3172,
+ NWKSTATUSREQ_NWKCONFIRMNETWORKSTATUSTX0 = 0x3175,
+ NWKSTATUSREQ_NWKCONFIRMNETWORKSTATUSTX1 = 0x3176,
+ NWKSTATUSREQ_NWKPREPARENETWORKSTATUSTX0 = 0x3177,
+ NWKSTATUSREQ_NWKSENDROUTEERRORCONF0 = 0x3178,
+ NWKADDRESSCONFLICT_NWKJOINCONF0 = 0x3180,
+ NWKADDRESSCONFLICT_NWKJOINCONF1 = 0x3181,
+ NWKADDRESSCONFLICT_MACSETCONF0 = 0x3182,
+ NWKADDRESSCONFLICT_NWKSTATUSCONF0 = 0x3183,
+ NWKPACKET_NWKALLOCINPUTPACKET0 = 0x3190,
+ NWKPACKET_NWKALLOCOUTPUTPACKET0 = 0x3191,
+ NWKPACKET_NWKFREEBUFFER0 = 0x3192,
+ NWKPACKET_NWKALLOCDATAREQ0 = 0x3193,
+ NWKPACKET_NWKALLOCDATAREQTASKHANDLER0 = 0x3194,
+ NWKPACKET_NWKALLOCDATAREQTASKHANDLER1 = 0x3195,
+ NWKPACKET_NWKFREEBUFFER1 = 0x3196,
+ NWKRX_NWKRXINDICATION0 = 0x31A0,
+ NWKRX_NWKDATAINDTRANSITCONF0 = 0x31A1,
+ NWKRX_NWKDATARESP0 = 0x31A2,
+ NWKRX_NWKRETRANSMITBUFFER0 = 0x31A3,
+ NWKRX_NWKDECRYPTTRANSITFRAMECONF0 = 0x31A4,
+ NWKRX_NWKDECRYPTFRAMECONF0 = 0x31A5,
+ NWKRX_NWKRETRANSMITBUFFER1 = 0x31A6,
+ NWKRX_NWKINITINPUTPACKET0 = 0x31A7,
+ NWKDATAREQ_NWKDATAREQ0 = 0x31B0,
+ NWKDATAREQ_NWKDATAREQ1 = 0x31B1,
+ NWKDATAREQ_NWKDATACONF0 = 0x31B3,
+ NWKDATAREQ_NWKDATACONFTASKHANDLER0 = 0x31B4,
+ NWKDATAREQ_NWKDATACONFTASKHANDLER1 = 0x31B5,
+ NWKDATAREQ_NWKDATACONFTASKHANDLER2 = 0x31B6,
+ NWKDATAREQ_NWKINITRADIUSFIELD0 = 0x31B7,
+ NWKTASKMANAGER_NWKTASKHANDLER0 = 0x31C0,
+ NWKCOMMANDS_NWKCOMMANDCONF0 = 0x31D0,
+ NWKCOMMANDS_NWKCOMMANDREQ0 = 0x31D2,
+ NWKCOMMANDS_NWKCOMMANDREQ1 = 0x31D3,
+ NWKTXSECURITY_NWKENCRYPTOUTPUTPACKETCONF0 = 0x31E0,
+ NWKTXSECURITY_NWKENCRYPTOUTPUTPACKETCONF1 = 0x31E1,
+ NWKTXSECURITY_NWKDECRYPTOUTPUTPACKETCONF0 = 0x31E2,
+ NWKTXSECURITY_NWKDECRYPTOUTPUTPACKETCONF1 = 0x31E3,
+ NWKROUTING_NWKGETNEXTHOP0 = 0x31F0,
+ NWKCONCENTRATOR_NWKSTARTCONCENTRATOR0 = 0x3200,
+ NWKCONCENTRATOR_NWKCONCENTRATORTIMERFIRED0 = 0x3201,
+ NWKCONCENTRATOR_NWKROUTEDISCOVERYCONF0 = 0x3202,
+ NWKCONCENTRATOR_NWKSTOPCONCENTRATOR_TIMER = 0x3203,
+ NWKTXDELAY_NWKINITDELAYANDRETRIES0 = 0x3210,
+ NWKTXDELAY_NWKINITDELAYANDRETRIES1 = 0x3211,
+ NWKTXDELAY_NWKTXDELAYREQ0 = 0x3212,
+ NWKTXDELAY_NWKTXDELAYREQ1 = 0x3213,
+ NWKTXDELAY_NWKTXDELAYREQ2 = 0x3214,
+ NWKTXDELAY_NWKTXDELAYREQ3 = 0x3215,
+ NWKTXDELAY_NWKTXDELAYTIMERFIRED0 = 0x3216,
+ NWKTXDELAY_NWKFLUSHTXDELAY0 = 0x3217,
+ NWKTXDELAY_NWKFLUSHTXDELAY1 = 0x3218,
+ NWKTXDELAY_NWKBROADCASTTXDELAYREQ0 = 0x3219,
+ NWKTXDELAY_NWKINITINITIALRREQTXDELAY0 = 0x321A,
+ NWKTXDELAY_NWKINITDELAYANDRETRIES2 = 0x321B,
+ NWKTX_NWKSENDPACKET0 = 0x3220,
+ NWKTX_MACDATACONF0 = 0x3221,
+ NWKTX_NWKROUTE0 = 0x3222,
+ NWKTX_NWKROUTE1 = 0x3223,
+ NWKTX_NWKROUTE2 = 0x3224,
+ NWKTX_NWKTXCONF0 = 0x3225,
+ NWKTX_NWKROUTEDISCOVERYCONF0 = 0x3226,
+ NWKTX_NWKTXDELAYCONF0 = 0x3227,
+ NWKTX_NWKTXREQ0 = 0x3228,
+ NWKTX_NWKTXTASKHANDLER0 = 0x3229,
+ NWKTX_NWKTXTASKHANDLER1 = 0x322A,
+ NWKTX_NWKISDATAPACKET0 = 0x322B,
+ NWKTX_NWKTRANSMITOUTPUTPACKET0 = 0x322C,
+ NWKTX_NWKROUTERECORDCONF0 = 0x322D,
+ NWKLOOPBACK_NWKLOOPBACKTXREQ0 = 0x3230,
+ NWKLOOPBACK_NWKPROCESSLOOPBACKREQUEST0 = 0x3231,
+ NWKLOOPBACK_NWKLOOPBACKTASKHANDLER0 = 0x3232,
+ NWKLOOPBACK_NWKLOOPBACKTASKHANDLER1 = 0x3233,
+ NWKLOOPBACK_NWKLOOPBACKTASKHANDLER2 = 0x3234,
+ NWKLOOPBACK_NWKLOOPBACKTASKHANDLER3 = 0x3235,
+ NWKLOOPBACK_NWKLOOPBACKTASKHANDLER4 = 0x3236,
+ NWKLOOPBACK_NWKLOOPBACKTASKHANDLER5 = 0x3237,
+ NWKROUTEREPLY_NWKPREPAREROUTEREPLYTX0 = 0x3240,
+ NWKROUTEREPLY_NWKPREPAREROUTEREPLYTX1 = 0x3241,
+ NWKROUTEREPLY_NWKPREPAREROUTEREPLYTX2 = 0x3242,
+ NWKROUTEREPLY_NWKPREPAREPAYLOADOFROUTEREPLY0 = 0x3243,
+ NWKROUTEREPLY_NWKCONFIRMROUTEREPLYTX0 = 0x3244,
+ NWKROUTEREPLY_NWKCONFIRMROUTEREPLYTX1 = 0x3245,
+ NWKROUTINGTABLE_NWKRESETROUTINGTABLE0 = 0x3250,
+ NWKROUTINGTABLE_NWKUPDATEROUTINGENTRY0 = 0x3251,
+ NWKROUTINGTABLE_NWKALLOCROUTINGENTRY0 = 0x3252,
+ NWKROUTEREQUEST_NWKPREPAREROUTEREQUESTTX0 = 0x3260,
+ NWKROUTEREQUEST_NWKPREPAREROUTEREQUESTTX1 = 0x3261,
+ NWKROUTEDISCOVERY_NWKROUTEDISCOVERYREQ0 = 3270,
+ NWKROUTEDISCOVERY_NWKROUTEDISCOVERYCONF0 = 0x3271,
+ NWKROUTEDISCOVERY_NWKROUTEDISCOVERYCONF1 = 0x3272,
+ NWKROUTEDISCOVERY_NWKROUTEDISCOVERYTASKHANDLER0 = 0x3273,
+ NWKROUTEDISCOVERY_NWKROUTEDISCOVERYTASKHANDLER1 = 0x3274,
+ NWKROUTEDISCOVERY_NWKROUTEDISCOVERYTASKHANDLER2 = 0x3275,
+ NWKRDTABLE_NWKSENDROUTEDISCOVERYREQUEST0 = 0x3280,
+ NWKRDTABLE_NWKSENDROUTEDISCOVERYREPLY0 = 0x3281,
+ NWKRDTABLE_NWKFREEROUTEDISCOVERYTABLE0 = 0x3282,
+ NWKRDTABLE_NWKCONFIRMROUTEREQUESTTX0 = 0x3283,
+ NWKRDTABLE_NWKRESETROUTEDISCOVERYTABLE0 = 0x3284,
+ NWKRDTABLE_NWKROUTEDISCOVERYTABLETASKHANDLER0 = 0x3285,
+ NWKROUTECACHE_NWKFINDROUTERECORD0 = 0x3290,
+ NWKROUTECACHE_NWKADDROUTERECORD0 = 0x3291,
+ NWKROUTECACHE_NWKADDROUTERECORD1 = 0x3292,
+ NWKROUTECACHE_NWKRESETROUTECACHE0 = 0x3293,
+ NWKROUTERECORD_NWKPREPAREROUTERECORDTX0 = 0x3300,
+ NWKROUTERECORD_NWKPREPAREHEADEROFROUTERECORD0 = 0x3301,
+ NWKROUTERECORD_NWKCONFIRMROUTERECORDTX1 = 0x3302,
+ NWKROUTERECORD_NWKCONFIRMROUTERECORDTX0 = 0x3303,
+ NWKROUTERECORD_NWKFORMATIONTASKHANDLER2 = 0x3304,
+ NWKROUTERECORD_NWKFORMATIONTASKHANDLER1 = 0x3305,
+ NWKROUTERECORD_NWKFORMATIONTASKHANDLER0 = 0x3306,
+ NWKROUTERECORD_NWKROUTERECORDREQ0 = 0x3307,
+ NWKROUTERECORD_NWKROUTERECORDREQ1 = 0x3308,
+ NWKSOURCEROUTING_NWKUSESOURCEROUTING0 = 0x3310,
+ NWKSOURCEROUTING_NWKUSESOURCEROUTING1 = 0x3311,
+ NWKSOURCEROUTING_NWKPREPARESOURCEROUTETX0 = 0x3312,
+ NWKSOURCEROUTING_NWKPREPARESOURCEROUTETX1 = 0x3313,
+ NWKSOURCEROUTING_NWKPREPARETRANSITSOURCEROUTETX0 = 0x3314,
+ NWKSOURCEROUTING_NWKPREPARETRANSITSOURCEROUTETX1 = 0x3315,
+ NWKDIRECTJOIN_NWKDIRECTJOINTASKHANDLER0 = 0x3320,
+ NWKDIRECTJOIN_NWKDIRECTJOINTASKHANDLER1 = 0x3321,
+ NWKORPHAN_NWKORPHANTASKHANDLER0 = 0x3330,
+ NWKORPHAN_NWKORPHANTASKHANDLER1 = 0x3331,
+ NWKORPHAN_NWKORPHANSCANCONF0 = 0x3340,
+ NWKORPHAN_CONFIRMREQUEST0 = 0x3341,
+ NWKORPHAN_NWKORPHANCOMMSTATUSIND0 = 0x3350,
+ NWKORPHAN_NWKORPHANGETCONF0 = 0x3360,
+ NWKORPHAN_NWKORPHANGETCONF1 = 0x3361,
+ NWKORPHAN_NWKORPHANSETCONF0 = 0x3370,
+ NWKORPHAN_NWKORPHANSETCONF1 = 0x3371,
+ NWKORPHAN_NWKORPHANREQ0 = 0x3380,
+ NWKMANYTOONE_NWKSHORTADDROFCONCENTRATOR0 = 0x3390,
+ NWKMANYTOONE_NWKSHORTADDROFCONCENTRATOR1 = 0x3391,
+ NWKMANYTOONE_NWKNEXTHOPTOCONCENTRATOR0 = 0x3392,
+ NWKMANYTOONE_NWKNEXTHOPTOCONCENTRATOR1 = 0x3393,
+ NWKMANYTOONE_NWKNEXTCONCENTRATOR0 = 0x3394,
+ NWKMANYTOONE_NWKNEXTCONCENTRATOR1 = 0x3495,
+ NWKMANYTOONE_NWKNEWCONCENTRATORFOUND0 = 0x3496,
+ NWKMANYTOONE_NWKMANYTOONETASKHANDLER0 = 0x3497,
+ NWKMANYTOONE_NWKMANYTOONETASKHANDLER1 = 0x3498,
+ NWKMANYTOONE_SUBSCRIBETOCONCENTRATORINFO = 0x3499,
+ NWKMANYTOONE_UNSUBSCRIBETOCONCENTRATORINFO = 0x349A,
+ NWKGROUP_NWKADDGROUP0 = 0x34A0,
+ NWKGROUP_NWKREMOVEGROUP0 = 0x34A1,
+ NWKGROUP_NWKISGROUPMEMBER0 = 0x34A2,
+ NWKGROUP_NWKREMOVEALLGROUPS0 = 0x34A3,
+ NWKSECURITY_NWKGETACTIVEKEYSEQNUMBER_0 = 0x34B0,
+ NWKSECURITY_NWKGETACTIVEKEY_0 = 0x34B1,
+ NWKSECURITY_NWKEXTRACTSECOUTCOUNTER_0 = 0x34B2,
+ NWKSECURITY_NWKRESETSECURITYIB_0 = 0x34B3,
+ NWKSYSTEM_MEMCPYCHECKOVERLAP0 = 0x34C0,
+ NWKROUTING_TRANSMITCOUNTEROVERFLOW0 = 0x34D0,
+ NWKROUTING_TRANSMITFAILURECOUNTEROVERFLOW0 = 0x34D1,
+ NWKSILENTJOIN_NWKSILENTJOINREQ0 = 0x34E0,
+ NWKSILENTJOIN_NWKSILENTJOINTASKHANDLER0 = 0x34E1,
+ NWKSILENTJOIN_NWKSILENTJOINTASKHANDLER1 = 0x34E2,
+ NWKSILENTJOIN_NWKSILENTJOINSETCONF0 = 0x34E3,
+ NWKSILENTJOIN_NWKSILENTJOINSETCONF1 = 0x34E4,
+ NWKPASSIVEACK_NWKNEWPASSIVEACK0 = 0x34F0,
+ NWKPASSIVEACK_NWKNEWPASSIVEACK1 = 0x34F1,
+ NWKPASSIVEACK_NWKTRACEPASSIVEACK0 = 0x34F2,
+ NWKPASSIVEACK_NWKISPASSIVEACKDONE0 = 0x34F3
+} NwkDbgCode_t;
+
+/** Values of system log messages */
+typedef enum _NwkLogCodeId_t
+{
+ LOG_NWK_DATA_REQ = 0x00,
+ LOG_NWK_DATA_REQ_NO_ASSOC = 0x01,
+ LOG_NWK_DATA_REQ_INVALID_RADIUS = 0x02,
+ LOG_NWK_DATA_REQ_MULTICAST_NO_SUPPORT = 0x03,
+ LOG_NWK_DATA_REQ_INVALID_BROADCAST_ADDR = 0x04,
+ LOG_NWK_DATA_REQ_BTT_FULL = 0x05,
+ LOG_NWK_DATA_REQ_BTR_EXISTS = 0x06,
+ LOG_NWK_DATA_CONF = 0x07,
+ LOG_NWK_SSP_ENCRYPT_FRAME_REQ = 0x08,
+ LOG_NWK_ENCRYPT_OUTPUT_PACKET_SUCCESS = 0x09,
+ LOG_NWK_ENCRYPT_OUTPUT_PACKET_FAIL = 0x0A,
+ LOG_NWK_START_CONCENTRATOR = 0x0B,
+ LOG_NWK_STOP_CONCENTRATOR = 0x0C,
+ LOG_NWK_START_CONCENTRATOR_TIMER = 0x0D,
+ LOG_NWK_CONCENTRATOR_PREPARE_ROUTE_DISCOVERY = 0x0E,
+ LOG_NWK_CONCENTRATOR_ROUTE_DISCOVERY_SUCCESS = 0x0F,
+ LOG_NWK_CONCENTRATOR_ROUTE_DISCOVERY_FAIL = 0x10,
+ LOG_NWK_LOOPBACK_REQUEST = 0x11,
+ LOG_NWK_LOOPBACK_TASK_HANDLER = 0x12,
+ LOG_NWK_LOOPBACK_REQUEST_DONE = 0x13
+} NwkLogCodeId_t;
+
+#endif /* _NWK_DBG_H */
+/** eof nwkDbg.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDirectJoin.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDirectJoin.h
new file mode 100644
index 00000000..6b87b025
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDirectJoin.h
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ \file nwkDirectJoin.h
+
+ \brief Interface of directly join another device to network.
+
+ \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:
+ 2010-03-17 I.Vagulin - Created.
+ Last change:
+ $Id: nwkDirectJoin.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_DIRECT_JOIN_H
+#define _NWKDIRECTJOIN_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Direct join memory */
+typedef struct _NwkDirectJoin_t
+{
+ /** Request queue */
+ QueueDescriptor_t queue;
+} NwkDirectJoin_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if (defined(_ROUTER_) || defined(_COORDINATOR_)) && defined(_NWK_DIRECT_JOIN_)
+/**************************************************************************//**
+ \brief Reseting of the direct join module.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetDirectJoin(void);
+
+/**************************************************************************//**
+ \brief task handler of diret join module
+ ******************************************************************************/
+NWK_PRIVATE void nwkDirectJoinTaskHandler(void);
+#else
+
+#define nwkResetDirectJoin() (void)0
+#define nwkDirectJoinTaskHandler NULL
+
+#endif /* _NWK_DIRECT_JOIN_ and (_ROUTER_ or _COORDINATOR_) */
+#endif /* _NWK_DIRECT_JOIN_H */
+/** eof nwkDirectJoin.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDiscovery.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDiscovery.h
new file mode 100644
index 00000000..e526d94f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkDiscovery.h
@@ -0,0 +1,73 @@
+/**************************************************************************//**
+ \file nwkDiscovery.h
+
+ \brief Discovery header file.
+
+ \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:
+ 2007-06-14 S. Vladykin - Created.
+ 2008-12-10 M. Gekk - Reduction of the used RAM.
+ 2009-04-06 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkDiscovery.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_DISCOVERY_H
+#define _NWK_DISCOVERY_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of NLME-NETWORK-DISCOVERY component */
+typedef enum _NwkDiscoveryState_t
+{
+ NWK_DISCOVERY_IDLE_STATE = 0xD6,
+ NWK_DISCOVERY_FIRST_STATE = 0x70,
+ NWK_DISCOVERY_BEGIN_STATE = NWK_DISCOVERY_FIRST_STATE,
+ NWK_DISCOVERY_MAC_SCAN_STATE = 0x71,
+ NWK_DISCOVERY_CONFIRM_STATE = 0x72,
+ NWK_DISCOVERY_LAST_STATE
+} NwkDiscoveryState_t;
+
+/** Internal parameters of NLME-NETWORK-DISCOVERY */
+typedef struct _NwkDiscovery_t
+{
+ QueueDescriptor_t queue; /**< Queue of requests from upper layer */
+ NwkDiscoveryState_t state; /**< finite-state machine */
+} NwkDiscovery_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Main task handler of NLME-NETWORK-DISCOVERY component
+ ******************************************************************************/
+NWK_PRIVATE void nwkDiscoveryTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Reset NLME-NETWORK-DISCOVERY component
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetDiscovery(void);
+
+/******************************************************************************
+ \brief nwkDiscovery idle checking.
+
+ \return true, if nwkDiscovery performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkDiscoveryIsIdle(void);
+
+#endif /* _NWK_DISCOVERY_H */
+/** eof nwkDiscovery.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkEDScan.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkEDScan.h
new file mode 100644
index 00000000..654a1972
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkEDScan.h
@@ -0,0 +1,75 @@
+/**************************************************************************//**
+ \file nwkEDScan.h
+
+ \brief EDScan header file.
+
+ \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:
+ 2007-06-14 S. Vladykin - Created.
+ 2008-12-10 M. Gekk - Reduction of the used RAM.
+ 2009-03-15 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkEDScan.h 17448 2011-06-09 13:53:59Z ataradov $
+ *****************************************************************************/
+#if !defined _NWK_EDSCAN_H
+#define _NWK_EDSCAN_H
+
+/*****************************************************************************
+ Includes section
+ *****************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <nwkCommon.h>
+
+/*****************************************************************************
+ Types section
+ *****************************************************************************/
+/** Internal states of NLME-ED-SCAN component */
+typedef enum _NwkEDScanState_t
+{
+ NWK_EDSCAN_IDLE_STATE = 0x13,
+ NWK_EDSCAN_FIRST_STATE = 0xE7,
+ NWK_EDSCAN_BEGIN_STATE = NWK_EDSCAN_FIRST_STATE,
+ NWK_EDSCAN_MAC_SCAN_STATE = 0xE8,
+ NWK_EDSCAN_CONFIRM_STATE = 0xE9,
+ NWK_EDSCAN_LAST_STATE
+} NwkEDScanState_t;
+
+/** Internal parameters of NLME-ED-SCAN */
+typedef struct _NwkEDScan_t
+{
+ QueueDescriptor_t queue; /**< Queue of requests from upper layer */
+ NwkEDScanState_t state; /**< finite-state machine */
+ NwkState_t savedStateMachine;
+} NwkEDScan_t;
+
+/*****************************************************************************
+ Prototypes section
+ *****************************************************************************/
+/*************************************************************************//**
+ \brief Reset NLME-ED-SCAN component.
+ *****************************************************************************/
+NWK_PRIVATE void nwkResetEDScan(void);
+
+/******************************************************************************
+ \brief nwkEDScan idle checking.
+
+ \return true, if nwkEDScan performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkEDScanIsIdle(void);
+
+/*************************************************************************//**
+ \brief Main task handler of NLME-ED-SCAN
+ *****************************************************************************/
+NWK_PRIVATE void nwkEDScanTaskHandler(void);
+
+#endif /* _NWK_EDSCAN_H */
+/** eof nwkEDScan.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkFormation.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkFormation.h
new file mode 100644
index 00000000..c383cbaf
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkFormation.h
@@ -0,0 +1,92 @@
+/**************************************************************************//**
+ \file nwkFormation.h
+
+ \brief Formation header file.
+
+ \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:
+ 2007-06-14 S. Vladykin - Created.
+ 2008-12-19 M. Gekk - Numbers are added to enum of state.
+ 2009-03-24 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkFormation.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_FORMATION_H
+#define _NWK_FORMATION_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <types.h>
+#include <queue.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of NLME-NETWORK-FORMATION component */
+typedef enum _NwkFormationState_t
+{
+ NWK_FORMATION_IDLE_STATE = 0xB7,
+ NWK_FORMATION_FIRST_STATE = 0x54,
+ NWK_FORMATION_BEGIN_STATE = NWK_FORMATION_FIRST_STATE,
+ NWK_FORMATION_MAC_REALIGNMENT_STATE = 0x55,
+ NWK_FORMATION_MAC_ACTIVE_SCAN_STATE = 0x56,
+ NWK_FORMATION_MAC_ED_SCAN_STATE = 0x57,
+ NWK_FORMATION_CONFIRM_STATE = 0x58,
+ NWK_FORMATION_SET_SHORT_ADDR_STATE = 0x59,
+ NWK_FORMATION_SET_BEACON_PAYLOAD_LEN_STATE = 0x5A,
+ NWK_FORMATION_SET_BEACON_PAYLOAD_STATE = 0x5B,
+ NWK_FORMATION_SET_RX_ON_WHEN_IDLE_STATE = 0x5C,
+ NWK_FORMATION_MAC_START_STATE = 0x5D,
+ NWK_FORMATION_RX_ENABLE_STATE = 0x5E,
+ NWK_FORMATION_SET_TRANSACTION_TIME_STATE = 0x5F,
+ NWK_FORMATION_LAST_STATE
+} NwkFormationState_t;
+
+/** Internal parameters of NLME-NETWORK-FORMATION component. */
+typedef struct _NwkFormation_t
+{
+ QueueDescriptor_t queue; /**< Queue of requests from upper layer. */
+ NwkFormationState_t state; /**< finite-state machine. */
+ bool coordRealignment;
+} NwkFormation_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _COORDINATOR_
+/**************************************************************************//**
+ \brief Main task handler of NLME-NETWORK-FORMATION component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkFormationTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Reset NLME-NETWORK-FORMATION component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetFormation(void);
+
+/******************************************************************************
+ \brief nwkFormation idle checking.
+
+ \return true, if nwkFormation performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkFormationIsIdle(void);
+
+#else /* not defined _COORDINATOR_ */
+
+#define nwkFormationTaskHandler NULL
+#define nwkFormationIsIdle NULL
+#define nwkResetFormation() (void)0
+
+#endif /* _COORDINATOR_ */
+#endif /* _NWK_FORMATION_H */
+/** eof nwkFormation.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkFrame.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkFrame.h
new file mode 100644
index 00000000..2a6781a5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkFrame.h
@@ -0,0 +1,363 @@
+/**************************************************************************//**
+ \file nwkFrame.h
+
+ \brief Network frames header file.
+
+ \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:
+ 2007-07-01 S. Vladykin - Created.
+ 2009-06-12 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkFrame.h 18245 2011-08-16 09:23:15Z arazinkov $
+ ******************************************************************************/
+#if !defined _NWK_FRAME_H
+#define _NWK_FRAME_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <types.h>
+#include <nwkSystem.h>
+#include <appFramework.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_HEADER(outPkt) ((NwkFrameHeader_t *)(NWK_GET_OUTPKT_DATA(outPkt)))
+#define IS_DATA(nwkHeader) \
+ (NWK_FRAMETYPE_DATA == (nwkHeader)->frameControl.frameType)
+#define IS_COMMAND(nwkHeader) \
+ (NWK_FRAMETYPE_COMMAND == (nwkHeader)->frameControl.frameType)
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Values of the Frame Type Sub-Field. ZigBee spec r17, Table 3.37. */
+typedef enum _NwkFrameTypeFlag_t
+{
+ NWK_FRAMETYPE_DATA = 0,
+ NWK_FRAMETYPE_COMMAND = 1,
+/**//**
+ * \brief Inter-PAN delivery modes
+ * ZigBee Smart Energy profile specification r15
+ * B.4 Frame Format, page 90
+ */
+ NWK_FRAMETYPE_INTERPAN = 3
+} NwkFrameTypeFlag_t;
+
+/** Values of the Discover Route Sub-Field. ZigBee spec r17, Table 3.38. */
+typedef enum _NwkDiscoverRouteFlag_t
+{
+ NWK_DISCOVER_ROUTE_SUPPRESS = 0,
+ NWK_DISCOVER_ROUTE_ENABLE = 1
+} NwkDiscoverRouteFlag_t;
+
+/** Values of the Multicast Mode Sub-Field. ZigBee spec r17, Table 3.39. */
+typedef enum _NwkMulticastMode_t
+{
+ NWK_FRAME_MULTICAST_NON_MEMBER_MODE = 0,
+ NWK_FRAME_MULTICAST_MEMBER_MODE = 1
+} NwkMulticastMode_t;
+
+/** NWK command frame identifiers. ZigBee spec r17, Table 3.40. */
+typedef enum _NwkCmdIdentifier_t
+{
+ NWK_CMD_ROUTE_REQUEST = 0x01, /**< ZigBee spec r17, 3.4.1 */
+ NWK_CMD_ROUTE_REPLY = 0x02, /**< ZigBee spec r17, 3.4.2 */
+ NWK_CMD_NETWORK_STATUS = 0x03, /**< ZigBee spec r17, 3.4.3 */
+ NWK_CMD_LEAVE = 0x04, /**< ZigBee spec r17, 3.4.4 */
+ NWK_CMD_ROUTE_RECORD = 0x05, /**< ZigBee spec r17, 3.4.5 */
+ NWK_CMD_REJOIN_REQUEST = 0x06, /**< ZigBee spec r17, 3.4.6 */
+ NWK_CMD_REJOIN_RESPONSE = 0x07, /**< ZigBee spec r17, 3.4.7 */
+ NWK_CMD_LINK_STATUS = 0x08, /**< ZigBee spec r17, 3.4.8 */
+ NWK_CMD_NETWORK_REPORT = 0x09, /**< ZigBee spec r17, 3.4.9 */
+ NWK_CMD_NETWORK_UPDATE = 0x0a /**< ZigBee spec r17, 3.4.10 */
+} NwkCmdIdentifier_t;
+
+/** Type of command id field. */
+typedef uint8_t NwkCommandIdField_t;
+
+/** Frame Control Field. ZigBee spec r17, 3.3.1.1, page 308. */
+/* The frame control field is 16 bits in length and contains
+ * information defining the frame type, addressing and sequencing
+ * fields and other control flags.*/
+BEGIN_PACK
+typedef struct PACK _NwkFrameControl_t
+{
+ LITTLE_ENDIAN_OCTET(3, (
+ /** The frame type sub-field is 2 bits in length and shall be set to one of
+ * the nonreserved values: NWK_FRAMETYPE_DATA or NWK_FRAMETYPE_COMMAND. */
+ NwkBitField_t frameType : 2,
+ /** The protocol version sub-field shall be set to a number reflecting
+ * the ZigBee NWK protocol version in use. The protocol version in use
+ * on a particular device shall be made available as the value of
+ * the NWK constant nwkcProtocolVersion. */
+ NwkBitField_t protocolVersion : 4,
+ /** The discover route sub-field may be used to control route discovery
+ * operations for the transit of this frame. */
+ NwkBitField_t discoverRoute : 2
+ ))
+ LITTLE_ENDIAN_OCTET(6, (
+ /** The multicast flag sub-field is 1 bit in length and has the value 0
+ * if the frame is a unicast or broadcast frame and the value 1 if it is
+ * a multicast frame. The multicast control field of the NWK header shall
+ * be present only if the multicast flag has the value 1.
+ * ZigBee spec r17, 3.3.1.1.4, page 309. */
+ NwkBitField_t multicastFlag : 1,
+ /** The security sub-field shall have a value of 1 if, and only if,
+ * the frame is to have NWK security operations enabled. If security for
+ * this frame is implemented at another layer or disabled entirely,
+ * it shall have a value of 0. */
+ NwkBitField_t security : 1,
+ /** The source route sub-field shall have a value of 1 if and only
+ * if a source route subframe is present in the NWK header.
+ * ZigBee spec r17, 3.3.1.1.6, page 308. */
+ NwkBitField_t sourceRoute : 1,
+ /** The destination IEEE address sub-field shall have a value of 1 if,
+ * and only if, the NWK header is to include the full IEEE address
+ * of the destination. */
+ NwkBitField_t dstExtAddr : 1,
+ /** The source IEEE address sub-field shall have a value of 1 if, and
+ * only if, the NWK header is to include the full IEEE address
+ * of the source device. */
+ NwkBitField_t srcExtAddr : 1,
+ NwkBitField_t reserved : 3
+ ))
+} NwkFrameControl_t;
+END_PACK
+
+/** Type of unaligned extended IEEE address. */
+BEGIN_PACK
+typedef union PACK _NwkFrameExtAddr_t
+{
+ ExtAddr_t value;
+ uint8_t raw[sizeof(ExtAddr_t)];
+} NwkFrameExtAddr_t;
+END_PACK
+
+/** The multicast control sub-field is 1 octet in length and shall only be
+ * present if the multicast flag sub-field has a value of 1. It is divided into
+ * three sub-fields as illustrated in ZigBee spec r17, Figure 3.7. */
+BEGIN_PACK
+typedef struct PACK _NwkFrameMulticastField_t
+{
+ LITTLE_ENDIAN_OCTET(3, (
+ /** The multicast mode sub-field indicates whether the frame is to be
+ * transmitted using member or non-member mode. Member mode is used to
+ * propagate multicasts between the devices that are members of
+ * the destination group. Nonmember mode is used to transmit a multicast
+ * frame from a device that is not a member of the multicast group to
+ * a device that is a member of the multicast group. */
+ NwkBitField_t mode : 2,
+ /** The nonmember radius sub-field indicates the range of a member mode
+ * multicast when relayed by devices that are not members of the
+ * destination group. */
+ NwkBitField_t nonMemberRadius : 3,
+ /** The maximum value of the NonmemberRadius sub-field for this frame.
+ * ZigBee spec r17, 3.3.1.8.3, page 312. */
+ NwkBitField_t maxNonMemberRadius : 3
+ ))
+} NwkFrameMulticastField_t;
+END_PACK
+
+/** Source route subframe format. ZigBee spec r18, Figure 3.8, page 316. */
+BEGIN_PACK
+typedef struct PACK _NwkSourceRouteSubframe_t
+{
+ /** The relay count sub-field indicates the number of relays contained in
+ * the relay list. ZigBee spec r18, 3.3.1.9.1, page 316. */
+ uint8_t relayCount;
+ /** The relay index sub-field indicates the index of the next relay in
+ * the relay list subfield to which the packet will be transmitted.
+ * ZigBee spec r18, 3.3.1.9.2, page 316. */
+ uint8_t relayIndex;
+ /** The relay list sub-field shall contain the list of relay addresses.
+ * ZigBee spec r18, 3.3.1.9.3, page 316. */
+ ShortAddr_t relayList[NWK_MAX_SOURCE_ROUTE];
+} NwkSourceRouteSubframe_t;
+END_PACK
+
+/** Type of parsed NWK header. */
+typedef struct _NwkParseHeader_t
+{
+ /** Pointer to a destination extended address in a original NWK header. */
+ const NwkFrameExtAddr_t *dstExt;
+ /** Pointer to a source extended address in a original NWK header. */
+ const NwkFrameExtAddr_t *srcExt;
+ /** Pointer to a multicast field. */
+ NwkFrameMulticastField_t *multicast;
+ /** Pointer to a source route subframe. */
+ NwkSourceRouteSubframe_t *sourceRouteSubframe;
+ /** Pointer to first octet of NWK payload. */
+ uint8_t *payload;
+ /** Size of NWK header in octets. */
+ NwkLength_t headerSize;
+ /** Size of NWK payload in octets. */
+ NwkLength_t payloadSize;
+ /** Source MAC short address. */
+ ShortAddr_t macSrcAddr;
+ /** Link quality indicator of received frame. */
+ Lqi_t lqi;
+ /** Received signal strength indication. */
+ Rssi_t rssi;
+ /** Extended address from auxilary header. It's address of previous hop. */
+ ExtAddr_t auxExtAddr;
+} NwkParseHeader_t;
+
+/** Type of a NWK header, which comprises frame control, addressing
+ * and sequencing information. */
+BEGIN_PACK
+typedef struct PACK _NwkFrameHeader_t
+{
+ /** The frame control field shall be formatted as illustrated in
+ * ZigBee spec r17, Figure 3.6. */
+ NwkFrameControl_t frameControl;
+ /** The destination address field shall always be present and shall be 2
+ * octets in length. If the multicast flag sub-field of the frame control
+ * field has the value 0, the destination address field shall hold the 16-bit
+ * network address of the destination device or a broadcast address
+ * (see Table 3.54). If the multicast flag sub-field has the value 1,
+ * the destination address field shall hold the 16-bit Group ID of the
+ * destination multicast group. ZigBee spec r17, 3.3.1.2, page 310. */
+ ShortAddr_t dstAddr;
+ /** The source address field shall always be present. It shall always be 2
+ * octets in length and shall hold the network address of the source device of
+ * the frame. ZigBee spec r17, 3.3.1.3, page 310. */
+ ShortAddr_t srcAddr;
+ /** The radius field shall always be present. It will be 1 octet in length and
+ * specifies the range of a radius-limited transmission. The field shall be
+ * decremented by 1 by each receiving device. */
+ NwkRadius_t radius;
+ /** The sequence number field is present in every frame and is 1 octet
+ * in length. The sequence number value shall be incremented by 1 with each
+ * new frame transmitted */
+ NwkSequenceNumber_t sequenceNumber;
+ union PACK
+ {
+ struct PACK
+ {
+ /** The destination IEEE address field, if present, contains the 64-bit
+ * IEEE address corresponding to the 16-bit network address contained in
+ * the destination address field of the NWK header.
+ * ZigBee spec r17, 3.3.1.6, page 310. */
+ NwkFrameExtAddr_t dstExt;
+ /** The source IEEE address field, if present, contains the 64-bit
+ * IEEE address corresponding to the 16-bit network address contained
+ * in the source address field. */
+ NwkFrameExtAddr_t srcExt;
+ uint8_t payload[1];
+ } dst_src;
+ struct PACK
+ {
+ NwkFrameExtAddr_t srcExt;
+ uint8_t payload[1];
+ } src;
+ struct PACK
+ {
+ /** The multicast control sub-field is 1 octet in length and shall only
+ * be present if the multicast flag sub-field has a value of 1. It is
+ * divided into three sub-fields as illustrated in ZigBee spec r17,
+ * Figure 3.7. */
+ NwkFrameMulticastField_t control;
+ uint8_t payload[1];
+ } multicast;
+ struct PACK
+ {
+ NwkFrameExtAddr_t dstExt;
+ NwkFrameExtAddr_t srcExt;
+ NwkFrameMulticastField_t control;
+ uint8_t payload[1];
+ } dst_src_multicast;
+ /** First octet of NWK payload. */
+ uint8_t payload[1];
+ } field;
+} NwkFrameHeader_t;
+END_PACK
+
+/** The beacon payload shall contain the information shown in ZigBee spec r17,
+ * Table 3.56. This enables the NWK layer to provide additional information
+ * to new devices that are performing network discovery and allows these new
+ * devices to more efficiently select a network and a particular neighbor
+ * to join. */
+BEGIN_PACK
+typedef struct PACK _NwkBeaconPayload_t
+{
+ /** This field identifies the network layer protocols in use and,
+ * for purposes of this specification, shall always be set to 0,
+ * indicating the ZigBee protocols. */
+ uint8_t protocolId;
+ struct PACK
+ {
+ LITTLE_ENDIAN_OCTET(2, (
+ /** A ZigBee stack profile identifier. */
+ NwkBitField_t stackProfile :4,
+ /** The version of the ZigBee protocol. */
+ NwkBitField_t nwkProtocolVersion :4
+ ))
+ LITTLE_ENDIAN_OCTET(4, (
+ NwkBitField_t reserved :2,
+ /** This value is set to 1 if this device is capable of accepting join
+ * requests from router capable devices and is set to 0 otherwise. */
+ NwkBitField_t routerCapacity :1,
+ /** The network depth of this device. A value of 0x00 indicates that
+ * this device is the ZigBee coordinator for the network. */
+ NwkBitField_t deviceDepth :4,
+ /** This value is set to 1 if the device is capable of accepting join
+ * requests from end devices seeking to join the network and is set
+ * to 0 otherwise. */
+ NwkBitField_t endDeviceCapacity :1
+ ))
+ } field;
+ /** The globally unique ID for the PAN of which the beaconing
+ * device is a member. */
+ ExtPanId_t nwkExtendedPanid;
+ /** This value indicates the difference in time, measured in symbols,
+ * between the beacon transmission time of the device and the beacon
+ * transmission time of its parent. */
+ uint8_t txOffset[3];
+ /** This field reflects the value of nwkUpdateId from the NIB. */
+ NwkUpdateId_t updateId;
+} NwkBeaconPayload_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/******************************************************************************
+ \brief Clear frame, then fill it with commonly used fields.
+
+ \param[in] nwkHeader - pointer to header.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareCommonFrame(NwkFrameHeader_t *const nwkHeader);
+
+/******************************************************************************
+ \brief Parse floating fields of frame.
+
+ \param[in] nwkHeader - header to parse.
+ \param[in] parse - structure with pointer to frame fields,
+ NULL - if field is not present, correct pointer otherwise.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkParseHeader(NwkFrameHeader_t *const nwkHeader,
+ NwkParseHeader_t *const parse);
+
+/**************************************************************************//**
+ \brief Gets maximum default radius. It's 2*maxDepth or 255.
+
+ \return 2 * maxDepth if maxDepth less 128 otherwise 255.
+ ******************************************************************************/
+NWK_PRIVATE NwkRadius_t nwkGetDefaultRadius(void);
+
+#endif /* _NWK_FRAME_H */
+/** eof nwkFrame.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkIB.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkIB.h
new file mode 100644
index 00000000..3db5b413
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkIB.h
@@ -0,0 +1,178 @@
+/**************************************************************************//**
+ \file nwkIB.h
+
+ \brief Network information base.
+
+ \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:
+ 2009-05-01 M. Gekk - Created.
+ Last change:
+ $Id: nwkIB.h 18296 2011-08-19 12:29:05Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_IB_H
+#define _NWK_IB_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <types.h>
+#include <configServer.h>
+#include <nwkSystem.h>
+#include <mac.h>
+#include <nwkCommon.h>
+#include <nwkSecurity.h>
+#include <nwkSystem.h>
+#include <nwkFrame.h>
+#include <nlmeReset.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+typedef struct _NIB_t
+{
+ /*** Attributes are initialized by NWK-layer. ***/
+ /** A network address of parent node. */
+ ShortAddr_t parentNetworkAddress;
+ /** The count of total transmissions. */
+ uint16_t transmitCounter;
+ /** The count of transmissions with failures. */
+ uint16_t transmitFailureCounter;
+ /** The address of the designated network channel manager function. */
+ ShortAddr_t managerAddr;
+ /** This field shall contain the device capability information established at
+ * network joining time. */
+ MAC_CapabilityInf_t capabilityInformation;
+ /** The tree depth of the neighbor device. A value of 0x00 indicates that
+ * the device is the ZigBee coordinator for the network. */
+ NwkDepth_t depth;
+ /** A sequence number used to identify outgoing frames */
+ NwkSequenceNumber_t sequenceNumber;
+ /** The total delivery time for a broadcast transmission, i.e. the time
+ * required for a broadcast to be delivered to every device in the network. */
+ uint32_t networkBroadcastDeliveryTime;
+ /** The value identifying a snapshot of the network settings with which this
+ * node is operating with. */
+ NwkUpdateId_t updateId;
+ /** Network rejoin permissions, by default end devices and routers can rejoin. */
+ NWK_RejoinPermit_t rejoinPermit;
+
+ struct {
+ /** This field is used by MAC layer. */
+ NwkLength_t header[MAC_MAX_BEACON_HEADER_LENGTH];
+ /** The beacon payload contain the information which enables the NWK layer
+ * to provide additional information to new devices that are performing
+ * network discovery and allows these new devices to more efficiently select
+ * a network and a particular neighbor to join. */
+ NwkBeaconPayload_t payload;
+ } beacon;
+ /*** Attributes are initialized in Config Server. ***/
+ /** The type of the device:
+ * - 0x00 - zigbee coordinator
+ * - 0x01 - zigbee router
+ * - 0x02 - zigbee end device */
+ DeviceType_t deviceType;
+ /** A value that determines the method used to assign addresses:
+ * - 0x00 = use distributed address allocation
+ * - 0x01 = reserved
+ * - 0x02 = use stochastic address allocation. */
+ NWK_AddrAlloc_t addrAlloc;
+ /** The current route symmetry setting. 1 means that routes are considered to
+ * be comprised of symmetric links. Backward and forward routes are created
+ * during one-route discovery and they are identical. 0 indicates that routes
+ * are not consider to be comprised of symmetric links. Only the forward route
+ * is stored during route discovery.*/
+ bool symLink;
+ /** Determines whether or not the static addressing mode will be used.
+ * If set to '1' then the device must use a static network address
+ * otherwise, the stochastic addressing mode will be employed. */
+ bool uniqueAddr;
+ /** The identifier of the ZigBee stack profile in use for this device. */
+ StackProfile_t stackProfile;
+ /** The version of the ZigBee NWK protocol in the device. */
+ uint8_t protocolVersion;
+ /** The depth a device can have. */
+ NwkDepth_t maxDepth;
+ /** Route to neighbor directly only if the incoming cost is less than given
+ * threshold. */
+ NwkLinkCost_t maxNeighborRouteCost;
+ /** RF channel page */
+ uint8_t channelPage;
+ /** Number of RF channel */
+ Channel_t logicalChannel;
+ /** The 16-bit address that the device uses to communicate with the PAN. */
+ ShortAddr_t networkAddress;
+ /** The short (16-bit) pan identifier of a zigbee network. */
+ PanId_t panId;
+ /** The Extended PAN Identifier for the PAN of which the device is a member.
+ * The value 0x0000000000000000 means the Extended PAN Identifier is unknown.
+ **/
+ ExtPanId_t extendedPanId;
+ /** The number of routers any one device is allowed to have as children. */
+ NwkChildCount_t maxRouters;
+ /** The number of end devices any one device is allowed to have as children.
+ **/
+ NwkChildCount_t maxEndDevices;
+#if defined _SECURITY_
+ /** Pointer to the security information base. */
+ NWK_SecurityIB_t securityIB;
+#endif /* _SECURITY_ */
+} NIB_t;
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Reset the network information base.
+
+ \param[in] powerFailureControl - stack restoring after power failure control bitfield;
+ affects on initialization procedure.
+ \param[in] capabilityInformation - this parameter shall contain the device
+ capability information. See ZigBee spec r18, Table 3.47, page 356.
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetNib(const NWK_PowerFailureControl_t powerFailureControl,
+ const MAC_CapabilityInf_t capabilityInformation);
+
+/**************************************************************************//**
+ \brief Update beacon payload depending on NIB values
+ ******************************************************************************/
+NWK_PRIVATE void nwkUpdateBeaconPayload(void);
+
+/**************************************************************************//**
+ \brief Set depth in NIB and update cSkips.
+
+ \param[in] depth - new value of depth.
+ ******************************************************************************/
+NWK_PRIVATE void nwkSetDepth(NwkDepth_t depth);
+
+/**************************************************************************//**
+ \brief Reload parameters from the config server.
+ ******************************************************************************/
+NWK_PRIVATE void nwkReloadNibFromConfigServer(void);
+
+#if defined _ROUTER_ || defined _ENDDEVICE_
+/**************************************************************************//**
+ \brief Set a network address of parent device.
+
+ \param[in] addr - short address of parent device.
+ ******************************************************************************/
+NWK_PRIVATE void nwkSetParentShortAddr(ShortAddr_t addr);
+
+#endif /* _ROUTER_ or _ENDDEVICE_ */
+
+#endif /* _NWK_IB_H */
+/** eof nwkIB.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkJoinInd.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkJoinInd.h
new file mode 100644
index 00000000..e2cddee0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkJoinInd.h
@@ -0,0 +1,209 @@
+/**************************************************************************//**
+ \file nwkJoinInd.h
+
+ \brief Join indication header file.
+
+ \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:
+ 2007-06-14 S. Vladykin - Created.
+ 2008-12-10 M. Gekk - Optimization of NWK memory.
+ 2009-02-13 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkJoinInd.h 19021 2011-10-26 12:36:59Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_JOININD_H
+#define _NWK_JOININD_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <types.h>
+#include <mac.h>
+#include <nldeData.h>
+#include <nwkNeighbor.h>
+#include <nwkFrame.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_JOIN_RESP_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, nwkPrepareJoinRespTx, \
+ nwkConfirmJoinRespTx, true}
+
+#define NWK_ADDR_CONFLICT_JOIN_RESP_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, nwkPrepareJoinRespTx, \
+ nwkConfirmAddrConflictJoinRespTx, true}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Payload of rejoin response command */
+BEGIN_PACK
+typedef struct PACK
+{
+ NwkCommandIdField_t commandId;
+ /** If the rejoin was successful, this two-octet field contains the new
+ * network address assigned to the rejoining device. If the rejoin was
+ * not successful, this field contains the broadcast address (0xffff).
+ * ZigBee spec r17, 3.4.7.3.1. */
+ ShortAddr_t networkAddr;
+ /** This field shall contain one of the nonreserved association status values
+ **/
+ uint8_t rejoinStatus;
+} NwkRejoinRespCmd_t;
+END_PACK
+
+/** Service fields of rejoin response */
+typedef struct _NwkRejoinResp_t
+{
+ ExtAddr_t extendedAddr;
+ ShortAddr_t newNetworkAddr;
+ ShortAddr_t oldNetworkAddr;
+ uint8_t status;
+ bool secureJoin;
+} NwkRejoinResp_t;
+
+/** States of join indication object */
+typedef enum _NwkJoinIndObjState_t
+{
+ NWK_JOIN_IND_FREE_STATE = 0x00,
+ NWK_JOIN_IND_FIRST_STATE = 0x01,
+ NWK_JOIN_IND_PENDING_STATE = NWK_JOIN_IND_FIRST_STATE,
+ NWK_JOIN_IND_ASSOC_INDICATE_STATE = 0x02,
+ NWK_JOIN_IND_REJOIN_INDICATE_STATE = 0x03,
+ NWK_JOIN_IND_SEND_REJOIN_RESPONSE_STATE = 0x04,
+ NWK_JOIN_IND_SEND_ASSOC_RESPONSE_STATE = 0x05,
+ NWK_JOIN_IND_LAST_STATE
+} NwkJoinIndObjState_t;
+
+/** Join indication object */
+typedef struct _NwkJoinIndObj_t
+{
+ NwkJoinIndObjState_t state;
+ MAC_CapabilityInf_t capabilityInformation;
+ union
+ {
+ MAC_AssociateResp_t assoc;
+ NwkRejoinResp_t rejoin;
+ } resp;
+} NwkJoinIndObj_t;
+
+/** Array of join indication objects */
+typedef struct _NwkJoinInd_t
+{
+ uint8_t totalObjects;
+ NwkJoinIndObj_t *objects;
+} NwkJoinInd_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _ROUTER_ || defined _COORDINATOR_
+/**************************************************************************//**
+ \brief Rejoin request has been received.
+
+ \param[in] payload - command payload pointer.
+ \param[in] header - command parameters.
+ \param[in] parse - source and destination extended address pointers.
+
+ \return 'true' if continue processing of command packet otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkRejoinRequestFrameInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+#if defined _RESOLVE_ADDR_CONFLICT_
+/**************************************************************************//**
+ \brief Reporting of end device address conflict.
+
+ \param[in] child - pointer to child's entry in the neighbor table.
+ ******************************************************************************/
+NWK_PRIVATE
+ void nwkSendUnsolicitedRejoinResponse(const NwkNeighbor_t *const child);
+#endif /* _RESOLVE_ADDR_CONFLICT_ */
+
+/**************************************************************************//**
+ \brief Task handler of join indication component
+ ******************************************************************************/
+NWK_PRIVATE void nwkJoinIndTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Reset the join indication component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetJoinInd(void);
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the rejoin response command.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareJoinRespTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of rejoin response command transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of rejoin response transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmJoinRespTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/**************************************************************************//**
+ \brief Adding child into table.
+ All required fields are filled. Address is allocated.
+
+ \param[in] extAddr - extended IEEE address of child.
+ \param[in] shortAddr - address that device selected for itself,
+ trying to keep it.
+ \param[in] capability - MAC capability information.
+
+ \return NULL if fail, or pointer to created record otherwise.
+ ******************************************************************************/
+NWK_PRIVATE NwkNeighbor_t* nwkAddChild(const ExtAddr_t extAddr,
+ ShortAddr_t shortAddr, const MAC_CapabilityInf_t capability);
+
+
+/******************************************************************************
+ \brief nwkJoinInd idle checking.
+
+ \return true, if nwkJoinInd performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkJoinIndIsIdle(void);
+
+/**************************************************************************//**
+ \brief Confirmation of address conflict rejoin response transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of rejoin response transmission.
+ ******************************************************************************/
+#if defined _RESOLVE_ADDR_CONFLICT_
+NWK_PRIVATE
+ void nwkConfirmAddrConflictJoinRespTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+#else
+#define nwkConfirmAddrConflictJoinRespTx NULL
+#endif /* _RESOLVE_ADDR_CONFLICT_ */
+
+#else /* _ROUTER_ or _COORDINATOR_ are not defined. */
+
+#define nwkRejoinRequestFrameInd NULL
+#define nwkJoinIndTaskHandler NULL
+#define nwkResetJoinInd() (void)0
+#define nwkPrepareJoinRespTx NULL
+#define nwkConfirmJoinRespTx NULL
+#define nwkConfirmAddrConflictJoinRespTx NULL
+#define nwkJoinIndIsIdle NULL
+
+#endif /* _ROUTER_ or _COORDINATOR_ */
+#endif /* _NWK_JOININD_H */
+/** eof nwkJoinInd.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkJoinReq.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkJoinReq.h
new file mode 100644
index 00000000..d9875567
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkJoinReq.h
@@ -0,0 +1,172 @@
+/**************************************************************************//**
+ \file nwkJoinReq.h
+
+ \brief Join request header file.
+
+ \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:
+ 2007-06-14 S. Vladykin - Created.
+ 2008-12-10 M. Gekk - Optimization of NWK memory.
+ 2009-02-09 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkJoinReq.h 17448 2011-06-09 13:53:59Z ataradov $
+******************************************************************************/
+#if !defined _NWK_JOINREQ_H
+#define _NWK_JOINREQ_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <mac.h>
+#include <nlmeJoin.h>
+#include <nldeData.h>
+#include <nlmeNetworkDiscovery.h>
+#include <nwkNeighbor.h>
+#include <nwkFrame.h>
+#include <appTimer.h>
+#include <nwkAddress.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_JOIN_REQ_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, nwkPrepareJoinReqTx, nwkConfirmJoinReqTx, true}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the join request component. */
+typedef enum _NwkJoinReqState_t
+{
+ JOIN_REQ_IDLE_STATE = 0xDA,
+ JOIN_REQ_FIRST_STATE = 0x21,
+ JOIN_REQ_GET_ELEM_FROM_QUEUE = JOIN_REQ_FIRST_STATE,
+ JOIN_REQ_CONFIRM_STATE = 0x22,
+ JOIN_REQ_ASSOCIATION_WAIT_STATE = 0x23,
+ JOIN_REQ_SET_BEACON_PAYLOAD_STATE = 0x24,
+ JOIN_REQ_SET_BEACON_PAYLOAD_LEN_STATE = 0x25,
+ JOIN_REQ_SET_RX_ON_WHEN_IDLE_STATE = 0x26,
+ JOIN_REQ_RX_ENABLE_STATE = 0x27,
+ JOIN_REQ_PKT_PREPARE_AND_SEND_STATE = 0x28,
+ JOIN_REQ_SET_PANID_STATE = 0x29,
+ JOIN_REQ_SET_CHANNEL_STATE = 0x2A,
+ JOIN_REQ_GET_RESPONSE_WAIT_TIME_STATE = 0x2B,
+ JOIN_REQ_WAIT_REJOIN_RESPONSE_DECRYPT = 0x2C,
+ JOIN_REQ_REJOIN_RESPONSE_WAITING_STATE = 0x2D,
+ JOIN_REQ_SET_SHORT_ADDRESS_STATE = 0x2E,
+ JOIN_REQ_SET_COORD_SHORT_ADDR_STATE = 0x2F,
+ JOIN_REQ_SET_COORD_EXT_ADDR_STATE = 0x30,
+ JOIN_REQ_SET_SHORT_ADDRESS_ONLY_STATE = 0x31,
+ JOIN_REQ_NETWORK_DISCOVERY_STATE = 0x32,
+ JOIN_REQ_SET_FIRST_SHORT_ADDRESS_STATE = 0x33,
+ JOIN_REQ_SET_TRANSACTION_TIME_STATE = 0x34,
+ JOIN_REQ_LAST_STATE
+} NwkJoinReqState_t;
+
+/** Format of rejoin command payload. ZigBee spec r17, 3.4.6.3, page 329. */
+/** The NWK frame payload contains a command identifier field and a capability
+ * information field. The command frame identifier shall contain the value
+ * indicating a rejoin request command frame. */
+BEGIN_PACK
+typedef struct PACK
+{
+ NwkCommandIdField_t commandId;
+ /** This one-octet field has the format of the capability information field
+ * in the association request command. ZigBee spec r17, 3.4.6.3.1, page 329. */
+ MAC_CapabilityInf_t capability;
+} NwkRejoinReqCmd_t;
+END_PACK
+
+/** Internal parameters of the join request component. */
+typedef struct _NwkJoinReq_t
+{
+ NwkJoinReqState_t state;
+ QueueDescriptor_t queue;
+ NWK_JoinReq_t *joinReq;
+ NwkNeighbor_t *currentCandidateRouter;
+ uint8_t attempNum;
+ HAL_AppTimer_t timer;
+ MAC_PollReq_t pollReq;
+ union
+ {
+ MAC_AssociateReq_t macAssoc;
+ MAC_SetReq_t macSet;
+ MAC_GetReq_t macGet;
+ MAC_RxEnableReq_t macRxEnable;
+ NWK_NetworkDiscoveryReq_t netDisc;
+ } req;
+} NwkJoinReq_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _ROUTER_ || defined _ENDDEVICE_
+/**************************************************************************//**
+ \brief Action when command received.
+
+ \param[in] payload - a payload of network join request command.
+ \param[in] header - pointer to raw NWK header.
+ \param[in] parse - parsed header fields.
+
+ \return 'true' if continue processing of command packet otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkRejoinResponseFrameInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+/**************************************************************************//**
+ \brief Reset the join request component
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetJoinReq(void);
+
+/**************************************************************************//**
+ \brief Task handler of NWK join request component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkJoinReqTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the join request command.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareJoinReqTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of join request command transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of join request transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmJoinReqTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/******************************************************************************
+ \brief nwkJoinReq idle checking.
+
+ \return true, if nwkJoinReq performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkJoinReqIsIdle(void);
+
+#else /* _ROUTER_ or _ENDDEVICE_ */
+
+#define nwkRejoinResponseFrameInd NULL
+#define nwkResetJoinReq() (void)0
+#define nwkJoinReqTaskHandler NULL
+#define nwkPrepareJoinReqTx NULL
+#define nwkConfirmJoinReqTx NULL
+#define nwkJoinReqIsIdle NULL
+
+#endif /* _ROUTER_ or _ENDDEVICE_ */
+#endif /* _NWK_JOINREQ_H */
+/** eof nwkJoinReq.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLeave.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLeave.h
new file mode 100644
index 00000000..a66a10d7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLeave.h
@@ -0,0 +1,200 @@
+/**************************************************************************//**
+ \file nwkLeave.h
+
+ \brief Network leave header file.
+
+ \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:
+ 2007-06-27 V. Panov - Created.
+ 2009-05-26 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkLeave.h 18970 2011-10-21 12:48:41Z mgekk $
+******************************************************************************/
+#if !defined _NWK_LEAVE_H
+#define _NWK_LEAVE_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <appFramework.h>
+#include <mac.h>
+#include <nwkNeighbor.h>
+#include <nwkFrame.h>
+#include <nldeData.h>
+#include <nlmeLeave.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Size of NWK leave command payload. */
+#define NWK_LEAVE_CMD_PAYLOAD_SIZE 2U
+/** Total size of self leave command - NWK header + payload */
+#define NWK_LEAVE_ITSELF_CMD_SIZE 18U
+/** Total size of child leave command - NWK header + payload */
+#define NWK_LEAVE_CHILD_CMD_SIZE 26U
+/** Parameters of leave command transmission. */
+#define NWK_LEAVE_ITSELF_TX_PARAMETERS \
+ {NWK_TX_DELAY_BROADCAST, nwkPrepareLeaveItselfTx,\
+ nwkConfirmLeaveItselfTx, true}
+#define NWK_LEAVE_CHILD_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, nwkPrepareLeaveChildTx,\
+ nwkConfirmLeaveChildTx, true}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of NLME-LEAVE component */
+typedef enum _NwkLeaveState_t
+{
+ NWK_LEAVE_IDLE_STATE = 0xE6,
+ NWK_LEAVE_FIRST_STATE = 0x11,
+ NWK_LEAVE_BEGIN_STATE = NWK_LEAVE_FIRST_STATE,
+ NWK_LEAVE_SELF_SEND_CMD_STATE = 0x12,
+ NWK_LEAVE_SELF_WAIT_CONFIRM_STATE = 0x13,
+ NWK_LEAVE_SELF_RESET_MAC_STATE = 0x14,
+ NWK_LEAVE_CHILD_SEND_CMD_STATE = 0x15,
+ NWK_LEAVE_CHILD_WAIT_CONFIRM_STATE = 0x16,
+ NWK_LEAVE_CONFIRM_STATE = 0x17,
+ NWK_LEAVE_LAST_STATE
+} NwkLeaveState_t;
+
+/** Leave Command Options Field */
+typedef enum _NwkLeaveCommandOptionsField_t
+{
+ /** The Rejoin sub-field is a single-bit field. If the value of this
+ * sub-field is 1, the device that is leaving from its current parent
+ * will rejoin the network. If the value of this sub-field is 0, the device
+ * will not rejoin the network. ZigBee spec r17, 3.4.4.3.1.1, page 325. */
+ NWK_LEAVE_REJOIN = 0x20,
+ /** The request sub-field is a single-bit field. If the value of this
+ * sub-field is 1, then the leave command frame is a request for another
+ * device to leave the network. If the value of this sub-field is 0,
+ * then the leave command frame is an indication that the sending device
+ * plans to leave the network. ZigBee spec r17, 3.4.4.3.1.2, page 326. */
+ NWK_LEAVE_REQUEST = 0x40,
+ /** The remove children sub-field is a single-bit field. If this sub-field
+ * has a value of 1, then the children of the device that is leaving
+ * the network will also be removed. If this sub-field has a value of 0,
+ * then the children of the device leaving the network will not be removed.
+ * ZigBee spec r17, 3.4.4.3.1.3, page 326. */
+ NWK_LEAVE_REMOVE_CHILDREN = 0x80
+} NwkLeaveCommandOptionsField_t;
+
+/** Internal variables of NLME-LEAVE component. */
+typedef struct _NwkLeave_t
+{
+ /** Finite-state machine */
+ NwkLeaveState_t state;
+ /** Queue of requests from upper layer */
+ QueueDescriptor_t queue;
+ /** Number of children which has been excluded from a network. */
+ NwkSizeOfNeighborTable_t leaveChildCount;
+ union
+ {
+ /** MLME-RESET request primitive's parameters. */
+ MAC_ResetReq_t macReset;
+ struct
+ {
+ /** The short address of the leaved child. */
+ ShortAddr_t shortAddr;
+ /** The extended address of the leaved child. */
+ ExtAddr_t extAddr;
+ /** The bits indicate the transmission options for the MAC frame. */
+ MAC_TxOptions_t txOptions;
+ } child;
+ } param;
+#if defined _ROUTER_ && defined _NWK_DISTRIBUTED_ADDRESSING_
+ /** The leave indication component is busy or not. */
+ bool leaveIndBusy;
+ /** Leave request which is used by the leave indication component. */
+ NWK_LeaveReq_t leaveReq;
+#endif /* _ROUTER_ and _NWK_DISTRIBUTED_ADDRESSING_ */
+} NwkLeave_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Main task handler of NLME-LEAVE component
+ ******************************************************************************/
+NWK_PRIVATE void nwkLeaveTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Reset NLME-LEAVE component
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetLeave(void);
+
+/**************************************************************************//**
+ \brief Action when a leave command is received.
+
+ \param[in] payload - pointer to NPDU of NWK leave command.
+ \param[in] header - NWK header.
+ \param[in] parse - parsed header fields.
+ \return 'true' if continue processing of command packet otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkLeaveFrameInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the leave itself command.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareLeaveItselfTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of the leave itself command transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of the leave command transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmLeaveItselfTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+#if defined _ROUTER_ || defined _COORDINATOR_
+/**************************************************************************//**
+ \brief Prepare header and payload of the leave child command.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareLeaveChildTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of the leave child command transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of the leave command transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmLeaveChildTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/******************************************************************************
+ \brief nwkLeaveReq idle checking.
+
+ \return true, if nwkLeaveReq performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkLeaveReqIsIdle(void);
+
+#else /* _ROUTER_ or _COORDINATOR_ */
+
+#define nwkPrepareLeaveChildTx NULL
+#define nwkConfirmLeaveChildTx NULL
+#define nwkLeaveReqIsIdle NULL
+
+#endif /* _ROUTER_ or _COORDINATOR_ */
+#endif /* _NWK_LEAVE_H */
+/** eof nwkLeave.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLinkStatus.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLinkStatus.h
new file mode 100644
index 00000000..534672f5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLinkStatus.h
@@ -0,0 +1,194 @@
+/**************************************************************************//**
+ \file nwkLinkStatus.h
+
+ \brief The data structures concerning processing of LinkStatus command
+
+ \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:
+ 2007-08-01 V. Panov - Created.
+ 2009-04-10 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkLinkStatus.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+/**//**
+ * The link status command frame allows neighboring routers to communicate
+ * their incoming link costs to each other as described in sub-clause 3.6.3.4.
+ * Link status frames are transmitted as one-hop broadcasts without retries.
+ * ZigBee spec r17, 3.4.8, page 330.
+ * */
+#if !defined _NWK_LINK_STATUS_H
+#define _NWK_LINK_STATUS_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkSystem.h>
+#include <appTimer.h>
+#include <appFramework.h>
+#include <nwkCommon.h>
+#include <nldeData.h>
+#include <nwkFrame.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_LINK_STATUS_TX_PARAMETERS \
+ {NWK_TX_DELAY_LINK_STATUS, nwkPrepareLinkStatusTx,\
+ nwkConfirmLinkStatusTx, true}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the link status component. */
+typedef enum _NwkLinkStatusState_t
+{
+ NWK_LINK_STATUS_IDLE_STATE = 0x00,
+ NWK_LINK_STATUS_FIRST_STATE = 0x01,
+ NWK_LINK_STATUS_WAIT_STATE = NWK_LINK_STATUS_FIRST_STATE,
+ NWK_LINK_STATUS_SEND_STATE = 0x02,
+ NWK_LINK_STATUS_LAST_STATE
+} NwkLinkStatusState_t;
+
+/** Internal parameters of the link status component. */
+typedef struct _NwkLinkStatus_t
+{
+ /** The timer of counting of the link status period. */
+ HAL_AppTimer_t timer;
+ NwkLinkStatusState_t state; /**< Finite-state machine */
+} NwkLinkStatus_t;
+
+BEGIN_PACK
+/** Command Options Field*/
+typedef struct PACK _NwkLinkStatusOptions_t
+{
+ LITTLE_ENDIAN_OCTET(4, (
+ /** This field indicates the number of link status entries */
+ NwkBitField_t entryCount : 5,
+ /** The first frame sub-field is set to 1 if this is the first frame of
+ * the sender's link status.*/
+ NwkBitField_t firstFrame : 1,
+ /** The last frame sub-field is set to 1 if this is the last frame of
+ * the sender's link status. */
+ NwkBitField_t lastFrame : 1,
+ NwkBitField_t reserved : 1
+ ))
+} NwkLinkStatusOptions_t;
+
+/** Link Status Entry. ZigBee spec r17, 3.4.8.3.2 */
+typedef struct PACK _NwkLinkStatusEntry_t
+{
+ LITTLE_ENDIAN_OCTET(4, (
+ /** The incoming cost field contains the device's estimate of the link cost
+ * for the neighbor, which is a value between 1 and 7.*/
+ NwkBitField_t incomingCost : 3,
+ NwkBitField_t reserved1 : 1,
+ /** The outgoing cost field contains the value of the outgoing cost field
+ * from the neighbor table.*/
+ NwkBitField_t outgoingCost : 3,
+ NwkBitField_t reserved2 : 1
+ ))
+} NwkLinkStatusEntry_t;
+
+/** Link status item. ZigBee spec r17, figure 3.23. */
+typedef struct PACK _NwkLinkStatusItem_t
+{
+ /** Each link status entry contains the network address of a router neighbor.
+ **/
+ ShortAddr_t addr;
+ /* Link Status Entry. */
+ NwkLinkStatusEntry_t linkStatus;
+} NwkLinkStatusItem_t;
+
+/** The NWK command payload of the link status command.
+ * ZigBee spec r17, figure 3.21. */
+typedef struct PACK _NwkLinkPayload_t
+{
+ NwkLinkStatusOptions_t options;
+ NwkLinkStatusItem_t table[1];
+} NwkLinkStatusPayload_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined(_ROUTER_) || defined(_COORDINATOR_)
+
+/******************************************************************************
+ \brief Start HAL timer for periodically send the link status.
+
+ A ZigBee router or coordinator shall periodically send a link status
+ command every nwkLinkStatusPeriod seconds. This function start the app timer.
+ ******************************************************************************/
+NWK_PRIVATE void nwkStartLinkStatusTimer(void);
+
+/******************************************************************************
+ \brief Stop HAL timer for periodically send the link status.
+
+ A ZigBee router or coordinator shall periodically send a link status
+ command every nwkLinkStatusPeriod seconds. This function stops the app timer.
+ ******************************************************************************/
+NWK_PRIVATE void nwkStopLinkStatusTimer(void);
+
+/**************************************************************************//**
+ \brief Reset the link status component
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetLinkStatus(void);
+
+/**************************************************************************//**
+ \brief Action when link status command received
+
+ \param[in] payload - command payload.
+ \param[in] header - raw NWK header.
+ \param[in] parse - parsed header fields.
+ \return 'true' if continue processing of command packet otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkLinkStatusInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the link status command.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareLinkStatusTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of link status command transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of link status transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmLinkStatusTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/******************************************************************************
+ \brief nwkLinkStatus idle checking.
+
+ \return true, if nwkLinkStatus performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkLinkStatusIsIdle(void);
+
+#else /* _ROUTER_ or _COORDINATOR_ */
+
+#define nwkResetLinkStatus() (void)0
+#define nwkStartLinkStatusTimer() (void)0
+#define nwkStopLinkStatusTimer() (void)0
+#define nwkLinkStatusInd NULL
+#define nwkPrepareLinkStatusTx NULL
+#define nwkConfirmLinkStatusTx NULL
+#define nwkLinkStatusIsIdle NULL
+
+#endif /* _ROUTER_ or _COORDINATOR_ */
+#endif /* _NWK_LINK_STATUS_H */
+/** eof nwkLinkStatus.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLoopback.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLoopback.h
new file mode 100644
index 00000000..91710e26
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkLoopback.h
@@ -0,0 +1,87 @@
+/**************************************************************************//**
+ \file nwkLoopback.h
+
+ \brief Interface of network loopback.
+
+ \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:
+ 2009-10-06 Max Gekk - Created.
+ Last change:
+ $Id: nwkLoopback.h 17923 2011-07-08 14:13:30Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_LOOPBACK_H
+#define _NWK_LOOPBACK_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <nldeData.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the loopback component. */
+typedef enum _NwkLoopbackState_t
+{
+ NWK_LOOPBACK_UNKNOWN_STATE = 0x00,
+ NWK_LOOPBACK_FIRST_STATE = 0x8e,
+ NWK_LOOPBACK_IDLE_STATE = NWK_LOOPBACK_FIRST_STATE,
+ NWK_LOOPBACK_REQUEST_PROCESSING_STATE = 0x8f,
+ NWK_LOOPBACK_WAIT_PACKET_STATE = 0x90,
+ NWK_LOOPBACK_LAST_STATE
+} NwkLoopbackState_t;
+
+/** Internal parameters of the loopback component. */
+typedef struct _NwkLoopback_t
+{
+ QueueDescriptor_t queue; /**< Queue of requests from upper layer */
+ NwkLoopbackState_t state; /**< Finite-state machine */
+} NwkLoopback_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+
+/**************************************************************************//**
+ \brief The main task handler of the network loopback component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkLoopbackTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Handler of free packet indication.
+ ******************************************************************************/
+NWK_PRIVATE void nwkLoopbackFreePacketInd(void);
+
+/**************************************************************************//**
+ \brief Reset the network loopback component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetLoopback(void);
+
+/******************************************************************************
+ \brief nwkLoopback idle checking.
+
+ \return true, if nwkLoopback performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkLoopbackIsIdle(void);
+
+/**************************************************************************//**
+ \brief Checks, if outgoing packet should be indicated to the next upper layer.
+
+ \param[in] req - pointer to NLDE-DATA.request parameter's structure.
+
+ \return True, if indication required, false - otherwise
+ ******************************************************************************/
+NWK_PRIVATE bool nwkLoopbackRequired(const NWK_DataReq_t *const req);
+
+#endif /* _NWK_LOOPBACK_H */
+/** nwkLoopback.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkManager.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkManager.h
new file mode 100644
index 00000000..f12c1b9b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkManager.h
@@ -0,0 +1,127 @@
+/**************************************************************************//**
+ \file nwkManager.h
+
+ \brief Interface of the network manager.
+
+ \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:
+ 2009-06-08 Max Gekk - Created.
+ Last change:
+ $Id: nwkManager.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_MANAGER_H
+#define _NWK_MANAGER_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <appFramework.h>
+#include <mac.h>
+#include <nldeData.h>
+#include <nwkFrame.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_UPDATE_TX_PARAMETERS \
+ {NWK_TX_DELAY_BROADCAST, nwkPrepareUpdateTx, nwkConfirmUpdateTx, true}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the report command component */
+typedef enum _NwkManagerState_t
+{
+ NWK_MANAGER_IDLE_STATE = 0xFB,
+ NWK_MANAGER_FIRST_STATE = 0x83,
+ NWK_MANAGER_MAC_SCAN_STATE = NWK_MANAGER_FIRST_STATE,
+ NWK_MANAGER_PREPARE_MAC_DATA_STATE = 0x84,
+ NWK_MANAGER_SEND_UPDATE_CMD_STATE = 0x85,
+ NWK_MANAGER_SET_PAN_ID_STATE = 0x86,
+ NWK_MANAGER_LAST_STATE
+} NwkManagerState_t;
+
+/** Internal variables of the network manager component. */
+typedef struct _NwkManager_t
+{
+ /** Finite-state machine */
+ NwkManagerState_t state;
+ PanId_t newPanId; /* New non conflicted panId. */
+ /* Range non conflicted panId from newPanId field. */
+ PanId_t nonConflictRange;
+ /** MLME-SCAN request primitive's parameters. */
+ MAC_ScanReq_t macScan;
+} NwkManager_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _RESOLVE_PANID_CONFLICT_ && defined _NETWORK_MANAGER_
+/**************************************************************************//**
+ \brief Processing a conflict of panId by the network manager.
+ ******************************************************************************/
+NWK_PRIVATE void nwkDetectPanIdConflictByNwkManager(void);
+
+/**************************************************************************//**
+ \brief Reset the report command component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetNetworkManager(void);
+
+/**************************************************************************//**
+ \brief Action when a report command is received.
+
+ \param[in] payload - pointer to NPDU of NWK report command.
+ \param[in] header - nwk header.
+ \param[in] parse - parsed header fields.
+ \return 'true' - continue command processing otherwise 'false'.
+******************************************************************************/
+NWK_PRIVATE bool nwkReportFrameInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the update command.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareUpdateTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of the update command transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of the update command transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmUpdateTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/******************************************************************************
+ \brief nwkNetworkManager idle checking.
+
+ \return true, if nwkNetworkManager performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkNetworkManagerIsIdle(void);
+
+#else /* _RESOLVE_PANID_CONFLICT_ and _NETWORK_MANAGER_ */
+
+/* Interface of the network manager is disabled. */
+INLINE void nwkDetectPanIdConflictByNwkManager(void) {}
+#define nwkResetNetworkManager() (void)0
+#define nwkReportFrameInd NULL
+#define nwkPrepareUpdateTx NULL
+#define nwkConfirmUpdateTx NULL
+#define nwkNetworkManagerIsIdle NULL
+
+#endif /* _RESOLVE_PANID_CONFLICT_ and _NETWORK_MANAGER_ */
+#endif /* _NWK_MANAGER_H */
+/* eof nwkManager.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkManyToOne.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkManyToOne.h
new file mode 100644
index 00000000..7eaf3dbc
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkManyToOne.h
@@ -0,0 +1,69 @@
+/**************************************************************************//**
+ \file nwkManyToOne.h
+
+ \brief Internal interface of the many-to-one component.
+
+ \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:
+ 2010-05-13 M. Gekk - Created.
+ Last change:
+ $Id: nwkManyToOne.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_MANY_TO_ONE_H
+#define _NWK_MANY_TO_ONE_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkRoutingTable.h>
+#include <queue.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/* Internal variables of the many-to-one component. */
+typedef struct _NwkManyToOne_t
+{
+ QueueDescriptor_t queue; /**< Queue of requests from upper layer. */
+} NwkManyToOne_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_MANY_TO_ONE_ROUTING_
+/**************************************************************************//**
+ \brief Main task handler of the many-to-one component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkManyToOneTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Reset the many-to-one component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetManyToOne(void);
+
+/**************************************************************************//**
+ \brief Many-to-one route request from concentrator has been received.
+
+ \param[in] entry - pointer to concentrator entry in the routing table.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkNewConcentratorFound(NwkRoutingTableEntry_t *const entry);
+
+#else
+
+#define nwkManyToOneTaskHandler NULL
+#define nwkResetManyToOne() (void)0
+#define nwkNewConcentratorFound(entry) (void)0
+
+#endif /* NWK_ROUTING_CAPACITY and _NWK_MANY_TO_ONE_ROUTING_ */
+#endif /* _NWK_MANY_TO_ONE_H */
+/** eof nwkManyToOne.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkMem.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkMem.h
new file mode 100644
index 00000000..8453f399
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkMem.h
@@ -0,0 +1,421 @@
+/**************************************************************************//**
+ \file nwkMem.h
+
+ \brief NWK Memory header file.
+
+ \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:
+ 2007-06-14 S. Vladykin - Created.
+ 2009-04-30 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkMem.h 18049 2011-07-20 13:08:36Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_MEM_H
+#define _NWK_MEM_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkCommon.h>
+#include <nwkIB.h>
+#include <nwkTaskManager.h>
+#include <nwkReset.h>
+#include <nwkDiscovery.h>
+#include <nwkTx.h>
+#include <nwkDataReq.h>
+#include <nwkTxDelay.h>
+#include <nwkPacket.h>
+#include <nwkLeave.h>
+#include <nwkEDScan.h>
+#include <nwkBTT.h>
+#include <nwkAddressConflict.h>
+#include <nwkAddressMap.h>
+#include <nwkCommands.h>
+#include <nwkLoopback.h>
+#include <nwkFormation.h>
+#include <nwkStartRouter.h>
+#include <nwkJoinReq.h>
+#include <nwkJoinInd.h>
+#include <nwkPermitJoining.h>
+#include <nwkLinkStatus.h>
+#include <nwkRoutingTable.h>
+#include <nwkRouteDiscovery.h>
+#include <nwkRouteDiscoveryTable.h>
+#include <nwkStatusInd.h>
+#include <nwkSync.h>
+#include <nwkSyncLoss.h>
+#include <nwkConcentrator.h>
+#include <nwkReportCommand.h>
+#include <nwkUpdateCommand.h>
+#include <nwkManager.h>
+#include <nwkDirectJoin.h>
+#include <nwkOrphan.h>
+#include <nwkSilentJoin.h>
+#include <nwkRouteRecord.h>
+#include <nwkRouteCache.h>
+#include <nwkManyToOne.h>
+#include <nwkGroup.h>
+#include <nwkPassiveAck.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal variables of NWK layer. */
+typedef struct _NwkMem_t
+{
+ /** Global NWK state. */
+ NwkState_t state;
+ /** State of task manager. */
+ NwkTaskManager_t taskManager;
+ /** Internal variables of NLME-RESET component. */
+ NwkReset_t reset;
+ /** Internal variables of NLME-DISCOVERY component. */
+ NwkDiscovery_t discovery;
+ /** States and parameters of packet transmission component. */
+ NwkTx_t tx;
+ NwkDataConf_t dataConf;
+ NwkTxDelay_t txDelay;
+ NwkPacketManager_t packetManager;
+ /** Internal variables of NLME-LEAVE component. */
+ NwkLeave_t leave;
+ /** Internal variables of NLME-ED-SCAN component. */
+ NwkEDScan_t edScan;
+ /** Broadcast transaction table. Only pointer to configServer
+ * and a size of table. */
+ NwkBTT_t BTT;
+ /** Address map table. */
+ NwkAddressMap_t addressTable;
+ /** Neighbor table */
+ NwkNeighborTable_t neighborTable;
+ /** Address conflict resolver. */
+ NwkAddrConflict_t addrConflict;
+ /** Requests to send command packets. */
+ NwkCommands_t commands;
+ /** Queue and state of loopback component. */
+ NwkLoopback_t loopback;
+#if defined _COORDINATOR_
+ /** Internal variables of NLME-FORMATION component. */
+ NwkFormation_t formation;
+#endif /* _COORDINATOR_ */
+#if defined _ROUTER_
+ /** Internal variables of NLME-START-ROUTER component. */
+ NwkStartRouter_t startRouter;
+#endif /* _ROUTER_ */
+#if defined _ROUTER_ || defined _ENDDEVICE_
+ /** Internal state of NLME-JOIN.request primitive. */
+ NwkJoinReq_t joinReq;
+#endif /* _ROUTER_ or _ENDDEVICE_ */
+#if defined _ROUTER_ || defined _COORDINATOR_
+ /** Internal state of NLME-JOIN.indication primitive. */
+ NwkJoinInd_t joinInd;
+ /** Internal variables of NLME-PERMIT-JOINING component. */
+ NwkPermitJoining_t permitJoining;
+ /** Internal state of handler of a link status command. */
+ NwkLinkStatus_t linkStatus;
+ #if defined NWK_ROUTING_CAPACITY \
+ && (defined _NWK_MESH_ROUTING_ || defined _NWK_MANY_TO_ONE_ROUTING_)
+ /** Status and internals variables of a routing components. */
+ NwkRouteDiscovery_t routeDiscovery;
+ NwkRouteDiscoveryTable_t routeDiscoveryTable;
+ NwkRoutingTable_t routingTable;
+ #endif /* NWK_ROUTING_CAPACITY and (_NWK_MESH_ROUTING_ or _NWK_MANY_TO_ONE_ROUTING_) */
+ #if defined NWK_ROUTING_CAPACITY && defined _NWK_ROUTE_RECORD_
+ /** Internal state of handler of a route record command. */
+ NwkRouteRecord_t routeRecord;
+ #endif /* NWK_ROUTING_CAPACITY and _NWK_ROUTE_RECORD_ */
+ /** Variables of network status sender. */
+ NwkStatusSender_t statusSender;
+#if defined _NWK_DIRECT_JOIN_
+ NwkDirectJoin_t directJoin;
+#endif /* _NWK_DIRECT_JOIN_ */
+#if defined _NWK_PASSIVE_ACK_
+ NwkPassiveAck_t passiveAck;
+#endif /* _NWK_PASSIVE_ACK_ */
+#endif /* _ROUTER_ or _COORDINATOR_ */
+#if defined _ENDDEVICE_
+ /** Internal variables of NLME-SYNC component. */
+ NwkSync_t sync;
+#endif /* _ENDDEVICE_ */
+#if defined _ROUTER_ && defined NWK_COORD_REALIGNMENT
+ /** Internal variables of NLME-SYNC-LOSS component. */
+ NwkSyncLoss_t syncLoss;
+#endif /* _ROUTER_ and NWK_COORD_REALIGNMENT */
+#if defined _RESOLVE_PANID_CONFLICT_
+ /** Internal state of handler of a report command. */
+ NwkReportCommand_t nwkReportCommand;
+ /** Internal state of handler of a update command. */
+ NwkUpdateCommand_t nwkUpdateCommand;
+ #if defined _NETWORK_MANAGER_
+ NwkManager_t manager;
+ #endif /* _NETWORK_MANAGER_ */
+#endif /* _RESOLVE_PANID_CONFLICT_ */
+#if defined _NWK_CONCENTRATOR_
+ NwkConcentrator_t concentrator;
+#endif /* _NWK_CONCENTRATOR_ */
+#if defined _NWK_ROUTE_CACHE_
+ NwkRouteCache_t routeCache;
+#endif /* _NWK_ROUTE_CACHE_ */
+#if defined _NWK_ORPHAN_JOIN_
+ NwkOrphan_t orphan;
+#endif
+#if defined _NWK_SILENT_JOIN_
+ NwkSilentJoin_t silentJoin;
+#endif
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_MANY_TO_ONE_ROUTING_
+ NwkManyToOne_t manyToOne;
+#endif
+#if defined _GROUP_TABLE_
+ NWK_GroupTable_t groupTable;
+#endif
+} NwkMem_t;
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+
+/** nwkMem is defined in nwkMem.c */
+extern NwkMem_t nwkMem;
+/** csNIB is defined in configServer.c */
+extern NIB_t csNIB;
+
+/******************************************************************************
+ Inline functions section
+ ******************************************************************************/
+INLINE NIB_t* nwkMemNib(void)
+{
+ return &csNIB;
+}
+
+INLINE NwkTaskManager_t* nwkMemTaskManager(void)
+{
+ return &nwkMem.taskManager;
+}
+
+INLINE NwkReset_t* nwkMemReset(void)
+{
+ return &nwkMem.reset;
+}
+
+INLINE NwkDiscovery_t* nwkMemDiscovery(void)
+{
+ return &nwkMem.discovery;
+}
+
+INLINE NwkTx_t* nwkMemTx(void)
+{
+ return &nwkMem.tx;
+}
+
+INLINE NwkDataConf_t* nwkMemDataConf(void)
+{
+ return &nwkMem.dataConf;
+}
+
+INLINE NwkTxDelay_t* nwkMemTxDelay(void)
+{
+ return &nwkMem.txDelay;
+}
+
+INLINE NwkPacketManager_t* nwkMemPacketManager(void)
+{
+ return &nwkMem.packetManager;
+}
+
+INLINE NwkLeave_t* nwkMemLeave(void)
+{
+ return &nwkMem.leave;
+}
+
+INLINE NwkEDScan_t* nwkMemEDScan(void)
+{
+ return &nwkMem.edScan;
+}
+
+INLINE NwkBTT_t* nwkMemBTT(void)
+{
+ return &nwkMem.BTT;
+}
+
+INLINE NwkAddressMap_t* nwkMemAddressMap(void)
+{
+ return &nwkMem.addressTable;
+}
+
+INLINE NwkAddrConflict_t* nwkMemAddrConflict(void)
+{
+ return &nwkMem.addrConflict;
+}
+
+INLINE NwkCommands_t* nwkMemCommands(void)
+{
+ return &nwkMem.commands;
+}
+
+INLINE NwkLoopback_t* nwkMemLoopback(void)
+{
+ return &nwkMem.loopback;
+}
+
+#if defined _COORDINATOR_
+INLINE NwkFormation_t* nwkMemFormation(void)
+{
+ return &nwkMem.formation;
+}
+#endif
+#if defined _ROUTER_
+INLINE NwkStartRouter_t* nwkMemStartRouter(void)
+{
+ return &nwkMem.startRouter;
+}
+#endif
+#if defined _ROUTER_ || defined _ENDDEVICE_
+INLINE NwkJoinReq_t* nwkMemJoinReq(void)
+{
+ return &nwkMem.joinReq;
+}
+#endif
+#if defined _ROUTER_ || defined _COORDINATOR_
+INLINE NwkJoinInd_t* nwkMemJoinInd(void)
+{
+ return &nwkMem.joinInd;
+}
+
+INLINE NwkPermitJoining_t* nwkMemPermitJoining(void)
+{
+ return &nwkMem.permitJoining;
+}
+
+INLINE NwkLinkStatus_t* nwkMemLinkStatus(void)
+{
+ return &nwkMem.linkStatus;
+}
+
+#if defined NWK_ROUTING_CAPACITY \
+ && (defined _NWK_MESH_ROUTING_ || defined _NWK_MANY_TO_ONE_ROUTING_)
+INLINE NwkRouteDiscovery_t* nwkMemRouteDiscovery(void)
+{
+ return &nwkMem.routeDiscovery;
+}
+
+INLINE NwkRouteDiscoveryTable_t* nwkMemRouteDiscoveryTable(void)
+{
+ return &nwkMem.routeDiscoveryTable;
+}
+
+INLINE NwkRoutingTable_t* nwkMemRoutingTable(void)
+{
+ return &nwkMem.routingTable;
+}
+#endif /* NWK_ROUTING_CAPACITY and (_NWK_MESH_ROUTING_ or _NWK_MANY_TO_ONE_ROUTING_) */
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_ROUTE_RECORD_
+INLINE NwkRouteRecord_t* nwkMemRouteRecord(void)
+{
+ return &nwkMem.routeRecord;
+}
+#endif /* NWK_ROUTING_CAPACITY and _NWK_ROUTE_RECORD_ */
+
+INLINE NwkStatusSender_t* nwkMemStatusSender(void)
+{
+ return &nwkMem.statusSender;
+}
+
+#if defined _NWK_PASSIVE_ACK_
+INLINE NwkPassiveAck_t* nwkMemPassiveAck(void)
+{
+ return &nwkMem.passiveAck;
+}
+#endif /* _NWK_PASSIVE_ACK_ */
+#endif /* _ROUTER_ or _COORDINATOR_ */
+
+#if defined _ENDDEVICE_
+INLINE NwkSync_t* nwkMemSync(void)
+{
+ return &nwkMem.sync;
+}
+#endif
+#if defined _ROUTER_ && defined NWK_COORD_REALIGNMENT
+INLINE NwkSyncLoss_t* nwkMemSyncLoss(void)
+{
+ return &nwkMem.syncLoss;
+}
+#endif /* _ROUTER_ and NWK_COORD_REALIGNMENT */
+
+INLINE NwkNeighborTable_t* nwkMemNeighborTable(void)
+{
+ return &nwkMem.neighborTable;
+}
+
+#if defined _RESOLVE_PANID_CONFLICT_
+INLINE NwkReportCommand_t* nwkMemReportCommand(void)
+{
+ return &nwkMem.nwkReportCommand;
+}
+
+INLINE NwkUpdateCommand_t* nwkMemUpdateCommand(void)
+{
+ return &nwkMem.nwkUpdateCommand;
+}
+#if defined _NETWORK_MANAGER_
+INLINE NwkManager_t* nwkMemManager(void)
+{
+ return &nwkMem.manager;
+}
+#endif /* _NETWORK_MANAGER_ */
+#endif /* _RESOLVE_PANID_CONFLICT_ */
+#if defined _NWK_CONCENTRATOR_
+INLINE NwkConcentrator_t* nwkMemConcentrator(void)
+{
+ return &nwkMem.concentrator;
+}
+#endif /* _NWK_CONCENTRATOR_ */
+#if defined _NWK_ROUTE_CACHE_
+INLINE NwkRouteCache_t* nwkMemRouteCache(void)
+{
+ return &nwkMem.routeCache;
+}
+#endif /* _NWK_ROUTE_CACHE_ */
+
+#if (defined(_ROUTER_) || defined(_COORDINATOR_)) && defined(_NWK_DIRECT_JOIN_)
+INLINE NwkDirectJoin_t* nwkMemDirectJoin(void)
+{
+ return &nwkMem.directJoin;
+}
+#endif
+
+#if defined _NWK_ORPHAN_JOIN_
+INLINE NwkOrphan_t* nwkMemOrphan(void)
+{
+ return &nwkMem.orphan;
+}
+#endif
+
+#if defined _NWK_SILENT_JOIN_
+INLINE NwkSilentJoin_t* nwkMemSilentJoin(void)
+{
+ return &nwkMem.silentJoin;
+}
+#endif
+
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_MANY_TO_ONE_ROUTING_
+INLINE NwkManyToOne_t* nwkMemManyToOne(void)
+{
+ return &nwkMem.manyToOne;
+}
+#endif
+#if defined _GROUP_TABLE_
+INLINE NWK_GroupTable_t* nwkMemGroup(void)
+{
+ return &nwkMem.groupTable;
+}
+#endif
+#endif /* _NWK_MEM_H */
+/** eof nwkMem.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkNeighborTable.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkNeighborTable.h
new file mode 100644
index 00000000..7c7c6179
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkNeighborTable.h
@@ -0,0 +1,261 @@
+/**************************************************************************//**
+ \file nwkNeighborTable.h
+
+ \brief Interface of the neighbor table..
+
+ \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:
+ 2009-05-12 M. Gekk - Created.
+ Last change:
+ $Id: nwkNeighborTable.h 18296 2011-08-19 12:29:05Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_NEIGHBOR_TABLE_H
+#define _NWK_NEIGHBOR_TABLE_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <mac.h>
+#include <nwkNeighbor.h>
+#include <nwkMem.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define IS_EMPTY(ntEntry) (RELATIONSHIP_EMPTY == ntEntry->relationship)
+#define IS_AUTHENTICATED_CHILD(ntEntry) \
+ (RELATIONSHIP_CHILD == ntEntry->relationship)
+#define IS_UNAUTHENTICATED_CHILD(ntEntry) \
+ (RELATIONSHIP_UNAUTHENTICATED_CHILD == ntEntry->relationship)
+#define IS_END_DEVICE(ntEntry) \
+ (DEVICE_TYPE_END_DEVICE == ntEntry->deviceType)
+#define IS_CHILD(ntEntry) \
+ (IS_AUTHENTICATED_CHILD(ntEntry) || IS_UNAUTHENTICATED_CHILD(ntEntry))
+#define IS_PARENT(ntEntry) (RELATIONSHIP_PARENT == ntEntry->relationship)
+#define IS_RX_ON_WHEN_IDLE(ntEntry) (ntEntry->rxOnWhenIdle)
+#define FREE_NEIGHBOR(neighbor) neighbor->relationship = RELATIONSHIP_EMPTY
+/** Getting mutable part of neighbor entry. */
+#define MUTABLE_PART(neighbor) nwkMutablePart(nwkMemNeighborTable(), neighbor)
+/** Minimum value of a cost metric. */
+#define NWK_MIN_LINK_COST 1
+
+/******************************************************************************
+ Inline static functions prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief First entry of the neighbor table.
+ ******************************************************************************/
+INLINE NwkNeighbor_t* nwkNtBegin(void)
+{
+ return nwkMemNeighborTable()->table;
+}
+
+/**************************************************************************//**
+ \brief Function returns a pointer to memory area after last entry of the
+ neighbor table.
+ ******************************************************************************/
+INLINE NwkNeighbor_t* nwkNtEnd(void)
+{
+ return nwkMemNeighborTable()->end;
+}
+
+/**************************************************************************//**
+ \brief Function return a total size of the neighbor table.
+ ******************************************************************************/
+INLINE NwkSizeOfNeighborTable_t nwkNtSize(void)
+{
+ return nwkMemNeighborTable()->size;
+}
+
+/**************************************************************************//**
+ \brief Getting the mutable part of given neighbor entry.
+ ******************************************************************************/
+INLINE NwkMutablePartOfNeighbor_t* nwkMutablePart(
+ NwkNeighborTable_t const *const neighborTable,
+ NwkNeighbor_t const *const neighbor)
+{
+ return neighborTable->mutableTable + (neighbor - neighborTable->table);
+}
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Reset the neighbor table.
+
+ \param[in] powerFailureControl - stack restoring after power failure control bitfield;
+ affects on initialization procedure.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetNeighborTable(NWK_PowerFailureControl_t powerFailureControl);
+
+/**************************************************************************//**
+ \brief Clear all entries in the neighbor table.
+
+ \param[in] removeParent - remove parent's entry.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkClearNeighborTable(const bool removeParent);
+
+/**************************************************************************//**
+ \brief Free a entry in the neighbor table.
+
+ \param[in] neighbor - pointer to a neighbor.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkFreeNeighbor(NwkNeighbor_t *const neighbor);
+
+/**************************************************************************//**
+ \brief Update of time of a life of the neighbor.
+
+ \param[in] neighbor - pointer to a neighbor.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkSetLifeTimeOfNeighbor(NwkNeighbor_t *const neighbor);
+
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_MESH_ROUTING_
+/**************************************************************************//**
+ \brief Checking of that the given device is destination node for the
+ short address.
+
+ \param[in] shortAddr - unicast or multicast short address.
+ \param[in] group - if 'true' then shortAddress is a multicast address.
+ \return 'true' if this node is destination else 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkIsRouteDestination(const ShortAddr_t shortAddr,
+ const bool group);
+#endif /* NWK_ROUTING_CAPACITY and _NWK_MESH_ROUTING_ */
+
+/**************************************************************************//**
+ \brief Calculate an incoming cost by LQI.
+
+ \param[in] lqi - link quality indicator.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE NwkPathCost_t nwkCostFromLqi(const Lqi_t lqi);
+
+/**************************************************************************//**
+ \brief Recalculation LQI and costs for the set neighbor.
+
+ \param[in] neighbor - pointer to a neighbor
+ \param[in] linkQuality - the link quality indicator of a received packet.
+ \param[in] rssi - received signal strength indication.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkUpdateLqiAndCostOfNeighbor(NwkNeighbor_t *const neighbor,
+ const Lqi_t linkQuality, const Rssi_t rssi);
+
+/**************************************************************************//**
+ \brief Recalculation LQI and costs for a neighbor with given short address.
+
+ \param[in] addr - short address of a neighbor.
+ \param[in] linkQuality - the link quality indicator of a received packet.
+ \param[in] rssi - received signal strength indication.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkUpdateLqiAndLifeTime(const ShortAddr_t addr,
+ const Lqi_t linkQuality, const Rssi_t rssi);
+
+/**************************************************************************//**
+ \brief Is there a free place in the neighbor table.
+
+ \param endDeviceCount - current number of end device children.
+ \param routerCount - current number of router children.
+
+ \return 'true' if the neighbor table is full otherwise return 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkIsNeighborTableFull(const NwkChildCount_t endDeviceCount,
+ const NwkChildCount_t routerCount);
+
+/**************************************************************************//**
+ \brief Gets value for the end device capacity bit in the beacon payload.
+
+ \param endDeviceCount - current number of end device children.
+
+ \return 1U if a end device can rejoin to this device otherwise return 0U.
+ ******************************************************************************/
+NWK_PRIVATE uint8_t nwkGetEdCapacity(const NwkChildCount_t endDeviceCount);
+
+/**************************************************************************//**
+ \brief Gets value for the router capacity bit in the beacon payload.
+
+ \param routerCount - current number of router children.
+
+ \return 1U if a router can rejoin to this device otherwise return 0U.
+ ******************************************************************************/
+NWK_PRIVATE uint8_t nwkGetRouterCapacity(const NwkChildCount_t routerCount);
+
+/**************************************************************************//**
+ \brief Calculation of quantity of children and updating of capacity bits.
+ ******************************************************************************/
+NWK_PRIVATE void nwkUpdateCapacityBitsInBeacon(void);
+
+/**************************************************************************//**
+ \brief Updating capacity bits in beacon by end devices and routers count.
+
+ \param[in] endDeviceCount - current number of end device children.
+ \param[in] routerCount - current number of router children.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkUpdateCapacityBits(const NwkChildCount_t endDeviceCount,
+ const NwkChildCount_t routerCount);
+
+#if defined _RESOLVE_ADDR_CONFLICT_
+/******************************************************************************
+ \brief Find a neighbor with address conflict.
+
+ This function reset the conflict flag.
+
+ \return Pointer to neighbor's entry in the neighbor table.
+******************************************************************************/
+NWK_PRIVATE NwkNeighbor_t* nwkFindAddrConflictNeighbor(void);
+
+#if defined _ROUTER_ || defined _COORDINATOR_
+/******************************************************************************
+ \brief Find a end device child with given short address.
+
+ \param[in] shortAddr - short address of end device child.
+ \return Pointer to neighbor's entry in the neighbor table.
+******************************************************************************/
+NWK_PRIVATE NwkNeighbor_t* nwkFindEndDeviceChild(const ShortAddr_t shortAddr);
+#endif /* _ROUTER_ or _COORDINATOR_ */
+#endif /* _RESOLVE_ADDR_CONFLICT_ */
+
+#if defined _ROUTER_ || defined _COORDINATOR_
+/**************************************************************************//**
+ \brief Start the age timer of the neighbor table.
+ ******************************************************************************/
+NWK_PRIVATE void nwkStartAgeTimerOfNeighborTable(void);
+
+/**************************************************************************//**
+ \brief Stop the age timer of the neighbor table.
+ ******************************************************************************/
+NWK_PRIVATE void nwkStopAgeTimerOfNeighborTable(void);
+
+/**************************************************************************//**
+ \brief Search of the following child after given with a flag rxOnWhenIdle
+ in 'false' and that can take indirect packet.
+
+ \param[in] neighbor - the neighbor with which search should begin.
+ \param[in] exceptShortAddr - the address of the child which should be passed.
+ \return Pointer to sleeping child's entry in the neighbor table.
+ ******************************************************************************/
+NWK_PRIVATE NwkNeighbor_t* nwkNextSleepingChildForIndirectTx(
+ NwkNeighbor_t* neighbor, const ShortAddr_t exceptShortAddr);
+
+#else
+#define nwkStartAgeTimerOfNeighborTable() (void)0
+#define nwkStopAgeTimerOfNeighborTable() (void)0
+
+#endif /* _ROUTER_ or _COORDINATOR_ */
+
+#endif /* _NWK_NEIGHBOR_TABLE_H */
+/** eof nwkNeighborTable.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkOrphan.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkOrphan.h
new file mode 100644
index 00000000..c1f3683a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkOrphan.h
@@ -0,0 +1,109 @@
+/*************************************************************************//**
+ \file nwkOrphan.h
+
+ \brief Interface of orphan join functionality.
+
+ \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:
+ 2010-03-17 I.Vagulin - Created.
+ Last change:
+ $Id: nwkOrphan.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ORPHAN_H
+#define _NWK_ORPHAN_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <nlmeJoin.h>
+#include <macOrphan.h>
+#include <macScan.h>
+#include <macSetGet.h>
+#include <macRxEnable.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+typedef enum
+{
+ NWK_ORPHAN_STATE_MIN = 0x65,
+ NWK_ORPHAN_STATE_IDLE,
+
+ /* child */
+ NWK_ORPHAN_STATE_REQUEST_QUEUED,
+ NWK_ORPHAN_STATE_WAIT_SCAN_CONFIRM,
+ NWK_ORPHAN_STATE_SET_PARAMS,
+ NWK_ORPHAN_STATE_GET_PARAMS,
+
+ /* parent */
+ NWK_ORPHAN_STATE_WAIT_RESPONSE_CONFIRM,
+
+ NWK_ORPHAN_STATE_MAX
+} NwkOrphanState_t ;
+
+/** Orphan memory */
+typedef struct _NwkOrphan_t
+{
+ NwkOrphanState_t state;
+
+#if defined _ROUTER_ || defined _ENDDEVICE_
+ /** Request queue */
+ QueueDescriptor_t queue;
+ /** joinReq currently in processing */
+ NWK_JoinReq_t *current;
+ /** Memory for mac requests */
+#endif
+ union
+ {
+#if defined _ROUTER_ || defined _COORDINATOR_
+ MAC_OrphanResp_t resp;
+#endif
+#if defined _ROUTER_ || defined _ENDDEVICE_
+ MAC_ScanReq_t scan;
+ MAC_GetReq_t get;
+ MAC_SetReq_t set;
+ MAC_RxEnableReq_t rxEnable;
+#endif
+ } req ;
+} NwkOrphan_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if (defined(_ROUTER_) || defined(_ENDDEVICE_)) && defined(_NWK_ORPHAN_JOIN_)
+/**************************************************************************//**
+ \brief Reseting of the orphan module.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetOrphan(void);
+
+/**************************************************************************//**
+ \brief Main task handler of orphan module.
+ ******************************************************************************/
+NWK_PRIVATE void nwkOrphanTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Process orphan join requests.
+
+ \param[in] req - NLME-JOIN request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkOrphanReq(NWK_JoinReq_t *req);
+
+#else
+
+#define nwkResetOrphan() (void)0
+#define nwkOrphanTaskHandler NULL
+
+#endif /* (_ROUTER_ or _ENDDEVICE_) and _NWK_ORPHAN_JOIN_ */
+#endif /* _NWK_ORPHAN_H */
+/** eof nwkOrphan.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPacket.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPacket.h
new file mode 100644
index 00000000..f93f21ed
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPacket.h
@@ -0,0 +1,154 @@
+/**************************************************************************//**
+ \file nwkPacket.h
+
+ \brief Interface of the network packet manager.
+
+ \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:
+ 2009-07-06 M. Gekk - Created.
+ Last change:
+ $Id: nwkPacket.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_PACKET_H
+#define _NWK_PACKET_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <mac.h>
+#include <nwkCommon.h>
+#include <nwkRx.h>
+#include <nwkTx.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Type of network packet. */
+typedef enum _NwkPacketType_t
+{
+ NWK_UNKNOWN_PACKET = 0x0,
+ /** Command packet from NWK component. */
+ NWK_OUTPUT_COMMAND_PACKET = 0x1,
+ /** Command packet from MAC-layer. */
+ NWK_INPUT_COMMAND_PACKET = 0x2,
+ /** Data packet from MAC-layer. */
+ NWK_INPUT_DATA_PACKET = 0x3,
+ /** Transit packet from MAC-layer. */
+ NWK_TRANSIT_PACKET = 0x4,
+ /** Loopback transmission from APS-layer. */
+ NWK_LOOPBACK_PACKET = 0x5,
+ /** Data packet from an external layer. */
+ NWK_EXTERN_PACKET = 0x6,
+ NWK_BUFFER_TYPE_LAST
+} NwkPacketType_t;
+
+/** Network packet type. */
+typedef struct _NwkPacket_t
+{
+ /** Network packet type. */
+ NwkPacketType_t type;
+ TOP_GUARD
+ uint8_t macHeader[MAC_MSDU_OFFSET];
+ uint8_t macPayload[MAC_MAX_MSDU_SIZE];
+#if (MAC_AFFIX_LENGTH - MAC_MSDU_OFFSET)
+ uint8_t macFooter[MAC_AFFIX_LENGTH - MAC_MSDU_OFFSET];
+#endif
+ BOTTOM_GUARD
+ union
+ {
+ /** Service information for incoming packet from MAC-layer. */
+ NwkInputPacket_t in;
+ /** Service information for outgoing packet from NWK-layer. */
+ NwkOutputPacket_t out;
+#if defined _NWK_ALLOCATOR_
+ /** Service information for outgoing packet from an upper-layer. */
+ NwkExternPacket_t ext;
+#endif /* _NWK_ALLOCATOR_ */
+ } pkt;
+} NwkPacket_t;
+
+/** Internal variables of the network packet manager. */
+typedef struct _NwkPacketManager_t
+{
+ /** Array of network packets. */
+ NwkPacket_t *pkt;
+ /** Total amount of network packets. */
+ uint8_t amount;
+ /** Queue of external packet allocation requests. */
+ QueueDescriptor_t queue;
+} NwkPacketManager_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Allocate a free memory space for an input packet with type.
+
+ \param[in] type - type of packet.
+ \param[in] length - needed packet length.
+ \return Pointer to input packet or NULL.
+ ******************************************************************************/
+NWK_PRIVATE NwkInputPacket_t* nwkAllocInputPacket(const NwkPacketType_t type,
+ const NwkLength_t length);
+
+/**************************************************************************//**
+ \brief Free an input packet.
+
+ \param[in] inPkt - pointer to an input packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkFreeInputPacket(NwkInputPacket_t *const inPkt);
+
+/**************************************************************************//**
+ \brief Allocate a free memory space for an output.
+
+ \param[in] type - type of output packet.
+ \return Pointer to output packet or NULL.
+ ******************************************************************************/
+NWK_PRIVATE NwkOutputPacket_t* nwkAllocOutputPacket(const NwkPacketType_t type);
+
+/**************************************************************************//**
+ \brief Free an output packet.
+
+ \param[in] outPkt - pointer to an output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkFreeOutputPacket(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Reset the network packet manager.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetPacketManager(void);
+
+#if defined NWK_ROUTING_CAPACITY
+/**************************************************************************//**
+ \brief To transform an input packet to the output packet.
+
+ \param[in] inPkt - pointer to an input packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE
+NwkOutputPacket_t* nwkTransformInToOutPacket(NwkInputPacket_t *const inPkt);
+#endif /* NWK_ROUTING_CAPACITY */
+
+#if defined _NWK_ALLOCATOR_
+/**************************************************************************//**
+ \brief Process an incoming request to allocate memory for NWK_DataReq.
+ ******************************************************************************/
+NWK_PRIVATE void nwkAllocDataReqTaskHandler(void);
+
+#else
+#define nwkAllocDataReqTaskHandler NULL
+#endif /* _NWK_ALLOCATOR_ */
+#endif /* _NWK_PACKET_H */
+/** eof nwkPacket.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPassiveAck.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPassiveAck.h
new file mode 100644
index 00000000..6e76b48c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPassiveAck.h
@@ -0,0 +1,174 @@
+/**************************************************************************//**
+ \file nwkPassiveAck.h
+
+ \brief Private interface of the passive acknowledgement mechanism.
+
+ \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:
+ 2011-07-16 Max Gekk - Created.
+ Last change:
+ $Id: nwkPassiveAck.h 18049 2011-07-20 13:08:36Z mgekk $
+ ******************************************************************************/
+/**//**
+ *
+ * Passive acknowledgement means that every ZigBee router and ZigBee
+ * coordinator keeps track of which of its neighboring devices have successfully
+ * relayed the broadcast transmission. ZigBee spec r18, 3.6.5, page 411.
+ *
+ **/
+#if !defined _NWK_PASSIVE_ACK_H
+#define _NWK_PASSIVE_ACK_H
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+#include <mac.h>
+#include <nwkFrame.h>
+#include <nwkTxDelay.h>
+#include <nwkRx.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+#define IS_PASSIVE_ACK_FOUND(offset) \
+ ((offset).index < nwkMemPassiveAck()->amount)
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** In this structute the node stores information about passive acks
+ * (rebroadcasts) that are received from other routers (and coordinator too)
+ * in the neighborhood. */
+typedef struct _NwkPassiveAckEntry_t
+{
+ /* This field is used as unque identifier of the entry. NULL means that
+ * the entry is free. txDelay only stores pointer to NwkTxDelayReq_t
+ * structure and nwkPassiveAck doesn't read or write fields of the structure. */
+ NwkTxDelayReq_t *txDelay;
+ /* Short address of node that originates a transmission of the broadcast packets. */
+ ShortAddr_t srcAddr;
+ /* Sequence number of NWK packets for which we wait passive acks. */
+ NwkSequenceNumber_t seqNum;
+} NwkPassiveAckEntry_t;
+
+/* Type of value for storing the amount of passive ack entries. */
+typedef uint8_t NwkPassiveAckAmount_t;
+/* Type of index of a passive ack record. */
+typedef NwkPassiveAckAmount_t NwkPassiveAckIndex_t;
+
+typedef struct _NwkPassiveAck_t
+{
+ /* Total amount of passive acknowledgement in the table. */
+ NwkPassiveAckAmount_t amount;
+ /* The pointer to the first item of table that stores information
+ * about each passive acks. */
+ NwkPassiveAckEntry_t *table;
+} NwkPassiveAck_t;
+
+/* Offset of the passive ack entry in the passive ack table. */
+typedef struct _NwkPassiveAckOffset_t
+{
+ /* Index of the passive ack entry in the passive ack table. */
+ NwkPassiveAckIndex_t index;
+ /* Value of this field is equal 1U << index. */
+ NwkPassiveAckMap_t mask;
+} NwkPassiveAckOffset_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _NWK_PASSIVE_ACK_ && (defined _ROUTER_ || defined _COORDINATOR_)
+/******************************************************************************
+ \brief Creates the new entry in the passive ack table.
+
+ \param[in] txDelay - that pointer is used as unique identifier.
+ \param[in] prevHopAddr - short address of node from which the packet is received.
+ \param[in] srcAddr - short address of node that initiates broadcast.
+ \param[in] seqNum - sequence number in NWK header of broadcast packet.
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkNewPassiveAck(NwkTxDelayReq_t *const txDelay,
+ const ShortAddr_t prevHopAddr, const ShortAddr_t srcAddr,
+ const NwkSequenceNumber_t seqNum);
+
+/******************************************************************************
+ \brief Starts tracing external broadcasts.
+
+ Creates the new entry only for transit broadcast packets.
+
+ \param[in] inPkt - the pointer to an incoming packet.
+ \param[in] prevHopAddr - short address of node from which the packet is received.
+ \param[in] srcAddr - short address of node that initiates broadcast.
+ \param[in] seqNum - sequence number in NWK header of broadcast packet.
+ \param[in] radius - value of radius from NWK header of original broadcast.
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkTracePassiveAck(NwkInputPacket_t *const inPkt,
+ const ShortAddr_t prevHopAddr, const ShortAddr_t srcAddr,
+ const NwkSequenceNumber_t seqNum, const NwkRadius_t radius);
+
+/******************************************************************************
+ \brief Finds an passive ack entry by the identifier.
+
+ \param[in] txDelay - primary key of an passive ack entry.
+
+ \return Offset of an passive ack entry if it is found
+ otherwise returns invalid offset \see IS_PASSIVE_ACK_FOUND.
+ ******************************************************************************/
+NWK_PRIVATE
+NwkPassiveAckOffset_t nwkFindPassiveAck(const NwkTxDelayReq_t *const txDelay);
+
+/******************************************************************************
+ \brief Frees an passive ack entry.
+
+ \param[in] txDelay - the valid pointer to NwkTxDelayReq_t structure,
+ used to find and free an entry in the passive ack table
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkFreePassiveAck(const NwkTxDelayReq_t *const txDelay);
+
+/******************************************************************************
+ \brief Checks that all expected rebroadcast are received.
+
+ \param[in] offset - offset of entry in the passive ack table.
+ \return 'true' if all expected neighbors confirms that they was received
+ original broadcast packet otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkIsPassiveAckDone(const NwkPassiveAckOffset_t offset);
+
+/******************************************************************************
+ \brief A rebroadcast is received, stores information about it.
+
+ \param[in] prevHopAddr - short address of node from which the packet is received.
+ \param[in] srcAddr - short address of node that initiates broadcast.
+ \param[in] seqNum - sequence number in NWK header of broadcast packet.
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPassiveAckReceived(const ShortAddr_t prevHopAddr,
+ const ShortAddr_t srcAddr, const NwkSequenceNumber_t seqNum);
+
+/******************************************************************************
+ \brief Resets the internal state and structures of the passive ack component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetPassiveAck(void);
+
+#else
+#define nwkNewPassiveAck(id, prevHopAddr, srcAddr, seqNum) (void)0
+#define nwkTracePassiveAck(inPkt, prevHopAddr, srcAddr, seqNum, radius) (void)0
+#define nwkFreePassiveAck(id) (void)0
+#define nwkPassiveAckReceived(prevHopAddr, srcAddr, seqNum) (void)0
+#define nwkResetPassiveAck() (void)0
+#endif /* _NWK_PASSIVE_ACK_ */
+#endif /* _NWK_PASSIVE_ACK_H */
+/** eof nwkPassiveAck.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPermitJoining.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPermitJoining.h
new file mode 100644
index 00000000..0df4d173
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkPermitJoining.h
@@ -0,0 +1,86 @@
+/**************************************************************************//**
+ \file nwkPermitJoining.h
+
+ \brief NWK permit joining header file.
+
+ \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:
+ 2007-06-27 V. Panov - Created.
+ 2008-12-10 M. Gekk - Reduction of usage of the RAM at separate compiling.
+ Last change:
+ $Id: nwkPermitJoining.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_PERMIT_JOINING_H
+#define _NWK_PERMIT_JOINING_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <mac.h>
+#include <nlmePermitJoining.h>
+#include <appTimer.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of NLME-PERMIT_JOINING component */
+typedef enum _NwkPermitJoiningStates_t
+{
+ NWK_PERMIT_JOINING_IDLE_STATE = 0x48,
+ NWK_PERMIT_JOINING_FIRST_STATE = 0x4A,
+ NWK_PERMIT_JOINING_WAIT_TIMER_FIRED_STATE = NWK_PERMIT_JOINING_FIRST_STATE,
+ NWK_PERMIT_JOINING_BEGIN_STATE = 0x5D,
+ NWK_PERMIT_JOINING_CONFIRM_STATE = 0x5E,
+ NWK_PERMIT_JOINING_TIMER_FIRED_STATE = 0x5F,
+ NWK_PERMIT_JOINING_SET_ASSOC_PERMIT_STATE = 0x60,
+ NWK_PERMIT_JOINING_LAST_STATE
+} NwkPermitJoiningState_t;
+
+/** Internal parameters of NLME-PERMIT-JOINING component. */
+typedef struct _NwkPermitJoining_t
+{
+ NwkPermitJoiningState_t state;
+ QueueDescriptor_t queue;
+ MAC_SetReq_t macReq;
+} NwkPermitJoining_t;
+
+/******************************************************************************
+ Inline functions section
+ ******************************************************************************/
+#if defined _ROUTER_ || defined _COORDINATOR_
+/*************************************************************************//**
+ \brief Task handler of the NLME-PERMIT-JOINING component.
+ *****************************************************************************/
+NWK_PRIVATE void nwkPermitJoiningTaskHandler(void);
+
+/*************************************************************************//**
+ \brief Reset the NLME-PERMIT-JOINING component.
+ *****************************************************************************/
+NWK_PRIVATE void nwkResetPermitJoining(void);
+
+/******************************************************************************
+ \brief nwkPermitJoining idle checking.
+
+ \return true, if nwkPermitJoining performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkPermitJoiningIsIdle(void);
+
+#else /* _ROUTER_ or _COORDINATOR_ */
+
+#define nwkPermitJoiningTaskHandler NULL
+#define nwkPermitJoiningIsIdle NULL
+#define nwkResetPermitJoining() (void)0
+
+#endif /* _ROUTER_ or _COORDINATOR_ */
+#endif /* _NWK_PERMIT_JOINING_H */
+/** eof nwkPermitJoining.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkReportCommand.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkReportCommand.h
new file mode 100644
index 00000000..552de474
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkReportCommand.h
@@ -0,0 +1,167 @@
+/**************************************************************************//**
+ \file nwkReportCommand.h
+
+ \brief Report command header file.
+
+ \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:
+ 2008-12-10 M. Gekk - Reduction of usage of the RAM at separate compiling.
+ 2009-06-05 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkReportCommand.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_REPORT_COMMAND_H
+#define _NWK_REPORT_COMMAND_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkSystem.h>
+#include <mac.h>
+#include <nldeData.h>
+#include <nwkFrame.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Maximum size of a list of 16-bit PAN identifiers that are operating in the
+ * neighborhood of the reporting device.*/
+#define NWK_MAX_REPORT_PANID 16U
+/** Types of report information command. */
+#define NWK_REPORT_TYPE_PANID_CONFLICT 0U
+/** Minimum size of the report command payload without
+ * report information field. */
+#define NWK_SIZE_OF_MIN_REPORT_CMD_PAYLOD 10U
+#define NWK_REPORT_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, nwkPrepareReportTx, nwkConfirmReportTx, true}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the report command component */
+typedef enum _NwkReportCommandState_t
+{
+ /** State after reset */
+ NWK_REPORT_IDLE_STATE = 0x27,
+ /** States of preparing and sending a report command. */
+ NWK_REPORT_FIRST_STATE = 0x51,
+ NWK_REPORT_SCAN_STATE = NWK_REPORT_FIRST_STATE,
+ NWK_REPORT_PREPARE_MAC_DATA_STATE = 0x52,
+ NWK_REPORT_SEND_STATE = 0x54,
+ NWK_REPORT_LAST_STATE
+} NwkReportCommandState_t;
+
+/** Internal variables of the report command component. */
+typedef struct _NwkReportCommand_t
+{
+ /** Finite-state machine */
+ NwkReportCommandState_t state;
+ /** MLME-SCAN request primitive's parameters */
+ MAC_ScanReq_t macScan;
+} NwkReportCommand_t;
+
+/** Payload of network report command. ZigBee spec r17, Figure 3.24. */
+BEGIN_PACK
+typedef struct PACK _NwkReportCommandPayload_t
+{
+ /** Id of report command. ZigBee spec r17, Table 3.40. */
+ NwkCommandIdField_t commandId;
+ LITTLE_ENDIAN_OCTET(2, (
+ /** Command Options Field. ZigBee spec r17, Figure 3.25. */
+ /** The report information count sub-field contains an integer indicating
+ * the number of records contained within the Report Information field.*/
+ NwkBitField_t infoCount : 5,
+ /** The report command identifier sub-field contains an integer indicating
+ * the type of report information command.
+ * ZigBee spec r17, 3.4.9.3.1.2, page 334. */
+ NwkBitField_t reportCmdId : 3
+ ))
+ /** The EPID field shall contain the 64-bit EPID that identifies the network
+ * that the reporting device is a member of.
+ * ZigBee spec r17, 3.4.9.3.2, page 334. */
+ ExtPanId_t extPanId;
+ /** The report information field provides the information being reported,
+ * the format of this field depends upon the value of the Report Command
+ * Identifier sub-field. */
+ union
+ {
+ uint8_t info[NWK_MAX_REPORT_PANID * sizeof(PanId_t)];
+ PanId_t panId[NWK_MAX_REPORT_PANID];
+ } report;
+} NwkReportCommandPayload_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _RESOLVE_PANID_CONFLICT_
+/**************************************************************************//**
+ \brief Function detects the potential conflict of addresses.
+
+ \param[in] beaconNotify - MLME-BEACON_NOTIFY indication parameters' pointer.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE
+void nwkDetectPanIdConflict(const MAC_BeaconNotifyInd_t *const beaconNotify);
+
+/**************************************************************************//**
+ \brief Reset the report command component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetReportCommand(void);
+
+/**************************************************************************//**
+ \brief Searching other network and fill MAC pan descriptors in configServer.
+
+ \param[in] macScan - MLME-SCAN.request parameters.
+ \param[in] MAC_ScanConf - MLME-SCAN confirm callback function.
+ ******************************************************************************/
+NWK_PRIVATE void nwkSearchOtherNetworks(MAC_ScanReq_t *const macScan,
+ void (*MAC_ScanConf)(MAC_ScanConf_t *));
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the report command.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareReportTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of the report command transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of report transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmReportTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/******************************************************************************
+ \brief nwkReportCommand idle checking.
+
+ \return true, if nwkReportCommand performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkReportCommandIsIdle(void);
+
+#else /* _RESOLVE_PANID_CONFLICT_ */
+
+/* Interface of the report command is disabled. */
+#define nwkDetectPanIdConflict(beaconNotify)
+#define nwkResetReportCommand() (void)0
+#define nwkSearchOtherNetworks(macScan, MAC_ScanConf)
+#define nwkPrepareReportTx NULL
+#define nwkConfirmReportTx NULL
+#define nwkReportCommandIsIdle NULL
+
+#endif /* _RESOLVE_PANID_CONFLICT_ */
+#endif /* _NWK_REPORT_COMMAND_H */
+/** eof nwkReportCommand.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkReset.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkReset.h
new file mode 100644
index 00000000..d0e1dfb6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkReset.h
@@ -0,0 +1,100 @@
+/**************************************************************************//**
+ \file nwkReset.h
+
+ \brief NWK reset header file.
+
+ \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:
+ 2007-06-20 V. Panov - Created.
+ 2009-03-07 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkReset.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_RESET_H
+#define _NWK_RESET_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <mac.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the NLME-RESET component. */
+typedef enum _NwkResetState_t
+{
+ NWK_RESET_IDLE_STATE = 0x19,
+ NWK_RESET_FIRST_STATE = 0xC1,
+ NWK_RESET_BEGIN_STATE = NWK_RESET_FIRST_STATE,
+ NWK_RESET_CONFIRM_STATE = 0xC2,
+ NWK_RESET_MAC_STATE = 0xC3,
+ NWK_RESET_RX_ENABLE_STATE = 0xC4,
+ NWK_RESET_SET_SHORT_ADDRESS_STATE = 0xC5,
+ NWK_RESET_SET_COORD_SHORT_ADDR_STATE = 0xC6,
+ NWK_RESET_SET_PANID_STATE = 0xC7,
+ NWK_RESET_SET_COORD_EXT_ADDR_STATE = 0xC8,
+ NWK_RESET_SET_ASSOC_PAN_COORD_STATE = 0xC9,
+ NWK_RESET_SET_CHANNEL_STATE = 0xCA,
+ NWK_RESET_SET_RX_ON_WHEN_IDLE_STATE = 0xCB,
+ NWK_RESET_SET_BEACON_PAYLOAD_STATE = 0xCC,
+ NWK_RESET_SET_BEACON_PAYLOAD_LEN_STATE = 0xCD,
+ NWK_RESET_SET_ASSOC_PERMIT_STATE = 0xCE,
+ NWK_RESET_MAC_START_STATE = 0xCF,
+ NWK_RESET_SET_TRANSACTION_TIME_STATE = 0xD0,
+ NWK_RESET_LAST_STATE
+} NwkResetState_t;
+
+/** Internal parameters of NLME-RESET component. */
+typedef struct _NwkReset_t
+{
+ /** Finite-state machine */
+ NwkResetState_t state;
+ /** Queue of requests from upper layer */
+ QueueDescriptor_t queue;
+ union
+ {
+ MAC_ResetReq_t reset;
+ MAC_SetReq_t set;
+ MAC_RxEnableReq_t rxEnable;
+ MAC_StartReq_t start;
+ } mac;
+} NwkReset_t;
+
+/** Type of reset function. */
+typedef void (* nwkResetFunction_t)(void);
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Task handler of reset component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetTaskHandler(void);
+
+/******************************************************************************
+ \brief nwkReset idle checking.
+
+ \return true, if nwkReset performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkResetIsIdle(void);
+
+/******************************************************************************
+ \brief NWK layer reset phase completion checker.
+
+ \return true, if NWK reset done, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkResetCompleted(void);
+
+#endif /* _NWK_RESET_H */
+/** eof nwkReset.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteCache.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteCache.h
new file mode 100644
index 00000000..2abc7f34
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteCache.h
@@ -0,0 +1,116 @@
+/**************************************************************************//**
+ \file nwkRouteCache.h
+
+ \brief Interface of the route cache (route record table).
+
+ \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:
+ 2010-03-15 M. Gekk - Created.
+ Last change:
+ $Id: nwkRouteCache.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ROUTE_CACHE_H
+#define _NWK_ROUTE_CACHE_H
+/** See format of the route cache record in ZigBee spec r18, Table 3.45. */
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <mac.h>
+#include <nwkCommon.h>
+#include <nwkRouteRecord.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Type of index in the route cache. */
+typedef uint16_t NwkRouteCacheIndex_t;
+/** Type of total size of the route cache. */
+typedef NwkRouteCacheIndex_t NwkRouteCacheSize_t;
+/** Type of the relay count field. Valid range 0-0xffff.
+ * See Zigbee spec r18, Table 3.45. */
+typedef uint16_t NwkRelayCount_t;
+
+/** Format of a route cache record. ZigBee spec r18, page 350. */
+typedef struct _NwkRouteCacheRecord_t
+{
+ /** The destination network address for this route record.*/
+ ShortAddr_t dstAddr;
+ /** The count of relay nodes from concentrator to the destination.
+ * ZigBee spec r18, Table 3.45, page 350. */
+ NwkRelayCount_t relayCount;
+ /** The set of network addresses that represent the route in order from
+ * the concentrator to the destination. ZigBee spec r18, Table 3.45. */
+ ShortAddr_t path[NWK_MAX_SOURCE_ROUTE];
+} NwkRouteCacheRecord_t;
+
+/* Internal variables and state of the route cache. */
+typedef struct _NwkRouteCache_t
+{
+ /* A set of cached route records. */
+ NwkRouteCacheRecord_t *record;
+ /* Total number of route records. */
+ NwkRouteCacheSize_t size;
+ /* The index of oldest route record. */
+ NwkRouteCacheIndex_t current;
+} NwkRouteCache_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _NWK_ROUTE_CACHE_
+/**************************************************************************//**
+ \brief Find a record in the route cache by a destination address.
+
+ \param[in] dstAddr - destination short address. Address must be valid.
+ \return Pointer to a record of the route cache if it is found
+ otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE
+NwkRouteCacheRecord_t* nwkFindRouteRecord(const ShortAddr_t dstAddr);
+
+/**************************************************************************//**
+ \brief Add new record into the route cache.
+
+ Preconditions:
+ - Size of relay list must be less NWK_MAX_SOURCE_ROUTE.
+ - Destination address must be valid (range 0x0000-0xFFF7).
+
+ \param[in] dstAddr - destination short address of new route record.
+ \param[in] routeRecordPayload - pointer to payload of a received route record
+ command packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkAddRouteRecord(const ShortAddr_t dstAddr,
+ const NwkRouteRecordPayload_t *const routeRecordPayload);
+
+/**************************************************************************//**
+ \brief Delete a record from the route cache.
+
+ \param[in] dstAddr - destination short address for a route record.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkDeleteRouteRecord(const ShortAddr_t dstAddr);
+
+/**************************************************************************//**
+ \brief Reset the route cache.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetRouteCache(void);
+
+#else /* _NWK_ROUTE_CACHE_ */
+
+#define nwkResetRouteCache() (void)0
+
+#endif /* _NWK_ROUTE_CACHE_ */
+#endif /* _NWK_ROUTE_CACHE_H */
+/** eof nwkRouteCache.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteDiscovery.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteDiscovery.h
new file mode 100644
index 00000000..996edcff
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteDiscovery.h
@@ -0,0 +1,91 @@
+/**************************************************************************//**
+ \file nwkRouteDiscovery.h
+
+ \brief Network route discovery header file.
+
+ \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:
+ 2007-09-05 V. Panov - Created.
+ 2008-09-06 M. Gekk - Modified to support parallel processing.
+ 2010-02-06 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkRouteDiscovery.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ROUTE_DISCOVERY_H
+#define _NWK_ROUTE_DISCOVERY_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <nlmeRouteDiscovery.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the route discovery component. */
+typedef enum _NwkRouteDiscoveryState_t
+{
+ NWK_ROUTE_DISCOVERY_IDLE_STATE = 0x99,
+ NWK_ROUTE_DISCOVERY_PROCESS_STATE = 0x38
+} NwkRouteDiscoveryState_t;
+
+/** Internal state and variables of route discovery component. */
+typedef struct _NwkRouteDiscovery_t
+{
+ QueueDescriptor_t queue; /**< Queue of requests from other components. */
+ /** Identifier of initial route request. */
+ NwkRouteRequestId_t routeRequestId;
+#if defined _SYS_ASSERT_ON_
+ /** Finite-state machine. */
+ NwkRouteDiscoveryState_t state;
+#endif /* _SYS_ASSERT_ON_ */
+} NwkRouteDiscovery_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined NWK_ROUTING_CAPACITY \
+ && (defined _NWK_MESH_ROUTING_ || defined _NWK_CONCENTRATOR_)
+/**************************************************************************//**
+ \brief Task handler of the route discovery component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkRouteDiscoveryTaskHandler(void);
+
+/******************************************************************************
+ \brief Reset the route discovery component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetRouteDiscovery(void);
+
+/******************************************************************************
+ \brief Flush all route discovery requests.
+ ******************************************************************************/
+NWK_PRIVATE void nwkFlushRouteDiscovery(void);
+
+/******************************************************************************
+ \brief nwkRouteDiscovery idle checking.
+
+ \return true, if nwkRouteDiscovery performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkRouteDiscoveryIsIdle(void);
+
+#else /* no NWK_ROUTING_CAPACITY */
+
+#define nwkRouteDiscoveryTaskHandler NULL
+#define nwkRouteDiscoveryIsIdle NULL
+#define nwkResetRouteDiscovery() (void)0
+#define nwkFlushRouteDiscovery() (void)0
+
+#endif /* NWK_ROUTING_CAPACITY and (_NWK_MESH_ROUTING_ or _NWK_CONCENTRATOR_) */
+#endif /* _NWK_ROUTE_DISCOVERY_H */
+/** eof nwkRouteDiscovery.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteDiscoveryTable.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteDiscoveryTable.h
new file mode 100644
index 00000000..c25509a2
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteDiscoveryTable.h
@@ -0,0 +1,240 @@
+/**************************************************************************//**
+ \file nwkRouteDiscoveryTable.h
+
+ \brief Interface of the route discovery table.
+
+ \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:
+ 2007-09-17 V. Panov - Created.
+ 2010-02-04 M. Gekk - Redesign.
+ Last change:
+ $Id: nwkRouteDiscoveryTable.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+/**//**
+ * A ZigBee router or ZigBee coordinator maintains a route discovery table
+ * containing the information that is required during route discovery.
+ **/
+#if !defined _NWK_ROUTE_DISCOVERY_TABLE_H
+#define _NWK_ROUTE_DISCOVERY_TABLE_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkSystem.h>
+#include <appFramework.h>
+#include <appTimer.h>
+#include <nwkCommon.h>
+#include <nlmeRouteDiscovery.h>
+#include <nwkPacket.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_RDISC_IS_MANY_TO_ONE(routeDiscoveryEntry) \
+ (NWK_DSTADDRMODE_NOADDR == (routeDiscoveryEntry)->dstAddrMode)
+#define NWK_RDISC_IS_MULTICAST(routeDiscoveryEntry) \
+ (NWK_DSTADDRMODE_MULTICAST == (routeDiscoveryEntry)->dstAddrMode)
+#define NWK_RDISC_IS_UNICAST(routeDiscoveryEntry) \
+ (NWK_DSTADDRMODE_SHORT == (routeDiscoveryEntry)->dstAddrMode)
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Route discovery table entry. See ZigBee spec r18, Table 3.53, page 391. */
+typedef struct _NwkRouteDiscoveryEntry_t
+{
+ /** Time-to-live of entry. If this field is equal to 0 then entry is inactive.
+ **/
+ uint8_t ttl;
+ /* For this entry route request transmission is required or not. */
+ bool routeRequestRequired : 1;
+ /** A flag indicating that route request is required on originator. */
+ bool initialRouteRequest : 1;
+ /* For this entry route reply transmission is required or not. */
+ bool routeReplyRequired : 1;
+ bool highPriority : 1;
+ /** A flag indicating that the concentrator does not store source routes. */
+ bool noRouteCache : 1;
+ /* - NWK_DSTADDRMODE_NOADDR - this value indicating that the source node
+ * is a concentrator that issued a many-to-one route request.
+ * - NWK_DSTADDRMODE_MULTICAST - the destination address is a Group ID.
+ * - NWK_DSTADDRMODE_SHORT - unicast route discovery.
+ * */
+ NwkBitField_t dstAddrMode : 2;
+ bool reserved : 1;
+ /** The accumulated path cost from the source of
+ * the route request to the current device. */
+ NwkPathCost_t forwardCost;
+ /** The accumulated path cost from the current device
+ * to the destination device. */
+ NwkPathCost_t residualCost;
+ /** The 16-bit network address of the route request's initiator. */
+ ShortAddr_t srcAddr;
+ /** The 16-bit network address of the device that has sent the most recent
+ * lowest cost route request command frame corresponding to this entry's
+ * route request identifier and source address. This field is used to
+ * determine the path that an eventual route reply command frame should
+ * follow. */
+ ShortAddr_t senderAddr;
+ /** Destination short address or group id of route discovery request. */
+ ShortAddr_t dstAddr;
+ /** A sequence number for a route request command frame that is incremented
+ * each time a device initiates a route request. */
+ NwkRouteRequestId_t routeRequestId;
+ /** Current hop distance from originator of route descovery. */
+ NwkRadius_t radius;
+ /** Sequence number of initial route request command. */
+ uint8_t sequenceNumber;
+ /** Initial route request parameters. */
+ NWK_RouteDiscoveryReq_t *req;
+ /** Pointer to output network packet. */
+ NwkOutputPacket_t *outPkt;
+} NwkRouteDiscoveryEntry_t;
+
+/** State of processing of incoming requests to send route request
+ * or reply commands. */
+typedef enum _NwkRouteDiscoveryTableState_t
+{
+ NWK_RDISC_TABLE_IDLE_STATE = 0x00,
+ /** Preparing and sending of route reqply or request command. */
+ NWK_RDISC_TABLE_REQUEST_PROCESSING_STATE = 0x93,
+ /** Wating a free packet from the network packet manager. */
+ NWK_RDISC_TABLE_WAIT_PACKET_STATE = 0x1A
+} NwkRouteDiscoveryTableState_t;
+
+/**
+ * Route discovery table - a table used by a ZigBee coordinator or ZigBee router
+ * to store temporary information used during route discovery.
+ **/
+typedef struct _NwkRouteDiscoveryTable_t
+{
+ /** The countdown timer that is used for decrement of time-to-live fields.*/
+ HAL_AppTimer_t timer;
+ /** Pointer to the route discovery table. */
+ NwkRouteDiscoveryEntry_t *table;
+ /** Pointer to memory area after last entry of the route discovery table. */
+ NwkRouteDiscoveryEntry_t *end;
+ /** Current state of the route discovery table. */
+ NwkRouteDiscoveryTableState_t state;
+ /** Boolean flag indicating that the countdown timer is started. */
+ bool isTimerStarted;
+} NwkRouteDiscoveryTable_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined NWK_ROUTING_CAPACITY \
+ && (defined _NWK_MESH_ROUTING_ || defined _NWK_MANY_TO_ONE_ROUTING_)
+/**************************************************************************//**
+ \brief Allocate place for new discovery request in the route discovery table.
+
+ \param[in] highPriority - if new entry is important
+ then this parameter is 'true' otherwise 'false'.
+ \return Pointer to an allocated route discovery entry or NULL.
+ ******************************************************************************/
+NWK_PRIVATE
+NwkRouteDiscoveryEntry_t* nwkAllocRouteDiscoveryEntry(const bool highPriority);
+
+/**************************************************************************//**
+ \brief Find an active route discovery entry by route request id and source address.
+
+ \param[in] srcAddr - network address of route discovery originator.
+ \param[in] requestId - identifier of initial route request.
+ \return Pointer to a route discovery entry or NULL if entry is not found.
+ ******************************************************************************/
+NWK_PRIVATE NwkRouteDiscoveryEntry_t* nwkFindRouteDiscoveryEntry(
+ const ShortAddr_t srcAddr,
+ const NwkRouteRequestId_t requestId);
+
+/**************************************************************************//**
+ \brief Main task handler of the NWK route discovery component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkRouteDiscoveryTableTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Indication about network packet realizing.
+ ******************************************************************************/
+NWK_PRIVATE void nwkRouteDiscoveryTableFreePacketInd(void);
+
+/**************************************************************************//**
+ \brief Reset internal state and entries of the route discovery table.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetRouteDiscoveryTable(void);
+
+/**************************************************************************//**
+ \brief Stop processing of route discovery entries.
+ ******************************************************************************/
+NWK_PRIVATE void nwkFlushRouteDiscoveryTable(void);
+
+/**************************************************************************//**
+ \brief Prepare and send the route request command.
+
+ \param[in] entry - pointer to a route discovery entry that is required
+ transmission of route request command.
+ \param[in] isInitialRequest - 'true' if this node is originator
+ of route discovery otherwise 'false'.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE
+void nwkSendRouteDiscoveryRequest(NwkRouteDiscoveryEntry_t *const entry,
+ const bool isInitialRequest);
+
+/******************************************************************************
+ \brief nwkRouteDiscoveryTable idle checking.
+
+ \return true, if nwkRouteDiscoveryTable performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkRouteDiscoveryTableIsIdle(void);
+
+#if defined _NWK_MESH_ROUTING_
+/**************************************************************************//**
+ \brief Prepare and send the route reply command.
+
+ \param[in] entry - pointer to a route discovery entry that is required
+ transmission of route reply command.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE
+void nwkSendRouteDiscoveryReply(NwkRouteDiscoveryEntry_t *const entry);
+#endif /* _NWK_MESH_ROUTING_ */
+
+/**************************************************************************//**
+ \brief Reliably adding a path cost and a link cost.
+
+ \param[in] pathCost - cost of path.
+ \param[in] linkCost - cost of link.
+ \return Summary path cost.
+ ******************************************************************************/
+NWK_PRIVATE NwkPathCost_t nwkSumPathCost(const NwkPathCost_t pathCost,
+ const NwkLinkCost_t linkCost);
+
+/**************************************************************************//**
+ \brief Confirmation of the route request transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of route request transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmRouteRequestTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+#else /* NWK_ROUTING_CAPACITY and _NWK_MESH_ROUTING_ */
+
+#define nwkRouteDiscoveryTableTaskHandler NULL
+#define nwkConfirmRouteRequestTx NULL
+#define nwkRouteDiscoveryTableIsIdle NULL
+#define nwkResetRouteDiscoveryTable() (void)0
+#define nwkRouteDiscoveryTableFreePacketInd() (void)0
+
+#endif /* NWK_ROUTING_CAPACITY and (_NWK_MESH_ROUTING_ or _NWK_MANY_TO_ONE_ROUTING_) */
+#endif /* _NWK_ROUTE_DISCOVERY_TABLE_H */
+/* eof nwkRouteDiscoveryTable.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteRecord.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteRecord.h
new file mode 100644
index 00000000..144628c9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteRecord.h
@@ -0,0 +1,172 @@
+/**************************************************************************//**
+ \file nwkRouteRecord.h
+
+ \brief Interface of the route record functionality.
+
+ \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:
+ 2007-09-28 V. Panov - Created.
+ 2008-12-10 M. Gekk - Memory optimization.
+ 2010-03-07 M. Gekk - Redesign.
+ Last change:
+ $Id: nwkRouteRecord.h 18167 2011-08-08 11:26:31Z mgekk $
+ ******************************************************************************/
+/**//**
+ * The route record command allows the route taken by a unicast packet
+ * through the network to be recorded in the command payload and delivered
+ * to the destination device. ZigBee spec r18, 3.4.5, page 330.
+ **/
+#if !defined _NWK_ROUTE_RECORD_H
+#define _NWK_ROUTE_RECORD_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <nwkCommon.h>
+#include <nldeData.h>
+#include <nwkFrame.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_ROUTE_RECORD_TX_PARAMETERS \
+ {NWK_TX_DELAY_INITIAL_ROUTE_RECORD, nwkPrepareRouteRecordTx, \
+ nwkConfirmRouteRecordTx, true}
+#define NWK_ROUTE_RECORD_TRANSIT_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, nwkPrepareTransitRouteRecordTx, NULL, true}
+#define NWK_IS_NOT_ROUTE_RECORD(outPkt) \
+ ((NWK_ROUTE_RECORD_TX_ID != (outPkt)->txId) && \
+ (NWK_ROUTE_RECORD_TRANSIT_TX_ID != (outPkt)->txId))
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Route record command format. ZigBee spec r18, Figure 3.18, page 330. */
+BEGIN_PACK
+typedef struct PACK _NwkRouteRecordPayload_t
+{
+ /** The identifier of the route request command. */
+ uint8_t commandId;
+ /** This field contains the number of relays in the relay list field of
+ * the route record command. ZigBee spec r18, 3.4.5.3.1, page 331. */
+ uint8_t relayCount;
+ /** The relay list field is a list of the 16-bit network addresses of the nodes
+ * that have relayed the packet. ZigBee spec r18, 3.4.5.3.2, page 331. */
+ ShortAddr_t relayList[NWK_MAX_SOURCE_ROUTE];
+} NwkRouteRecordPayload_t;
+END_PACK
+
+/** Internal states of the route record component */
+typedef enum _NwkRouteRecordState_t
+{
+ NWK_ROUTE_RECORD_IDLE_STATE = 0x2E,
+ NWK_ROUTE_RECORD_FIRST_STATE = 0xF6,
+ NWK_ROUTE_RECORD_BEGIN_STATE = NWK_ROUTE_RECORD_FIRST_STATE,
+ NWK_ROUTE_RECORD_PREPARE_STATE = 0xF7,
+ NWK_ROUTE_RECORD_SEND_STATE = 0xF8,
+ NWK_ROUTE_RECORD_CONFIRM_STATE = 0xF9,
+ NWK_ROUTE_RECORD_LAST_STATE
+} NwkRouteRecordState_t;
+
+/** Internal variables and state of the route record component. */
+typedef struct _NwkRouteRecord_t
+{
+ QueueDescriptor_t queue; /**< Queue of requests from other NWK components. */
+ NwkRouteRecordState_t state; /**< finite-state machine. */
+} NwkRouteRecord_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_ROUTE_RECORD_
+/**************************************************************************//**
+ \brief Send the route record command before given output packet.
+
+ \param[in] outPkt - pointer to output packet for which route record is sending.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkRouteRecordReq(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Transmission of the route record command is done.
+
+ \param[in] outPkt - pointer to output packet for which route record is sending.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkRouteRecordConf(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the route record command.
+
+ \param outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareRouteRecordTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of the route record command transmission.
+
+ \param outPkt - pointer to output packet.
+ \param status - network status of route record transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmRouteRecordTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/**************************************************************************//**
+ \brief Relay list of transit route record is changed.
+
+ \param outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE
+void nwkPrepareTransitRouteRecordTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Reset the route record component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetRouteRecord(void);
+
+/**************************************************************************//**
+ \brief Main task handler of the route record component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkRouteRecordTaskHandler(void);
+
+#else /* NWK_ROUTING_CAPACITY and _NWK_ROUTE_RECORD_ */
+
+#define nwkPrepareRouteRecordTx NULL
+#define nwkConfirmRouteRecordTx NULL
+#define nwkPrepareTransitRouteRecordTx NULL
+#define nwkResetRouteRecord() (void)0
+#define nwkRouteRecordTaskHandler NULL
+
+#endif /* NWK_ROUTING_CAPACITY and _NWK_ROUTE_RECORD_ */
+
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_ROUTE_CACHE_
+/******************************************************************************
+ \brief Action when a route record command is received.
+
+ \param payload - pointer to raw command payload.
+ \param header - pointer to raw NWK header of command.
+ \param parse - parsed NWK header fields.
+ \return 'true' if continue processing of command packet otherwise 'false'.
+******************************************************************************/
+NWK_PRIVATE bool nwkRouteRecordFrameInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+#else /* NWK_ROUTING_CAPACITY and _NWK_ROUTE_CACHE_*/
+#define nwkRouteRecordFrameInd NULL
+#endif /* NWK_ROUTING_CAPACITY and _NWK_ROUTE_CACHE_ */
+
+#endif /* _NWK_ROUTE_RECORD_H */
+/** eof nwkRouteRecord.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteReply.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteReply.h
new file mode 100644
index 00000000..f0b8c0f2
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteReply.h
@@ -0,0 +1,125 @@
+/**************************************************************************//**
+ \file nwkRouteReply.h
+
+ \brief Route reply command types and functions.
+
+ \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:
+ 2007-09-17 V. Panov - Created.
+ 2009-11-07 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkRouteReply.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ROUTE_REPLY_H
+#define _NWK_ROUTE_REPLY_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkSystem.h>
+#include <appFramework.h>
+#include <nwkCommon.h>
+#include <nldeData.h>
+#include <nwkFrame.h>
+#include <nwkRouteDiscoveryTable.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_ROUTE_REPLY_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, NULL, NULL, true}
+/* Maximum amount of extended addresses in the route reply payload. */
+#define NWK_MAX_RREPLY_EXT_ADDR_AMOUNT 2U
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** The options field of route reply command. ZigBee spec. r17, Figure 3.14. */
+BEGIN_PACK
+typedef struct PACK _NwkRouteReplyOptions_t
+{
+ LITTLE_ENDIAN_OCTET(5, (
+ NwkBitField_t reserved1 : 4,
+ /** If this field has value of 1 then the IEEE address of originator is
+ * included in the payload of the route reply command. */
+ NwkBitField_t extAddrOfOriginator : 1,
+ /** If this field has value of 1 then the IEEE address of responder is
+ * included in the payload of the route reply command. */
+ NwkBitField_t extAddrOfResponder : 1,
+ /** This field shall have a value of 1 if and only if the command frame is
+ * a reply to a request for a route to a multicast group. */
+ NwkBitField_t multicast : 1,
+ NwkBitField_t reserved2 : 1
+ ))
+} NwkRouteReplyOptions_t;
+
+/** The NWK payload of the route reply command. */
+typedef struct PACK _NwkRouteReplyPayload_t
+{
+ /** The identifier of the route reply command. */
+ NwkCommandIdField_t commandId;
+ /** The format of the 8-bit command options field is shown in
+ * ZigBee spec r17, Figure 3.14, page 319. */
+ NwkRouteReplyOptions_t options;
+ /** The route request identifier is the number of the route request to which
+ * this frame is a reply. ZigBee spec r17, 3.4.2.3.2. */
+ uint8_t routeRequestId;
+ /** The network address of the originator of the route request command frame
+ * to which this frame is a reply. ZigBee spec r17, 3.4.2.3.3, page 320. */
+ ShortAddr_t shortAddrOfOriginator;
+ /** The responder address field shall always be the same as the value
+ * in the destination address field of the corresponding route request
+ * command frame.*/
+ ShortAddr_t shortAddrOfResponder;
+ /** The path cost field is used to sum link cost as the route reply
+ * command frame transits the network. */
+ NwkPathCost_t pathCost;
+ /** The first element contain the 64-bit address of the originator of
+ * the route request command frame to which this frame is a reply.
+ * The second element contain the 64-bit address of the destination of
+ * the route request command frame to which this frame is a reply.*/
+ ExtAddr_t extAddr[NWK_MAX_RREPLY_EXT_ADDR_AMOUNT];
+} NwkRouteReplyPayload_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_MESH_ROUTING_
+/******************************************************************************
+ \brief Action when command received.
+
+ \param[in] payload - pointer to payload of route reply command.
+ \param[in] header - pointer to raw network header of route reply command.
+ \param[in] parse - parsed header fields.
+ \return 'true' if continue processing of command packet otherwise 'false'.
+******************************************************************************/
+NWK_PRIVATE bool nwkRouteReplyFrameInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the route reply command.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] entry - pointer to a route discovery entry.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareRouteReplyTx(NwkOutputPacket_t *const outPkt,
+ NwkRouteDiscoveryEntry_t *const entry);
+
+#else /* NWK_ROUTING_CAPACITY */
+
+#define nwkRouteReplyFrameInd NULL
+
+#endif /* NWK_ROUTING_CAPACITY */
+#endif /* _NWK_ROUTE_REPLY_H */
+/** eof nwkRouteReply.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteRequest.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteRequest.h
new file mode 100644
index 00000000..45bf6d03
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteRequest.h
@@ -0,0 +1,149 @@
+/**************************************************************************//**
+ \file nwkRouteRequest.h
+
+ \brief Interface of route request commands.
+
+ \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:
+ 2007-09-17 V. Panov - Created.
+ 2008-12-10 M. Gekk - Optimization of NWK memory.
+ 2009-11-20 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkRouteRequest.h 18498 2011-09-12 08:49:29Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_ROUTE_REQUEST_H
+#define _NWK_ROUTE_REQUEST_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkSystem.h>
+#include <appFramework.h>
+#include <nldeData.h>
+#include <nwkFrame.h>
+#include <nwkRouteDiscoveryTable.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+/** Transmission parameters of route request command. */
+#define NWK_INITIAL_ROUTE_REQ_TX_PARAMETERS \
+ {NWK_TX_DELAY_INITIAL_ROUTE_REQUEST, NULL, nwkConfirmRouteRequestTx, true}
+#define NWK_ROUTE_REQ_TX_PARAMETERS \
+ {NWK_TX_DELAY_ROUTE_REQUEST, NULL, NULL, true}
+#define NWK_INITIAL_MANYTOONE_ROUTE_REQ_TX_PARAMETERS \
+ {NWK_TX_DELAY_INITIAL_MANYTOONE_ROUTE_REQUEST, NULL, nwkConfirmRouteRequestTx, true}
+#define NWK_MANYTOONE_ROUTE_REQ_TX_PARAMETERS \
+ {NWK_TX_DELAY_MANYTOONE_ROUTE_REQUEST, NULL, NULL, true}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Many-to-One field values. See ZigBee spec r18, 3.4.1.3.1.1, page 320. */
+typedef enum _NwkRReqManyToOneFlag_t
+{
+ /** The route request is not a many-to-one route request. */
+ NWK_RREQ_IS_NOT_MANY_TO_ONE = 0,
+ /** The route request is a many-to-one route request and the sender supports
+ * a route record table.*/
+ NWK_RREQ_IS_MANY_TO_ONE = 1,
+ /** The route request is a many-to-one route request and the sender does not
+ * support a route record table. */
+ NWK_RREQ_IS_MANY_TO_ONE_NO_RREC_TABLE = 2,
+ NWK_RREQ_RESERVED_MANY_TO_ONE_FLAG = 3
+} NwkRReqManyToOneFlag_t;
+
+BEGIN_PACK
+/** Route request command options field. ZigBee spec r18, 3.4.1.3.1, page 320.
+ **/
+typedef struct PACK _NwkRouteRequestOptions_t
+{
+ LITTLE_ENDIAN_OCTET(5, (
+ NwkBitField_t reserved1 : 3,
+ /** The many-to-one field shall have one of the non-reserved values shown
+ * in ZigBee spec r18, Table 3.41 and type NwkRReqManyToOneFlag_t. */
+ NwkBitField_t manyToOne : 2,
+ /** The destination IEEE address field is a single-bit field. It shall have
+ * a value of 1 if, and only if, the command frame contains the destination
+ * IEEE address. ZigBee spec r18, 3.4.1.3.1.2, page 321. */
+ NwkBitField_t dstExt : 1,
+ /** The multicast sub-field is a single-bit field. It shall have a value
+ * of 1 if, and only if, the command frame is a request for a route
+ * to a multicast group... ZigBee spec r18, 3.4.1.3.1.3, page 321. */
+ NwkBitField_t multicast : 1,
+ NwkBitField_t reserved2 : 1
+ ))
+} NwkRouteRequestOptions_t;
+END_PACK
+
+BEGIN_PACK
+/** Route request command frame format. See ZigBee spec r18,
+ * Figure 3.11, page 319. */
+typedef struct PACK _NwkRouteRequestPayload_t
+{
+ /** The identifier of the route request command. */
+ uint8_t commandId;
+ /** Route request command options field. See NwkRouteRequestOptions_t. */
+ NwkRouteRequestOptions_t options;
+ /** The route request identifier is an 8-bit sequence number for route
+ * requests and is incremented by 1 every time the NWK layer on a particular
+ * device issues a route request. ZigBee spec r18, 3.4.1.3.2, page 321. */
+ NwkRouteRequestId_t identifier;
+ /** The destination address shall be 2 octets in length and represents
+ * the intended destination of the route request command frame.
+ * ZigBee spec r18, 3.4.1.3.3. */
+ ShortAddr_t dstAddr;
+ /** The path cost field is eight bits in length and is used to accumulate
+ * routing cost information as a route request command frame moves through
+ * the network. ZigBee spec r18, 3.4.1.3.4, page 321; sub-clause 3.6.3.5.2. */
+ NwkPathCost_t pathCost;
+ /** The destination IEEE address shall be 8 octets in length and represents
+ * the IEEE address of the destination of the route request command frame.
+ ** ZigBee spec r18, 3.4.1.3.5, page 321. */
+ ExtAddr_t dstExtAddr;
+} NwkRouteRequestPayload_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined NWK_ROUTING_CAPACITY \
+ && (defined _NWK_MESH_ROUTING_ || defined _NWK_MANY_TO_ONE_ROUTING_)
+/**************************************************************************//**
+ \brief Action when route request command received.
+
+ \param[in] payload - pointer to payload of route request command.
+ \param[in] header - pointer to raw network header of route request command.
+ \param[in] parse - parsed header fields.
+
+ \return 'true' if continue processing of command packet otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkRouteRequestFrameInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the route request command.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] entry - pointer to a route discovery entry.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareRouteRequestTx(NwkOutputPacket_t *const outPkt,
+ NwkRouteDiscoveryEntry_t *const entry);
+
+#else /* NWK_ROUTING_CAPACITY and (_NWK_MESH_ROUTING_ or _NWK_MANY_TO_ONE_ROUTING_) */
+
+#define nwkRouteRequestFrameInd NULL
+
+#endif /* NWK_ROUTING_CAPACITY and (_NWK_MESH_ROUTING_ or _NWK_MANY_TO_ONE_ROUTING_) */
+#endif /* _NWK_ROUTE_REQUEST_H */
+/** eof nwkRouteRequest.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouting.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouting.h
new file mode 100644
index 00000000..3ed7e025
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouting.h
@@ -0,0 +1,71 @@
+/**************************************************************************//**
+ \file nwkRouting.h
+
+ \brief Routing header file.
+
+ \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:
+ 2007-06-14 V. Panov - Created.
+ 2008-09-06 M. Gekk - Modified to support parallel processing.
+ 2009-09-08 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkRouting.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ROUTING_H
+#define _NWK_ROUTING_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <appFramework.h>
+#include <nldeData.h>
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Getting MAC short address of next hop by destination network address.
+
+ \param[in] dstAddr - destination network address.
+ \param[in] srcAddr - short address of node for that a next hop is searched.
+ \param[in] prevHopAddr - address of previous hop.
+ \param[in] isMulticast - 'true' if destination address is multicast group.
+ \param[in] isMulticastMember - 'true' if destination address is multicast
+ member address.
+ \param[in] nextHop - pointer to short address of next hop node
+ or MAC_NO_SHORT_ADDR.
+ \param[in] hops - number of hops that is equal to CS_MAX_NETWORK_DEPTH * 2.
+ It is not read in function to avoid unnecessary reading of
+ CS_MAX_NETWORK_DEPTH when not implementing routing of packet
+ from upper layer.
+
+ \return Routing method used for searching the next hop node.
+ ******************************************************************************/
+NWK_PRIVATE NwkRouting_t nwkGetNextHop(const ShortAddr_t dstAddr,
+ const ShortAddr_t srcAddr, const ShortAddr_t prevHopAddr,
+ const bool isMulticast, const bool isMulticastMember,
+ ShortAddr_t *const nextHop, NwkRadius_t hops);
+
+/**************************************************************************//**
+ \brief Process routing result.
+
+ Update link state, the routing table and indicate to upper layer..
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] nwkStatus - status of transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkRoutingIsCompleted(const NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t nwkStatus);
+
+#endif /* _NWK_ROUTING_H */
+/** eof nwkRouting.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRoutingTable.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRoutingTable.h
new file mode 100644
index 00000000..b0a80408
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRoutingTable.h
@@ -0,0 +1,162 @@
+/**************************************************************************//**
+ \file nwkRoutingTable.h
+
+ \brief Interface of the routing table.
+
+ \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:
+ 2009-11-15 Max Gekk - Created.
+ Last change:
+ $Id: nwkRoutingTable.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_ROUTING_TABLE_H
+#define _NWK_ROUTING_TABLE_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <appFramework.h>
+#include <nwkCommon.h>
+#include <nwkSystem.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Type of routing table size. */
+typedef uint8_t NwkRoutingTableSize_t;
+/** Type of routing entry index. */
+typedef NwkRoutingTableSize_t NwkRoutingEntryIndex_t;
+/** Type of routing rate. */
+typedef uint8_t NwkRoutingRate_t;
+
+/** Routing table entry. ZigBee spec r17, Table 3.51. */
+typedef struct _NwkRoutingTableEntry_t
+{
+ /** The 16-bit network address or Group ID of this route. If the destination
+ * device is a ZigBee router, ZigBee coordinator, or an end device, and
+ * nwkAddrAlloc has a value of 0x02, this field shall contain the actual
+ * 16-bit address of that device. If the destination device is an end device
+ * and nwkAddrAlloc has a value of 0x00, this field shall contain the 16-bit
+ * network address of the device's parent. */
+ ShortAddr_t dstAddr;
+ /** The 16-bit network address of the next hop on the way to the destination.
+ **/
+ ShortAddr_t nextHopAddr;
+ /** A flag indicating that the entry is active. */
+ bool active : 1;
+ /** A flag indicating that the destination indicated by this address does
+ * not store source routes. */
+ bool noRouteCache : 1;
+ /** A flag indicating that the destination is a concentrator
+ * that issued a many-to-one route request. */
+ bool manyToOne : 1;
+ /** A flag indicating that a route record command frame should be sent to
+ * the destination prior to the next data packet. */
+ bool routeRecordRequired : 1;
+ /** A flag indicating that the destination address is a Group ID. */
+ bool groupId : 1;
+ /** Counter of the many-to-one discovery periods
+ * without any source route packets. */
+ NwkBitField_t noSourceRoutePeriods : 2;
+ /** Indicate to upper layer about new concentrator. */
+ bool newConcentrator : 1;
+ NwkRoutingRate_t rate;
+ /** Cost of route path to destination node. */
+ NwkPathCost_t cost;
+} NwkRoutingTableEntry_t;
+
+/** The routing table. */
+typedef struct _NwkRoutingTable_t
+{
+ /** Pointer to first entry of the routing table. */
+ NwkRoutingTableEntry_t *table;
+ /** Current size of the routing table. */
+ NwkRoutingTableSize_t size;
+ /* Number of failure transmission after that a routing entry will be deleted.
+ **/
+ uint8_t failOrder;
+} NwkRoutingTable_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined NWK_ROUTING_CAPACITY \
+ && (defined _NWK_MESH_ROUTING_ || defined _NWK_MANY_TO_ONE_ROUTING_)
+/**************************************************************************//**
+ \brief Allocate a new entry in the routing table.
+
+ \return pointer to an entry or NULL.
+ ******************************************************************************/
+NWK_PRIVATE NwkRoutingTableEntry_t* nwkAllocRoutingEntry(void);
+
+/**************************************************************************//**
+ \brief Free the entry of the routing table.
+
+ \param[in] dstAddr - a short address of destination node.
+ \param[in] isGroupId - 'true' if dstAddr is group id otherwise 'false'.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkFreeRoutingEntry(const ShortAddr_t dstAddr,
+ const bool isGroupId);
+
+/**************************************************************************//**
+ \brief Find a routing table entry by destination address.
+
+ \param[in] dstAddr - a short address of destination node.
+ \param[in] isGroupId - 'true' if dstAddr is group id otherwise 'false'.
+
+ \return pointer to a routing table entry with given dstAddr.
+ ******************************************************************************/
+NWK_PRIVATE
+NwkRoutingTableEntry_t* nwkFindRoutingEntry(const ShortAddr_t dstAddr,
+ const bool isGroupId);
+
+/******************************************************************************
+ \brief Update information of the routing table entry after a packet transmission.
+
+ \param[in] entry - pointer to an entry in the routing table.
+ \param status - NWK status of packet transmission.
+ ******************************************************************************/
+NWK_PRIVATE void nwkUpdateRoutingEntry(NwkRoutingTableEntry_t *const entry,
+ const NWK_Status_t status);
+
+/**************************************************************************//**
+ \brief Reset the routing table.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetRoutingTable(void);
+
+#if defined _NWK_MESH_ROUTING_
+/**************************************************************************//**
+ \brief Setting the next hop address of the routing table entry.
+
+ \param[in] dstAddr - a short address of destination node.
+ \param[in] nextHopAddr - short address of next hop node.
+ \param[in] isGroupId - 'true' if dstAddr is group id otherwise 'false'.
+ \param[in] cost - cost of path to destination node.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkUpdateNextHop(const ShortAddr_t dstAddr,
+ const bool isGroupId, const ShortAddr_t nextHopAddr,
+ const NwkPathCost_t cost);
+
+#else
+#define nwkUpdateNextHop(dstAddr, isGroupId, nextHopAddr, cost) (void)0
+#endif /* _NWK_MESH_ROUTING_ */
+#else /* NWK_ROUTING_CAPACITY and (_NWK_MESH_ROUTING_ or _NWK_MANY_TO_ONE_ROUTING_) */
+
+#define nwkResetRoutingTable() (void)0
+#define nwkUpdateNextHop(dstAddr, isGroupId, nextHopAddr, cost) (void)0
+#define nwkFreeRoutingEntry(dstAddr, isGroupId) (void)0
+
+#endif /* NWK_ROUTING_CAPACITY and (_NWK_MESH_ROUTING_ or _NWK_MANY_TO_ONE_ROUTING_) */
+#endif /* _NWK_ROUTING_TABLE_H */
+/** eof nwkRoutingTable.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRx.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRx.h
new file mode 100644
index 00000000..5366119f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRx.h
@@ -0,0 +1,85 @@
+/**************************************************************************//**
+ \file nwkRx.h
+
+ \brief Functions of processing of input data
+
+ \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:
+ 2007-06-14 V. Panov - Created.
+ 2008-11-25 M. Gekk - Counters of buffers have been remote.
+ 2008-12-10 M. Gekk - Memory optimization.
+ 2009-07-08 M. Gekk - Redesign.
+ Last change:
+ $Id: nwkRx.h 18298 2011-08-19 12:42:09Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_RX_H
+#define _NWK_RX_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkCommon.h>
+#include <nwkSystem.h>
+#include <nwkFrame.h>
+#include <nldeData.h>
+#include <nwkTx.h>
+#if defined _SECURITY_
+#include <sspSfp.h>
+#endif /* _SECURITY_ */
+
+/******************************************************************************
+ Definition section
+ ******************************************************************************/
+#define NWK_UNICAST_COMMAND_TRANSIT_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, NULL, NULL, true}
+#define NWK_UNICAST_DATA_TRANSIT_TX_PARAMETERS \
+ {NWK_TX_DELAY_TRANSIT_DATA, NULL, NULL, true}
+#define NWK_BROADCAST_TRANSIT_TX_PARAMETERS \
+ {NWK_TX_DELAY_BROADCAST, NULL, NULL, true}
+#define NWK_MULTICAST_MEMBER_TRANSIT_TX_PARAMETERS \
+ {NWK_TX_DELAY_MULTICAST, NULL, NULL, true}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Input packet meta information. */
+typedef struct _NwkInputPacket_t
+{
+ bool retransmit : 1;
+ bool decryptRequired : 1;
+ bool indicate : 1;
+ NwkBitField_t txId : 5;
+ uint8_t *data;
+ NwkLength_t length;
+ NwkParseHeader_t parsedHeader;
+ union
+ {
+ NWK_DataInd_t dataInd;
+#if defined _SECURITY_
+ SSP_DecryptFrameReq_t decryptReq;
+#endif /* _SECURITY_ */
+ } primitive;
+} NwkInputPacket_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief The upper layer has completed data processing.
+
+ \param[in] resp - NLDE-DATA indication primitive's parameters structure.
+ \return None.
+ ******************************************************************************/
+void NWK_DataResp(NWK_DataResp_t *resp);
+
+#endif /* _NWK_RX_H */
+/** eof nwkRx.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRxSecurity.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRxSecurity.h
new file mode 100644
index 00000000..3bdea48a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRxSecurity.h
@@ -0,0 +1,54 @@
+/**************************************************************************//**
+ \file nwkRxSecurity.h
+
+ \brief Interface of security processing of incoming packets.
+
+ \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:
+ 2011-02-03 M. Gekk - Created.
+ Last change:
+ $Id: nwkRxSecurity.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_RX_SECURITY_H
+#define _NWK_RX_SECURITY_H
+
+#if defined _SECURITY_
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkSecurity.h>
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Update the incoming frame counter by key sequence number.
+
+ \param[in] seqNum - key sequence number.
+ \param[in] srcExtAddr - an extended source address.
+ \param[in] newValue - a new value of the incoming frame counter.
+
+ \return 'true' if incoming frame counter is updated otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkUpdateInFrameCounter(const NWK_KeySeqNum_t seqNum,
+ const ExtAddr_t srcExtAddr, const NwkInFrameCounter_t counter);
+
+/**************************************************************************//**
+ \brief Get network key by key sequence number.
+
+ \return Pointer to value of a network key.
+ ******************************************************************************/
+NWK_PRIVATE const uint8_t* NWK_GetKey(const NWK_KeySeqNum_t seqNum);
+
+#endif /* _SECURITY_ */
+#endif /* _NWK_RX_SECURITY_H */
+/** eof nwkRxSecurity.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSilentJoin.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSilentJoin.h
new file mode 100644
index 00000000..430dc08d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSilentJoin.h
@@ -0,0 +1,94 @@
+/*************************************************************************//**
+ \file nwkSilentJoin.h
+
+ \brief Interface of silent join functionality.
+
+ \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:
+ 2011-03-17 A. Taradov - Created.
+ Last change:
+ $Id: nwkOrphan.h 15388 2011-02-20 23:55:47Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_SILENT_JOIN_H
+#define _NWK_SILENT_JOIN_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <nlmeJoin.h>
+#include <macSetGet.h>
+#include <macRxEnable.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+typedef enum
+{
+ NWK_SILENT_JOIN_STATE_MIN = 0x15,
+ NWK_SILENT_JOIN_STATE_IDLE,
+ NWK_SILENT_JOIN_STATE_REQUEST_QUEUED,
+ NWK_SILENT_JOIN_STATE_SET_PARAMS,
+ NWK_SILENT_JOIN_STATE_MAX
+} NwkSilentJoinState_t;
+
+/** Silent join memory */
+typedef struct _NwkSilentJoin_t
+{
+ NwkSilentJoinState_t state;
+
+#if defined _ROUTER_ || defined _ENDDEVICE_
+ /** Request queue */
+ QueueDescriptor_t queue;
+#endif
+
+#if defined _ROUTER_ || defined _ENDDEVICE_
+ /** Memory for mac requests */
+ union
+ {
+ MAC_SetReq_t set;
+ MAC_RxEnableReq_t rxEnable;
+ } req;
+#endif
+} NwkSilentJoin_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if (defined(_ROUTER_) || defined(_ENDDEVICE_)) && defined(_NWK_SILENT_JOIN_)
+/**************************************************************************//**
+ \brief Silent join module reset.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetSilentJoin(void);
+
+/**************************************************************************//**
+ \brief Main task handler of the silent join module.
+ ******************************************************************************/
+NWK_PRIVATE void nwkSilentJoinTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Process silent join requests.
+
+ \param[in] req - NLME-JOIN request parameters' structure pointer.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkSilentJoinReq(NWK_JoinReq_t *req);
+
+#else
+
+#define nwkResetSilentJoin() (void)0
+#define nwkSilentJoinTaskHandler NULL
+
+#endif /* (_ROUTER_ or _ENDDEVICE_) and _NWK_SILENT_JOIN_ */
+#endif /* _NWK_SILENT_JOIN_H */
+
+/** eof nwkSilentJoin.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSourceRouting.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSourceRouting.h
new file mode 100644
index 00000000..449c859d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSourceRouting.h
@@ -0,0 +1,119 @@
+/**************************************************************************//**
+ \file nwkSourceRouting.h
+
+ \brief Interface of source routing functionality.
+
+ \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:
+ 2010-03-14 M. Gekk - Created.
+ Last change:
+ $Id: nwkSourceRouting.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+/**//**
+ * Source routing allows a sender of a packet to completely specify
+ * the route the packet takes through the network.
+ **/
+#if !defined _NWK_SOURCE_ROUTING_H
+#define _NWK_SOURCE_ROUTING_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nldeData.h>
+#include <nwkDataReq.h>
+#include <nwkFrame.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+#define NWK_SOURCE_ROUTE_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_DATA, nwkPrepareSourceRouteTx, nwkConfirmDataTx, false}
+#define NWK_SOURCE_ROUTE_TRANSIT_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_DATA, nwkPrepareTransitSourceRouteTx, \
+ nwkConfirmTransitSoureRouteTx, true}
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined NWK_ROUTING_CAPACITY \
+ && defined _NWK_SOURCE_ROUTING_ && defined _NWK_CONCENTRATOR_
+/**************************************************************************//**
+ \brief Try to use the source routing, and write the source route subframe.
+
+ Initialize of transmission identifier if source route is used.
+
+ \param[in] req - pointer to NLDE-Data request's parameters.
+ \param[in] nwkHeaderLength - pointer to current maximum length of NWK header.
+
+ \return 'true' if the source route subframe is present otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkUseSourceRouting(NWK_DataReq_t *const req,
+ NwkLength_t *const nwkHeaderLength);
+
+/**************************************************************************//**
+ \brief Prepare an initial source route packet.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareSourceRouteTx(NwkOutputPacket_t *const outPkt);
+
+#else /* NWK_ROUTING_CAPACITY and _NWK_SOURCE_ROUTING_ and _NWK_CONCENTRATOR_ */
+
+#define nwkUseSourceRouting(req, nwkHeaderLength) false
+#define nwkPrepareSourceRouteTx NULL
+
+#endif /* NWK_ROUTING_CAPACITY and _NWK_SOURCE_ROUTING_ and _NWK_CONCENTRATOR_ */
+
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_SOURCE_ROUTING_
+/**************************************************************************//**
+ \brief Decrement the relay index sub-field by 1, and relay the frame to
+ the address immediately prior to its own address in the relay list.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE
+void nwkPrepareTransitSourceRouteTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of source route packet transmission.
+
+ If status isn't NWK_SUCCESS_STATUS then send back NWK status command with
+ code 0x0B (NWK_SOURCE_ROUTE_FAILURE).
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - NWK status of source route packet transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmTransitSoureRouteTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/**************************************************************************//**
+ \brief A data packet has been received for this node.
+
+ Update the source route information about a concentrator.
+
+ \param[in] nwkHeader - pointer to the raw NWK header of a source route packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE
+void nwkUpdateSourceRouteInfo(const NwkFrameHeader_t *const nwkHeader);
+
+#else /* NWK_ROUTING_CAPACITY and _NWK_SOURCE_ROUTING_ */
+#define nwkPrepareTransitSourceRouteTx NULL
+#define nwkConfirmTransitSoureRouteTx NULL
+#define nwkUpdateSourceRouteInfo(nwkHeader) (void)0
+#endif /* NWK_ROUTING_CAPACITY and _NWK_SOURCE_ROUTING_ */
+
+#endif /* _NWK_SOURCE_ROUTING_H */
+/** eof nwkSourceRouting.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStartRouter.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStartRouter.h
new file mode 100644
index 00000000..cb1f3fe9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStartRouter.h
@@ -0,0 +1,89 @@
+/**************************************************************************//**
+ \file nwkStartRouter.h
+
+ \brief Start router header file.
+
+ \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:
+ 2007-06-27 V. Panov - Created.
+ 2008-12-10 M. Gekk - Reduction of usage of the RAM at separate compiling.
+ 2009-03-19 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkStartRouter.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_START_ROUTER_H
+#define _NWK_START_ROUTER_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of NLME-START-ROUTER component */
+typedef enum _NwkStartRouterState_t
+{
+ NWK_START_ROUTER_IDLE_STATE = 0x9A,
+ NWK_START_ROUTER_FIRST_STATE = 0x45,
+ NWK_START_ROUTER_BEGIN_STATE = NWK_START_ROUTER_FIRST_STATE,
+ NWK_START_ROUTER_MAC_REQ_STATE = 0x46,
+ NWK_START_ROUTER_CONFIRM_STATE = 0x47,
+ NWK_START_ROUTER_LAST_STATE
+} NwkStartRouterState_t;
+
+/** Internal parameters of NLME-START-ROUTER */
+typedef struct _NwkStartRouter_t
+{
+ NwkStartRouterState_t state; /**< Finite-state machine */
+ QueueDescriptor_t queue; /**< Queue of requests from upper layer */
+ bool coordRealignment;
+} NwkStartRouter_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _ROUTER_
+/**************************************************************************//**
+ \brief Main task handler of NLME-START-ROUTER component
+ ******************************************************************************/
+NWK_PRIVATE void nwkStartRouterTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Reset NLME-START-ROUTER component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetStartRouter(void);
+
+/******************************************************************************
+ \brief nwkStartRouter idle checking.
+
+ \return true, if nwkStartRouter performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkStartRouterIsIdle(void);
+
+#if defined NWK_COORD_REALIGNMENT
+/**************************************************************************//**
+ \brief Is network configuration realignment allowed or not?
+ ******************************************************************************/
+NWK_PRIVATE bool nwkRealignmentIsAllowed(void);
+#endif /* NWK_COORD_REALIGNMENT */
+
+#else /* _ROUTER_ */
+
+#define nwkStartRouterTaskHandler NULL
+#define nwkStartRouterIsIdle NULL
+#define nwkResetStartRouter() (void)0
+
+#endif /* _ROUTER_ */
+#endif /* _NWKSTARTROUTER_H */
+/** eof nwkStartRouter.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStateMachine.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStateMachine.h
new file mode 100644
index 00000000..19a92871
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStateMachine.h
@@ -0,0 +1,154 @@
+/**************************************************************************//**
+ \file nwkStateMachine.h
+
+ \brief State machine header file.
+
+ \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:
+ 2007-06-14 V. Panov - Created.
+ 2009-02-21 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkStateMachine.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_STATE_MACHINE_H
+#define _NWK_STATE_MACHINE_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkCommon.h>
+#include <nwkMem.h>
+
+/******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+/* Identifiers of modules, packed to groups. A combination of modules, which
+ activity is accepted, forms global NWK layer state. All modules in group
+ change their status simultaneously by some event, so if the activity
+ permission politics changes, perform corrsponding changes. */
+
+#define NWK_MODULE_ID_DATA_REQ (1U << 0)
+#define NWK_MODULE_ID_SYNC (1U << 0)
+#define NWK_MODULE_ID_LINK_STATUS (1U << 0)
+#define NWK_MODULE_ID_NETWORK_COMMAND (1U << 0)
+#define NWK_MODULE_ID_LEAVE (1U << 0)
+#define NWK_MODULE_ID_PANID_CONFLICT (1U << 0)
+#define NWK_MODULE_ID_DATA_IND (1U << 0)
+#define NWK_MODULE_ID_EDSCAN (1U << 0)
+#define NWK_MODULE_ID_ADDR_CONFLICT (1U << 0)
+#define NWK_MODULE_ID_ROUTE_DISCOVERY (1U << 0)
+#define NWK_MODULE_ID_PERMIT_JOINING (1U << 0)
+
+#define NWK_MODULE_ID_FORMATION (1U << 1)
+#define NWK_MODULE_ID_START_ROUTER (1U << 2)
+#define NWK_MODULE_ID_JOIN_IND (1U << 3)
+
+#define NWK_MODULE_ID_JOIN_REQ (1U << 4)
+#define NWK_MODULE_ID_COMMAND_REQ (1U << 4)
+
+#define NWK_MODULE_ID_COMMAND_IND (1U << 5)
+#define NWK_MODULE_ID_DISCOVERY (1U << 5)
+
+/** Reserved bit is set until NWK reset process completed. */
+#define NWK_MODULE_ID_RESERVED (1U << 7)
+
+/* Module permissions */
+#define NWK_MODULE_NONE 0U
+
+#define NWK_EVENT_RESET_REQ \
+ (NWK_MODULE_ID_DISCOVERY | NWK_MODULE_ID_FORMATION \
+ | NWK_MODULE_ID_JOIN_REQ | NWK_MODULE_ID_COMMAND_REQ \
+ | NWK_MODULE_ID_COMMAND_IND | NWK_MODULE_ID_START_ROUTER)
+
+#define NWK_EVENT_FORMATION_SUCCESS \
+ ((NwkStateMachineEvent_t)(~NWK_MODULE_ID_FORMATION))
+
+#define NWK_EVENT_LEAVE_ALL_CHILDREN \
+ ((NwkStateMachineEvent_t)(~NWK_MODULE_ID_JOIN_IND\
+ & ~NWK_MODULE_ID_FORMATION \
+ & ~NWK_MODULE_ID_START_ROUTER))
+
+#define NWK_EVENT_LEAVE_SUCCESS \
+ (NWK_MODULE_ID_JOIN_REQ | NWK_MODULE_ID_COMMAND_REQ \
+ | NWK_MODULE_ID_FORMATION)
+
+#define NWK_EVENT_REJOIN_REQ \
+ (NWK_MODULE_ID_JOIN_REQ | NWK_MODULE_ID_COMMAND_REQ \
+ | NWK_MODULE_ID_COMMAND_IND | NWK_MODULE_ID_DISCOVERY)
+
+#define NWK_EVENT_AWAYTING_RESET (NWK_MODULE_ID_RESERVED)
+#define NWK_EVENT_REJOIN_SUCCESS (NWK_EVENT_FORMATION_SUCCESS)
+#define NWK_EVENT_POWER_FAILURE_RESET (NWK_EVENT_FORMATION_SUCCESS)
+#define NWK_EVENT_JOIN_SUCCESS (NWK_EVENT_FORMATION_SUCCESS)
+#define NWK_EVENT_LEAVE_FAIL (NWK_EVENT_FORMATION_SUCCESS)
+
+#define NWK_EVENT_EDSCAN NWK_MODULE_NONE /* Disable all NWK modules */
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Type of identifier of module. */
+typedef uint8_t NwkStateMachineModuleID_t;
+
+/** Type of NWK event. */
+typedef NwkState_t NwkStateMachineEvent_t;
+
+/******************************************************************************
+ Inline functions section
+ *****************************************************************************/
+/**************************************************************************//**
+ \brief this function return true, if module with moduleID is allowed to work.
+ ******************************************************************************/
+INLINE uint8_t nwkCheckStateMachine(NwkStateMachineModuleID_t moduleID)
+{
+ return (nwkMem.state & moduleID);
+}
+
+/**************************************************************************//**
+ \brief Modules that can switch state machine shall send events.
+
+ \param[in] event - id of event.
+ \return None.
+ ******************************************************************************/
+INLINE void nwkSwitchStateMachine(NwkStateMachineEvent_t event)
+{
+ nwkMem.state = event;
+}
+
+/**************************************************************************//**
+ \brief This function return the current state of network layer.
+
+ \return Current global state of NWK-layer.
+ ******************************************************************************/
+INLINE NwkState_t nwkGetStateMachine(void)
+{
+ return nwkMem.state;
+}
+
+/**************************************************************************//**
+ \brief Set new the network layer state.
+
+ \param[in] state - new state.
+ \return current state
+ ******************************************************************************/
+INLINE void nwkRestoreStateMachine(NwkState_t state)
+{
+ nwkMem.state = state;
+}
+
+/**************************************************************************//**
+ \brief State machine reset routine.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetStateMachine(void);
+
+#endif /* _NWK_STATE_MACHINE_H */
+/** eof nwkStateMachine.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStatusInd.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStatusInd.h
new file mode 100644
index 00000000..ee464c82
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStatusInd.h
@@ -0,0 +1,86 @@
+/**************************************************************************//**
+ \file nwkStatusInd.h
+
+ \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:
+ 2007-06-14 V. Panov - Created
+ 2009-06-16 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkStatusInd.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_STATUS_IND_H
+#define _NWK_STATUS_IND_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nlmeNwkStatus.h>
+#include <nwkFrame.h>
+#include <nwkRx.h>
+
+/******************************************************************************
+ Inline functions section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Wrapper for NLME-NWK-STATUS indication primitive.
+
+ \param[in] shortAddr - a network address of the device associated with
+ the status information.
+ \param[in] status - error code associated with the status indication.
+ \return None.
+ ******************************************************************************/
+INLINE void nwkStatusIndicate(const ShortAddr_t shortAddr,
+ const NWK_StatusIndErrorCodes_t status)
+{
+ NWK_NwkStatusInd_t ind;
+
+ ind.shortAddress = shortAddr;
+ ind.status = status;
+ NWK_NwkStatusInd(&ind);
+}
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined(_ROUTER_) || defined(_COORDINATOR_)
+/**************************************************************************//**
+ \brief NWK status command has been received.
+
+ \param[in] payload - pointer to status code field and destination address.
+ \param[in] header - NWK header of the network status command.
+ \param[in] parse - parsed NWK header.
+ \return 'true' if continue processing of command packet otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkStatusFrameInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+#else /* _ROUTER_ or _COORDINATOR_ */
+#define nwkStatusFrameInd NULL
+#endif /* _ROUTER_ or _COORDINATOR_ */
+
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_MANY_TO_ONE_ROUTING_
+/**************************************************************************//**
+ \brief Is it the input many-to-one network status.
+
+ \param[in] inPkt - pointer to the input packet
+
+ \return 'true' if the input packet is network status command with status code
+ equal to many-to-one route error otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE
+bool nwkIsManyToOneNetworkStatus(const NwkInputPacket_t *const inPkt);
+
+#else
+#define nwkIsManyToOneNetworkStatus(inPkt) false
+#endif /* NWK_ROUTING_CAPACITY and _NWK_MANY_TO_ONE_ROUTING_ */
+#endif /* _NWK_STATUS_IND_H */
+/** eof nwkStatusInd.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStatusReq.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStatusReq.h
new file mode 100644
index 00000000..70ee0f6d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkStatusReq.h
@@ -0,0 +1,230 @@
+/**************************************************************************//**
+ \file nwkStatusReq.h
+
+ \brief Interface of the network status sender.
+
+ \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:
+ 2009-06-23 Max Gekk - Created.
+ Last change:
+ $Id: nwkStatusReq.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_STATUS_REQ_H
+#define _NWK_STATUS_REQ_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <nwkCommon.h>
+#include <nldeData.h>
+#include <nwkFrame.h>
+#include <nwkRx.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Size of NWK status command payload:
+ * - command id - 1 octet
+ * - status code - 1 octet
+ * - destination address - 2 octet */
+#define NWK_STATUS_CMD_PAYLOAD_SIZE 4U
+/** Constant parameters of network status transmission. */
+#define NWK_UNICAST_STATUS_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, nwkPrepareNetworkStatusTx,\
+ nwkConfirmNetworkStatusTx, true}
+#define NWK_BROADCAST_STATUS_TX_PARAMETERS \
+ {NWK_TX_DELAY_BROADCAST, nwkPrepareNetworkStatusTx, \
+ nwkConfirmNetworkStatusTx, true}
+#define NWK_MANY_TO_ONE_STATUS_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, nwkPrepareNetworkStatusTx, \
+ nwkConfirmManyToOneNetworkStatusTx, false}
+#define NWK_MANY_TO_ONE_TRANSIT_STATUS_TX_PARAMETERS \
+ {NWK_TX_DELAY_UNICAST_COMMAND, NULL,\
+ nwkConfirmManyToOneNetworkStatusTx, false}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Confirmation parameters of NWK status command sending. */
+typedef struct _NwkStatusConf_t
+{
+ /* Status of NWK status command sending.*/
+ NWK_Status_t status;
+} NwkStatusConf_t;
+
+/** Type of NWK status request parameters. */
+typedef struct _NwkStatusReq_t
+{
+ /** Service field - for internal needs. */
+ struct
+ {
+ QueueElement_t qelem; /**< link used for queuing */
+ } service;
+ /** Value of status code field in network status frame. */
+ NWK_StatusIndErrorCodes_t statusCode;
+ /** Target address for this network status command. */
+ ShortAddr_t targetAddr;
+ /** Destination address for this network status command. */
+ ShortAddr_t dstAddr;
+ /* Short address of next hop for this command. */
+ ShortAddr_t nextHopAddr;
+ /* Short address of previous hop of original packet. */
+ ShortAddr_t prevHopAddr;
+ /** Callback for request to send of the NWK status command.*/
+ void (* nwkStatusConf)(NwkStatusConf_t *conf);
+ NwkStatusConf_t confirm;
+} NwkStatusReq_t;
+
+/** Network status command frame format. ZigBee spec r17, figure 3.15. */
+BEGIN_PACK
+typedef struct PACK _NwkStatusCommandPayload_t
+{
+ /** Command frame identifier. */
+ NwkCommandIdField_t commandId;
+ /** Status code field. This field shall be set to one of the non-reserved
+ * values shown in ZigBee spec r17, Table 3.42. */
+ uint8_t statusCode;
+ /** The destination address field is 2 octets in length and shall be present
+ * if, and only if, the network status command frame is being sent in
+ * response to a routing failure. In this case, it shall contain
+ * the destination address from the data frame that encountered the failure.
+ * ZigBee spec r17, 3.4.3.3.2, page 324. */
+ ShortAddr_t dstAddr;
+} NwkStatusCommandPayload_t;
+END_PACK
+
+/** Internal states of NWK status command sender. */
+typedef enum _NwkStateOfStatusSender_t
+{
+ NWK_STATUS_SENDER_IDLE_STATE = 0x78,
+ NWK_STATUS_SENDER_FIRST_STATE = 0x20,
+ NWK_STATUS_SENDER_PREPARE_TX_STATE = NWK_STATUS_SENDER_FIRST_STATE,
+ NWK_STATUS_SENDER_SEND_STATE = 0x21,
+ NWK_STATUS_SENDER_LAST_STATE
+} NwkStateOfStatusSender_t;
+
+/** Internal variables of the NWK status command sender. */
+typedef struct _NwkStatusSender_t
+{
+ /** Current state of NWK status sender. */
+ NwkStateOfStatusSender_t state;
+ /** Queue of requests to send NWK status command. */
+ QueueDescriptor_t queue;
+ /** Route error command is sent. */
+ bool routeErrorBusy;
+ /** The request to send the route error status command. */
+ NwkStatusReq_t routeError;
+} NwkStatusSender_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _ROUTER_ || defined _COORDINATOR_
+#if defined _RESOLVE_ADDR_CONFLICT_ || defined _NWK_MANY_TO_ONE_ROUTING_ ||\
+ defined _NWK_SOURCE_ROUTING_ || defined _NWK_MESH_ROUTING_
+/**************************************************************************//**
+ \brief Request to send a network status command.
+
+ \param[in] req - request information: statusCode, destination address and etc.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkStatusReq(NwkStatusReq_t *const req);
+#endif
+
+/**************************************************************************//**
+ \brief Reset NWK status sender.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetStatusSender(void);
+
+#if defined _NWK_SOURCE_ROUTING_ || defined _NWK_MESH_ROUTING_
+/**************************************************************************//**
+ \brief Send the status command with status code NWK_NO_ROUTE_AVAILABLE.
+
+ \param[in] srcAddr - source address of route path.
+ \param[in] dstAddr - destination address of route path.
+ \param[in] statusCode - status code for network status command frame.
+ \param[in] prevHopAddr - short address of previous hop of data frame
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkSendRouteErrorStatus(const ShortAddr_t srcAddr,
+ const ShortAddr_t dstAddr, const ShortAddr_t prevHopAddr,
+ const NWK_StatusIndErrorCodes_t statusCode);
+#endif /* _NWK_SOURCE_ROUTING_ or _NWK_MESH_ROUTING_*/
+
+/**************************************************************************//**
+ \brief Prepare header and payload of the network status command.
+
+ \param[in] outPkt - pointer to output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPrepareNetworkStatusTx(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Confirmation of network status command transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of status command transmission.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkConfirmNetworkStatusTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+#if defined _NWK_MANY_TO_ONE_ROUTING_
+/**************************************************************************//**
+ \brief Send the many-to-one route error status command.
+
+ \param[in] srcAddr - the source address of the data frame
+ \param[in] concAddr - short address of concentrator
+ \param[in] prevHopAddr - short address of previous hop of data frame
+ \param[in] nextHopAddr - short address of failure next hop
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkSendManyToOneRouteErrorStatus(const ShortAddr_t srcAddr,
+ const ShortAddr_t concAddr, const ShortAddr_t prevHopAddr,
+ const ShortAddr_t nextHopAddr);
+#endif /* _NWK_MANY_TO_ONE_ROUTING_ */
+
+#else /* _ROUTER_ or _COORDINATOR_ */
+
+#define nwkResetStatusSender() (void)0
+#define nwkPrepareNetworkStatusTx NULL
+#define nwkConfirmNetworkStatusTx NULL
+
+INLINE void nwkSendRouteErrorStatus(const ShortAddr_t srcAddr,
+ const ShortAddr_t dstAddr, const bool multicast)
+{
+ (void)srcAddr, (void)dstAddr, (void)multicast;
+}
+
+#endif /* _ROUTER_ or _COORDINATOR_ */
+
+#if defined NWK_ROUTING_CAPACITY && defined _NWK_MANY_TO_ONE_ROUTING_
+/**************************************************************************//**
+ \brief Confirmation of sending NWK status command with many-to-one error.
+
+ \param[in] outPkt - pointer to output packet
+ \param[in] status - status of sending
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE
+void nwkConfirmManyToOneNetworkStatusTx(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+#else
+#define nwkConfirmManyToOneNetworkStatusTx NULL
+#endif /* NWK_ROUTING_CAPACITY and _NWK_MANY_TO_ONE_ROUTING_ */
+#endif /* _NWK_STATUS_REQ_H */
+/** nwkStatusReq.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSync.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSync.h
new file mode 100644
index 00000000..75bf12c1
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSync.h
@@ -0,0 +1,92 @@
+/**************************************************************************//**
+ \file nwkSync.h
+
+ \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:
+ 2007-06-27 V. Panov - Created.
+ 2008-12-10 M. Gekk - Reduction of usage of the RAM at separate compiling.
+ 2009-03-10 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkSync.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_SYNC_H
+#define _NWK_SYNC_H
+
+/*****************************************************************************
+ Includes section
+ *****************************************************************************/
+#include <nwkConfig.h>
+#include <queue.h>
+#include <mac.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Maximum synchronization attempts. */
+#define MAX_SYNC_FAIL_COUNTER 8U
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of NLME-SYNC component */
+typedef enum _NwkSyncState_t
+{
+ NWK_SYNC_IDLE_STATE = 0x31,
+ NWK_SYNC_FIRST_STATE = 0xA3,
+ NWK_SYNC_BEGIN_STATE = NWK_SYNC_FIRST_STATE,
+ NWK_SYNC_MAC_POLL_STATE = 0xA4,
+ NWK_SYNC_CONFIRM_STATE = 0xA5,
+ NWK_SYNC_LAST_STATE
+} NwkSyncState_t;
+
+/** Internal parameters of NLME-SYNC component. */
+typedef struct _NwkSync_t
+{
+ /** Internal component's state*/
+ NwkSyncState_t state;
+ /** Counter of synchronization attempts */
+ uint8_t counter;
+ /** Queue of NLME-SYNC.request from an upper layer */
+ QueueDescriptor_t queue;
+ /** MLME-POLL request primitive's parameters */
+ MAC_PollReq_t macReq; /**< macReq must be no in union */
+} NwkSync_t;
+
+/*****************************************************************************
+ Prototypes section
+ *****************************************************************************/
+#if defined _ENDDEVICE_
+/*************************************************************************//**
+ \brief Main task handler of NLME-SYNC component
+ *****************************************************************************/
+NWK_PRIVATE void nwkSyncTaskHandler(void);
+
+/*************************************************************************//**
+ \brief Reset NLME-SYNC component.
+ *****************************************************************************/
+NWK_PRIVATE void nwkResetSync(void);
+
+/******************************************************************************
+ \brief nwkSync idle checking.
+
+ \return true, if nwkSync performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkSyncIsIdle(void);
+
+#else /* _ENDDEVICE_ */
+
+#define nwkSyncTaskHandler NULL
+#define nwkSyncIsIdle NULL
+#define nwkResetSync() (void)0
+
+#endif /* _ENDDEVICE_ */
+#endif /* _NWK_SYNC_H */
+/** eof nwkSync.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSyncLoss.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSyncLoss.h
new file mode 100644
index 00000000..aef3a380
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSyncLoss.h
@@ -0,0 +1,61 @@
+/**************************************************************************//**
+ \file nwkSyncLoss.h
+
+ \brief SyncLoss header file.
+
+ \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:
+ 2009-04-02 M. Gekk - Created.
+ Last change:
+ $Id: nwkSyncLoss.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWKSYNCLOSS_H
+#define _NWKSYNCLOSS_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nlmeStartRouter.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of SyncLoss component */
+typedef enum _NwkSyncLossState_t
+{
+ NWK_SYNC_LOSS_IDLE_STATE = 0x00,
+ NWK_REALIGNMENT_START_STATE = 0x01
+} NwkSyncLossState_t;
+
+/** Internal parameters of SyncLoss */
+typedef struct _NwkSyncLoss_t
+{
+ NwkSyncLossState_t state;
+ NWK_StartRouterReq_t startRouter;
+} NwkSyncLoss_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined(_ROUTER_) && defined(NWK_COORD_REALIGNMENT)
+/******************************************************************************
+ \brief Reset SyncLoss component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetSyncLoss(void);
+
+#else /* _ROUTER_ && NWK_COORD_REALIGNMENT */
+
+#define nwkResetSyncLoss() (void)0
+
+#endif /* _ROUTER_ && NWK_COORD_REALIGNMENT */
+#endif /* _NWKSYNCLOSS_H */
+/** eof nwkSyncLoss.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSystem.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSystem.h
new file mode 100644
index 00000000..f001f90f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkSystem.h
@@ -0,0 +1,100 @@
+/**************************************************************************//**
+ \file nwkSystem.h
+
+ \brief Network system header file.
+
+ \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:
+ 2007-06-20 V. Panov - Created.
+ 2009-08-16 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkSystem.h 17801 2011-07-04 08:55:01Z mgekk $
+ ******************************************************************************/
+#if !defined _NWKSYSTEM_H
+#define _NWKSYSTEM_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+#include <appFramework.h>
+#include <mnUtils.h>
+
+ /******************************************************************************
+ Inline static functions prototypes section
+ ******************************************************************************/
+INLINE bool isCorrectExtPanId(const uint64_t panId)
+{
+ const uint8_t *p = (const uint8_t *)&panId;
+ const uint8_t *const pend = p + sizeof(panId);
+ uint16_t sum = 0U;
+
+ do
+ sum += *p;
+ while (++p < pend);
+ return (0U != sum) && ((8U * 0xFFU) != sum);
+}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+typedef ShortAddr_t NwkAddrRange_t;
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Converting of time value from milliseconds to seconds. */
+#define NWK_MSEC_TO_SEC(time) ((time) >> 10)
+/** Converting of time value from seconds to milliseconds. */
+#define NWK_SEC_TO_MSEC(time) ((time) << 10)
+
+#define IS_CORRECT_BROADCAST_ADDR(A) \
+ ((0xFFFFU == (A))||((0xFFFBU <= LE16_TO_CPU(A))&&(LE16_TO_CPU(A) <= 0xFFFDU)))
+
+#define NWK_INVALID_PANID 0xFFFFU
+
+#define CHECK_MEM_OVERLAP(dst, src, len, assert_num) \
+ assert(!(((src) < (dst)) \
+ && ((uint8_t *)(dst) < (const uint8_t *)(src) + (len))), \
+ assert_num)
+
+#if defined UINT64_MEMCMP
+ #define IS_EQ_EXT_PANID(A, B) (0 == memcmp(&(A), &(B), sizeof(uint64_t)))
+ #define IS_CORRECT_EXT_PANID(P) isCorrectExtPanId(P)
+ #define COPY_TO_RAW_EXT_ADDR(DST, SRC) \
+ memmove((DST).raw, &(SRC), sizeof(uint64_t))
+ #define COPY_FROM_RAW_EXT_ADDR(DST, SRC) \
+ memmove(&(DST), (SRC).raw, sizeof(uint64_t))
+ #define COPY_EXT_PANID(DST, SRC) memmove(&(DST), &(SRC), sizeof(uint64_t))
+#else
+ #define IS_EQ_EXT_PANID(A, B) ((A) == (B))
+ #define IS_CORRECT_EXT_PANID(P) \
+ ((0ULL < (P)) && ((P) < 0xFFFFFFFFFFFFFFFFULL))
+ #define COPY_TO_RAW_EXT_ADDR(DST, SRC) (DST).value = (SRC)
+ #define COPY_FROM_RAW_EXT_ADDR(DST, SRC) (DST) = (SRC).value
+ #define COPY_EXT_PANID(DST, SRC) (DST) = (SRC)
+#endif
+
+/* Get address of any NWK table. */
+#define NWK_ADDR_OF_TABLE(table) ((void **)&(table))
+
+/* Macros are used for queue operations. */
+#define NWK_DEL_QELEM(queue, type) \
+ GET_PARENT_BY_FIELD(type, service.qelem, deleteHeadQueueElem(queue))
+
+#define NWK_GET_QELEM(queue, type) \
+ GET_PARENT_BY_FIELD(type, service.qelem, getQueueElem(queue))
+
+#define NWK_NEXT_QELEM(parent, type) \
+ GET_PARENT_BY_FIELD(type, service.qelem, getNextQueueElem(&(parent)->service.qelem))
+
+#endif /* _NWKSYSTEM_H */
+/** eof nwkSystem.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTaskManager.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTaskManager.h
new file mode 100644
index 00000000..4ea4c019
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTaskManager.h
@@ -0,0 +1,98 @@
+/**************************************************************************//**
+ \file nwkTaskManager.h
+
+ \brief Header file of NWK task manager.
+
+ \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:
+ 2007-06-14 V. Panov - Created.
+ 2008-08-21 Max Gekk - More fair planning of tasks.
+ 2009-06-12 Max Gekk - Refactoring.
+ Last change:
+ $Id: nwkTaskManager.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_TASK_MANAGER_H
+#define _NWK_TASK_MANAGER_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Identifiers of NWK task handlers. */
+typedef enum _NwkTaskID_t
+{
+ NWK_TASK_RESET,
+ NWK_TASK_SYNC,
+ NWK_TASK_ADDR_CONFLICT,
+ NWK_TASK_TX,
+ NWK_TASK_ROUTE_DISCOVERY,
+ NWK_TASK_ROUTE_DISCOVERY_TABLE,
+ NWK_TASK_START_ROUTER,
+ NWK_TASK_PERMIT_JOINING,
+ NWK_TASK_DISCOVERY_REQ,
+ NWK_TASK_FORMATION_REQ,
+ NWK_TASK_JOIN_REQ,
+ NWK_TASK_JOIN_IND,
+ NWK_TASK_LEAVE,
+ NWK_TASK_EDSCAN,
+ NWK_TASK_DATA_CONF,
+ NWK_TASK_LOOPBACK,
+ NWK_TASK_ROUTE_RECORD,
+ NWK_TASK_DIRECT_JOIN,
+ NWK_TASK_ORPHAN,
+ NWK_TASK_SILENT_JOIN,
+ NWK_TASK_MANYTOONE,
+ NWK_TASK_ALLOC_DATA_REQ,
+ NWK_TASKS_SIZE
+} NwkTaskID_t;
+
+/** Bit array of NWK task. If bit is '1' the task is posted. */
+typedef uint32_t NwkTaskBitMask_t;
+
+/** Type of iterator for task identifiers. */
+typedef uint8_t NwkTaskIdIter_t;
+
+typedef struct _NwkTaskManager_t
+{
+ NwkTaskBitMask_t bitMap;
+ NwkTaskIdIter_t current;
+} NwkTaskManager_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/******************************************************************************
+ \brief post NWK task.
+
+ \param taskID - identifier of NWK task.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPostTask(const NwkTaskID_t taskID);
+
+/******************************************************************************
+ \brief Cancel NWK task.
+
+ \param[in] mask - bit mask of NWK task dentifier.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkClearTaskBit(const NwkTaskBitMask_t mask);
+
+/******************************************************************************
+ \brief Reset the task manager.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetTaskManager(void);
+
+#endif /* _NWK_TASK_MANAGER_H */
+/** eof nwkTaskManager.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTx.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTx.h
new file mode 100644
index 00000000..d2e35d4e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTx.h
@@ -0,0 +1,209 @@
+/**************************************************************************//**
+ \file nwkTx.h
+
+ \brief Interface of NWK transmission.
+
+ \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:
+ 2007-06-14 V. Panov - Created.
+ 2008-12-10 Max Gekk - Reduction of the used RAM.
+ 2009-10-16 Max Gekk - Redesign.
+ Last change:
+ $Id: nwkTx.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_TX_H
+#define _NWK_TX_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nldeData.h>
+#include <nwkDbg.h>
+
+/******************************************************************************
+ Definition section
+ ******************************************************************************/
+/** List of transmission parameters: delay type, prepare and confirm functions.
+ * NOTE: Offset of tx parameters in this list must be equal tx id. */
+#define NWK_TX_PARAMETERS \
+{ \
+ NWK_LINK_STATUS_TX_PARAMETERS, /* NWK_LINK_STATUS_TX_ID */ \
+ NWK_BROADCAST_STATUS_TX_PARAMETERS, /* NWK_BROADCAST_STATUS_TX_ID */ \
+ NWK_UNICAST_STATUS_TX_PARAMETERS, /* NWK_UNICAST_STATUS_TX_ID */ \
+ NWK_JOIN_REQ_TX_PARAMETERS, /* NWK_JOIN_REQ_TX_ID */ \
+ NWK_ADDR_CONFLICT_JOIN_RESP_TX_PARAMETERS, /* NWK_ADDR_CONFLICT_JOIN_RESP_TX_ID */ \
+ NWK_JOIN_RESP_TX_PARAMETERS, /* NWK_JOIN_RESP_TX_ID */ \
+ NWK_LEAVE_ITSELF_TX_PARAMETERS, /* NWK_LEAVE_ITSELF_TX_ID */ \
+ NWK_LEAVE_CHILD_TX_PARAMETERS, /* NWK_LEAVE_CHILD_TX_ID */ \
+ NWK_REPORT_TX_PARAMETERS, /* NWK_REPORT_TX_ID */ \
+ NWK_UPDATE_TX_PARAMETERS, /* NWK_UPDATE_TX_ID */ \
+ NWK_ROUTE_REPLY_TX_PARAMETERS, /* NWK_ROUTE_REPLY_TX_ID */ \
+ NWK_INITIAL_ROUTE_REQ_TX_PARAMETERS, /* NWK_INITIAL_ROUTE_REQ_TX_ID */\
+ NWK_INITIAL_MANYTOONE_ROUTE_REQ_TX_PARAMETERS, /* NWK_INITIAL_MANYTOONE_ROUTE_REQ_TX_ID */\
+ NWK_ROUTE_REQ_TX_PARAMETERS, /* NWK_ROUTE_REQ_TX_ID */ \
+ NWK_MANYTOONE_ROUTE_REQ_TX_PARAMETERS, /* NWK_MANYTOONE_ROUTE_REQ_TX_ID */\
+ NWK_ROUTE_RECORD_TX_PARAMETERS, /* NWK_ROUTE_RECORD_TX_ID */ \
+ NWK_MANY_TO_ONE_STATUS_TX_PARAMETERS, /* NWK_MANY_TO_ONE_STATUS_TX_ID */\
+ \
+ NWK_UNICAST_COMMAND_TRANSIT_TX_PARAMETERS, /* NWK_UNICAST_COMMAND_TRANSIT_TX_ID */ \
+ NWK_UNICAST_DATA_TRANSIT_TX_PARAMETERS, /* NWK_UNICAST_DATA_TRANSIT_TX_ID */ \
+ NWK_BROADCAST_TRANSIT_TX_PARAMETERS, /* NWK_BROADCAST_TRANSIT_TX_ID */ \
+ NWK_MULTICAST_MEMBER_TRANSIT_TX_PARAMETERS, /* NWK_MULTICAST_MEMBER_TRANSIT_TX_ID */\
+ NWK_SOURCE_ROUTE_TRANSIT_TX_PARAMETERS, /* NWK_SOURCE_ROUTE_TRANSIT_TX_ID */ \
+ NWK_ROUTE_RECORD_TRANSIT_TX_PARAMETERS, /* NWK_ROUTE_RECORD_TRANSIT_TX_ID */ \
+ NWK_MANY_TO_ONE_TRANSIT_STATUS_TX_PARAMETERS, /* NWK_MANY_TO_ONE_TRANSIT_STATUS_TX_ID */\
+ \
+ NWK_UNICAST_DATA_TX_PARAMETERS, /* NWK_UNICAST_DATA_TX_ID */ \
+ NWK_BROADCAST_DATA_TX_PARAMETERS, /* NWK_BROADCAST_DATA_TX_ID */ \
+ NWK_MULTICAST_MEMBER_TX_PARAMETERS, /* NWK_MULTICAST_MEMBER_TX_ID */ \
+ NWK_SOURCE_ROUTE_TX_PARAMETERS /* NWK_SOURCE_ROUTE_TX_ID */ \
+}
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Identifiers of transmission requests. */
+typedef enum _NwkTxId_t
+{
+ NWK_LINK_STATUS_TX_ID = 0x00,
+ NWK_BROADCAST_STATUS_TX_ID = 0x01,
+ NWK_UNICAST_STATUS_TX_ID = 0x02,
+ NWK_JOIN_REQ_TX_ID = 0x03,
+ NWK_ADDR_CONFLICT_JOIN_RESP_TX_ID = 0x04,
+ NWK_JOIN_RESP_TX_ID = 0x05,
+ NWK_LEAVE_ITSELF_TX_ID = 0x06,
+ NWK_LEAVE_CHILD_TX_ID = 0x07,
+ NWK_REPORT_TX_ID = 0x08,
+ NWK_UPDATE_TX_ID = 0x09,
+ NWK_ROUTE_REPLY_TX_ID = 0x0A,
+ NWK_INITIAL_ROUTE_REQ_TX_ID = 0x0B,
+ NWK_INITIAL_MANYTOONE_ROUTE_REQ_TX_ID = 0x0C,
+ NWK_ROUTE_REQ_TX_ID = 0x0D,
+ NWK_MANYTOONE_ROUTE_REQ_TX_ID = 0x0E,
+ NWK_ROUTE_RECORD_TX_ID = 0x0F,
+ NWK_MANY_TO_ONE_STATUS_TX_ID = 0x10,
+ NWK_MAX_COMMAND_TX_ID = NWK_MANY_TO_ONE_STATUS_TX_ID,
+
+ NWK_UNICAST_COMMAND_TRANSIT_TX_ID = 0x11,
+ NWK_UNICAST_DATA_TRANSIT_TX_ID = 0x12,
+ NWK_MULTICAST_NON_MEMBER_TRANSIT_TX_ID = NWK_UNICAST_DATA_TRANSIT_TX_ID,
+ NWK_BROADCAST_TRANSIT_TX_ID = 0x13,
+ NWK_MULTICAST_MEMBER_TRANSIT_TX_ID = 0x14,
+ NWK_SOURCE_ROUTE_TRANSIT_TX_ID = 0x15,
+ NWK_ROUTE_RECORD_TRANSIT_TX_ID = 0x16,
+ NWK_MANY_TO_ONE_TRANSIT_STATUS_TX_ID = 0x17,
+
+ NWK_MIN_DATA_TX_ID = 0x18,
+ NWK_UNICAST_DATA_TX_ID = NWK_MIN_DATA_TX_ID,
+ NWK_MULTICAST_NON_MEMBER_TX_ID = NWK_UNICAST_DATA_TX_ID,
+ NWK_BROADCAST_DATA_TX_ID = 0x19,
+ NWK_MULTICAST_MEMBER_TX_ID = 0x1A,
+ NWK_SOURCE_ROUTE_TX_ID = 0x1B,
+
+ NWK_MAX_TX_ID
+} NwkTxId_t;
+
+/** Type of iterator for transmission identifiers. */
+typedef uint8_t NwkTxIdIter_t;
+
+/** Type of callback function for preparing an output packet. */
+typedef void (* NwkPrepareTxFunc_t)(NwkOutputPacket_t *const);
+/** Type of callback function for confirmation of packet transmission. */
+typedef void (* NwkConfirmTxFunc_t)(NwkOutputPacket_t *const,
+ const NWK_Status_t);
+
+/** Internal variables of transmission component. */
+typedef struct _NwkTx_t
+{
+ /** Queue of output packets */
+ QueueDescriptor_t queue;
+} NwkTx_t;
+
+/** Internal states of output packet for debug. */
+typedef enum _NwkOutPktState_t
+{
+ NWK_OUTPKT_IN_QUEUE_STATE = 0x00,
+ NWK_OUTPKT_RDISCOVERY_STATE = 0x01,
+ NWK_OUTPKT_MAC_STATE = 0x02,
+ NWK_OUTPKT_DELAY_STATE = 0x03,
+ NWK_OUTPKT_ENCRYPT_STATE = 0x04,
+ NWK_OUTPKT_DECRYPT_STATE = 0x05,
+ NWK_OUTPKT_ROUTE_RECORD_STATE = 0x06
+} NwkOutPktState_t;
+
+/******************************************************************************
+ Inline static functions prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Is this packet a network data?
+
+ \param[in] outPkt - pointer to the output network packet.
+ \return 'true' if this output packet is data packet otherwise return 'false'.
+ ******************************************************************************/
+INLINE bool nwkIsDataPacket(const NwkOutputPacket_t *const outPkt)
+{
+ assert(outPkt->txId < NWK_MAX_TX_ID, NWKTX_NWKISDATAPACKET0);
+ return NWK_MIN_DATA_TX_ID <= outPkt->txId;
+}
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Request to transmit the output packet.
+
+ \param[in] outPkt - pointer to the output network packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkTxReq(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Main task handler of the packet transmission component
+ ******************************************************************************/
+NWK_PRIVATE void nwkTxTaskHandler(void);
+
+/**************************************************************************//**
+ \brief Reset the packet transmission component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetTx(void);
+
+/**************************************************************************//**
+ \brief Confirmation of packet transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] status - network status of packet transmission.
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkTxConf(NwkOutputPacket_t *const outPkt,
+ const NWK_Status_t status);
+
+/**************************************************************************//**
+ \brief Write default values to parameters of MAC_DataReq request.
+
+ \param[in] outPkt - pointer to an output packet.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkInitMacDataReq(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Start packet transmission.
+
+ \param[in] outPkt - pointer to output packet.
+ \param[in] encrypt - if 'true' then packet encrypting is required.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkTransmitOutputPacket(NwkOutputPacket_t *const outPkt,
+ const bool encrypt);
+
+#endif /* _NWK_TX_H */
+/** eof nwkTx.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTxDelay.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTxDelay.h
new file mode 100644
index 00000000..fb841445
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTxDelay.h
@@ -0,0 +1,101 @@
+/**************************************************************************//**
+ \file nwkTxDelay.h
+
+ \brief Interface of transmission delays.
+
+ \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:
+ 2009-09-20 Max Gekk - Created.
+ Last change:
+ $Id: nwkTxDelay.h 18167 2011-08-08 11:26:31Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_TX_DELAY_H
+#define _NWK_TX_DELAY_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <appTimer.h>
+#include <queue.h>
+#include <nldeData.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal variables of delay component. */
+typedef struct _NwkTxDelay_t
+{
+ bool isTimerStarted;
+ HAL_AppTimer_t timer;
+ QueueDescriptor_t queue;
+} NwkTxDelay_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Transmission delay request.
+
+ \param[in] delayReq - pointer to delay request's parameters.
+ \param[in] macStatus - pointer to MAC status of MLDE-DATA.confirm or NULL if
+ it is first transmission.
+ \return further behavior.
+ ******************************************************************************/
+NWK_PRIVATE NwkTxDelayStatus_t nwkTxDelayReq(NwkTxDelayReq_t *const delayReq,
+ MAC_Status_t *const macStatus);
+
+/**************************************************************************//**
+ \brief The transmission delay has expired.
+
+ \param[in] delayReq - pointer to delay request's parameters.
+ \param[in] status - status of further behavior.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkTxDelayConf(NwkTxDelayReq_t *const delayReq,
+ const NwkTxDelayStatus_t status);
+
+/**************************************************************************//**
+ \brief Flush all delays.
+ ******************************************************************************/
+NWK_PRIVATE void nwkFlushTxDelays(void);
+
+/**************************************************************************//**
+ \brief Reset delay component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetTxDelays(void);
+
+/******************************************************************************
+ \brief nwkTxDelay idle checking.
+
+ \return true, if nwkTxDelay performs no activity, false - otherwise.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkTxDelayIsIdle(void);
+
+/**************************************************************************//**
+ \brief Delivery time of broadcast data transmission on a network.
+
+ \return Current value of broadcast delivery time in milliseconds.
+ ******************************************************************************/
+NWK_PRIVATE uint32_t nwkGetBroadcastDeliveryTime(void);
+
+#if defined _NWK_PASSIVE_ACK_ && (defined _ROUTER_ || defined _COORDINATOR_)
+/**************************************************************************//**
+ \brief All expected passive acks are received, confirm the passive ack req.
+
+ \param[in] delayReq - pointer to delay request's parameters.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkPassiveAckConf(NwkTxDelayReq_t *const delayReq);
+#endif /* _NWK_PASSIVE_ACK_ */
+
+#endif /* _NWK_TX_DELAY_H */
+/** eof nwkTxDelay.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTxSecurity.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTxSecurity.h
new file mode 100644
index 00000000..fc9d0120
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkTxSecurity.h
@@ -0,0 +1,70 @@
+/**************************************************************************//**
+ \file nwkTxSecurity.h
+
+ \brief Interface of transmission security.
+
+ \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:
+ 2009-08-31 M. Gekk - Created.
+ Last change:
+ $Id: nwkTxSecurity.h 17721 2011-06-27 10:38:42Z mgekk $
+ ******************************************************************************/
+#if !defined _NWK_TX_SECURITY_H
+#define _NWK_TX_SECURITY_H
+
+#if defined _SECURITY_
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <mac.h>
+#include <sspSfp.h>
+#include <nwkTx.h>
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Check of that enciphering for a proceeding network packet is required.
+
+ \param[in] outPkt - pointer to a network output packet.
+ \return 'true' if encrypting is required otherwise 'false'
+ ******************************************************************************/
+NWK_PRIVATE bool nwkIsEncryptingRequired(NwkOutputPacket_t *const outPkt);
+
+/**************************************************************************//**
+ \brief Request to encrypt an output network packet.
+
+ \param[in] encryptReq - encrypt frame primitive's parameters structure.
+ \param[in] macDataReq - MCPS-DATA request primitive's parameters structure.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkEncryptOutputPacket(SSP_EncryptFrameReq_t *const encryptReq,
+ const MAC_DataReq_t *const macDataReq);
+
+/**************************************************************************//**
+ \brief Request to decrypt an output network packet.
+
+ \param[in] decryptReq - decrypt frame primitive's parameters structure.
+ \param[in] macDataReq - MCPS-DATA request primitive's parameters structure.
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkDecryptOutputPacket(SSP_DecryptFrameReq_t *const decryptReq,
+ const MAC_DataReq_t *const macDataReq);
+
+#else /* _SECURITY_ */
+
+#define nwkIsEncryptingRequired(outPkt) false
+#define nwkIsDecryptingRequired(outPkt) false
+
+#endif /* _SECURITY_ */
+#endif /* _NWK_TX_SECURITY_H */
+/** eof nwkTxSecurity.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkUpdateCommand.h b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkUpdateCommand.h
new file mode 100644
index 00000000..e0fff7de
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkUpdateCommand.h
@@ -0,0 +1,146 @@
+/**************************************************************************//**
+ \file nwkUpdateCommand.h
+
+ \brief Update command header file.
+
+ \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:
+ 2008-12-10 M. Gekk - Reduction of usage of the RAM at separate compiling.
+ 2009-06-08 M. Gekk - Refactoring.
+ Last change:
+ $Id: nwkUpdateCommand.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _NWK_UPDATE_COMMAND_H
+#define _NWK_UPDATE_COMMAND_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <nwkConfig.h>
+#include <nwkSystem.h>
+#include <mac.h>
+#include <nwkCommon.h>
+#include <appTimer.h>
+#include <nwkFrame.h>
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/** Types of update information command. */
+#define NWK_UPDATE_TYPE_PANID_CONFLICT 0U
+/** Minimum size of the update command payload without update information field.
+ **/
+#define NWK_SIZE_OF_UPDATE_CMD_PAYLOD 13U
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/** Internal states of the update command component. */
+typedef enum _NwkUpdateCommandState_t
+{
+ /** State after reset */
+ NWK_UPDATE_IDLE_STATE = 0x92,
+ NWK_UPDATE_FIRST_STATE = 0x19,
+ NWK_UPDATE_WAIT_BROADCAST_DELIVERY_STATE = NWK_UPDATE_FIRST_STATE,
+ NWK_UPDATE_MAC_SET_PAN_ID_STATE = 0x1B,
+ NWK_UPDATE_LAST_STATE
+} NwkUpdateCommandState_t;
+
+/** Confirmation of setting a new pan id. */
+typedef void (* NwkUpdatePanIdConf_t)(void);
+
+/** Internal variables of the update command component. */
+typedef struct _NwkUpdateCommand_t
+{
+ /** Finite-state machine */
+ NwkUpdateCommandState_t state;
+ PanId_t newPanId;
+ NwkUpdateId_t updateId;
+ NwkUpdatePanIdConf_t callback;
+ union
+ {
+ HAL_AppTimer_t timer;
+ MAC_SetReq_t macSet;
+ } req;
+} NwkUpdateCommand_t;
+
+/** Payload of network update command. ZigBee spec r17, Figure 3.28. */
+BEGIN_PACK
+typedef struct PACK _NwkUpdateCommandPayload_t
+{
+ /** Id of the update command. ZigBee spec r17, Table 3.40. */
+ NwkCommandIdField_t commandId;
+ /** The update information count sub-field contains an integer indicating
+ * the number of records contained within the Update Information field. */
+ LITTLE_ENDIAN_OCTET(2, (
+ NwkBitField_t infoCount :5,
+ /** The update command identifier sub-field contains an integer indicating
+ * the type of update information command.
+ * ZigBee spec r17, Figure 3.30, page 337. */
+ NwkBitField_t updateCmdId :3
+ ))
+ /** The EPID field shall contain the 64bit EPID that identifies the network
+ * that is to be updated. ZigBee spec r17, 3.4.10.3.2, page 337. */
+ ExtPanId_t extPanId;
+ /** The update information field provides the information being updated,
+ * the format of this field depends upon the value of the Update Command
+ * Identifier sub-field. ZigBee spec r17, 3.4.10.3.4, page 337. */
+ NwkUpdateId_t updateId;
+ /** The PAN identifier update shall be made up of a single 16-bit PAN
+ * identifier that is the new PAN identifier for this network to use.
+ * ZigBee spec r17, 3.4.10.3.4.1, page 338. */
+ PanId_t newPanId;
+} NwkUpdateCommandPayload_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+#if defined _RESOLVE_PANID_CONFLICT_
+/**************************************************************************//**
+ \brief Set a new pan id.
+
+ \param[in] newPanId - a new identifier of PAN.
+ \param[in] updateId - a new update identifier.
+ \param[in] callback - pointer to a update confirmation function.
+
+ \return None.
+ ******************************************************************************/
+NWK_PRIVATE void nwkUpdatePanId(const PanId_t newPanId,
+ const NwkUpdateId_t updateId, const NwkUpdatePanIdConf_t callback);
+
+/**************************************************************************//**
+ \brief Action when a update command is received.
+
+ \param[in] payload - pointer to NPDU of NWK update command.
+ \param[in] header - nwk header.
+ \param[in] parse - parsed header fields.
+
+ \return 'true' - continue processing command otherwise 'false'.
+ ******************************************************************************/
+NWK_PRIVATE bool nwkUpdateFrameInd(const uint8_t *const payload,
+ const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);
+
+/**************************************************************************//**
+ \brief Reset the update command component.
+ ******************************************************************************/
+NWK_PRIVATE void nwkResetUpdateCommand(void);
+
+#else /* _RESOLVE_PANID_CONFLICT_ */
+
+/* Interface of the update command is disabled. */
+#define nwkUpdatePanId(newPanId,updateId,callback)
+#define nwkUpdateFrameInd NULL
+#define nwkResetUpdateCommand() (void)0
+
+#endif /* _RESOLVE_PANID_CONFLICT_ */
+#endif /* _NWK_UPDATE_COMMAND_H */
+/** eof nwkUpdateCommand.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/PersistDataServer/Makefile b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/Makefile
new file mode 100644
index 00000000..1983e28b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/Makefile
@@ -0,0 +1,73 @@
+COMPONENTS_PATH = ..
+include $(MAKERULES)
+
+# Compiler flags extending with Confiuration server parameters.
+CFLAGS += $(CFLAGS_CS)
+
+# Compiler flags extending with "debug info" compiler flag.
+CFLAGS += $(CFLAGS_DBG)
+
+# Hardware flags.
+CFLAGS += $(CFLAGS_HW)
+
+##### PATHS FLAGS OF INCLUDES #########
+CFLAGS += -I$(PDS_PATH)/include
+CFLAGS += -I$(PDS_PATH)/include/private
+CFLAGS += -I$(CS_PATH)/include
+CFLAGS += -I$(BSP_PATH)/include
+CFLAGS += -I$(SE_PATH)/include
+CFLAGS += -I$(ZDO_PATH)/include
+CFLAGS += -I$(NWK_PATH)/include
+CFLAGS += -I$(APS_PATH)/include
+CFLAGS += -I$(APS_PATH)/include/private
+CFLAGS += -I$(MAC_PHY_PATH)/include
+CFLAGS += -I$(HAL_PATH)/include
+CFLAGS += -I$(HAL_HWD_COMMON_PATH)/include
+CFLAGS += -I$(SSP_PATH)/include
+CFLAGS += -I$(CS_PATH)/include/private
+CFLAGS += -I$(MAC_PHY_PATH)/MAC_ENV/include
+CFLAGS += -I$(MAC_PHY_PATH)/MAC_HWD_PHY/include
+CFLAGS += -I$(MAC_PHY_PATH)/MAC_HWI/include
+
+#We take address of packed structure members in pdsWriteData.c, IAR for ARM don't like this.
+#Suppress this warning, code is correct.
+ifeq ($(COMPILER_AND_MICRO_TYPE), IAR_ARM)
+ CFLAGS += --diag_suppress Pa039
+endif
+
+###### LIB #########
+BUILDDIR = .
+LIBDIR = $(BUILDDIR)/lib
+LISTDIR = $(BUILDDIR)/list
+LDFLAGS = -L$(LIBDIR)
+
+objects = \
+$(BUILDDIR)/objs/pdsDataServer.o \
+$(BUILDDIR)/objs/pdsWriteData.o \
+$(BUILDDIR)/objs/pdsCrcService.o
+###### TARGETS ################
+all: component_label LIB_PERSIST_DATA_SERVER
+component_label:
+ @echo
+ @echo ----------------------------------------------------
+ @echo Persist Data Server library creation.
+ @echo ----------------------------------------------------
+
+################
+$(objects):
+ $(CC) $(CFLAGS) $^ -o $@
+$(BUILDDIR)/objs/pdsDataServer.o: $(BUILDDIR)/src/pdsDataServer.c
+$(BUILDDIR)/objs/pdsWriteData.o: $(BUILDDIR)/src/pdsWriteData.c
+$(BUILDDIR)/objs/pdsCrcService.o: $(BUILDDIR)/src/pdsCrcService.c
+################
+LIB_PERSIST_DATA_SERVER : $(objects)
+ $(AR) $(AR_KEYS) $(LIBDIR)/lib$(PDS_LIB).a $(objects)
+ $(SIZE) -td $(LIBDIR)/lib$(PDS_LIB).a
+################
+
+clean:
+ @echo
+ @echo ----------------------------------------------------
+ @echo Persist Data Server component cleaning.
+ @echo ----------------------------------------------------
+ rm -f $(objects) $(LIBDIR)/lib$(PDS_LIB).a $(LISTDIR)/*.*
diff --git a/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/pdsDataServer.h b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/pdsDataServer.h
new file mode 100644
index 00000000..67855a66
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/pdsDataServer.h
@@ -0,0 +1,99 @@
+/***************************************************************************//**
+ \file pdsDataServer.h
+
+ \brief The header file describes the Persistence Data Server interface
+
+ \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:
+ 28/09/07 A. Khromykh - Created
+ 01/11/10 A. Razinkov - Modified
+*****************************************************************************/
+
+#ifndef _PERSISTDATASERVER_H
+#define _PERSISTDATASERVER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <configServer.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+//! PDS state result after a command call
+typedef enum
+{
+ PDS_SUCCESS, //!< - Command completed successfully
+ PDS_EEPROM_ERROR, //!< - EEPROM error occurred
+ PDS_CRC_ERROR, //!< - Wrong CRC
+ PDS_COMMIT_IN_PROGRESS //!< - Commit to external memory started
+} PDS_DataServerState_t;
+
+#ifdef _COMMISSIONING_
+//! \cond internal
+/***************************************************************************//**
+\brief Reads all parameters from EEPROM to Config Server memory.
+
+Reads all parameters from EEPROM to Config Server memory and also checks CRC of
+EEPROM stack parameters. In case of wrong CRC ConfigServer should reset EEPROM stack
+parameters to default values.
+*******************************************************************************/
+void PDS_Init(void);
+//! \endcond
+
+/*****************************************************************************//**
+\brief Writes default values of parameters to EEPROM
+
+\return - PDS state as a result of setting parameters to default state
+*******************************************************************************/
+PDS_DataServerState_t PDS_SetToDefault(void);
+
+/***************************************************************************//**
+\brief Must be called from the ::APL_TaskHandler() function only.\n
+The function forces writing data from ConfigServer to EEPROM. After returning from the function
+all ConfigServer data is stored in EEPROM.
+*******************************************************************************/
+void PDS_FlushData(void);
+
+/***************************************************************************//**
+\brief Must be called from the ::APL_TaskHandler() function only.\n
+Stops Persist Data Server.
+*******************************************************************************/
+void PDS_Stop(void);
+#endif /* _COMMISSIONING_ */
+
+/*****************************************************************************//**
+\brief Must be called from the ::APL_TaskHandler() function only.\n
+Reads data from the user area of EEPROM.
+
+\param[in] offset - data offset
+\param[in] data - pointer to user data area
+\param[in] length - data length
+\param[in] callback - pointer to a callback function; if callback is NULL, then data will be read syncronously
+
+\return - PDS state as a result of data reading operation
+*******************************************************************************/
+PDS_DataServerState_t PDS_ReadUserData(uint16_t offset, uint8_t *data, uint16_t length, void (*callback)(void));
+
+/****************************************************************************//**
+\brief Must be called only from ::APL_TaskHandler() function.\n
+Writes data to user area of EEPROM.
+
+\param[in] offset - data offset
+\param[in] data - pointer to user data area
+\param[in] length - data length
+\param[in] callback - pointer to a callback function; if callback is NULL, then data will be written syncronously
+
+\return - PDS state as a result of data writing operation
+*******************************************************************************/
+PDS_DataServerState_t PDS_WriteUserData(uint16_t offset, uint8_t *data, uint16_t length, void (*callback)(void));
+
+#endif //#ifndef _PERSISTDATASERVER_H
+
diff --git a/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsAuxService.h b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsAuxService.h
new file mode 100644
index 00000000..3735afaa
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsAuxService.h
@@ -0,0 +1,80 @@
+/***************************************************************************//**
+ \file pdsAuxService.h
+
+ \brief The header file describes the auxiliary service of Persistence Data Server
+
+ \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:
+ 22/01/08 A. Khromykh - Created
+ 01/11/10 A. Razinkov - Modified
+*****************************************************************************/
+
+#ifndef _PDSAUXSERVICE_H
+#define _PDSAUXSERVICE_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#ifndef _MAC2_
+ #include <aps.h>
+ #include <nwk.h>
+ #include <appFramework.h>
+#else // _MAC2_
+ #include <appTimer.h>
+#endif // _MAC2_
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+/* define for eeprom write highlight */
+//#define USE_LED
+
+// crc area
+#define PDS_CRC_AREA 10
+// user area
+#define USER_BASE_EEPROM_ADDRESS (csPersistentMemorySize + PDS_CRC_AREA)
+
+#define PDS_CS_PARAMETER 0
+#define PDS_CS_MEMORY 1
+#define PDS_STOP_SAVE 2
+
+#define EEPROM_BUSY -2
+#define EEPROM_ERROR -1
+
+#define STORE_TIMER_TIMEOUT 300000ul // 5 minutes
+#define SHORT_TIMEOUT 50ul // 50 msec
+#define PDS_LONG_INTERVAL 0
+#define PDS_SHORT_INTERVAL 1
+#define SAVE_IS_STARTED 1
+#define SAVE_IS_STOPED 0
+
+#define MAX_CS_PDS_VARIABLE_SIZE 16
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+// crc property
+typedef struct
+{
+ uint8_t crc;
+ uint16_t position;
+ PDS_DataServerState_t eepromState;
+} PDS_ServiceCrc_t;
+
+/******************************************************************************
+ External global variables section
+******************************************************************************/
+extern HAL_AppTimer_t pdsEepromSaveServiceTimer;
+extern uint8_t savingIsStarted;
+extern const uint8_t csPersistentItemsAmount;
+extern const uint16_t csPersistentMemorySize;
+
+#endif /*_PDSAUXSERVICE_H*/
diff --git a/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsCrcService.h b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsCrcService.h
new file mode 100644
index 00000000..cf00f9f4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsCrcService.h
@@ -0,0 +1,73 @@
+/***************************************************************************//**
+ \file pdsCrcService.h
+
+ \brief The header file describes the interface of crc counting
+
+ \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:
+ 22/01/08 A. Khromykh - Created
+ 01/11/10 A. Razinkov - Modified
+*****************************************************************************/
+
+#ifndef _PDSCRCSERVICE_H
+#define _PDSCRCSERVICE_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <pdsDataServer.h>
+#include <pdsAuxService.h>
+
+#ifdef _COMMISSIONING_
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+\brief Calculate CRC of persistent data stored in persist memory
+\
+\param[out] crcStation - pointer to CRC service structure
+******************************************************************************/
+void pdsCalculateCrc(PDS_ServiceCrc_t *crcStation);
+
+/******************************************************************************
+\brief Read CRC of stored data from persist memory
+\
+\param[out] crcStation - pointer to CRC service structure
+******************************************************************************/
+void pdsReadCrc(PDS_ServiceCrc_t *crcStation);
+
+/******************************************************************************
+\brief Write CRC of stored data to persist memory. The ring buffer used
+\ to increase persist memory life cycle
+\
+\param[out] crcStation - pointer to CRC service structure
+******************************************************************************/
+PDS_DataServerState_t pdsWriteCrc(void);
+
+/******************************************************************************
+\brief Clears whole CRC area in persist memory
+\
+\return operation result
+******************************************************************************/
+PDS_DataServerState_t pdsClearCrcArea(void);
+
+/******************************************************************************
+\brief Check if any valid data exists in persist memory
+\
+\return operation result
+******************************************************************************/
+PDS_DataServerState_t pdsCheckPersistMemory(void);
+
+#ifdef __DBG_PDS__
+ void pdsDbgReadAllEeprom(void);
+#endif
+
+#endif /* _COMMISSIONING_ */
+#endif /*_PDSCRCSERVICE_H*/
diff --git a/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsDbg.h b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsDbg.h
new file mode 100644
index 00000000..b336095f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsDbg.h
@@ -0,0 +1,37 @@
+/******************************************************************************
+ \file csDbg.h
+
+ \brief
+ Persistent Data Server debug info
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2010 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 29.10.10 A. Razinkov - Created.
+******************************************************************************/
+
+#ifndef _PDSDBG_H_
+#define _PDSDBG_H_
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <dbg.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+typedef enum
+{
+ PDS_PDSPREPAREMEMORYACCESS0,
+ PDS_PDSPREPAREMEMORYACCESS1
+} PDS_DbgCodeId_t;
+
+#endif /* CSDBG_H_ */
diff --git a/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsMemAbstract.h b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsMemAbstract.h
new file mode 100644
index 00000000..ca95f064
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsMemAbstract.h
@@ -0,0 +1,70 @@
+/***************************************************************************//**
+ \file pdsMemAbstract.h
+
+ \brief Memory abstract header
+
+ \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:
+ 6/11/08 A. Khromykh - Created
+*****************************************************************************/
+#ifndef _PDSMEMABSTRACT_H
+#define _PDSMEMABSTRACT_H
+
+/* Type of usage memory */
+#define USE_EEPROM
+
+/* This header file performs persistence memory API redefinition.
+ * The goal is to achieve memory type independence for persist data server (PDS).
+ *
+ *
+ * MEMORY_DESCRIPTOR - persistence memory descriptor. It is a structure type, which
+ * includes the following variables:
+ * uint16_t address - internal persistence memory address to be accessed.
+ * uint8_t *data - pointer to the variable in RAM to be stored (or to be filled
+ * by read value from persistence).
+ * uint16_t length - "data" variable length (bytes). Equal to the number of bytes
+ * to be exchanged between persistence memory and RAM.
+ *
+ *
+ * WRITE_MEMORY, READ_MEMORY - persistence memory access functions. These functions
+ * should have the following form:
+ * int write/read(MEMORY_DESCRIPTOR *memoryDescr, void (*callback)(void));
+ * Parameters:
+ * memoryDescr - pointer to memory descriptor
+ * callback - pointer to callback function. Callback function will be called
+ * after read or write persistence memory operation is completed.
+ * Returns:
+ * 0 - successful access;
+ * -1 - the number of bytes to read (write) is too large.
+ * Persistence memory access functions should perform memory arbitration also, i.e.
+ * memory busy return status is illegal.
+ *
+ *
+ * IS_MEMORY_BUSY - persistence memory access function, should have the following form:
+ * bool isMemoryBusy(void);
+ * Parameters:
+ * none.
+ * Returns:
+ * true - memory is busy
+ * false - memory is free;
+*/
+
+#if defined(USE_EEPROM)
+
+#include <eeprom.h>
+
+#define WRITE_MEMORY HAL_WriteEeprom
+#define READ_MEMORY HAL_ReadEeprom
+#define IS_MEMORY_BUSY HAL_IsEepromBusy
+#define MEMORY_DESCRIPTOR HAL_EepromParams_t
+
+#endif
+
+#endif /* _PDSMEMABSTRACT_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsWriteData.h b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsWriteData.h
new file mode 100644
index 00000000..17cedbc4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsWriteData.h
@@ -0,0 +1,84 @@
+/******************************************************************************
+ \file csDbg.h
+
+ \brief
+ Persistent Periodic data save implementation header
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2010 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 29.10.10 A. Razinkov - Created.
+******************************************************************************/
+
+#ifndef _PDSWRITEDATA_H_
+#define _PDSWRITEDATA_H_
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <pdsMemAbstract.h>
+
+#ifdef _COMMISSIONING_
+/******************************************************************************
+ Functions prototypes section
+******************************************************************************/
+/******************************************************************************
+\brief Update persistent items values in Configuration Server from persist memory
+\
+\return Operation result
+******************************************************************************/
+PDS_DataServerState_t pdsUpdate(void);
+
+/******************************************************************************
+\brief Locates parameter by it's index in persistent memory table. And prepares
+\ memory descriptor to store parameter's value in EEPROM
+\
+\param[in] index - index of the parameter in persistent memory table
+\param[out]descriptor - memory descriptor to store parameter value
+******************************************************************************/
+void pdsPrepareMemoryAccess(uint8_t index, MEMORY_DESCRIPTOR* descriptor);
+
+/******************************************************************************
+\brief Timer callback, initiates the commit process.
+******************************************************************************/
+void pdsOnTimerSave(void);
+
+/*******************************************************************************
+\brief Start server work
+*******************************************************************************/
+void pdsStartPersistServer(void);
+#endif /* _COMMISSIONING_ */
+
+/******************************************************************************
+\brief Writes data to persist memory
+\
+\param[in] descriptor - memory descriptor to store parameter value
+\param[out]callback - callback to write-finidhed event handler
+******************************************************************************/
+PDS_DataServerState_t pdsWrite(MEMORY_DESCRIPTOR* descriptor, void (*callback)(void));
+
+/******************************************************************************
+\brief Read data from persist memory
+\
+\param[in] descriptor - memory descriptor to read parameter value
+\param[out]callback - callback to read-finished event handler
+******************************************************************************/
+PDS_DataServerState_t pdsRead(MEMORY_DESCRIPTOR* descriptor, void (*callback)(void));
+
+/******************************************************************************
+\brief Wait until memory be ready for transaction
+******************************************************************************/
+void pdsWaitMemoryFree(void);
+
+/*******************************************************************************
+\brief Dummy callback
+*******************************************************************************/
+void pdsDummyCallback(void);
+
+#endif /* _PDSWRITEDATA_H_ */
diff --git a/digital/zigbit/bitcloud/stack/Components/PersistDataServer/src/pdsCrcService.c b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/src/pdsCrcService.c
new file mode 100644
index 00000000..de9631dc
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/src/pdsCrcService.c
@@ -0,0 +1,217 @@
+/***************************************************************************//**
+ \file pdsCrcService.c
+
+ \brief Persistence Data Server implementation
+
+ \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:
+ 22/01/08 A. Khromykh - Created
+ 01/11/10 A. Razinkov - Modified
+*****************************************************************************/
+
+#ifdef _COMMISSIONING_
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <pdsMemAbstract.h>
+#include <pdsCrcService.h>
+#include <pdsAuxService.h>
+#include <taskManager.h>
+#include <csPersistentMem.h>
+#include <pdsWriteData.h>
+
+/******************************************************************************
+\brief Calculate CRC of persistent data stored in persist memory
+\
+\param[out] crcStation - pointer to CRC service structure
+******************************************************************************/
+void pdsCalculateCrc(PDS_ServiceCrc_t *crcStation)
+{
+ uint8_t tdata = 0;
+ MEMORY_DESCRIPTOR descriptor;
+
+ if (NULL == crcStation)
+ return;
+
+ crcStation->crc = 0;
+ descriptor.address = SYSTEM_BASE_EEPROM_ADDRESS;
+ descriptor.length = 1;
+ while (descriptor.address < csPersistentMemorySize)
+ {
+ descriptor.data = &tdata;
+
+ pdsWaitMemoryFree();
+
+ if (EEPROM_ERROR == READ_MEMORY(&descriptor, NULL))
+ {
+ crcStation->eepromState = PDS_EEPROM_ERROR;
+ return;
+ }
+
+ pdsWaitMemoryFree();
+
+ crcStation->crc += tdata;
+ descriptor.address++;
+ }
+ crcStation->eepromState = PDS_SUCCESS;
+}
+
+/******************************************************************************
+\brief Read CRC of stored data from persist memory
+\
+\param[out] crcStation - pointer to CRC service structure
+******************************************************************************/
+void pdsReadCrc(PDS_ServiceCrc_t *crcStation)
+{
+ MEMORY_DESCRIPTOR descriptor;
+
+ if (NULL == crcStation)
+ return;
+
+ descriptor.address = csPersistentMemorySize;
+ descriptor.length = 1;
+ while (descriptor.address < USER_BASE_EEPROM_ADDRESS)
+ {
+ descriptor.data = &(crcStation->crc);
+
+ pdsWaitMemoryFree();
+
+ if (EEPROM_ERROR == READ_MEMORY(&descriptor, NULL))
+ {
+ crcStation->eepromState = PDS_EEPROM_ERROR;
+ return;
+ }
+
+ pdsWaitMemoryFree();
+
+ if (0xFF != crcStation->crc)
+ {
+ crcStation->position = descriptor.address;
+ crcStation->eepromState = PDS_SUCCESS;
+ return;
+ }
+ descriptor.address++;
+ }
+ crcStation->position = csPersistentMemorySize;
+ crcStation->eepromState = PDS_SUCCESS;
+}
+
+/******************************************************************************
+\brief Clears whole CRC area in persist memory
+\
+\return operation result
+******************************************************************************/
+PDS_DataServerState_t pdsClearCrcArea(void)
+{
+ uint8_t value = 0xFF;
+ MEMORY_DESCRIPTOR descriptor;
+ uint8_t status;
+
+ descriptor.data = &value;
+ descriptor.address = csPersistentMemorySize;
+ descriptor.length = 1;
+
+ for (uint8_t i = 0; i < PDS_CRC_AREA; i++)
+ {
+ status = pdsWrite(&descriptor, pdsDummyCallback);
+ if (status != PDS_SUCCESS)
+ return status;
+
+ descriptor.address++;
+ }
+ return PDS_SUCCESS;
+}
+
+/******************************************************************************
+\brief Write CRC of stored data to persist memory. The ring buffer used
+\ to increase persist memory life cycle
+\
+\param[out] crcStation - pointer to CRC service structure
+******************************************************************************/
+PDS_DataServerState_t pdsWriteCrc(void)
+{
+ PDS_ServiceCrc_t crcRead, crcCalc;
+ MEMORY_DESCRIPTOR descriptor;
+ uint8_t datadelete = 0xFF;
+ PDS_DataServerState_t status;
+
+ pdsReadCrc(&crcRead);
+ if (PDS_EEPROM_ERROR == crcRead.eepromState)
+ return PDS_EEPROM_ERROR;
+
+ pdsCalculateCrc(&crcCalc);
+ if (PDS_EEPROM_ERROR == crcCalc.eepromState)
+ return PDS_EEPROM_ERROR;
+
+ if (0 == (uint8_t)(crcCalc.crc + crcRead.crc))
+ return PDS_SUCCESS;
+
+ crcCalc.crc = 0 - crcCalc.crc;
+ descriptor.address = crcRead.position;
+ descriptor.data = &datadelete;
+ descriptor.length = 1;
+
+ status = pdsWrite(&descriptor, pdsDummyCallback);
+ if (status != PDS_SUCCESS)
+ return status;
+
+ if (++descriptor.address >= USER_BASE_EEPROM_ADDRESS)
+ descriptor.address = csPersistentMemorySize;
+ descriptor.data = &(crcCalc.crc);
+
+ status = pdsWrite(&descriptor, pdsDummyCallback);
+ if (status != PDS_SUCCESS)
+ return status;
+
+ return PDS_SUCCESS;
+}
+
+/******************************************************************************
+\brief Check if any valid data exists in persist memory
+\
+\return operation result
+******************************************************************************/
+PDS_DataServerState_t pdsCheckPersistMemory(void)
+{
+ PDS_ServiceCrc_t crcRead, crcCalc;
+
+ pdsCalculateCrc(&crcCalc);
+ if (PDS_EEPROM_ERROR == crcCalc.eepromState)
+ return PDS_EEPROM_ERROR;
+
+ pdsReadCrc(&crcRead);
+ if (PDS_EEPROM_ERROR == crcRead.eepromState)
+ return PDS_EEPROM_ERROR;
+
+ if (0x00 == (uint8_t)(crcCalc.crc + crcRead.crc))
+ return PDS_SUCCESS;
+
+ return PDS_CRC_ERROR;
+}
+
+#ifdef __DBG_PDS__
+ uint8_t eepromCopy[0x400u];
+
+ void pdsDbgReadAllEeprom(void)
+ {
+ PDS_DataServerState_t status;
+ MEMORY_DESCRIPTOR descriptor;
+
+ descriptor.address = 0;
+ descriptor.data = eepromCopy;
+ descriptor.length = 0x400u;
+
+ status = pdsRead(&descriptor, pdsDummyCallback);
+ if (status != PDS_SUCCESS)
+ return;
+ }
+#endif
+#endif /* _COMMISSIONING_ */
+// eof pdsDataServer.c
diff --git a/digital/zigbit/bitcloud/stack/Components/PersistDataServer/src/pdsDataServer.c b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/src/pdsDataServer.c
new file mode 100644
index 00000000..530ac0a7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/src/pdsDataServer.c
@@ -0,0 +1,206 @@
+/***************************************************************************//**
+ \file pdsDataServer.c
+
+ \brief Persistence Data Server implementation
+
+ \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:
+ 22/01/08 A. Khromykh - Created
+ 01/11/10 A. Razinkov - Modified
+*****************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <pdsMemAbstract.h>
+#include <appTimer.h>
+#include <pdsDataServer.h>
+#include <pdsCrcService.h>
+#include <pdsAuxService.h>
+#include <leds.h>
+#include <pdsWriteData.h>
+#include <csPersistentMem.h>
+#include <taskManager.h>
+
+#ifdef _COMMISSIONING_
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+/* Number of records in csPersistentMemTable*/
+extern const uint8_t csPersistentItemsAmount;
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/******************************************************************************
+\brief Persist Data Server initialization procedure
+******************************************************************************/
+void PDS_Init(void)
+{
+ PDS_DataServerState_t status;
+
+#ifdef USE_LED
+ BSP_OpenLeds();
+#endif
+
+ /* Check if any valid data exists in persist memory */
+ status = pdsCheckPersistMemory();
+
+ /* Valid data exists - try to update from persist memory */
+ if (PDS_SUCCESS == status)
+ {
+ if (PDS_EEPROM_ERROR != pdsUpdate())
+ {
+ pdsStartPersistServer();
+ }
+ }
+
+ else if (PDS_EEPROM_ERROR != status)
+ {
+ pdsStartPersistServer();
+ }
+}
+
+/******************************************************************************
+\brief Set the default system area values and store persistent data to persist
+ memory
+
+\return operation result
+******************************************************************************/
+PDS_DataServerState_t PDS_SetToDefault(void)
+{
+ MEMORY_DESCRIPTOR descriptor;
+ PDS_DataServerState_t status;
+
+ CS_PdsDefaultValue();
+ /* Store all persistent parameters */
+ for (uint8_t index = 0; index < csPersistentItemsAmount; index++)
+ {
+ pdsPrepareMemoryAccess(index, &descriptor);
+ status = pdsWrite(&descriptor, pdsDummyCallback);
+ if (status != PDS_SUCCESS)
+ return status;
+ }
+
+ /* Reset CRC area and rewrite CRC*/
+ status = pdsClearCrcArea();
+ if (status != PDS_SUCCESS)
+ return status;
+ status = pdsWriteCrc();
+ if (status != PDS_SUCCESS)
+ return status;
+
+ return PDS_SUCCESS;
+}
+
+/******************************************************************************
+\brief On-demand data storing in persist memory
+******************************************************************************/
+void PDS_FlushData(void)
+{
+ if (SAVE_IS_STOPED == savingIsStarted)
+ {
+ /* Force timer to finish - store data immediately */
+ HAL_StopAppTimer(&pdsEepromSaveServiceTimer);
+ pdsOnTimerSave();
+ }
+
+ while (SAVE_IS_STARTED == savingIsStarted)
+ {
+ SYS_ForceRunTask();
+ }
+}
+
+/***************************************************************************//**
+\brief Must be called only from ::APL_TaskHandler() function.\n
+ Stops persist data server.
+*******************************************************************************/
+void PDS_Stop(void)
+{
+ while (SAVE_IS_STARTED == savingIsStarted)
+ {
+ SYS_ForceRunTask();
+ }
+
+ HAL_StopAppTimer(&pdsEepromSaveServiceTimer);
+}
+#endif /* _COMMISSIONING_ */
+
+/******************************************************************************
+\brief Read data from user area in persist memory
+
+\param[in] offset - data offset in persist memory
+\param[in] length - data lenght
+\param[out] data - pointer to user data area in RAM
+\param[out] callback - callback to read-finished event handler
+
+\return operation result
+******************************************************************************/
+PDS_DataServerState_t PDS_ReadUserData(uint16_t offset, uint8_t *data, uint16_t length, void (*callback)(void))
+{
+ MEMORY_DESCRIPTOR descriptor;
+ PDS_DataServerState_t status;
+
+ descriptor.address = USER_BASE_EEPROM_ADDRESS + offset;
+ descriptor.length = length;
+ descriptor.data = data;
+
+ while(SAVE_IS_STARTED == savingIsStarted)
+ {
+ SYS_ForceRunTask();
+ }
+
+ if (NULL == callback)
+ callback = pdsDummyCallback;
+
+ status = pdsRead(&descriptor, callback);
+ if (status != PDS_SUCCESS)
+ return status;
+
+ return PDS_SUCCESS;
+}
+
+/******************************************************************************
+\brief Write data to user area in persist memory
+\
+\param[in] offset - data offset in persist memory
+\param[in] length - data lenght
+\param[out] data - pointer to user data area
+\param[out] callback - callback to read-finished event handler
+
+\return operation result
+******************************************************************************/
+PDS_DataServerState_t PDS_WriteUserData(uint16_t offset, uint8_t *data, uint16_t length, void (*callback)(void))
+{
+ MEMORY_DESCRIPTOR descriptor;
+ PDS_DataServerState_t status;
+
+ descriptor.address = USER_BASE_EEPROM_ADDRESS + offset;
+ descriptor.length = length;
+ descriptor.data = data;
+
+ while(SAVE_IS_STARTED == savingIsStarted)
+ {
+ SYS_ForceRunTask();
+ }
+
+ if (NULL == callback)
+ callback = pdsDummyCallback;
+
+ status = pdsWrite(&descriptor, callback);
+ if (status != PDS_SUCCESS)
+ return status;
+
+ return PDS_SUCCESS;
+}
+// eof pdsDataServer.c
diff --git a/digital/zigbit/bitcloud/stack/Components/PersistDataServer/src/pdsWriteData.c b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/src/pdsWriteData.c
new file mode 100644
index 00000000..bb7f9859
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/src/pdsWriteData.c
@@ -0,0 +1,286 @@
+/**************************************************************************//**
+ \file pdsWriteData.c
+
+ \brief Periodic data save implementation
+
+ \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:
+ 22/01/08 A. Khromykh - Created
+ 01/11/10 A. Razinkov - Modified
+*****************************************************************************/
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <pdsMemAbstract.h>
+#include <appTimer.h>
+#include <pdsCrcService.h>
+#include <pdsAuxService.h>
+#include <leds.h>
+#include <stddef.h>
+#include <csPersistentMem.h>
+#include <pdsDbg.h>
+#include <pdsWriteData.h>
+#include <taskManager.h>
+
+/******************************************************************************
+ Global variables section
+******************************************************************************/
+uint8_t savingIsStarted = SAVE_IS_STOPED;
+
+#ifdef _COMMISSIONING_
+HAL_AppTimer_t pdsEepromSaveServiceTimer;
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+/* Configuration Server persistent memory table */
+extern const CS_PersistantData_t PROGMEM_DECLARE(csPersistentMemTable[]);
+
+/* Number of records in csPersistentMemTable*/
+extern const uint8_t csPersistentItemsAmount;
+
+/* Total size of memory occupied by persistent parameters */
+extern const uint16_t csPersistentMemorySize;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+static PDS_DataServerState_t pdsCommit(void);
+static bool pdsCommitStarted(MEMORY_DESCRIPTOR* descriptor);
+
+/******************************************************************************
+ Implementation section
+******************************************************************************/
+/******************************************************************************
+\brief Start internal PDS timer
+\
+\param[in] typeInterval - set timer interval. Available intervals are:
+ PDS_LONG_INTERVAL - 5 minutes
+ PDS_SHORT_INTERVAL - 50 msec
+\param[out] callback - callback on timer fired event
+
+******************************************************************************/
+void pdsStartPdsTimer(void (*callback)(void), uint8_t typeInterval)
+{
+ pdsEepromSaveServiceTimer.callback = callback;
+ if (PDS_LONG_INTERVAL == typeInterval)
+ {
+#ifdef _POWER_FAILURE_
+ uint32_t storingInterval;
+
+ CS_ReadParameter(CS_PDS_STORING_INTERVAL_ID, &storingInterval);
+ pdsEepromSaveServiceTimer.interval = storingInterval;
+#else
+ pdsEepromSaveServiceTimer.interval = STORE_TIMER_TIMEOUT;
+#endif /* _POWER_FAILURE_ */
+ }
+ else
+ pdsEepromSaveServiceTimer.interval = SHORT_TIMEOUT;
+ pdsEepromSaveServiceTimer.mode = TIMER_ONE_SHOT_MODE;
+ HAL_StartAppTimer(&pdsEepromSaveServiceTimer);
+}
+
+/*******************************************************************************
+\brief Start server work
+*******************************************************************************/
+void pdsStartPersistServer(void)
+{
+ pdsStartPdsTimer(pdsOnTimerSave, PDS_LONG_INTERVAL);
+}
+
+/******************************************************************************
+\brief Commit item value changes (if any) from Configuration Server to persist
+\ memory
+\
+\param[in] descriptor - memory descriptor to store parameter value
+
+\return true - if changes found and commit started; false - otherwise
+******************************************************************************/
+static bool pdsCommitStarted(MEMORY_DESCRIPTOR* descriptor)
+{
+ uint8_t data;
+ MEMORY_DESCRIPTOR byteAccessDescriptor =
+ {
+ .data = &data,
+ .length = 1
+ };
+
+ /* Check for any changes in byte-by-byte order */
+ for (uint16_t i = 0; i < descriptor->length; i++)
+ {
+ byteAccessDescriptor.address = descriptor->address + i;
+ pdsRead(&byteAccessDescriptor, pdsDummyCallback);
+ /* Start rewrite out of date data in persist memory*/
+ if (*byteAccessDescriptor.data != *((descriptor->data) + i))
+ {
+ pdsWrite(descriptor, pdsOnTimerSave);
+ return true;
+ }
+ }
+ return false;
+}
+
+/******************************************************************************
+\brief Update persistent items values in Configuration Server from persist memory
+\
+\return Operation result
+******************************************************************************/
+PDS_DataServerState_t pdsUpdate(void)
+{
+ PDS_DataServerState_t status;
+ MEMORY_DESCRIPTOR descriptor;
+
+ for (uint8_t item = 0; item < csPersistentItemsAmount; item++)
+ {
+ pdsPrepareMemoryAccess(item, &descriptor);
+ status = pdsRead(&descriptor, pdsDummyCallback);
+ if (status != PDS_SUCCESS)
+ return status;
+ }
+ return PDS_SUCCESS;
+}
+
+/******************************************************************************
+\brief Commit persistent memory changes (if any) from Configuration Server
+\ to persist memory. Process comes iterative way - when some item stored,
+\ this function will be called as a callback.
+\
+\return Operation result
+******************************************************************************/
+PDS_DataServerState_t pdsCommit(void)
+{
+ MEMORY_DESCRIPTOR descriptor;
+ static uint8_t item = 0;
+
+ while (item < csPersistentItemsAmount)
+ {
+ pdsPrepareMemoryAccess(item, &descriptor);
+ if(pdsCommitStarted(&descriptor))
+ return PDS_COMMIT_IN_PROGRESS;
+
+ item++;
+ }
+ item = 0;
+ return PDS_SUCCESS;
+}
+
+/******************************************************************************
+\brief Timer callback, initiates the commit process.
+******************************************************************************/
+void pdsOnTimerSave(void)
+{
+#ifdef USE_LED
+ BSP_OnLed(LED_YELLOW);
+#endif
+
+ savingIsStarted = SAVE_IS_STARTED;
+
+ if (PDS_SUCCESS == pdsCommit())
+ {
+ if (PDS_EEPROM_ERROR == pdsWriteCrc())
+ {
+ pdsStartPdsTimer(pdsOnTimerSave, PDS_SHORT_INTERVAL);
+ }
+ else
+ {
+ pdsStartPersistServer();
+#ifdef USE_LED
+ BSP_OffLed(LED_YELLOW);
+#endif
+ savingIsStarted = SAVE_IS_STOPED;
+ }
+ }
+}
+
+/******************************************************************************
+\brief Locates parameter by it's index in persistent memory table. And prepares
+\ memory descriptor to store parameter's value in EEPROM
+\
+\param[in] index - index of the parameter in persistent memory table
+\param[out]descriptor - memory descriptor to store parameter value
+******************************************************************************/
+void pdsPrepareMemoryAccess(uint8_t index, MEMORY_DESCRIPTOR* descriptor)
+{
+ CS_PersistantData_t item;
+
+ memcpy_P(&item, &csPersistentMemTable[index], sizeof(CS_PersistantData_t));
+
+ assert(item.value, PDS_PDSPREPAREMEMORYACCESS0);
+ descriptor->data = item.value;
+ descriptor->address = item.offset;
+
+ /* Calculate item size using offsets */
+ if (index == (csPersistentItemsAmount-1))
+ {
+ descriptor->length = csPersistentMemorySize - item.offset;
+ }
+ else
+ {
+ CS_PersistantData_t nextItem;
+ memcpy_P(&nextItem, &csPersistentMemTable[index+1], sizeof(CS_PersistantData_t));
+ assert(nextItem.value, PDS_PDSPREPAREMEMORYACCESS1);
+ descriptor->length = nextItem.offset - item.offset;
+ }
+}
+#endif /* _COMMISSIONING_ */
+
+/******************************************************************************
+\brief Write data to persist memory
+\
+\param[in] descriptor - memory descriptor to store parameter value
+\param[out]callback - callback to write-finished event handler
+******************************************************************************/
+PDS_DataServerState_t pdsWrite(MEMORY_DESCRIPTOR* descriptor, void (*callback)(void))
+{
+ pdsWaitMemoryFree();
+ if (EEPROM_ERROR == WRITE_MEMORY(descriptor, callback))
+ return PDS_EEPROM_ERROR;
+
+ if (callback == pdsDummyCallback)
+ pdsWaitMemoryFree();
+
+ return PDS_SUCCESS;
+}
+
+/******************************************************************************
+\brief Read data from persist memory
+\
+\param[in] descriptor - memory descriptor to read parameter value
+\param[out]callback - callback to read-finished event handler
+******************************************************************************/
+PDS_DataServerState_t pdsRead(MEMORY_DESCRIPTOR* descriptor, void (*callback)(void))
+{
+ pdsWaitMemoryFree();
+ if (EEPROM_ERROR == READ_MEMORY(descriptor, callback))
+ return PDS_EEPROM_ERROR;
+
+ if (callback == pdsDummyCallback)
+ pdsWaitMemoryFree();
+
+ return PDS_SUCCESS;
+}
+
+/******************************************************************************
+\brief Wait until memory be ready for transaction
+******************************************************************************/
+void pdsWaitMemoryFree(void)
+{
+ while(IS_MEMORY_BUSY())
+ {
+ SYS_ForceRunTask();
+ }
+}
+
+/*******************************************************************************
+\brief Dummy callback
+*******************************************************************************/
+void pdsDummyCallback(void)
+{}
+// eof pdsDataServer.c
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspAuthenticHandler.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspAuthenticHandler.h
new file mode 100644
index 00000000..37c66d44
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspAuthenticHandler.h
@@ -0,0 +1,75 @@
+/**************************************************************************//**
+ \file sspAuthenticHandler.h
+
+ \brief Mutual Symmetric-Key Entity Authentication routine handler's header file.
+
+ \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:
+ 17/12/07 ALuzhetsky - Created.
+******************************************************************************/
+#ifndef _SSPAUTHENTICHANDLER_H
+#define _SSPAUTHENTICHANDLER_H
+
+#ifdef _LINK_SECURITY_
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <sspManager.h>
+#include <sspHashHandler.h>
+#include <sspAesHandler.h>
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+/******************************************************************************
+ TBD
+******************************************************************************/
+typedef struct
+{
+ SspKeyedHashMacReq_t keyedHashMacParams;
+ BEGIN_PACK
+ struct PACK
+ {
+ volatile uint8_t keyExpander[SECURITY_KEY_SIZE];
+ uint8_t macData[MAX_HASH_TEXT_SIZE];
+ volatile uint8_t bitsExpander[16];
+ };
+ END_PACK
+} SspAuthenticHandlerMem_t;
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+/*******************************************************************************
+ Calculates parameters (MacTag1) for Mutual Symmetric-Key Entity Authentication
+ procedure.
+ Parameters:
+ none.
+ Return:
+ none.
+********************************************************************************/
+void sspCalculateAuthenticMacTag1ReqHandler(void);
+
+/*******************************************************************************
+ Calculates parameters (MacTag2) for Mutual Symmetric-Key Entity Authentication
+ procedure.
+ Parameters:
+ none.
+ Return:
+ none.
+********************************************************************************/
+void sspCalculateAuthenticMacTag2ReqHandler(void);
+
+#endif // _LINK_SECURITY_
+
+#endif //_SSPAUTHENTICHANDLER_H
+
+// eof sspAuthenticHandler.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspCcmHandler.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspCcmHandler.h
new file mode 100644
index 00000000..1e924c49
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspCcmHandler.h
@@ -0,0 +1,171 @@
+/**************************************************************************//**
+ \file sspCcmHandler.h
+
+ \brief CCM routine header file.
+
+ \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:
+ 2006 - VGribanovsky created.
+ 29/11/2007 - ALuzhetsky API corrected.
+******************************************************************************/
+#ifndef _SSPCCMHANDLER_H
+#define _SSPCCMHANDLER_H
+
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+
+
+/******************************************************************************
+ Definitions section.
+******************************************************************************/
+#define CCM_MIC_MAX_SIZE 16
+#define CCM_NONCE_SIZE 13
+
+/******************************************************************************
+ Types' definitions section.
+******************************************************************************/
+/**************************************************************************//**
+ TBD
+******************************************************************************/
+typedef enum
+{
+ CCM_REQ_TYPE_CRYPT,
+ CCM_REQ_TYPE_AUTH,
+ CCM_REQ_TYPE_CHECK_MIC
+} CcmReqType_t;
+
+/**************************************************************************//**
+ TBD
+******************************************************************************/
+typedef enum
+{
+ CCM_STATE_IDLE,
+ CCM_STATE_SET_KEY_WHILE_AUTH_OR_MIC_CHECK,
+ CCM_STATE_SET_KEY_WHILE_CRYPT,
+ CCM_STATE_CALC_X1_FOR_HDR_WHILE_AUTH_OR_MIC_CHECK,
+ CCM_STATE_CALC_XN_FOR_HDR_WHILE_AUTH_OR_MIC_CHECK,
+ CCM_STATE_CALC_XN_FOR_PLD_WHILE_CRYPT_OR_MIC_CHECK,
+ CCM_STATE_CALC_LAST_X_FOR_HDR_WHILE_MIC_CHECK,
+ CCM_STATE_CALC_LAST_X_FOR_HDR_WHILE_AUTH,
+ CCM_STATE_CALC_LAST_X_FOR_PLD_WHILE_CRYPT_OR_MIC_CHECK,
+ CCM_STATE_CRYPT_NEXT_PLD_BLOCK_WHILE_CRYPT_OR_MIC_CHECK,
+ CCM_STATE_CALC_XN_FOR_PLD_WHILE_AUTH,
+ CCM_STATE_CALC_LAST_X_FOR_PLD_WHILE_AUTH,
+ CCM_STATE_CRYPT_MIC,
+} SspCcmState_t;
+
+/**************************************************************************//**
+ \brief Input param structure for CCM authentification & encrypt
+ OR decode & authentification operations.
+******************************************************************************/
+typedef struct
+{
+ //!< key
+ uint8_t *key/*[SECURITY_KEY_SIZE]*/;
+ //!< nonce
+ uint8_t *nonce/*[CCM_NONCE_SIZE]*/;
+ //!< header
+ uint8_t *a/*[len_a]*/;
+ //!< pdu
+ uint8_t *m/*[len_m]*/;
+ //!< MIC length (or MAC - message authentication code).
+ //!< Limitations: does not work correctly if MIC length >= 0xfeff.
+ uint8_t M;
+ //!< header length
+ uint8_t len_a;
+ //!< pdu length
+ uint8_t len_m;
+ //!< Pointer to MIC memory - real MIC value will be XORed to this memory.
+ //!< Set to zero MIC byte values if you want the new MIC to be generated.
+ //!< To verify MIC check that it's value is all zeroes after authentication.
+ uint8_t *mic/*[M]*/;
+ //!< Confirm callback function
+ void (*ccmConfirm)(void);
+} CcmReq_t;
+
+/******************************************************************************
+ \brief Cryptographic context. Used for only for MIC generation and checking.
+******************************************************************************/
+typedef struct
+{
+ uint8_t textSize;
+ uint8_t *text/*[textSize]*/;
+ uint8_t x_i[SECURITY_BLOCK_SIZE];
+} CcmAuthCtx_t;
+
+/**************************************************************************//**
+ \brief CCM handler module static memory structure.
+******************************************************************************/
+typedef struct
+{
+ //!< Current CCM request pointer
+ CcmReq_t *ccmReq;
+ //!< Current CCM request type
+ CcmReqType_t reqType;
+ //!< Current CCM module state
+ SspCcmState_t ccmState;
+ //!< Buffer is used to save intermidiate decryption results while MIC
+ //!< calculating procedure and to form B1 while authentication.
+ uint8_t tmpCcmBuf[SECURITY_BLOCK_SIZE];
+ //!< Payload block counter
+ uint8_t pldBlockCounter;
+ CcmAuthCtx_t ccmAuthCtx;
+} SspCcmHandlerMem_t;
+
+
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+/******************************************************************************
+ Calculate the CCM* authentication tag (CBC-MAC in RFC 3610 terms).
+ Arguments:
+ key - AES-128 key;
+ nonce_block - 16-byte block containing nonce in bytes 1..13
+ (bytes 0,14,15 are arbitrary);
+ frame - ptr to data to be protected by the authentication tag;
+ len_auth - data that have to be authentified only;
+ len_crypt - data that have to be authentified and encrypted;
+ auth - buffer to place the authentication tag;
+ M - MIC length,
+ temp - 176-byte array used by AES encryption algorithm.
+ If M=0 (which is permitted by ZigBee Standard but not by RFC 3610)
+ the function returns immediately.
+ Limitations: does not work correctly if len_auth >= 0xfeff.
+******************************************************************************/
+void ccmAuthReq(CcmReq_t *ccmParam);
+
+
+/******************************************************************************
+ Encrypt the buffer in place by the CCM*. Arguments:
+ key - AES-128 key;
+ nonce_block - 16-byte block containing nonce in bytes 1..13
+ (bytes 0,14,15 are arbitrary);
+ payload - buffer to be encrypted;
+ len_payload - length of this buffer;
+ auth - MIC which have to be encrypted additionally (also in place);
+ M - its length;
+ temp - 176-byte array used by AES encryption algorithm.
+******************************************************************************/
+void ccmCryptReq(CcmReq_t *);
+
+/**************************************************************************//**
+ \brief Performs encrypted frame MIC check procedure.
+
+ \param checMecReq - request parametrs structure pointer. Take a look at the
+ CcmReq_t type declaration for the detailes.
+******************************************************************************/
+void ccmCheckMicReq(CcmReq_t *checkMicReq);
+
+#endif //_SSPCCMHANDLER_H
+
+//eof sspCcmHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspChallengeGenHandler.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspChallengeGenHandler.h
new file mode 100644
index 00000000..a245e581
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspChallengeGenHandler.h
@@ -0,0 +1,42 @@
+/**************************************************************************//**
+ \file sspChallengeGenHandler.h
+
+ \brief Challenge generator handler header file.
+
+ \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:
+ 17/12/07 ALuzhetsky - Created.
+******************************************************************************/
+#ifndef _SSPCHALLENGEGENHANDLER_H
+#define _SSPCHALLENGEGENHANDLER_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+
+/******************************************************************************
+ Definition section.
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+/*******************************************************************************
+ Resets Security Service Provider entity.
+ Parameters:
+ challenge - pointer to the memory for saving generated challenge.
+ Return:
+ none.
+********************************************************************************/
+void sspGenerateChallengeHandler(uint8_t challenge[/*CHALLENGE_SEQUENCE_SIZE*/]);
+#endif //_SSPCHALLENGEGENHANDLER_H
+
+// eof sspChallengeGenHandler.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspHashHandler.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspHashHandler.h
new file mode 100644
index 00000000..c89a1193
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspHashHandler.h
@@ -0,0 +1,118 @@
+/**************************************************************************//**
+ \file sspHashHandler.h
+
+ \brief Hash routine header file.
+
+ \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:
+ 29/11/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _SSPHASHHANDLER_H
+#define _SSPHASHHANDLER_H
+
+#ifdef _LINK_SECURITY_
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <sspCommon.h>
+
+/******************************************************************************
+ Definitions section.
+******************************************************************************/
+#define MAX_HASH_TEXT_SIZE 53 // 1 + 2*sizeof(uint64_t) + 2*CHALLENGE_SIZE + sizeof(uint32_t)
+#define IPAD 0x36
+#define OPAD 0x5C
+
+/******************************************************************************
+ Types' definitions section.
+******************************************************************************/
+/******************************************************************************
+ TBD
+******************************************************************************/
+typedef struct
+{
+ // Service field - for internal needs.
+ SSP_Service_t service;
+ // There is should be an additional memory before and after text (16 bytes in both cases).
+ uint8_t *text/*[SECURITY_KEY_SIZE + textSize + 16]*/;
+ // Pointer to key fir Keyed Hash Function.
+ const uint8_t *key/*[SECURITY_KEY_SIZE]*/;
+ // Size of the text.
+ uint8_t textSize;
+ // Buffer for generated hash. Shoul be initialized by the user.
+ uint8_t *hash_i/*[SECURITY_KEY_SIZE]*/;
+ void (*sspKeyedHashMacConfirm)(void);
+} SspKeyedHashMacReq_t;
+
+/******************************************************************************
+ TBD
+******************************************************************************/
+typedef enum
+{
+ HASH_STATE_IDLE,
+ HASH_STATE_CREATE_HASH1,
+ HASH_STATE_CREATE_HASH2,
+} SspHashHandlerState_t;
+
+/******************************************************************************
+ TBD
+******************************************************************************/
+typedef struct
+{
+ uint8_t *M/*[textSize + 16]*/;
+ uint8_t *hash_i/*[SECURITY_KEY_SIZE]*/;
+ uint8_t textSize;
+ void (*bcbHashConf)(void);
+} SspBcbHashReq_t;
+
+/******************************************************************************
+ TBD
+******************************************************************************/
+typedef struct
+{
+ SspBcbHashReq_t *currentBcbHashReq;
+ SspKeyedHashMacReq_t *keyedHashMacReq;
+ SspBcbHashReq_t bcbHashReq;
+ uint8_t bcbBlockCounter;
+ SspHashHandlerState_t hashHandlerState;
+} SspHashHandlerMem_t;
+
+
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+/*******************************************************************************
+ Keyed hash function implementation.
+ Parameters:
+ param - parameters of the primitive (for detailed description look at
+ SspKeyedHashMacReq_t declaration).
+ Return:
+ none.
+********************************************************************************/
+void sspKeyedHashMacReq(SspKeyedHashMacReq_t *param);
+
+/*******************************************************************************
+ Block Cipher Based hash function implementation.
+ Parameters:
+ param - parameters of the primitive (for detailed description look at
+ SspBcbHashReq_t declaration).
+ Return:
+ none.
+********************************************************************************/
+void sspBcbHashReq(SspBcbHashReq_t *param);
+
+#endif // _LINK_SECURITY_
+
+#endif //_SSPHASHHANDLER_H
+
+//eof sspHashHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspManager.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspManager.h
new file mode 100644
index 00000000..034ebf89
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspManager.h
@@ -0,0 +1,174 @@
+/**************************************************************************//**
+ \file sspManager.h
+
+ \brief Security Service Provider header file.
+
+ \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:
+ 06/12/2007 - ALuzhetsky API corrected.
+******************************************************************************/
+#ifndef _SSPMANAGER_H
+#define _SSPMANAGER_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <queue.h>
+
+/******************************************************************************
+ Definition section.
+******************************************************************************/
+#ifdef _SSP_USE_FLASH_FOR_CONST_DATA
+ #include <types.h>
+ #define HANDLERS_MEM FLASH_VAR
+ #define HANDLERS_GET(A, I) memcpy_P(A, &sspHandlers[I], sizeof(SspTask_t))
+#else // _SSP_USE_FLASH_FOR_CONST_DATA
+ #define HANDLERS_MEM
+ #define HANDLERS_GET(A, I) (((A)->task) = sspHandlers[I].task)
+#endif // _SSP_USE_FLASH_FOR_CONST_DATA
+
+#if defined(_MAC_HW_AES_) || defined(_HAL_HW_AES_)
+ #ifdef _LINK_SECURITY_
+ #define SSP_TASKS_LIST \
+ {sspCalculateAuthenticMacTag1ReqHandler}, \
+ {sspCalculateAuthenticMacTag2ReqHandler}, \
+ {sspCalculateSkkeParamsReqHandler}, \
+ {sspKeyedHashReqHandler}, \
+ {sspEncryptFrameReqHandler}, \
+ {sspDecryptFrameReqHandler}
+ #else // _LINK_SECURITY_
+ #define SSP_TASKS_LIST \
+ {sspEncryptFrameReqHandler}, \
+ {sspDecryptFrameReqHandler}
+ #endif // _LINK_SECURITY_
+
+#elif defined(_SSP_SW_AES_)
+ #ifdef _LINK_SECURITY_
+ #define SSP_TASKS_LIST \
+ {sspCalculateAuthenticMacTag1ReqHandler}, \
+ {sspCalculateAuthenticMacTag2ReqHandler}, \
+ {sspCalculateSkkeParamsReqHandler}, \
+ {sspKeyedHashReqHandler}, \
+ {sspEncryptFrameReqHandler}, \
+ {sspDecryptFrameReqHandler}, \
+ {sspAesReqHandler},
+ #else // _LINK_SECURITY_
+ #define SSP_TASKS_LIST \
+ {sspEncryptFrameReqHandler}, \
+ {sspDecryptFrameReqHandler}, \
+ {sspAesReqHandler}
+ #endif // _LINK_SECURITY_
+
+#else
+ #error Unknown AES routine provider
+#endif
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef struct
+{
+ void (*task)(void);
+} SspTask_t;
+
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef enum
+{
+#ifdef _LINK_SECURITY_
+ SSP_TASK_AUTHENTIC_MAC_TAG1,
+ SSP_TASK_AUTHENTIC_MAC_TAG2,
+ SSP_TASK_SKKE,
+ SSP_TASK_KEYED_HASH,
+#endif // _LINK_SECURITY_
+ SSP_TASK_ENCRYPT_FRAME,
+ SSP_TASK_DECRYPT_FRAME,
+#ifdef _SSP_SW_AES_
+ SSP_TASK_AES,
+#endif // _SSP_SW_AES_
+
+ SSP_TASKS_SIZE,
+} SspTaskId_t;
+
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef enum // ssp possible requests' types.
+{
+#ifdef _LINK_SECURITY_
+ SSP_REQ_ID_AUTHENTIC_MAC_TAG1 = SSP_TASK_AUTHENTIC_MAC_TAG1,
+ SSP_REQ_ID_AUTHENTIC_MAC_TAG2 = SSP_TASK_AUTHENTIC_MAC_TAG2,
+ SSP_REQ_ID_SKKE = SSP_TASK_SKKE,
+ SSP_REQ_ID_KEYED_HASH = SSP_TASK_KEYED_HASH,
+#endif // _LINK_SECURITY_
+ SSP_REQ_ID_SFP_ENCRYPT_FRAME = SSP_TASK_ENCRYPT_FRAME,
+ SSP_REQ_ID_SFP_DECRYPT_FRAME = SSP_TASK_DECRYPT_FRAME,
+
+} SspRequestId_t;
+
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef uint8_t SspTaskBitMask_t;
+
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef struct
+{
+ SspTaskBitMask_t taskBitMask;
+ QueueDescriptor_t reqQueueDescr;
+} SspManagerMem_t;
+
+/******************************************************************************
+ Functions prototypes section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+void sspPostTask(SspTaskId_t taskID);
+
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+void sspResetTaskManager(void);
+
+/******************************************************************************
+ Sends confirmation to the SSP user.
+ Parameters:
+ request - parameters of the request to be confirmed.
+ Returns:
+ none.
+******************************************************************************/
+void sspSendConfToUpperLayer(void *request);
+
+#endif // _SSPMANAGER_H
+
+// eof sspManager.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspMem.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspMem.h
new file mode 100644
index 00000000..1512a170
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspMem.h
@@ -0,0 +1,238 @@
+/**************************************************************************//**
+ \file sspMem.h
+
+ \brief Security Service Provider memory manager header file.
+
+ \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:
+ 06/12/2007 - ALuzhetsky created.
+******************************************************************************/
+#ifndef _SSPMEM_H
+#define _SSPMEM_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <queue.h>
+#include <sspManager.h>
+#include <sspAuthenticHandler.h>
+#include <sspSkkeHandler.h>
+#include <sspSfpHandler.h>
+#include <sspCcmHandler.h>
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+typedef struct
+{
+ void *sspReq; // Used by all modules which need to save requests' parameters.
+ // For Manager needs.
+ SspManagerMem_t managerMem;
+ SspAesMem_t aes;
+ union
+ {
+#ifdef _LINK_SECURITY_
+ SspAuthenticHandlerMem_t authenticHandlerMem;
+ SspSkkeHandlerMem_t skkeHandlerMem;
+#endif // _LINK_SECURITY_
+ SspSfpHandlerMem_t sfpHandlerMem;
+ };
+ union
+ {
+#ifdef _LINK_SECURITY_
+ SspHashHandlerMem_t hashHandlerMem;
+#endif // _LINK_SECURITY_
+ SspCcmHandlerMem_t ccmHandlerMem;
+ };
+} SspMem_t;
+
+/******************************************************************************
+ External variables.
+******************************************************************************/
+extern SspMem_t sspMem;
+
+/******************************************************************************
+ Inline static functions prototypes section.
+******************************************************************************/
+/******************************************************************************
+ Stores the pointer to the current request.
+ Parameters:
+ req - pointer to the current request.
+ returns:
+ none.
+******************************************************************************/
+INLINE void sspStoreReqParams(void *req)
+{
+ sspMem.sspReq = req;
+}
+
+/******************************************************************************
+ Gets the pointer to the current request.
+ Parameters:
+ none.
+ returns:
+ Pointer to the current request.
+******************************************************************************/
+INLINE void* sspGetReqParams(void)
+{
+ return sspMem.sspReq;
+}
+
+/******************************************************************************
+ Gets the current manager state.
+ Parameters:
+ none.
+ returns:
+ current manager state.
+******************************************************************************/
+/*INLINE SspState_t sspGetManagerState(void)
+{
+ return sspMem.managerMem.managerState;
+}*/
+
+/******************************************************************************
+ Sets the current manager state.
+ Parameters:
+ new state.
+ returns:
+ none.
+******************************************************************************/
+/*INLINE void sspSetManagerState(SspState_t newState)
+{
+ sspMem.managerMem.managerState = newState;
+}*/
+
+/******************************************************************************
+ Gets pointer to the queue descriptor.
+ Parameters:
+ none.
+ returns:
+ pointer to the queue descriptor.
+******************************************************************************/
+INLINE QueueDescriptor_t* sspGetQueueDescr(void)
+{
+ return &sspMem.managerMem.reqQueueDescr;
+}
+
+/******************************************************************************
+ Gets pointer to the queue descriptor.
+ Parameters:
+ none.
+ returns:
+ pointer to the queue descriptor.
+******************************************************************************/
+INLINE SspTaskBitMask_t* sspGetTaskBitMask(void)
+{
+ return &sspMem.managerMem.taskBitMask;
+}
+
+/******************************************************************************
+ Gets pointer to the current request.
+ Parameters:
+ none.
+ returns:
+ pointer to the current request.
+******************************************************************************/
+INLINE void* sspGetCurrentReq(void)
+{
+ return sspMem.sspReq;
+}
+
+/******************************************************************************
+ Stores pointer to the current request.
+ Parameters:
+ pointer to the current request.
+ returns:
+ none.
+******************************************************************************/
+INLINE void sspSetCurrentReq(void* param)
+{
+ sspMem.sspReq = param;
+}
+
+#ifdef _LINK_SECURITY_
+/******************************************************************************
+ Gets pointer to the authentic handler memory.
+ Parameters:
+ none.
+ returns:
+ pointer to the authentic handler memory.
+******************************************************************************/
+INLINE SspAuthenticHandlerMem_t* sspGetAuthenticHandlerMem(void)
+{
+ return &sspMem.authenticHandlerMem;
+}
+
+/******************************************************************************
+ Gets pointer to the skke handler memory.
+ Parameters:
+ none.
+ returns:
+ pointer to the skke handler memory.
+******************************************************************************/
+INLINE SspSkkeHandlerMem_t* sspGetSkkeHandlerMem(void)
+{
+ return &sspMem.skkeHandlerMem;
+}
+
+/******************************************************************************
+ Gets pointer to the hash handler memory.
+ Parameters:
+ none.
+ returns:
+ pointer to the hash handler memory.
+******************************************************************************/
+INLINE SspHashHandlerMem_t* sspGetHashHandlerMem(void)
+{
+ return &sspMem.hashHandlerMem;
+}
+#endif // _LINK_SECURITY_
+
+/******************************************************************************
+ Gets pointer to the sfp handler memory.
+ Parameters:
+ none.
+ returns:
+ pointer to the sfp handler memory.
+******************************************************************************/
+INLINE SspSfpHandlerMem_t* sspGetSfpHandlerMem(void)
+{
+ return &sspMem.sfpHandlerMem;
+}
+
+/******************************************************************************
+ Gets pointer to the memory for aes encryption procedure.
+ Parameters:
+ none.
+ returns:
+ pointer to the memory for aes encryption procedure.
+******************************************************************************/
+INLINE SspAesMem_t* sspGetAesMem(void)
+{
+ return &sspMem.aes;
+}
+
+/******************************************************************************
+ Gets pointer to the ccm handler memory.
+ Parameters:
+ none.
+ returns:
+ pointer to the ccm handler memory.
+******************************************************************************/
+INLINE SspCcmHandlerMem_t* sspGetCcmHandlerMem(void)
+{
+ return &sspMem.ccmHandlerMem;
+}
+
+
+//#endif // _SSP_USE_STATIC_MEM_
+
+#endif //_SSPMEM_H
+// eof sspMem.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspSfpHandler.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspSfpHandler.h
new file mode 100644
index 00000000..3cc50904
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspSfpHandler.h
@@ -0,0 +1,134 @@
+/**************************************************************************//**
+ \file sspSfpHandler.h
+
+ \brief SFP routine header file.
+
+ \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:
+ 2006 - VGribanovsky created.
+ 29/11/2007 - ALuzhetsky API corrected.
+******************************************************************************/
+
+#ifndef _SSPSFPHANDLER_H
+#define _SSPSFPHANDLER_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <bcEndian.h>
+#include <sspManager.h>
+#include <sspSfp.h>
+#include <sspAesHandler.h>
+#include <sspCcmHandler.h>
+
+/******************************************************************************
+ Types definition section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD
+******************************************************************************/
+typedef enum
+{
+ SFP_STATE_IDLE,
+ SFP_STATE_ENCRYPTION_KEY_TRANSFORMING,
+ SFP_STATE_ENCRYPTION_AUTHENTIC,
+ SFP_STATE_ENCRYPTION_ENCRYPT,
+ SFP_STATE_DECRYPTION_KEY_TRANSFORMING,
+ SFP_STATE_DECRYPTION_AUTHENTIC,
+ SFP_STATE_DECRYPTION_ENCRYPT,
+ SFP_STATE_DECRYPTION_MIC_CHECK
+} SspSfpHandlerState_t;
+
+/**************************************************************************//**
+ \brief TBD
+******************************************************************************/
+typedef struct
+{
+ SspSfpHandlerState_t sfpState;
+ uint8_t nonce[CCM_NONCE_SIZE];
+ uint8_t transformedKey[SECURITY_KEY_SIZE];
+ uint8_t mic[CCM_MIC_MAX_SIZE];
+ uint8_t auxiliaryHeaderLength;
+ union
+ {
+ CcmReq_t ccmReq;
+#ifdef _LINK_SECURITY_
+ SspKeyedHashMacReq_t hashMacReq;
+#endif // _LINK_SECURITY_
+ };
+ BEGIN_PACK
+ struct PACK
+ {
+ volatile uint8_t keyExpander[16];
+ uint8_t text;
+ volatile uint8_t bitsExpander[16];
+ }; // For hash function
+ END_PACK
+} SspSfpHandlerMem_t;
+
+/**************************************************************************//**
+ \brief Security Control field format.
+******************************************************************************/
+BEGIN_PACK
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(4,(
+ uint8_t securityLevel : 3,
+ uint8_t keyIdentifier : 2,
+ uint8_t extendedNonce : 1,
+ uint8_t reserved : 2
+ ))
+} SecurityCtrlField_t;
+END_PACK
+
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+/******************************************************************************
+ Encrypts frame. Encoding is based on incoming param which are extracted from
+ SSP_EncryptFrameReq param.
+ Parameters:
+ none.
+ Return:
+ none.
+******************************************************************************/
+void sspEncryptFrameReqHandler(void);
+
+/******************************************************************************
+ Decrypts frame. Decrypting is based on incoming param which are extracted from
+ SSP_DecryptFrameReq param.
+ Parameters:
+ none.
+ Return:
+ none.
+******************************************************************************/
+void sspDecryptFrameReqHandler(void);
+
+/******************************************************************************
+ Parses auxiliary frame header.
+ Parameters:
+ param - contains pointer to the frame and parameters to be initialized.
+ Return:
+ Auxiliary header length.
+******************************************************************************/
+uint8_t sspParseAuxiliaryHeaderHandler(SSP_ParseAuxiliaryHeader_t *param);
+
+/******************************************************************************
+ Security Frame Processor Handler's task.
+ Parameters:
+ none
+ Return:
+ none.
+******************************************************************************/
+void sspSfpTaskHandler(void);
+
+#endif //_SSPSFPHANDLER_H
+
+// eof sspSfpHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspSkkeHandler.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspSkkeHandler.h
new file mode 100644
index 00000000..c9d881e0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/private/sspSkkeHandler.h
@@ -0,0 +1,96 @@
+/**************************************************************************//**
+ \file sspSkkeHandler.h
+
+ \brief SKKE routine handler header file.
+
+ \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:
+ 29/11/07 ALuzhetsky - Created.
+******************************************************************************/
+#ifndef _SSPSKKEHANDLER_H
+#define _SSPSKKEHANDLER_H
+
+#ifdef _LINK_SECURITY_
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <sspManager.h>
+#include <sspAesHandler.h>
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+typedef enum
+{
+ SKKE_STATE_IDLE,
+ SKKE_STATE_CALCULATE_MACTAG1,
+ SKKE_STATE_CALCULATE_MACTAG2,
+ SKKE_STATE_CALCULATE_FINAL_MACTAG1,
+ SKKE_STATE_CALCULATE_HASH1,
+ SKKE_STATE_CALCULATE_HASH2,
+} SspSkkeState_t;
+/******************************************************************************
+ TBD
+******************************************************************************/
+typedef struct
+{
+ SspSkkeState_t skkeState;
+ uint8_t macKey[SECURITY_KEY_SIZE];
+ BEGIN_PACK
+ struct PACK
+ {
+ volatile uint8_t keyExpander[SECURITY_KEY_SIZE];
+ uint8_t macData[MAX_HASH_TEXT_SIZE];
+ volatile uint8_t bitsExpander[16];
+ };
+ END_PACK
+ union
+ {
+ SspKeyedHashMacReq_t keyedHashMacParam;
+ SspBcbHashReq_t bcbHashReqParam;
+ };
+} SspSkkeHandlerMem_t;
+
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+/*******************************************************************************
+ Calculates parameters of Security-Key Key Esteblishment procedure.
+ Parameters:
+ none.
+ Return:
+ none.
+********************************************************************************/
+void sspCalculateSkkeParamsReqHandler(void);
+
+/***************************************************************************\\**
+ \brief Copies with mirroring "length" bytes from "src" to "dst".
+
+ \param
+ dst - destination memory.
+ src - source memory.
+ length - number of bytes to copy.
+ \return
+ none.
+********************************************************************************/
+INLINE void mirrorMemcpy(uint8_t *dst, uint8_t *src, uint8_t length)
+{
+ while(length)
+ *(dst++) = *(src + --length);
+}
+
+#endif // _LINK_SECURITY_
+
+#endif //_SSPSKKEHANDLER_H
+
+// eof sspSkkeHandler.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspAuthentic.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspAuthentic.h
new file mode 100644
index 00000000..b1134c4a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspAuthentic.h
@@ -0,0 +1,101 @@
+/**************************************************************************//**
+ \file sspAuthentic.h
+
+ \brief Mutual Symmetric-Key Entity Authentication routine header file.
+
+ \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:
+ 29/11/07 ALuzhetsky - Created.
+******************************************************************************/
+#ifndef _SSPAUTHENTIC_H
+#define _SSPAUTHENTIC_H
+
+#ifdef _LINK_SECURITY_
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <sspCommon.h>
+#include <sspChallengeGen.h>
+
+/******************************************************************************
+ Definitions section.
+******************************************************************************/
+#define HASH_SIZE 16
+
+/******************************************************************************
+ Types' definition section.
+******************************************************************************/
+
+/**************************************************************************//**
+ \brief Declaration of CalculateAuthenticParamsConf primitive parameters structure.
+******************************************************************************/
+typedef struct
+{
+ //! Calculated MacTag1 or MacTag2.
+ uint8_t macTag[HASH_SIZE];
+} SSP_CalculateAuthenticParamsConf_t;
+
+/**************************************************************************//**
+ \brief Declaration of CalculateAuthenticParamsConf primitive parameters structure.
+******************************************************************************/
+typedef struct
+{
+ //! Service field - for internal needs.
+ SSP_Service_t service;
+ //! Extended address of the device which initiated authnetication procedure.
+ const uint64_t *initiatorIEEEAddr;
+ //! Extended address of the device which should response.
+ const uint64_t *responderIEEEAddr;
+ //! Initiator or responder device frame counter.
+ uint32_t frameCounter;
+ //! Preset key which should be known by both devices (initiator and responder).
+ const uint8_t *networkKey/*[SECURITY_KEY_SIZE]*/;
+ //! Initiator challenge sequence (just 128-bit random number).
+ uint8_t *qeu;
+ //! Responder challenge sequence (just 128-bit random number).
+ uint8_t *qev;
+ //! Security Service Provider CalculateAuthenticParams confirm callback function's pointer.
+ void (*SSP_CalculateAuthenticParamsConf)(SSP_CalculateAuthenticParamsConf_t *conf);
+ //! Security Service Provider CalculateAuthenticParams confirm parameters' structure.
+ SSP_CalculateAuthenticParamsConf_t confirm;
+} SSP_CalculateAuthenticParamsReq_t;
+
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+/*******************************************************************************
+ Performs calculation of the parameters for Mutual Symmetric-Key Entity
+ Authentication procedure (MatTag1).
+ Parameters:
+ param - procedure parameters (for detailed description look at
+ SSP_CalculateAuthenticParamsReq_t declaration).
+ Return:
+ none.
+********************************************************************************/
+void SSP_CalculateAuthenticMacTag1Req(SSP_CalculateAuthenticParamsReq_t *param);
+
+/*******************************************************************************
+ Performs calculation of the parameters for Mutual Symmetric-Key Entity
+ Authentication procedure (MatTag2).
+ Parameters:
+ param - procedure parameters (for detailed description look at
+ SSP_CalculateAuthenticParamsReq_t declaration).
+ Return:
+ none.
+********************************************************************************/
+void SSP_CalculateAuthenticMacTag2Req(SSP_CalculateAuthenticParamsReq_t *param);
+
+#endif // _LINK_SECURITY_
+
+#endif //_SSPAUTHENTIC_H
+
+// eof sspAuthentic.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspChallengeGen.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspChallengeGen.h
new file mode 100644
index 00000000..ac9677ab
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspChallengeGen.h
@@ -0,0 +1,50 @@
+/**************************************************************************//**
+ \file sspChallengeGen.h
+
+ \brief Challenge genrator header file.
+
+ \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:
+ 07/12/07 ALuzhetsky - Created.
+******************************************************************************/
+#ifndef _SSPCHALLENGEGEN_H
+#define _SSPCHALLENGEGEN_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <sspCommon.h>
+
+/******************************************************************************
+ Definitions section.
+******************************************************************************/
+#define CHALLENGE_SEQUENCE_SIZE 16
+
+/******************************************************************************
+ Types' definition section.
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+/*******************************************************************************
+ Generates challenge.
+ Parameters:
+ challenge - space to store generated challenge.
+ Return:
+ none.
+********************************************************************************/
+void SSP_GenerateChallenge(uint8_t challenge[/*CHALLENGE_SEQUENCE_SIZE*/]);
+
+#endif //_SSPCHALLENGEGEN_H
+
+// eof sspChellenge.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspCommon.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspCommon.h
new file mode 100644
index 00000000..5fd2bea3
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspCommon.h
@@ -0,0 +1,74 @@
+/**************************************************************************//**
+ \file sspCommon.h
+
+ \brief Declarations of common Security Service Provider's fields and types.
+
+ \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:
+ 06/12/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _SSPCOMMON_H
+#define _SSPCOMMON_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Definitions section.
+******************************************************************************/
+#define SECURITY_KEY_SIZE 16U
+#define SECURITY_BLOCK_SIZE 16U
+#define SSP_SECURITY_CONTROL_FIELD_LENGTH 1U
+#define SSP_FRAME_COUNTER_FIELD_LENGTH 4U
+#define SSP_KEY_SEQ_NUMBER_FIELD_LENGTH 1U
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief Possible status values of different SSP primitives.
+******************************************************************************/
+typedef enum
+{
+ SSP_SUCCESS_STATUS,
+ SSP_NOT_PERMITED_STATUS,
+ SSP_MAX_FRM_COUNTER_STATUS,
+ SSP_BAD_CCM_OUTPUT_STATUS,
+} SSP_Status_t;
+
+/**************************************************************************//**
+ \brief Internal service fields which give an opportunity to compose requests' queue.
+******************************************************************************/
+typedef struct
+{
+ void *next;
+ uint8_t requestId;
+} SSP_Service_t;
+
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/*******************************************************************************
+ Checks a security key.
+ Parameters:
+ key - valid pointer to a security key.
+ Return:
+ true - if key is not zero otherwise return false.
+********************************************************************************/
+bool SSP_IsKeyValid(const uint8_t *key);
+
+
+#endif //_SSPCOMMON_H
+
+// eof sspCommon.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspDbg.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspDbg.h
new file mode 100644
index 00000000..86415548
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspDbg.h
@@ -0,0 +1,38 @@
+/********************************************************************************//**
+ \file sspDbg.h
+
+ \brief
+
+ \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
+**********************************************************************************/
+#ifndef _SSPDBGH
+#define _SSPDBGH
+
+#include <dbg.h>
+
+typedef enum
+{
+ SSPSFPHANDLERC_SSPENCRYPTFRAMEREQHANDLER_00 = 0x7800,
+ SSPMANAGER_TASKHANDLER_00 = 0x7801,
+ SSPMANAGER_TASKHANDLER_01 = 0x7802,
+ SSPCCM_SSPAESCONF_00 = 0x7803,
+ SSPSFPHANDLERC_CCMCONFIRM_00 = 0x7804,
+ SSPHASHHANDLERC_BCBHASHCONF_00 = 0x7805,
+ SSPSFPHANDLERC_SSPKEYEDHASHMACCONFIRM_00 = 0x7806,
+ SSPSKKEHANDLERC_HASHCONFIRM_00 = 0x7807,
+ SSPMANAGER_SENDREQTOHANDLER_00 = 0x7808,
+ SSPHASHHANDLERC_SSPBCBHASH_0 = 0x7809,
+ SSPCCM_SSPAESCONFWHILEMICCHECK_00 = 0x780a,
+ SSPCCM_SSPAESCONFWHILEMICCHECK_01 = 0x780b,
+ SSPCCM_SSPAESCONFWHILEMICCHECK_02 = 0x780c,
+ SSPCCMHANDLER_DETECTNEXTSTATE_0 = 0x780d,
+ SSPCCMHANDLER_SSPAESCONF_00 = 0x780e,
+} SspDbgCodeId_t;
+#endif // _SSPDBGH
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspHash.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspHash.h
new file mode 100644
index 00000000..ade0fe31
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspHash.h
@@ -0,0 +1,69 @@
+/**************************************************************************//**
+ \file sspHash.h
+
+ \brief Security Hash Processor header file.
+
+ \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/05/2008 A.Potashov - Created
+******************************************************************************/
+
+#ifndef _SSPHASH_H
+#define _SSPHASH_H
+
+#include <types.h>
+#include <private/sspHashHandler.h>
+
+typedef struct
+{
+ //! Service field - for internal needs.
+ SSP_Service_t service;
+ // Service field - for internal needs.
+ SSP_Service_t sspService;
+ // There is should be an additional memory before and after text (16 bytes in both cases).
+ uint8_t *text/*[SECURITY_KEY_SIZE + textSize + 16]*/;
+ // Pointer to key fir Keyed Hash Function.
+ uint8_t (*key)/*[SECURITY_KEY_SIZE]*/;
+ // Size of the text.
+ uint8_t textSize;
+ // Buffer for generated hash. Shoul be initialized by the user.
+ uint8_t (*hash_i)/*[SECURITY_KEY_SIZE]*/;
+ // Confirm handler pointer for internal use
+ void (*sspKeyedHashMacConf)(void);
+
+ // Confirm handler pointer
+ void (*SSP_KeyedHashMacConf)(void);
+} SSP_KeyedHashMacReq_t;
+
+
+void SSP_KeyedHashMacReq(SSP_KeyedHashMacReq_t *req);
+void sspKeyedHashReqHandler(void);
+#ifndef _USE_CERTICOM_HASH_
+/**************************************************************************\\**
+ \brief This function computes the AES MMO digest of the data parameter of
+ length <tt>sz</tt>, and stores the result in.
+
+ \param[out] digest This is an unsigned char buffer to hold the message digest.
+ The length of the digest must be AES_MMO_HASH_SIZE bytes.
+ \param[in] sz The size in bytes of the message to be hashed.
+ \param[in] data This is an unsigned char buffer of data to be hashed.
+
+ \return MCE_ERR_NULL_OUTPUT_BUF digest is NULL
+ MCE_ERR_NULL_INPUT_BUF data is NULL
+ MCE_SUCCESS indicates successful completion.
+
+******************************************************************************/
+int SSP_BcbHash(unsigned char *digest, unsigned long sz, unsigned char *data);
+//int aesMmoHash(unsigned char *digest, unsigned long sz, unsigned char *data);
+#endif // _USE_CERTICOM_HASH_
+
+#endif //#ifndef _SSPHASH_H
+
+//eof sspHash.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspReset.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspReset.h
new file mode 100644
index 00000000..165dcb71
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspReset.h
@@ -0,0 +1,34 @@
+/**************************************************************************//**
+ \file sspReset.h
+
+ \brief Security Frame Processor reset routine header file.
+
+ \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:
+ 07/12/2007 - ALuzhetsky created.
+******************************************************************************/
+
+#ifndef _SSPRESET_H
+#define _SSPRESET_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+
+
+/******************************************************************************
+ Functions' prototypes section.
+******************************************************************************/
+void SSP_Init(void);
+
+
+#endif //_SSPRESET_H
+
+// eof sspReset.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspSfp.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspSfp.h
new file mode 100644
index 00000000..ac53c27d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspSfp.h
@@ -0,0 +1,203 @@
+/**************************************************************************//**
+ \file sspSfp.h
+
+ \brief Security Frame Processor header file.
+
+ \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:
+ 2006 - VGribanovsky created.
+ 29/11/2007 - ALuzhetsky.
+******************************************************************************/
+
+#ifndef _SSPSFP_H
+#define _SSPSFP_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <macAddr.h>
+#include <sspCommon.h>
+
+
+/******************************************************************************
+ Definitions section.
+******************************************************************************/
+#define SSP_MAX_AUXILIARY_HEADER_LENGTH 14
+
+/**************************************************************************//**
+ \brief Possible key types.
+******************************************************************************/
+enum
+{
+ SSP_DATA_KEY_ID = 0x00,
+ SSP_NETWORK_KEY_ID = 0x01,
+ SSP_KEY_TRANSPORT_KEY_ID = 0x02,
+ SSP_KEY_LOAD_KEY_ID = 0x03
+};
+
+/**************************************************************************//**
+ \brief Possible levels of security.
+******************************************************************************/
+enum
+{
+ SSP_NONE_SECURITY_LEVEL = 0x00,
+ SSP_MIC_32_SECURITY_LEVEL = 0x01,
+ SSP_MIC_64_SECURITY_LEVEL = 0x02,
+ SSP_MIC_128_SECURITY_LEVEL = 0x03,
+ SSP_ENC_SECURITY_LEVEL = 0x04,
+ SSP_ENC_MIC_32_SECURITY_LEVEL = 0x05,
+ SSP_ENC_MIC_64_SECURITY_LEVEL = 0x06,
+ SSP_ENC_MIC_128_SECURITY_LEVEL = 0x07
+};
+
+/******************************************************************************
+ Types' definition section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief Confirm parameters of SSP_EncryptFrame.
+******************************************************************************/
+typedef struct
+{
+ //! Status of frame encoding.
+ SSP_Status_t status;
+} SSP_EncryptFrameConf_t;
+
+typedef struct
+{
+ //! Status of frame encoding.
+ SSP_Status_t status;
+
+ //! Type of the used key.
+ uint8_t keyIdentifier;
+} SSP_DecryptFrameConf_t;
+
+/**************************************************************************//**
+ \brief Declaration of Encrypt Frame primitive's parameters structure.
+******************************************************************************/
+typedef struct
+{
+ //! Service field - for internal needs.
+ SSP_Service_t service;
+ //! The sequence number of active network key in nwkSecurityMaterialSet.
+ uint8_t nwkActiveKeySeqNumber;
+ //! The actual value of the key.
+ const uint8_t *key/*[SECURITY_KEY_SIZE]*/;
+ //! Identifies the type of the key which is used to protect the frame.
+ uint8_t keyIdentifier;
+ //! Outgoing frame counter used only for outgoing frames.
+ uint32_t outFrameCounter;
+ //! The security level for outgoing and incoming NWK and APS frames.
+ uint8_t securityLevel;
+ //! Detects whether the extended address is present in the nonce or not.
+ bool extendedNoncePresent;
+ //! Extended (64-bit) device address responsible for securing of the frame. Should always be presented.
+ const ExtAddr_t *extAddr;
+ //! Layer protocol data unit pointer. There is should be allocated memory for auxiliary header before pdu.
+ uint8_t *pdu/*[headerLength + payloadLength]*/;
+ //! Length of the header.
+ uint8_t headerLength;
+ //! Payload length.
+ uint8_t payloadLength;
+ //! Security Service Provider SSP_EncryptFrame confirm parameters' structure.
+ SSP_EncryptFrameConf_t confirm;
+ //! Encrypt frame confirm callback function.
+ void (*SSP_EncryptFrameConf)(SSP_EncryptFrameConf_t *conf);
+} SSP_EncryptFrameReq_t;
+
+/**************************************************************************//**
+ \brief Declaration of Encrypt Frame primitive's parameters structure.
+******************************************************************************/
+typedef struct
+{
+ //! Service field - for internal needs.
+ SSP_Service_t service;
+ //! The actual value of the key.
+ const uint8_t *key/*[SECURITY_KEY_SIZE]*/;
+ //! The security level for outgoing and incoming NWK and APS frames.
+ uint8_t securityLevel;
+ //! Extended (64-bit) source device address.
+ const ExtAddr_t *extAddr;
+ //! Layer protocol data unit pointer.
+ uint8_t *pdu;
+ //! Length of the header.
+ uint8_t headerLength;
+ //! Payload length.
+ uint8_t payloadLength;
+ //! Enables a separate MIC check without payload decryption
+ // Payload actually will be decrypted, but decryption results
+ // will not overwrite original payload and they will be lost.
+ bool onlyMicCheck;
+ //! Encrypt frame confirm callback function.
+ void (*SSP_DecryptFrameConf)(SSP_DecryptFrameConf_t *conf);
+ //! Security Service Provider SSP_DecryptFrame confirm parameters' structure.
+ SSP_DecryptFrameConf_t confirm;
+} SSP_DecryptFrameReq_t;
+
+/**************************************************************************//**
+ \brief Declaration of Parse Auxiliary Header primitive's parameters structure.
+******************************************************************************/
+typedef struct
+{
+ //! Layer protocol data unit pointer - should be initialized by user.
+ uint8_t *pdu;
+ //! Length of the header.
+ uint8_t headerLength;
+ //! The sequence number of active network key in nwkSecurityMaterialSet.
+ //! This parameter will be initialized during ParseAuxiliaryHeader function executing.
+ uint8_t nwkActiveKeySeqNumber;
+ //! Received frame counter.
+ //! This parameter will be initialized during ParseAuxiliaryHeader function executing.
+ u32Packed_t *receivedFrameCounter;
+ //! Extended (64-bit) source device address.
+ //! This parameter will be initialized during ParseAuxiliaryHeader function executing.
+ u64Packed_t *sourceExtAddr;
+ //! Identifies the type of the key which is used to protect the frame.
+ uint8_t keyIdentifier;
+ //! Extended nonce presented flag
+ bool extendedNoncePresented;
+} SSP_ParseAuxiliaryHeader_t;
+
+
+/******************************************************************************
+ Functions' prototypes section.
+******************************************************************************/
+/**************************************************************************//**
+ Performs frame encrypting based on incoming parameters.
+ Parameters:
+ param - encrypt frame procedure parameters (for detailed description look at
+ SSP_EncryptFrameReq_t declaration).
+ Return:
+ none.
+******************************************************************************/
+void SSP_EncryptFrameReq(SSP_EncryptFrameReq_t *param);
+
+/**************************************************************************//**
+ Performs frame decrypting based on incoming parameters.
+ Parameters:
+ param - decrypt frame procedure parameters (for detailed description look at
+ SSP_DecryptFrameReq_t declaration).
+ Return:
+ none.
+******************************************************************************/
+void SSP_DecryptFrameReq(SSP_DecryptFrameReq_t *param);
+
+/**************************************************************************//**
+ Extracts parameters from secured frame auxiliary header.
+ Parameters:
+ param - parse frame procedure parameters (for detailed description look at
+ SSP_ParseAuxiliaryHeader_t declaration).
+ Return:
+ Auxiliary header length.
+******************************************************************************/
+uint8_t SSP_ParseAuxiliaryHeader(SSP_ParseAuxiliaryHeader_t *param);
+
+#endif //_SSPSFP_H
+// eof sspSfp.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspSkke.h b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspSkke.h
new file mode 100644
index 00000000..788e50e7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/ServiceProvider/include/sspSkke.h
@@ -0,0 +1,92 @@
+/**************************************************************************//**
+ \file sspSkke.h
+
+ \brief Security-Key Key Esteblishment routine header file.
+
+ \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:
+ 29/11/07 ALuzhetsky - Created.
+******************************************************************************/
+#ifndef _SSPSKKE_H
+#define _SSPSKKE_H
+
+#ifdef _LINK_SECURITY_
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <sspCommon.h>
+#include <sspAuthentic.h>
+#include <sspChallengeGen.h>
+
+/******************************************************************************
+ Definitions section.
+******************************************************************************/
+
+/******************************************************************************
+ Types' definition section.
+******************************************************************************/
+
+/**************************************************************************//**
+ \brief Declaration of CalculateSkkeParamsConf primitive parameters structure.
+******************************************************************************/
+typedef struct
+{
+ //! Calculated MacTag1.
+ uint8_t macTag1[HASH_SIZE];
+ //! Calculated MacTag2.
+ uint8_t macTag2[HASH_SIZE];
+ //! Calculated keyData.
+ uint8_t keyData[HASH_SIZE];
+} SSP_CalculateSkkeParamsConf_t;
+
+/**************************************************************************//**
+ \brief Declaration of CalculateSkkeParamsReq primitive parameters structure.
+******************************************************************************/
+typedef struct
+{
+ //! Service field - for internal needs.
+ SSP_Service_t service;
+ //! Extended address of the device which initiated SKKE procedure.
+ const uint64_t *initiatorIEEEAddr;
+ //! Extended address of the device which should response.
+ const uint64_t *responderIEEEAddr;
+ //! Preset key which should be known by both devices (initiator and responder).
+ uint8_t *masterKey/*[SECURITY_KEY_SIZE]*/;
+ //! Initiator challenge sequence (just 128-bit random number).
+ uint8_t qeu[CHALLENGE_SEQUENCE_SIZE];
+ //! Responder challenge sequence (just 128-bit random number).
+ uint8_t qev[CHALLENGE_SEQUENCE_SIZE];
+ //! Security Service Provider CalculateSkkeParams confirm callback function's pointer.
+ void (*SSP_CalculateSkkeParamsConf)(SSP_CalculateSkkeParamsConf_t *conf);
+ //! Security Service Provider CalculateSkkeParams confirm parameters' structure.
+ SSP_CalculateSkkeParamsConf_t confirm;
+} SSP_CalculateSkkeParamsReq_t;
+
+/******************************************************************************
+ Prototypes section.
+******************************************************************************/
+/*******************************************************************************
+ Performs calculation of the parameters for Symmetric key key establishment
+ procedure.
+ Parameters:
+ param - SKKE procedure parameters (for detailed description look at
+ SSP_CalculateSkkeParamsReq_t declaration).
+ Return:
+ none.
+********************************************************************************/
+void SSP_CalculateSkkeParamsReq(SSP_CalculateSkkeParamsReq_t *param);
+
+#endif // _LINK_SECURITY_
+
+#endif //_SSPSKKE_H
+
+// eof sspSkke.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcAuthenticHandler.h b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcAuthenticHandler.h
new file mode 100644
index 00000000..290f0764
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcAuthenticHandler.h
@@ -0,0 +1,67 @@
+/**************************************************************************//**
+ \file tcAuthenticHandler.h
+
+ \brief Trust Centre authentic routine header file.
+
+ \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:
+ 2007.12 - ALuzhetsky created.
+******************************************************************************/
+#ifndef _TCAUTHENTICHANDLERH
+#define _TCAUTHENTICHANDLERH
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <aps.h>
+#include <types.h>
+#include <tcAuthentic.h>
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef struct
+{
+ TC_AuthenticObj_t *authenticObj;
+ uint8_t maxRequests;
+} TcAuthenticHandlerMem_t;
+
+/******************************************************************************
+ Functions prototypes section.
+******************************************************************************/
+
+/******************************************************************************
+ Functions prototypes section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+void tcUpdateDeviceIndToAuthenticHandler(APS_UpdateDeviceInd_t *indParam);
+
+
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+void tcResetAuthenticHandler(void);
+
+#endif //_TCAUTHENTICHANDLERH
+
+// eof tcAuthenticHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcDeviceTableCtrlHandler.h b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcDeviceTableCtrlHandler.h
new file mode 100644
index 00000000..8d67c9eb
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcDeviceTableCtrlHandler.h
@@ -0,0 +1,46 @@
+/**************************************************************************//**
+ \file tcDeviceTableCtrlHandler.h
+
+ \brief Security Trust Centre devices' permission table control header file.
+
+ \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:
+ 2008.03 - ALuzhetsky created.
+******************************************************************************/
+#ifndef _TCDEVICETABLECTRLHANDLERH
+#define _TCDEVICETABLECTRLHANDLERH
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#ifdef _TC_PERMISSION_TABLE_
+/******************************************************************************
+ Functions prototypes section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief Initializes Trust Centre device permission table.
+
+ \param none.
+ \return none.
+******************************************************************************/
+void tcResetDevicePermissionTable(void);
+
+/**************************************************************************//**
+ \brief Finds device in Trust Centre device permission table.
+
+ \param none.
+ \return true if device presents, false - otherwise.
+******************************************************************************/
+bool tcFindDeviceInPermissionTable(ExtAddr_t *extAddr);
+#endif
+#endif // _TCDEVICETABLECTRLHANDLERH
+// eof tcDeviceTableCtrlHandler.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcKeyEstablishHandler.h b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcKeyEstablishHandler.h
new file mode 100644
index 00000000..975e38f4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcKeyEstablishHandler.h
@@ -0,0 +1,82 @@
+/**************************************************************************//**
+ \file tcKeyEstablishHandler.h
+
+ \brief Trust Centre end to end key establishment routine header file.
+
+ \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:
+ 2008.01.17 - ALuzhetsky created.
+******************************************************************************/
+#ifndef _TCKEYESTABLISHHANDLERH
+#define _TCKEYESTABLISHHANDLERH
+
+#ifdef _LINK_SECURITY_
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <aps.h>
+#include <types.h>
+#include <tcKeyEstablish.h>
+
+/******************************************************************************
+ Definitions section.
+******************************************************************************/
+
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef enum
+{
+ TC_KEY_ESTABLISH_OBJ_STATE_IDLE,
+ TC_KEY_ESTABLISH_OBJ_STATE_TRANSPORT_KEY_POSTED,
+ TC_KEY_ESTABLISH_OBJ_STATE_FIRST_TRANSPORT_KEY_EXECUTING,
+ TC_KEY_ESTABLISH_OBJ_STATE_SECOND_TRANSPORT_KEY_EXECUTING,
+} TcKeyEstablishHandlerObjState_t;
+
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef struct
+{
+ TC_KeyEstablishObj_t *keyEstablishObj;
+ uint8_t maxRequests;
+} TcKeyEstablishHandlerMem_t;
+
+/******************************************************************************
+ Functions prototypes section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+void tcKeyEstablishTaskHandler(void);
+
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+void tcResetKeyEstablishHandler(void);
+
+#endif // _LINK_SECURITY_
+
+#endif //_TCKEYESTABLISHHANDLERH
+// eof tcKeyEstablishHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcKeyUpdateHandler.h b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcKeyUpdateHandler.h
new file mode 100644
index 00000000..652dd3ec
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcKeyUpdateHandler.h
@@ -0,0 +1,60 @@
+/**************************************************************************//**
+ \file tcKeyUpdateHandler.h
+
+ \brief Trust Centre key update routine header file.
+
+ \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:
+ 2008.01.11 - ALuzhetsky created.
+******************************************************************************/
+#ifndef _TCKEYUPDATEHANDLERH
+#define _TCKEYUPDATEHANDLERH
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <queue.h>
+#include <appTimer.h>
+#include <aps.h>
+
+typedef struct
+{
+ QueueDescriptor_t reqQueueDescr;
+ APS_KeyHandle_t keyHandle;
+ void *currentReq;
+ union
+ {
+ APS_TransportKeyReq_t transportKeyReq;
+ APS_SwitchKeyReq_t switchKeyReq;
+ HAL_AppTimer_t keyUpdateTimer;
+ };
+} TcKeyUpdateHandlerMem_t;
+
+/******************************************************************************
+ Functions prototypes section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+void tcKeyUpdateTaskHandler(void);
+
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+void tcResetKeyUpdateHandler(void);
+
+#endif //_TCKEYUPDATEHANDLERH
+// eof tcKeyUpdateHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcMem.h b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcMem.h
new file mode 100644
index 00000000..78bc08b9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcMem.h
@@ -0,0 +1,116 @@
+/**************************************************************************//**
+ \file tcMem.h
+
+ \brief Security Trust Centre memory manager header file.
+
+ \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:
+ 2007.12.25 - ALuzhetsky created.
+******************************************************************************/
+#ifndef _TCMEM_H
+#define _TCMEM_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <queue.h>
+#include <tcTaskManager.h>
+#include <tcAuthenticHandler.h>
+#include <tcKeyUpdateHandler.h>
+#include <tcKeyEstablishHandler.h>
+#include <tcRemoveHandler.h>
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef struct
+{
+ TcTaskManagerMem_t taskManagerMem;
+ TcAuthenticHandlerMem_t authenticHandlerMem;
+ TcKeyUpdateHandlerMem_t keyUpdateHandlerMem;
+#ifdef _LINK_SECURITY_
+ TcKeyEstablishHandlerMem_t keyEstablishHandlerMem;
+#endif // _LINK_SECURITY_
+ TcRemoveHandlerMem_t removeHandlerMem;
+} TcMem_t;
+
+/******************************************************************************
+ External variables.
+******************************************************************************/
+extern TcMem_t tcMem;
+
+/******************************************************************************
+ Inline functions prototypes section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+INLINE TcTaskManagerMem_t* tcGetTaskManagerMem(void)
+{
+ return &tcMem.taskManagerMem;
+}
+
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+INLINE TcAuthenticHandlerMem_t* tcGetAuthenticHandlerMem(void)
+{
+ return &tcMem.authenticHandlerMem;
+}
+
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+INLINE TcKeyUpdateHandlerMem_t* tcGetKeyUpdateHandlerMem(void)
+{
+ return &tcMem.keyUpdateHandlerMem;
+}
+
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+#ifdef _LINK_SECURITY_
+INLINE TcKeyEstablishHandlerMem_t* tcGetKeyEstablishHandlerMem(void)
+{
+ return &tcMem.keyEstablishHandlerMem;
+}
+#endif // _LINK_SECURITY_
+
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+INLINE TcRemoveHandlerMem_t* tcGetRemoveHandlerMem(void)
+{
+ return &tcMem.removeHandlerMem;
+}
+
+#endif //_TCMEM_H
+
+// eof tcMem.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcRemoveHandler.h b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcRemoveHandler.h
new file mode 100644
index 00000000..84bcac00
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcRemoveHandler.h
@@ -0,0 +1,77 @@
+/**************************************************************************//**
+ \file tcRemoveHandler.h
+
+ \brief Trust Centre device remove routine header file.
+
+ \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:
+ 2008.01.20 - ALuzhetsky created.
+******************************************************************************/
+#ifndef _TCREMOVEHANDLERH
+#define _TCREMOVEHANDLERH
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <queue.h>
+#include <aps.h>
+#include <types.h>
+#include <tcRemove.h>
+
+
+/******************************************************************************
+ Definition section.
+******************************************************************************/
+/******************************************************************************
+ Types section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef struct
+{
+ QueueDescriptor_t reqQueueDescr;
+ APS_RemoveDeviceReq_t removeDeviceReq;
+ TC_RemoveDeviceReq_t *currentReq;
+} TcRemoveHandlerMem_t;
+
+/******************************************************************************
+ Functions prototypes section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+void tcUpdateDeviceIndToRemoveHandler(APS_UpdateDeviceInd_t *indParam);
+
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+void tcRemoveTaskHandler(void);
+
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+void tcResetRemoveHandler(void);
+
+
+#endif //_TCREMOVEHANDLERH
+
+// eof tcRemoveHandler.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcTaskManager.h b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcTaskManager.h
new file mode 100644
index 00000000..6753472e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/private/tcTaskManager.h
@@ -0,0 +1,81 @@
+/**************************************************************************//**
+ \file tcTaskManager.h
+
+ \brief Security Trust Centre task manager header file.
+
+ \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:
+ 2007.12.25 - ALuzhetsky created.
+******************************************************************************/
+#ifndef _TCTASKMANAGER_H
+#define _TCTASKMANAGER_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef enum
+{
+ //TC_TASK_RESET,
+ TC_TASK_KEY_UPDATE,
+#ifdef _LINK_SECURITY_
+ TC_TASK_KEY_ESTABLISH,
+#endif // _LINK_SECURITY_
+ TC_TASK_REMOVE,
+} tcTaskID_t;
+
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef uint8_t TcTaskBitMask_t;
+
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef struct
+{
+ TcTaskBitMask_t taskBitMask;
+} TcTaskManagerMem_t;
+
+/******************************************************************************
+ Functions prototypes section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+void tcPostTask(tcTaskID_t taskID);
+
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+void tcResetTaskManager(void);
+
+#endif // _TCTASKMANAGER_H
+
+// eof tcTaskManager.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tc.h b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tc.h
new file mode 100644
index 00000000..67768f8b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tc.h
@@ -0,0 +1,37 @@
+/******************************************************************************//**
+ \file tc.h
+
+ \brief Security Trust Centre main header file - includes all others TC public
+ header files.
+
+ \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:
+ 2008.01 - ALuzhetsky created.
+********************************************************************************/
+#ifndef _TCH
+#define _TCH
+
+/******************************************************************************
+ Include section.
+******************************************************************************/
+#include <tcAuthentic.h>
+#include <tcCommon.h>
+#include <tcDbg.h>
+#include <tcDeviceTableCtrl.h>
+#include <tcKeyUpdate.h>
+#include <tcRemove.h>
+#include <tcReset.h>
+#ifdef _LINK_SECURITY_
+ #include <tcKeyEstablish.h>
+#endif // _LINK_SECURITY_
+
+#endif // _TCH
+
+// eof tc.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcAuthentic.h b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcAuthentic.h
new file mode 100644
index 00000000..f5314499
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcAuthentic.h
@@ -0,0 +1,63 @@
+/**************************************************************************//**
+ \file tcAuthentic.h
+
+ \brief Security Trust Centre authentic primitive header file.
+
+ \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:
+ 2007.12 - ALuzhetsky created.
+******************************************************************************/
+#ifndef _TCAUTHENTICH
+#define _TCAUTHENTICH
+
+/******************************************************************************
+ Include section.
+******************************************************************************/
+#include <aps.h>
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+typedef enum _TcAuthObjState_t
+{
+ TC_AUTHENTIC_OBJ_STATE_IDLE,
+ TC_AUTHENTIC_OBJ_STATE_TRANSPORTING_NETWORK_KEY,
+ TC_AUTHENTIC_OBJ_STATE_TRANSPORTING_MASTER_KEY,
+ TC_AUTHENTIC_OBJ_STATE_ESTABLISHING_KEY,
+ TC_AUTHENTIC_OBJ_STATE_REMOVING_DEVICE,
+} TcAuthObjState_t;
+
+/**************************************************************************//**
+ \brief Authentic handler memory object.
+
+ This struct declares memory wichshould be reserved for the Trust Centre
+ Authentication proceure.
+******************************************************************************/
+typedef struct
+{
+ union
+ { //! Memory for APS_TransportKeyReq.
+ APS_TransportKeyReq_t transportKey;
+ //! Memory for APS_RemoveDeviceReq.
+ APS_RemoveDeviceReq_t removeDevice;
+#if defined _LINK_SECURITY_ && defined _HI_SECURITY_
+ //! Memory for APS_EstablishKeyReq.
+ APS_EstablishKeyReq_t establishKey;
+#endif
+ } buffer;
+ //! Memory to store source address of APS_UpdateDeviceInd command.
+ ExtAddr_t updateIndSrcAddr;
+ //! Current state for Trust Centre authentic handler.
+ TcAuthObjState_t state;
+} TC_AuthenticObj_t;
+
+#endif // _TCAUTHENTICH
+
+// eof tcAuthentic.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcCommon.h b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcCommon.h
new file mode 100644
index 00000000..0db8fec8
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcCommon.h
@@ -0,0 +1,31 @@
+/**************************************************************************//**
+ \file tcCommon.h
+
+ \brief Trust Centre common types and definitions header file.
+
+ \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:
+ 2008.12.01 - ALuzhetsky created.
+******************************************************************************/
+#ifndef _TCCOMMONH
+#define _TCCOMMONH
+
+/**************************************************************************//**
+ \brief Trust Centre service field.
+
+ Service field - for internal needs - to store requets in the requets' queue.
+******************************************************************************/
+typedef struct
+{
+ void *next;
+} TC_Service_t;
+
+#endif // _TCCOMMONH
+// eof tcCommon.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcDbg.h b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcDbg.h
new file mode 100644
index 00000000..77d7b907
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcDbg.h
@@ -0,0 +1,49 @@
+/**************************************************************************//**
+ \file tcDbg.h
+
+ \brief Security Trust Centre debug header file.
+
+ \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:
+ 2007.12 - ALuzhetsky created.
+******************************************************************************/
+#ifndef _TCDBGH
+#define _TCDBGH
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <dbg.h>
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief Trust Centre debug codes declaration.
+
+ These codes are used for debuging.
+******************************************************************************/
+typedef enum
+{
+ TCAUTHENTICHANDLERC_APSUPDATEDEVICEINDICATION_01 = 0x7000,
+ TCAUTHENTICHANDLERC_APSUPDATEDEVICEINDICATION_02 = 0x7001,
+ TCAUTHENTICHANDLERC_TCAUTHENTICTASKHANDLER_01 = 0x7002,
+ TCKEYUPDATEHANDLER_TCKEYUPDATETASKHANDLER_00 = 0x7003,
+ TCAUTHENTICHANDLERC_APSREMOVEDEVICECONF_00 = 0x7004,
+ TCKEYUPDATEHANDLERC_ENDUPDATENETWORKKEYOPERATION_00 = 0x7005,
+ TCDEVICETABLECTRLHANDLER_TCSETDEVICEKEY_00 = 0x7006,
+ TCAUTHENTICHANDLERC_APSESTABLISHKEYCONF_00 = 0x7007,
+ TCTASKMANAGER_00 = 0x7008,
+ TCAUTHENTICHANDLERC_APSUPDATEDEVICEINDICATION_03 = 0x7009,
+ TCAUTHENTICHANDLERC_APSTRANSPORTKEYCONF_00 = 0x700A,
+} TcDbgCodeId_t;
+#endif // _TCDBGH
+
+// eof tcDbg.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcDeviceTableCtrl.h b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcDeviceTableCtrl.h
new file mode 100644
index 00000000..ad076bd3
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcDeviceTableCtrl.h
@@ -0,0 +1,109 @@
+/**************************************************************************//**
+ \file tcDeviceTableCtrl.h
+
+ \brief Security Trust Centre devices' control header file.
+
+ \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:
+ 2008.02 - ALuzhetsky created.
+******************************************************************************/
+#ifndef _TCDEVICETABLECTRLH
+#define _TCDEVICETABLECTRLH
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <mac.h>
+#include <aps.h>
+#include <sspCommon.h>
+
+#ifdef _TC_PERMISSION_TABLE_
+/******************************************************************************
+ Functions prototypes section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief Adds new device to Trust Centre device permission table.
+
+ \param extAddr - new device's address.
+ \return true in case if operation is successful - false if there is no free
+ space in Trust Centre device permission table.
+******************************************************************************/
+bool TC_AddDeviceToPermissionTable(ExtAddr_t *extAddr);
+
+
+/**************************************************************************//**
+ \brief Removes device from Trust Centre device permission table.
+
+ \param extAddr - address of the device to remove.
+ \return true in case if operation is successful - false if there is no such
+ device in Trust Centre device permission table.
+******************************************************************************/
+bool TC_RemoveDeviceFromPermissionTable(ExtAddr_t *extAddr);
+#endif // _TC_PERMISSION_TABLE_
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief Possible key types which could be stored for each device.
+
+ Used in TC_SetDeviceKey primitive - to fill device table with particular
+ values.
+******************************************************************************/
+typedef enum
+{
+ //! Master key type.
+ KEY_TYPE_MASTER,
+ //! Link key type.
+ KEY_TYPE_LINK
+} TC_KeyType_t;
+
+/**************************************************************************//**
+ \brief Trust Centre set device key primitive paramemtrs.
+
+ Used in TC_SetDeviceKey primitive - to fill device table with particular
+ values.
+******************************************************************************/
+typedef struct
+{
+ //! Device extended address.
+ ExtAddr_t *deviceAddr;
+ //! Key value - 16 bytes array.
+ uint8_t (*key)[SECURITY_KEY_SIZE];
+ //! Key type.
+ TC_KeyType_t keyType;
+} TC_SetDeviceKey_t;
+
+/******************************************************************************
+ Functions prototypes section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief Sets device parameters in device table - extended address associated
+ with particular key.
+
+ \param params - request parameters' structure pointer.
+ \return true in case if operation is successful - false otherwise.
+******************************************************************************/
+bool TC_SetDeviceKey(TC_SetDeviceKey_t *param);
+
+/**************************************************************************//**
+ \brief Deletes whole information about device with extended address equeal to
+ deviceAddr from APS_KeyPairSet_t table.
+ \param deviceAddr - device address.
+
+ \return true - if device with extended address deviceAddr was found and its
+ entry was deleted, false - otherwise.
+******************************************************************************/
+bool TC_DeleteDeviceEntry(ExtAddr_t *deviceAddr);
+
+#endif // _TCDEVICETABLECTRLH
+
+// eof tcDeviceTableCtrl.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcKeyEstablish.h b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcKeyEstablish.h
new file mode 100644
index 00000000..e986064f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcKeyEstablish.h
@@ -0,0 +1,53 @@
+/**************************************************************************//**
+ \file tcKeyEstablish.h
+
+ \brief Security Trust Centre End to End Key Establish primitive header file.
+
+ \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:
+ 2008.01.17 - ALuzhetsky created.
+******************************************************************************/
+#ifndef _TCKEYESTABLISH
+#define _TCKEYESTABLISH
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef struct
+{
+ union
+ {
+ APS_TransportKeyReq_t transportKeyReq;
+ };
+ //ExtAddr_t updateIndSrcAddr;
+ uint8_t state;
+} TC_KeyEstablishObj_t;
+
+/******************************************************************************
+ Functions prototypes section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+#ifdef _LINK_SECURITY_
+void APS_RequestKeyInd(APS_RequestKeyInd_t *indParams);
+#endif // _LINK_SECURITY_
+
+#endif // _LINK_SECURITY_
+
+// eof tcKeyEstablish.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcKeyUpdate.h b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcKeyUpdate.h
new file mode 100644
index 00000000..ce0d2ca7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcKeyUpdate.h
@@ -0,0 +1,66 @@
+/**************************************************************************//**
+ \file tcKeyUpdate.h
+
+ \brief Security Trust Centre key update primitive header file.
+
+ \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:
+ 2007.12 - ALuzhetsky created.
+******************************************************************************/
+#ifndef _TCKEYUPDATEH
+#define _TCKEYUPDATEH
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <tcCommon.h>
+#include <tcKeyUpdate.h>
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef struct
+{
+ uint8_t status;
+} TC_KeyUpdateConf_t;
+
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef struct
+{
+ TC_Service_t service;
+ void (*TC_KeyUpdateConf)(TC_KeyUpdateConf_t *conf);
+ TC_KeyUpdateConf_t confirm;
+} TC_KeyUpdateReq_t;
+
+/******************************************************************************
+ Functions prototypes section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief Peforms trust centre key updating procedure in the network.
+
+ \param reqParam - parameters of operation (for detailed description refer to
+ TC_KeyUpdateReq_t type declaration).
+ \return none.
+******************************************************************************/
+void TC_KeyUpdateReq(TC_KeyUpdateReq_t *reqParam);
+
+#endif //_TCKEYUPDATEH
+// eof tcKeyUpdate.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcPromiscuousMode.h b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcPromiscuousMode.h
new file mode 100644
index 00000000..843d21af
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcPromiscuousMode.h
@@ -0,0 +1,59 @@
+/******************************************************************************
+ \file tcPromiscuousMode.h
+
+ \brief
+ TC Promiscuous mode module interface.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2010 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 2010-25-01 arazinkov - Created.
+ Last change:
+ $Id: tcPromiscuousMode.h 14525 2010-12-23 10:18:45Z arazinkov $
+******************************************************************************/
+
+#ifndef _TCPROMISCUOUSMODE_H_
+#define _TCPROMISCUOUSMODE_H_
+
+#ifdef _LINK_SECURITY_
+#ifdef _TC_PROMISCUOUS_MODE_
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief Forces TC to enter the Promiscuous mode
+
+ \return None.
+******************************************************************************/
+void TC_EnterPromiscuousMode(void);
+
+/**************************************************************************//**
+ \brief Forces TC to leave the Promiscuous mode
+
+ \return None.
+******************************************************************************/
+void TC_LeavePromiscuousMode(void);
+
+/**************************************************************************//**
+ \brief Checks, if TC is in the Promiscuous mode
+
+ \return True, if TC is in the Promiscuous mode, False - otherwise
+******************************************************************************/
+bool TC_IsPromiscuousMode(void);
+
+#endif /* _LINK_SECURITY_ */
+
+#endif /* _TC_PROMISCUOUS_MODE_ */
+#endif /* _TCPROMISCUOUSMODE_H_ */
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcRemove.h b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcRemove.h
new file mode 100644
index 00000000..c0d37786
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcRemove.h
@@ -0,0 +1,56 @@
+/**************************************************************************//**
+ \file tcRemove.h
+ \brief Security Trust Centre remove primitive header file.
+
+ \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:
+ 2008.01.20 - ALuzhetsky created.
+******************************************************************************/
+#ifndef _TCREMOVEH
+#define _TCREMOVEH
+
+#include <tcCommon.h>
+#include <macAddr.h>
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef struct
+{
+ uint8_t status;
+} TC_RemoveDeviceConf_t;
+
+/**************************************************************************//**
+ \brief TBD.
+
+ TBD
+******************************************************************************/
+typedef struct
+{
+ TC_Service_t service;
+ ExtAddr_t deviceAddr;
+ ExtAddr_t parentAddr;
+ void (*TC_RemoveDeviceConf)(TC_RemoveDeviceConf_t *conf);
+ TC_RemoveDeviceConf_t confirm;
+} TC_RemoveDeviceReq_t;
+
+/******************************************************************************
+ Functions prototypes section.
+******************************************************************************/
+void TC_RemoveDeviceReq(TC_RemoveDeviceReq_t *param);
+
+#endif // _TCREMOVEH
+
+// eof tcRemove.h
diff --git a/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcReset.h b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcReset.h
new file mode 100644
index 00000000..c386d83b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/Security/TrustCentre/include/tcReset.h
@@ -0,0 +1,33 @@
+/**************************************************************************//**
+ \file tcReset.h
+
+ \brief Security Trust Centre reset routine header file.
+
+ \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:
+ 2007.12 - ALuzhetsky created.
+******************************************************************************/
+#ifndef _TCRESETHANDLERH
+#define _TCRESETHANDLERH
+
+/******************************************************************************
+ Functions prototypes section.
+******************************************************************************/
+
+/**************************************************************************//**
+ \brief TBD.
+
+ \param TBD.
+ \return TBD.
+******************************************************************************/
+void TC_Reset(NWK_PowerFailureControl_t powerFailureControl);
+
+#endif // _TCRESETHANDLERH
+// eof tcReset.h
diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/bcEndian.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/bcEndian.h
new file mode 100644
index 00000000..405e2fc3
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/bcEndian.h
@@ -0,0 +1,144 @@
+/***************************************************************************//**
+ \file bcEndian.h
+
+ \brief
+ Interface for endian-neutral code.
+
+ \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:
+ 3/10/09 Max Gekk - Created.
+ ******************************************************************************/
+#ifndef _BC_ENDIAN_H
+#define _BC_ENDIAN_H
+#ifdef _BIG_ENDIAN_
+ #ifdef _DO_NOT_USE_BE
+ #undef _BIG_ENDIAN_
+ #endif //_DO_NOT_USE_BE
+#endif //_BIG_ENDIAN_
+
+/******************************************************************************
+ Definitions section
+ ******************************************************************************/
+/* Swaping bytes */
+#define SWAP16(x) ((uint16_t)(\
+ (((uint16_t)(x) & (uint16_t)0x00ffU) << 8) | \
+ (((uint16_t)(x) & (uint16_t)0xff00U) >> 8)))
+
+#define SWAP32(x) ((uint32_t)(\
+ (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
+ (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
+ (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \
+ (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
+
+#define SWAP64(x) ((uint64_t)(\
+ (((uint64_t)(x) & (uint64_t)0x00000000000000ffULL) << 56) | \
+ (((uint64_t)(x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
+ (((uint64_t)(x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
+ (((uint64_t)(x) & (uint64_t)0x00000000ff000000ULL) << 8) | \
+ (((uint64_t)(x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \
+ (((uint64_t)(x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
+ (((uint64_t)(x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
+ (((uint64_t)(x) & (uint64_t)0xff00000000000000ULL) >> 56)))
+/* Macroses for reversing of bit fields in structure type depending on endian. */
+#if defined _BIG_ENDIAN_
+ #define BIT_FIELDS_1(f1) f1;
+ #define BIT_FIELDS_2(f1, f2) f2; f1;
+ #define BIT_FIELDS_3(f1, f2, f3) f3; f2; f1;
+ #define BIT_FIELDS_4(f1, f2, f3, f4) f4; f3; f2; f1;
+ #define BIT_FIELDS_5(f1, f2, f3, f4, f5) f5; f4; f3; f2; f1;
+ #define BIT_FIELDS_6(f1, f2, f3, f4, f5, f6) f6; f5; f4; f3; f2; f1;
+ #define BIT_FIELDS_7(f1, f2, f3, f4, f5, f6, f7) f7; f6; f5; f4; f3; f2; f1;
+ #define BIT_FIELDS_8(f1, f2, f3, f4, f5, f6, f7, f8) \
+ f8; f7; f6; f5; f4; f3; f2; f1;
+#else /* _LITTLE_ENDIAN_ by default */
+ #define BIT_FIELDS_1(f1) f1;
+ #define BIT_FIELDS_2(f1, f2) f1; f2;
+ #define BIT_FIELDS_3(f1, f2, f3) f1; f2; f3;
+ #define BIT_FIELDS_4(f1, f2, f3, f4) f1; f2; f3; f4;
+ #define BIT_FIELDS_5(f1, f2, f3, f4, f5) f1; f2; f3; f4; f5;
+ #define BIT_FIELDS_6(f1, f2, f3, f4, f5, f6) f1; f2; f3; f4; f5; f6;
+ #define BIT_FIELDS_7(f1, f2, f3, f4, f5, f6, f7) f1; f2; f3; f4; f5; f6; f7;
+ #define BIT_FIELDS_8(f1, f2, f3, f4, f5, f6, f7, f8) \
+ f1; f2; f3; f4; f5; f6; f7; f8;
+#endif /* _BIG_ENDIAN_ */
+
+/* various macroses to swap bytes */
+#ifdef _BIG_ENDIAN_
+// Toggles the endianism of u16 (by swapping its bytes).
+#if (defined __GNUC__)
+ #define swap16(x) ((uint16_t)__builtin_bswap_16((uint16_t)(x)))
+#elif (defined __ICCAVR32__)
+ #define swap16(x) ((uint16_t)__swap_bytes_in_halfwords((uint16_t)(x)))
+#else
+ #error unknown compiler
+#endif
+
+// Toggles the endianism of u32 (by swapping its bytes).
+#if (defined __GNUC__)
+ #define swap32(x) ((uint32_t)__builtin_bswap_32((uint32_t)(x)))
+#elif (defined __ICCAVR32__)
+ #define swap32(x) ((uint32_t)__swap_bytes((uint32_t)(x)))
+#else
+ #error unknown compiler
+#endif
+
+// Toggles the endianism of u64 (by swapping its bytes).
+#define swap64(x) ((uint64_t)(((uint64_t)swap32((uint64_t)(x) >> 32)) | ((uint64_t)swap32((uint64_t)(x)) << 32)))
+
+#define CPU_TO_LE16(x) swap16(x)
+#define CPU_TO_LE32(x) swap32(x)
+#define CPU_TO_LE64(x) swap64(x)
+#define LE16_TO_CPU(x) swap16(x)
+#define LE32_TO_CPU(x) swap32(x)
+#define LE64_TO_CPU(x) swap64(x)
+
+/* Converting of constants from CPU endian to little endian. */
+#define CCPU_TO_LE16(x) SWAP16(x)
+
+#define CCPU_TO_LE32(x) SWAP32(x)
+
+#define CCPU_TO_LE64(x) SWAP64(x)
+
+/* Converting of constants from little endian to CPU endian. */
+#define CLE16_TO_CPU(x) CCPU_TO_LE16(x)
+#define CLE32_TO_CPU(x) CCPU_TO_LE32(x)
+#define CLE64_TO_CPU(x) CCPU_TO_LE64(x)
+
+#else //_BIG_ENDIAN_
+
+#define CPU_TO_LE16(x) (x)
+#define CPU_TO_LE32(x) (x)
+#define CPU_TO_LE64(x) (x)
+#define LE16_TO_CPU(x) (x)
+#define LE32_TO_CPU(x) (x)
+#define LE64_TO_CPU(x) (x)
+#define CLE16_TO_CPU(x) (x)
+#define CLE32_TO_CPU(x) (x)
+#define CLE64_TO_CPU(x) (x)
+
+/* Converting of constants from CPU endian to little endian. */
+#define CCPU_TO_LE16(x) (x)
+#define CCPU_TO_LE32(x) (x)
+#define CCPU_TO_LE64(x) (x)
+
+#endif
+
+/******************************************************************************
+ \brief The macro for declaration of bit fields with little endian order.
+
+ Total size of bit fields must equal 8 bit (or one octet).
+
+ \param amount - amount of bit fields in octet.
+ \param fields - list of bit fields that are separated by ','.
+ ******************************************************************************/
+#define LITTLE_ENDIAN_OCTET(amount, fields) BIT_FIELDS_ ## amount fields
+
+#endif /* _BC_ENDIAN_H */
+/* eof bcEndian.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/bcSysSleep.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/bcSysSleep.h
new file mode 100644
index 00000000..6ea0be2c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/bcSysSleep.h
@@ -0,0 +1,37 @@
+/****************************************************************************//**
+ \file bcSysSleep.h
+
+ \brief
+ Implementation of the system sleep service.
+
+ \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:
+ 8/06/09 A. Khromykh - Created
+*********************************************************************************/
+
+#ifndef _MNSYSSLEEP_H
+#define _MNSYSSLEEP_H
+/*********************************************************************************
+ Includes section.
+**********************************************************************************/
+#include <sleep.h>
+
+/*********************************************************************************
+ Function prototypes section.
+**********************************************************************************/
+/******************************************************************************//**
+\brief Prepares system for sleep.
+
+\param[in]
+ sleepParam - pointer to sleep structure.
+**********************************************************************************/
+void SYS_Sleep(HAL_Sleep_t *sleepParam);
+
+#endif /* _MNSYSSLEEP_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/dbg.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/dbg.h
new file mode 100644
index 00000000..16b277eb
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/dbg.h
@@ -0,0 +1,244 @@
+/*******************************************************************************//**
+ \file dbg.h
+
+ \brief
+ A module should use the SYS_writeLog define and should not use writeLog() directly
+ Module should define own #define on SYS_WriteLog() to have an opportunity
+ to turn on/off logging by setting special define during compilation
+
+ The LOG is turned on by the _SYS_LOG_ON_ define defined in Makefile
+ \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:
+ 29/05/07 D. Ovechkin - Created
+ 17/01/11 M. Gekk - Guards are added
+**********************************************************************************/
+
+#ifndef _DBG_H
+#define _DBG_H
+
+/*********************************************************************************
+ Includes section.
+**********************************************************************************/
+#include <types.h>
+#ifdef _SYS_ASSERT_ON_
+ #include <halAssert.h>
+#endif // _SYS_ASSERT_ON_
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+/* log type of message */
+typedef enum
+{
+ HAL_LOG_MESSAGE = 0x80,
+ MAC_LOG_MESSAGE = 0x81,
+ NWK_LOG_MESSAGE = 0x82,
+ APS_LOG_MESSAGE = 0x83,
+ ZDO_LOG_MESSAGE = 0x84,
+ SSP_TC_LOG_MESSAGE = 0x85,
+ ZCL_LOG_MESSAGE = 0x86,
+ APL_LOG_MESSAGE = 0x87
+} LogMessageLevel_t;
+
+#if defined(_SYS_LOG_ON_) && defined(_HAL_LOG_ON_)
+ #define HAL_WRITE_LOG(A) SYS_WriteLog((uint8_t)HAL_LOG_MESSAGE, (uint8_t)A);
+#else
+ #define HAL_WRITE_LOG(A)
+#endif
+
+#if defined(_SYS_LOG_ON_) && defined(_MAC_LOG_ON_)
+ #define MAC_WRITE_LOG(A) SYS_WriteLog((uint8_t)MAC_LOG_MESSAGE, (uint8_t)A);
+#else
+ #define MAC_WRITE_LOG(A)
+#endif
+
+#if defined(_SYS_LOG_ON_) && defined(_NWK_LOG_ON_)
+ #define NWK_WRITE_LOG(A) SYS_WriteLog((uint8_t)NWK_LOG_MESSAGE, (uint8_t)A);
+#else
+ #define NWK_WRITE_LOG(A)
+#endif
+
+#if defined(_SYS_LOG_ON_) && defined(_APS_LOG_ON_)
+ #define APS_WRITE_LOG(A) SYS_WriteLog((uint8_t)APS_LOG_MESSAGE, (uint8_t)A);
+#else
+ #define APS_WRITE_LOG(A)
+#endif
+
+#if defined(_SYS_LOG_ON_) && defined(_ZDO_LOG_ON_)
+ #define ZDO_WRITE_LOG(A) SYS_WriteLog((uint8_t)ZDO_LOG_MESSAGE, (uint8_t)A);
+#else
+ #define ZDO_WRITE_LOG(A)
+#endif
+
+#if defined(_SYS_LOG_ON_) && defined(_SSP_TC_LOG_ON_)
+ #define SSP_TC_WRITE_LOG(A) SYS_WriteLog((uint8_t)SSP_TC_LOG_MESSAGE, (uint8_t)A);
+#else
+ #define SSP_TC_WRITE_LOG(A)
+#endif
+
+#if defined(_SYS_LOG_ON_) && defined(_ZCL_LOG_ON_)
+ #define ZCL_WRITE_LOG(A) SYS_WriteLog((uint8_t)ZCL_LOG_MESSAGE, (uint8_t)A);
+#else
+ #define ZCL_WRITE_LOG(A)
+#endif
+
+#if defined(_SYS_LOG_ON_) && defined(_APL_LOG_ON_)
+ #define APL_WRITE_LOG(A) SYS_WriteLog((uint8_t)APL_LOG_MESSAGE, (uint8_t)A);
+#else
+ #define APL_WRITE_LOG(A)
+#endif
+
+#define assert_static(e) {enum {_SA_ = 1/(e)};}
+
+/*********************************************************************************
+ Function prototypes section.
+**********************************************************************************/
+/* ________________________________ SYS_LOG __________________________________ */
+#ifdef _SYS_LOG_ON_
+ /******************************************************************************
+ Define(s) section
+ ******************************************************************************/
+ #define SYS_INFINITY_LOOP_MONITORING sysInfinityLoopMonitoring = 0;
+ /* 1 = 10 ms */
+ #define TASK_LENGTH 100
+
+ #if defined(_HAL_LOG_INTERFACE_UART0_)
+ #define INFORMATION_HANDLER HAL_TaskHandler();
+ #elif defined(_HAL_LOG_INTERFACE_UART1_)
+ #define INFORMATION_HANDLER HAL_TaskHandler();
+ #else
+ #define INFORMATION_HANDLER
+ #endif
+
+ /******************************************************************************
+ External variables section
+ ******************************************************************************/
+ extern volatile uint8_t sysInfinityLoopMonitoring;
+
+ /*********************************************************************************
+ Function prototypes section.
+ **********************************************************************************/
+ /*****************************************************************************//**
+ \brief Write log information to defined destination. The destination can be
+ UART, EEPROM, Ethernet... The destination is determined by the define
+ during compilation
+ \param[in]
+ leyerID - identical definition of application layer;
+ \param[in]
+ message - information byte (must be less then 0x80);
+ **********************************************************************************/
+ void SYS_WriteLog(uint8_t leyerID, uint8_t message);
+
+ /*****************************************************************************//**
+ \brief Initialization of logging system.
+ **********************************************************************************/
+ void SYS_InitLog(void);
+
+ #if defined(_HAL_LOG_INTERFACE_UART0_) || defined(_HAL_LOG_INTERFACE_UART1_)
+ /**************************************************************************//**
+ \brief HAL task handler.
+ ******************************************************************************/
+ void HAL_TaskHandler(void);
+ #endif
+
+ /*********************************************************************************
+ Inline static functions section
+ **********************************************************************************/
+ /*****************************************************************************//**
+ \brief Monitoring infinity loop in the soft.
+ **********************************************************************************/
+ INLINE void SYS_InfinityLoopMonitoring(void)
+ {
+ sysInfinityLoopMonitoring++;
+ if (sysInfinityLoopMonitoring > TASK_LENGTH)
+ {
+ INFORMATION_HANDLER
+ }
+ }
+#else
+ INLINE void SYS_InitLog(void){}
+ INLINE void SYS_InfinityLoopMonitoring(void){}
+ INLINE void SYS_WriteLog(uint8_t leyerID, uint8_t message){(void)leyerID; (void)message;}
+ #define SYS_INFINITY_LOOP_MONITORING
+#endif // _SYS_LOG_ON_
+
+
+
+/* ________________________________ SYS_ASSERT _______________________________ */
+#ifdef _SYS_ASSERT_ON_
+ /*********************************************************************************
+ ASSERT is used for debugging wrong conditions
+ Dbg codes are in each layers.
+ *********************************************************************************/
+ /*********************************************************************************
+ Function catches unexpected conditions in the logic.
+ Parameters:
+ condition - TRUE or FALSE. FALSE means problems in the logic.
+ dbgCode - assert's unique code.
+ dbgCode ranges: 0x1000 - 0x1fff - MAC
+ 0x2000 - 0x2fff - HAL
+ 0x3000 - 0x3fff - NWK
+ 0x4000 - 0x4fff - APS
+ 0x5000 - 0x5fff - ZDO
+ 0x6000 - 0x6fff - Configuration Server
+ 0x7000 - 0x7fff - SSP/TC
+ 0x8000 - 0x8fff - System Environment
+ 0x9000 - 0x9fff - BSP
+ 0xf000 - 0xfffe - APL
+ Returns:
+ none.
+ *********************************************************************************/
+ void assert(bool condition, uint16_t dbgCode);
+ // Inline Assert
+ #define ASSERT(condition, dbgCode) halAssert(condition, dbgCode);
+
+#else // !_SYS_ASSERT_ON_
+ #define ASSERT(condition, dbgCode) {if(condition){}}
+#ifndef assert
+ #define assert(condition, dbgCode) {if(condition){}}
+#endif
+#endif // _SYS_ASSERT_ON_
+
+#define assert_static(e) {enum {_SA_ = 1/(e)};}
+
+#if defined _SYS_ASSERT_ON_
+#define TOP_GUARD_VALUE 0x55U
+#define BOTTOM_GUARD_VALUE 0xAAU
+
+#define TOP_GUARD uint8_t topGuard;
+#define BOTTOM_GUARD uint8_t bottomGuard;
+#define INIT_GUARDS(obj) \
+ {\
+ (obj)->topGuard = TOP_GUARD_VALUE;\
+ (obj)->bottomGuard = BOTTOM_GUARD_VALUE;\
+ }
+
+#define CHECK_GUARDS(obj, assertNum) \
+ assert((TOP_GUARD_VALUE == (obj)->topGuard) \
+ && (BOTTOM_GUARD_VALUE == (obj)->bottomGuard), assertNum)
+
+#define GUARDED_STRUCT(obj) \
+ (obj) = \
+ { \
+ .topGuard = TOP_GUARD_VALUE, \
+ .bottomGuard = BOTTOM_GUARD_VALUE \
+ }
+
+#else
+#define TOP_GUARD
+#define BOTTOM_GUARD
+#define INIT_GUARDS(obj) ((void)0)
+#define CHECK_GUARDS(obj, assertNum) ((void)0)
+#define GUARDED_STRUCT(obj) (obj)
+#endif
+
+#endif // _DBG_H
+//end of dbg.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/mnUtils.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/mnUtils.h
new file mode 100644
index 00000000..1be01c42
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/mnUtils.h
@@ -0,0 +1,127 @@
+/**************************************************************************//**
+ \file mnUtils.h
+ \brief Header file describes stack utilities functions.
+
+ \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:
+ 07/10/08 - Created.
+******************************************************************************/
+#ifndef _MNUTILS_H
+#define _MNUTILS_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+#include <string.h>
+#include <stdlib.h>
+
+/******************************************************************************
+ Definitions section.
+******************************************************************************/
+#if defined(AT91SAM7X256) || defined(AT91SAM3S4C)
+ #define SYS_BYTE_MEMCPY SYS_ByteMemcpy
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) \
+ || defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3) || defined(ATMEGA128RFA1)
+ #define SYS_BYTE_MEMCPY memcpy
+#else
+ #define SYS_BYTE_MEMCPY memcpy
+#endif
+
+#if defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) || \
+ defined(ATMEGA128RFA1)
+/* Macroses to accept memory I/O registers for AVR Mega family */
+#define MMIO_BYTE(mem_addr) (*(volatile uint8_t *)(mem_addr))
+#define MMIO_WORD(mem_addr) (*(volatile uint16_t *)(mem_addr))
+#endif /* AVR Mega family */
+
+#define GET_FIELD_PTR(structPtr, typeName, fieldName) \
+ ((uint8_t *)(structPtr) + offsetof(typeName, fieldName))
+
+#define GET_PARENT_BY_FIELD(TYPE, FIELD, FIELD_POINTER) \
+ ((TYPE *)(((uint8_t *)FIELD_POINTER) - offsetof(TYPE, FIELD)))
+#define GET_CONST_PARENT_BY_FIELD(TYPE, FIELD, FIELD_POINTER) \
+ ((const TYPE *)(((const uint8_t *)FIELD_POINTER) - offsetof(TYPE, FIELD)))
+
+#define GET_STRUCT_BY_FIELD_POINTER(struct_type, field_name, field_pointer)\
+ ((struct_type *) (((uint8_t *) field_pointer) - FIELD_OFFSET(struct_type, field_name)))
+#define GET_INDEX_FROM_OFFSET(PTR1, PTR2) (PTR1 - PTR2)
+
+// Size of slice between firstField end lastField of struct (including lastField)
+#define SLICE_SIZE(type, firstField, lastField)\
+ (offsetof(type, lastField) - offsetof(type, firstField) + sizeof(((type *)0)->lastField))
+
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
+
+#undef FIELD_OFFSET
+#define FIELD_OFFSET(struct_type, field_name)\
+ (((uint8_t*) &((struct_type *)(NULL))->field_name) - (uint8_t*)NULL)
+
+#define MIN(x,y) ((x)<(y)?(x):(y))
+#define MAX(x,y) ((x)<(y)?(y):(x))
+
+/******************************************************************************
+ Inline functions' section.
+******************************************************************************/
+/**************************************************************************//**
+ \brief Performs bytes memory copying operation.
+
+ \param dst - points destination memory start address.
+ src - points source memory start address.
+ size - number of bytes to copy.
+ \return pointer to dst.
+******************************************************************************/
+INLINE void *SYS_ByteMemcpy(void *dst, const void *src, uint16_t size)
+{
+ uint8_t *dst_ = (uint8_t *) dst;
+ const uint8_t *src_ = (const uint8_t *) src;
+
+ while(size--)
+ *(dst_++) = *(src_++);
+ return dst;
+}
+
+/**************************************************************************//**
+ \brief Performs swap bytes in array of length
+
+ \param array - pointer to array.
+ length - array length
+ \return no return.
+******************************************************************************/
+void SYS_Swap(uint8_t *array, uint8_t length);
+
+/**************************************************************************//**
+ \brief Random number generator. The range of the generator is 0-0xFFFF.The SID
+ is generated in ZDO from UID by srand()
+
+ \param: none.
+ \returns: a random number.
+******************************************************************************/
+static inline uint16_t SYS_GetRandomNumber(void)
+{
+ uint16_t result = (rand() << 4) & 0xFF00;
+
+ result |= rand() & 0x00FF;
+ return result;
+}
+
+/**************************************************************************//**
+ \brief This function copies size bytes of random data into buffer.
+
+ \param: buffer - This is an unsigned char array of size at least sz to hold
+ the random data.
+ size - The number of bytes of random data to compute and store.
+
+ \return: 0 Indicates successful completion.
+******************************************************************************/
+int SYS_GetRandomSequence(uint8_t *buffer, unsigned long size);
+
+#endif // _MNUTILS_H
+// eof mnUtils.h
diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/queue.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/queue.h
new file mode 100644
index 00000000..0a7f8094
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/queue.h
@@ -0,0 +1,92 @@
+/**********************************************************************//**
+ \file queue.h
+
+ \brief
+
+ \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:
+ 21/05/07 D. Ovechkin - Created
+**************************************************************************/
+#ifndef _QUEUE_H
+#define _QUEUE_H
+
+#include <types.h>
+
+/***************************************************************************
+ Declare a queue and reset to the default state
+ Every queue should be declared with this macros!
+ Any queue element passed as parameter to functions should have as first
+ field pointer for adding to a queue.
+
+ Parameters:
+ queue - the name of object.
+ Returns:
+ None
+****************************************************************************/
+#define DECLARE_QUEUE(queue) QueueDescriptor_t queue = {.head = NULL,}
+
+// Type of queue element
+typedef struct _QueueElement_t
+{
+ struct _QueueElement_t *next;
+} QueueElement_t;
+
+// Queue descriptor
+typedef struct
+{
+ QueueElement_t *head;
+} QueueDescriptor_t;
+
+/***************************************************************************
+ Reset a queue
+ Parameters:
+ queue - pointer to a queue descriptor
+ Returns:
+ None
+****************************************************************************/
+INLINE void resetQueue(QueueDescriptor_t *queue)
+{
+ queue->head = NULL;
+}
+
+/***************************************************************************
+ Get a element from a queue. Element is got from the head
+ Parameters:
+ queue - pointer to a queue descriptor
+ Returns:
+ None
+****************************************************************************/
+INLINE void *getQueueElem(const QueueDescriptor_t *queue)
+{
+ return queue->head;
+}
+
+/***************************************************************************
+ Get next element of queue after current element. The movement is made from
+ head to tail. At the beginning of looking for elements the head element
+ should be obtained.
+ Parameters:
+ currElement - current element
+ Returns:
+ NULL - no next element
+ NOT NULL - next element is got
+****************************************************************************/
+INLINE void* getNextQueueElem(const void *currElem)
+{
+ return currElem? ((const QueueElement_t*) currElem)->next: NULL;
+}
+
+bool isQueueElem(const QueueDescriptor_t *const queue, const void *const element);
+void putQueueElem(QueueDescriptor_t *queue, void *element);
+void *deleteHeadQueueElem(QueueDescriptor_t *queue);
+bool deleteQueueElem(QueueDescriptor_t *queue, void *element);
+
+#endif
+//eof queue.h
diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysDbg.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysDbg.h
new file mode 100644
index 00000000..2e6494f7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysDbg.h
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ \file sysDbg.h
+
+ \brief
+
+ \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:
+ 13.10.2009 ivagulin - Created
+******************************************************************************/
+
+
+#ifndef _SYSDBG_H_
+#define _SYSDBG_H_
+
+#include <dbg.h>
+
+typedef enum
+{
+ SYS_ASSERT_ID_DOUBLE_QUEUE_PUT = 0x8000,
+ SYS_ASSERT_ID_DRT_SIZE_TOO_BIG = 0x8001,
+ SYS_ASSERT_ID_DEVICE_WAS_NOT_ABLE_TO_SLEEP = 0x8002
+} SysAssertId_t;
+
+#endif /* _SYSDBG_H_ */
diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysDuplicateTable.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysDuplicateTable.h
new file mode 100644
index 00000000..4fd5fe89
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysDuplicateTable.h
@@ -0,0 +1,82 @@
+/*****************************************************************************
+ \file sysDuplicateEntry.h
+
+ \brief
+
+ \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:
+ 11/20/2009 I.Vagulin - Created
+******************************************************************************/
+
+
+#ifndef _SYSDUPLICATEENTRY_H_
+#define _SYSDUPLICATEENTRY_H_
+
+#include <types.h>
+
+typedef enum
+{
+ SYS_DUPLICATE_TABLE_ANSWER_FOUND,
+ SYS_DUPLICATE_TABLE_ANSWER_ADDED,
+ SYS_DUPLICATE_TABLE_ANSWER_FULL, // check can return Full only if removeOldest set to false
+} SysDuplicateTableAnswer_t ;
+
+typedef struct _SYS_DuplicateTableEntry_t
+{
+ uint16_t address;
+ uint8_t seqNumber;
+ uint8_t ttl;
+ uint8_t mask;
+} SYS_DuplicateTableEntry_t ;
+
+typedef struct _SYS_DuplicateTable_t
+{
+ bool removeOldest:1;
+ uint8_t size:7;
+ SYS_DuplicateTableEntry_t *entries;
+
+ uint16_t agingPeriod;
+ uint32_t lastStamp;
+ uint8_t maxTTL;
+} SYS_DuplicateTable_t ;
+
+/*****************************************************************************
+ Prepare duplicate table to real work :)
+
+ Parameters: table - pointer to allocated table,
+ entrySize - count of entries in table
+ entries - pointer to array of entries
+ agingPeriod - aging period ms
+ removeOldest - change behaviour on full table
+ Returns: nothing
+*****************************************************************************/
+void SYS_DuplicateTableReset(SYS_DuplicateTable_t *table,
+ SYS_DuplicateTableEntry_t *entries, uint8_t tableSize,
+ uint16_t agingPeriod, uint8_t maxTTL, bool removeOldest);
+
+/*****************************************************************************
+ Search for record in table, add if not found
+ Parameters: table - pointer to allocated table,
+ address, seqNumber - record to search for or to add if not found
+ Returns: true if record is found false otherwise.
+*****************************************************************************/
+SysDuplicateTableAnswer_t SYS_DuplicateTableCheck(SYS_DuplicateTable_t *table,
+ uint16_t address, uint8_t seqNumber);
+
+/*****************************************************************************
+ Search for record in table, remove if found.
+ Parameters: table - pointer to allocated table,
+ address, seqNumber - record to search for and to remove if found
+ Returns: nothing
+*****************************************************************************/
+void SYS_DuplicateTableClear(SYS_DuplicateTable_t *table,
+ uint16_t address, uint8_t seqNumber);
+
+#endif /* _SYSDUPLICATEENTRY_H_ */
diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysStat.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysStat.h
new file mode 100644
index 00000000..79b36051
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysStat.h
@@ -0,0 +1,53 @@
+/**************************************************************************//**
+\file sysStat.h
+
+\brief Collection of internal runtime data for report
+
+\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:
+ 15/04/11 D. Loskutnikov - Created
+*******************************************************************************/
+#ifndef _SYS_STAT_H
+#define _SYS_STAT_H
+
+#ifdef _REPORT_STATS_
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef struct _SYS_StatGenerator_t
+{
+ void *next;
+ uint8_t (*gen)(uint8_t *buf, uint8_t maxSize);
+} SYS_StatGenerator_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Register new generator of stat data
+
+\param[in] gen - generator
+******************************************************************************/
+extern void SYS_RegisterStatGenerator(SYS_StatGenerator_t *gen);
+
+/**************************************************************************//**
+\brief Collect stats from registered generators into the supplied buffer
+
+\param[out] buf - buffer to place stat report
+\param[in] maxSize - size limit of buffer
+\return number of actually placed bytes
+******************************************************************************/
+extern uint8_t SYS_GenerateStatReport(uint8_t *buf, uint8_t maxSize);
+
+#endif // _REPORT_STATS_
+
+#endif // _SYS_STAT_H
+// eof sysStat.h
diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysTimer.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysTimer.h
new file mode 100644
index 00000000..4420725d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysTimer.h
@@ -0,0 +1,79 @@
+/**************************************************************************//**
+ \file sysTimer.h
+
+ \brief Simple interface of HAL application timer.
+
+ \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:
+ 2010-10-18 Max Gekk - Created.
+ Last change:
+ $Id: sysTimer.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _SYS_TIMER_H
+#define _SYS_TIMER_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appTimer.h>
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/* Internal states of system timer. */
+typedef enum _SYS_TimerState_t
+{
+ SYS_TIMER_STOPPED = 0x00,
+ SYS_TIMER_STARTED = 0x01
+} SYS_TimerState_t;
+
+/* Type of the system timer. */
+typedef struct _SYS_Timer_t
+{
+ SYS_TimerState_t state;
+ HAL_AppTimer_t timer;
+} SYS_Timer_t;
+
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/******************************************************************************
+ \brief Initialize the System Timer.
+
+ \param[in] sysTimer - timer pointer will be initialized.
+ \param[in] mode - timer mode: TIMER_ONE_SHOT_MODE or TIMER_REPEAT_MODE.
+ \param[in] interval - timer interval (milliseconds).
+ \param[in] handler - timer handler function pointer.
+
+ \return None.
+ *****************************************************************************/
+void SYS_InitTimer(SYS_Timer_t *const sysTimer, const TimerMode_t mode,
+ const uint32_t interval, void (*handler)(void));
+
+/******************************************************************************
+ \brief Start the HAL Application Timer.
+
+ \param[in] appTimer - timer pointer will be started.
+ \return None.
+ ******************************************************************************/
+void SYS_StartTimer(SYS_Timer_t *const sysTimer);
+
+/******************************************************************************
+ \brief Stop the HAL Application Timer.
+
+ \param[in] appTimer - timer pointer will be stopped.
+
+ \return None.
+ *****************************************************************************/
+void SYS_StopTimer(SYS_Timer_t *const sysTimer);
+
+#endif /* _SYS_TIMER_H */
+/** eof sysTimer.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/taskManager.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/taskManager.h
new file mode 100644
index 00000000..ad974a16
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/taskManager.h
@@ -0,0 +1,118 @@
+/*************************************************************************//**
+ \file taskManager.h
+
+ \brief The header file describes the public stack Task Manager interface,
+ task handlers and tasks IDs of Task Manager
+
+ \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:
+ 15/05/07 E. Ivanov - Created
+*****************************************************************************/
+
+#ifndef _TASKMANAGER_H
+#define _TASKMANAGER_H
+#include <types.h>
+#include <atomic.h>
+
+// \cond internal
+//! The list of task ID
+typedef enum
+{
+ MAC_PHY_HWD_TASK_ID = 1 << 0,
+ HAL_TASK_ID = 1 << 1,
+ MAC_HWI_TASK_ID = 1 << 2,
+ NWK_TASK_ID = 1 << 3,
+ ZDO_TASK_ID = 1 << 4,
+ APS_TASK_ID = 1 << 5,
+ SSP_TASK_ID = 1 << 6,
+ TC_TASK_ID = 1 << 7,
+ BSP_TASK_ID = 1 << 8,
+ ZCL_TASK_ID = 1 << 9,
+ APL_TASK_ID = 1 << 0x0A,
+} SYS_TaskId_t;
+// \endcond
+
+/*! This function is called to process a user application task.
+ The function should be defined in the user application.
+ Its very first call is intended just for setting stack parameters.
+ For starting a network a new task should be posted. */
+extern void APL_TaskHandler(void);
+// \cond internal
+//! This function is called for processing HAL task. Should be defined in HAL
+extern void HAL_TaskHandler(void);
+//! This function is called for processing BSP task. Should be defined in BSP
+extern void BSP_TaskHandler(void);
+//! This function is called for processing MAC_PHY_HWD task. Should be defined in MAC_PHY_HWD
+extern void MAC_PHY_HWD_TaskHandler(void);
+//! This function is called for processing MAC_HWI task. Should be defined in MAC_HWI
+extern void MAC_HWI_TaskHandler(void);
+//! This function is called for processing NWK task. Should be defined in NWK
+extern void NWK_TaskHandler(void);
+//! This function is called for processing ZDO task. Should be defined in ZDO
+extern void ZDO_TaskHandler(void);
+//! This function is called for processing APS task. Should be defined in APS
+extern void APS_TaskHandler(void);
+//! This function is called for processing SSP task. Should be defined in SSP
+extern void SSP_TaskHandler(void);
+//! This function is called for processing Trust Center task. Should be defined in Trust Center
+extern void TC_TaskHandler(void);
+//! This function is called for processing ZCL task. Should be defined in ZCL
+extern void ZCL_TaskHandler(void);
+//! Initializes radio chip
+extern void RF_Init(void);
+
+extern volatile uint16_t SYS_taskFlag;
+// \endcond
+
+/**************************************************************************************//**
+\brief Posts task to the stack Task Manager
+
+\param[in] taskId - ID of the posted task. An application has APL_TASK_ID.
+*********************************************************************************************/
+/*
+IDs of the tasks are listed in the SYS_TaskId enum. Each task has its own priority and is called
+only if there is no any task with higher priority. A handler is called when respective task can be run.
+Each task has its own task handler. Correspondence between tasks and handlers is listed below: \n
+HAL - HAL_TaskHandler() \n
+BSP - BSP_TaskHandler() \n
+MAC_PHY_HWD - MAC_PHY_HWD_TaskHandler() \n
+MAC_HWI - MAC_HWI_TaskHandler() \n
+NWK - NWK_TaskHandler() \n
+ZDO - ZDO_TaskHandler() \n
+APS - APS_TaskHandler() \n
+APL - APL_TaskHandler() \n
+*/
+INLINE void SYS_PostTask(SYS_TaskId_t taskId)
+{
+ ATOMIC_SECTION_ENTER
+ SYS_taskFlag |= taskId;
+ ATOMIC_SECTION_LEAVE
+}
+
+//\cond internal
+/**************************************************************************************//**
+\brief This function is called by the stack or from the main() function to process tasks.
+***************************************************************************************/
+bool SYS_RunTask(void);
+
+/**************************************************************************************//**
+ \brief To force runTask to help making sync calls
+******************************************************************************************/
+void SYS_ForceRunTask(void);
+// \endcond
+
+/**************************************************************************//**
+ \brief Initializes the microconroller and the radio chip
+
+ \param none
+ \return none
+******************************************************************************/
+void SYS_SysInit(void);
+#endif
diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/types.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/types.h
new file mode 100644
index 00000000..16be4404
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/types.h
@@ -0,0 +1,242 @@
+/************************************************************************************************//**
+ \file types.h
+
+ \brief The header file describes global system types and pre-processor words
+ which depends on compiler or platform
+
+ \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
+*****************************************************************************************************/
+
+#ifndef _TYPES_H
+#define _TYPES_H
+
+#include <stdint.h>
+#include <string.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <bcEndian.h>
+
+#if defined(__ICCAVR__) || defined(__ICCARM__) || defined(__ICCAVR32__)
+
+// \cond
+#if defined(AT91SAM7X256) || defined(AT91SAM3S4C)
+ #include <intrinsics.h>
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) \
+ || defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3) || defined(ATMEGA128RFA1)
+ #include <inavr.h>
+ #include <ioavr.h>
+ #include <intrinsics.h>
+ #include <pgmspace.h>
+#elif defined(AT32UC3A0512)
+ #include <intrinsics.h>
+#endif
+// \endcond
+
+/**
+ * Some preprocessor magic to allow for a header file abstraction of
+ * interrupt service routine declarations for the IAR compiler. This
+ * requires the use of the C99 _Pragma() directive (rather than the
+ * old #pragma one that could not be used as a macro replacement), as
+ * well as two different levels of preprocessor concetanations in
+ * order to do both, assign the correct interrupt vector name, as well
+ * as construct a unique function name for the ISR.
+ *
+ * Do *NOT* try to reorder the macros below, or you'll suddenly find
+ * out about all kinds of IAR bugs...
+ */
+#define PRAGMA(x) _Pragma(#x)
+
+// \cond
+#if defined(AT91SAM7X256) || defined(AT91SAM3S4C)
+
+ #define PROGMEM_DECLARE(x) x
+ #define FLASH_VAR
+ #define FLASH_PTR
+ #define memcpy_P memcpy
+ #define hw_platform_address_size_t uint32_t
+ #define BEGIN_PACK PRAGMA(pack(push, 1))
+ #define END_PACK PRAGMA(pack(pop))
+ #define INLINE static inline
+
+#elif defined(AT32UC3A0512)
+
+ #define PROGMEM_DECLARE(x) x
+ #define FLASH_VAR
+ #define FLASH_PTR
+ #define memcpy_P memcpy
+ #define hw_platform_address_size_t uint32_t
+ #define BEGIN_PACK PRAGMA(pack(push, 1))
+ #define END_PACK PRAGMA(pack(pop))
+ #define INLINE static inline
+ #define INTERRUPT __interrupt
+
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) \
+ || defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3) || defined(ATMEGA128RFA1)
+
+ #ifndef __HAS_ELPM__
+ #define _MEMATTR __flash
+ #else /* __HAS_ELPM__ */
+ #define _MEMATTR __farflash
+ #endif /* __HAS_ELPM__ */
+
+ #define PROGMEM_DECLARE(x) _MEMATTR x
+ #define FLASH_VAR _MEMATTR
+ #define FLASH_PTR _MEMATTR
+ #define BEGIN_PACK
+ #define END_PACK
+ #define INLINE PRAGMA(inline=forced) static
+
+ #define ASM asm
+ #define __SLEEP __sleep()
+
+ #if defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3)
+ #define ENABLE_CHANGE_PROTECTION_REGISTER CCP = 0xD8
+ #endif
+
+ #define ISR(vec) PRAGMA(vector=vec) __interrupt void handler_##vec(void)
+ #define sei() (__enable_interrupt())
+ #define cli() (__disable_interrupt())
+ /** Wait until bit \c bit in IO register \c sfr is clear. */
+ #define loop_until_bit_is_clear(sfr, bit) do {;} while (sfr & (1 << bit))
+
+ #define wdt_reset() (__watchdog_reset())
+
+ #define SF_GET_LOW_FUSES() __AddrToZByteToSPMCR_LPM((void __flash *)0x0000, 0x09)
+#endif
+
+#if defined(ATMEGA1284)
+ #define EEMPE 2
+ #define EEPE 1
+ #define PSRASY 1
+#endif
+
+#if defined(AT90USB1287)
+ #define UPE1 2
+ #define USB_GEN_vect USB_General_vect
+ #define USB_COM_vect USB_Endpoint_Pipe_vect
+#endif
+
+// \endcond
+
+#define PACK
+#define MAY_ALIAS
+#define NOP __no_operation()
+#define nop() (__no_operation())
+#define PRINTF_STYLE
+
+#elif defined(__GNUC__)
+
+// Leave this here until new security naming will settle
+#pragma GCC poison _HIGH_SECURITY_ _USE_SKKE_ _AUTHENTICATION_ _ZCL_KE_CLUSTER_
+
+// \cond
+#if defined(AT91SAM7X256) || defined(AT91SAM3S4C)
+#elif defined(X86)
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) \
+ || defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3) || defined(ATMEGA128RFA1)
+ #include <avr/io.h>
+ #include <avr/pgmspace.h>
+ #if !defined(ATXMEGA128A1) && !defined(ATXMEGA256A3) && !defined(ATXMEGA256D3)
+ #include <avr/boot.h>
+ #endif
+ #include <avr/interrupt.h>
+ #include <avr/wdt.h>
+#elif defined(SIMULATOR)
+#endif
+// \endcond
+
+// \cond
+#if defined(AT91SAM7X256) || defined(AT91SAM3S4C)
+
+ #define PROGMEM_DECLARE(x) x
+ #define FLASH_VAR
+ #define FLASH_PTR
+ #define memcpy_P memcpy
+ #define hw_platform_address_size_t uint32_t
+ #define BEGIN_PACK
+ #define END_PACK
+ #define PACK __attribute__ ((packed))
+
+#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) \
+ || defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3) || defined(ATMEGA128RFA1)
+
+ #define SF_GET_LOW_FUSES() boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS)
+ #define PROGMEM_DECLARE(x) x __attribute__((__progmem__))
+ #define FLASH_VAR PROGMEM
+ #define FLASH_PTR
+ #define hw_platform_address_size_t uint16_t
+ #define BEGIN_PACK
+ #define END_PACK
+ #define PACK
+
+ #define ASM asm volatile
+ #define __SLEEP asm volatile ("sleep")
+ #define UINT64_MEMCMP
+
+ #if defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3)
+ #define ENABLE_CHANGE_PROTECTION_REGISTER CCP = 0xD8
+ #endif
+
+#elif defined(X86)
+ #define PROGMEM_DECLARE(x) x
+ #define FLASH_VAR
+ #define FLASH_PTR
+ #define memcpy_P memcpy
+ #define hw_platform_address_size_t uint32_t
+ #define BEGIN_PACK
+ #define END_PACK
+ #define PACK __attribute__ ((packed))
+
+#elif defined(SIMULATOR)
+ #define PROGMEM_DECLARE(x) x
+ #define FLASH_VAR
+ #define FLASH_PTR
+ #define memcpy_P memcpy
+ #define hw_platform_address_size_t uint32_t
+ #define BEGIN_PACK
+ #define END_PACK
+ #define PACK __attribute__ ((packed))
+
+#endif
+// \endcond
+
+#define INLINE static inline __attribute__ ((always_inline))
+#define MAY_ALIAS __attribute__((__may_alias__))
+#define NOP asm volatile ("nop")
+#define PRINTF_STYLE __attribute__ ((format (printf, 1, 2)))
+
+#else
+ #error 'Compiler not supported.'
+#endif
+
+typedef bool result_t;
+typedef uint64_t BcTime_t;
+
+BEGIN_PACK
+typedef struct PACK {uint16_t val;} u16Packed_t;
+typedef struct PACK {uint32_t val;} u32Packed_t;
+typedef struct PACK {uint64_t val;} u64Packed_t;
+typedef struct PACK {int16_t val;} s16Packed_t;
+typedef struct PACK {int32_t val;} s32Packed_t;
+typedef struct PACK {int64_t val;} s64Packed_t;
+END_PACK
+
+#if defined __ICCAVR__ || defined __ICCARM__
+ typedef uint8_t BitField_t;
+#else
+ typedef unsigned int BitField_t;
+#endif
+
+#define BC_SUCCESS false
+#define BC_FAIL true
+
+#endif
+// eof types.h
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/caps.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/caps.h
new file mode 100644
index 00000000..a37b19ff
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/caps.h
@@ -0,0 +1,90 @@
+/************************************************************************//**
+ \file caps.h
+
+ \brief
+ The header file describes the CAPS interface
+
+ The file describes the interface and types of CAPS
+
+ \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 _CAPS_H
+#define _CAPS_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <aps.h>
+#include <appFramework.h>
+#include <macAddr.h>
+//#include <usart.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define CAPS_SERIAL_CHANNEL UART_CHANNEL_1
+#ifdef _ZCL_SECURITY_
+ #define CAPS_DO_NOT_USE_APS_SECURITY false
+#else /* _ZCL_SECURITY_ */
+ #define CAPS_DO_NOT_USE_APS_SECURITY true
+#endif /* _ZCL_SECURITY_ */
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+
+/*****************************************************************************
+ Special CAPS data types definition
+*****************************************************************************/
+typedef enum
+{
+ CAPS_SERIAL_NONE = 0x00,
+ CAPS_SERIAL_UART = 0x01
+} CAPS_Serial_t;
+
+
+/******************************************************************************
+ Constants section
+******************************************************************************/
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+
+/*****************************************************************************
+ CAPS API Prototypes
+*****************************************************************************/
+
+/**************************************************************************//**
+ \brief CAPS Data Request interface.
+
+ APS_DataConf field in APS_DataReq must be an actual confirm handler pointer.
+
+ \param[in] req The APS_DataReq_t primitive pointer.
+ \param[in] serial The serial flag for redirection to the serial interface. CAPS_Serial_t must be used.
+ \param[in] noApsSecurity If true APS security is switched off.
+ \return None.
+*****************************************************************************/
+extern void CAPS_DataReq(APS_DataReq_t *req, uint8_t serial, bool noApsSecurity);
+
+#endif //#ifndef _CAPS_H
+
+
+//eof caps.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/clusters.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/clusters.h
new file mode 100644
index 00000000..42bcd00c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/clusters.h
@@ -0,0 +1,186 @@
+/************************************************************************//**
+ \file clusters.h
+
+ \brief
+ The header file describes the ZCLclusters
+
+ The file describes the ZCL clusters
+
+ \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 _CLUSTERS_H
+#define _CLUSTERS_H
+
+#include <zcl.h>
+#include <bcEndian.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#define DEFINE_ATTRIBUTE(name, props, aid, atype) \
+ .name = {.id = aid, .type = atype, .properties = props}
+
+#define DEFINE_REPORTABLE_ATTRIBUTE(name, props, aid, atype, min, max) \
+ .name = {.id = aid, .type = atype, .properties = ZCL_REPORTABLE_ATTRIBUTE | (props), .minReportInterval = min, .maxReportInterval = max}
+
+#define COMMAND_OPTIONS(cldirection, clwaitingResponse, clackRequest) \
+ {.direction = ZCL_FRAME_CONTROL_DIRECTION_##cldirection, .waitingResponse = clwaitingResponse, \
+ .ackRequest = clackRequest}
+
+#define DEFINE_COMMAND(cname, cid, coptions, cind) \
+ .cname = {.id = cid, .options = coptions, cind}
+
+/***************************************************************************//**
+\brief The type describes possible parts of a ZCL cluster.
+
+A cluster is a related collection of commands and attributes, which together define
+an interface to specific functionality. Typically, the entity that stores the attributes
+of a cluster is referred to as the server of that cluster and an entity that affects or
+manipulates those attributes is referred to as the client of that cluster. However, if
+required, attributes may also be present on the client of a cluster.
+Commands that allow devices to manipulate attributes, e.g. the read attribute or
+write attribute commands, are (typically) sent from a client device and received
+by the server device. Any response to those commands, e.g. the read attribute response
+or the write attribute response commands, are sent from the server device and
+received by the client device.
+*******************************************************************************/
+/*ZCL command ack request field*/
+#define ZCL_COMMAND_NO_ACK 0
+#define ZCL_COMMAND_ACK 1
+
+#define ZCL_SERVER_CLUSTER_TYPE 0 //!< server part of a cluster
+#define ZCL_CLIENT_CLUSTER_TYPE 1 //!< client part of a cluster
+
+/*ZCL Header Direction sub-field value*/
+#define ZCL_FRAME_CONTROL_DIRECTION_CLIENT_TO_SERVER 0x00
+#define ZCL_FRAME_CONTROL_DIRECTION_SERVER_TO_CLIENT 0x01
+
+/*ZCL cluster side possible values*/
+#define ZCL_CLUSTER_SIDE_SERVER ZCL_FRAME_CONTROL_DIRECTION_CLIENT_TO_SERVER
+#define ZCL_CLUSTER_SIDE_CLIENT ZCL_FRAME_CONTROL_DIRECTION_SERVER_TO_CLIENT
+
+/*! A value to disable default response for a cluster's command*/
+#define ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE 0x01
+/*! A value to enable default response for a cluster's command*/
+#define ZCL_FRAME_CONTROL_ENABLE_DEFAULT_RESPONSE 0x00
+
+/* There is other relevant response specified for the command or not */
+#define ZCL_THERE_IS_RELEVANT_RESPONSE 0x01
+#define ZCL_THERE_IS_NO_RELEVANT_RESPONSE 0x00
+
+#define ZCL_NETWORK_KEY_CLUSTER_SECURITY 0
+#define ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY 1
+
+
+/* Bits for declaring properties bitmask of attribute */
+#define ZCL_READWRITE_ATTRIBUTE 0U
+#define ZCL_REPORTABLE_ATTRIBUTE 1U
+#define ZCL_READONLY_ATTRIBUTE 2U
+
+#ifdef _ZCL_SECURITY_
+ #define ZCL_DEFAULT_CLUSTER_SECURITY ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY
+#else
+ #define ZCL_DEFAULT_CLUSTER_SECURITY ZCL_NETWORK_KEY_CLUSTER_SECURITY
+#endif
+
+/*************************************************************************//**
+ \brief Clusters Id definition
+*****************************************************************************/
+enum
+{
+ /* General clusters defined by ZCL Specification */
+ BASIC_CLUSTER_ID = CCPU_TO_LE16(0x0000), //!<Basic cluster Id
+ POWER_CONFIGURATION_CLUSTER_ID = CCPU_TO_LE16(0x0001), //!<Power configuration cluster Id
+ IDENTIFY_CLUSTER_ID = CCPU_TO_LE16(0x0003), //!<Identify cluster Id
+ GROUPS_CLUSTER_ID = CCPU_TO_LE16(0x0004), //!<Groups cluster Id
+ SCENES_CLUSTER_ID = CCPU_TO_LE16(0x0005), //!<Scenes cluster Id
+ ONOFF_CLUSTER_ID = CCPU_TO_LE16(0x0006), //!<OnOff cluster id
+ ONOFF_SWITCH_CONFIGURATION_CLUSTER_ID = CCPU_TO_LE16(0x0007), //!<OnOff Switch Configuration cluster id
+ LEVEL_CONTROL_CLUSTER_ID = CCPU_TO_LE16(0x0008), //!<Level Control cluster id
+ TEMPERATURE_MEASUREMENT_CLUSTER_ID = CCPU_TO_LE16(0x0402), //!<Temperature measurement cluster id
+ HUMIDITY_MEASUREMENT_CLUSTER_ID = CCPU_TO_LE16(0x0405), //!<Humidity measurement cluster id
+ OCCUPANCY_SENSING_CLUSTER_ID = CCPU_TO_LE16(0x0406), //!<Occupancy Sensing cluster id
+ TIME_CLUSTER_ID = CCPU_TO_LE16(0x000a), //!<Time cluster Id
+ OTAU_CLUSTER_ID = CCPU_TO_LE16(0x0019), //!<OTAU cluster Id
+ GENERIC_TUNNEL_CLUSTER_ID = CCPU_TO_LE16(0x0600), //!<Generic tunnel cluster Id
+ BACNET_PROTOCOL_TUNNEL_CLUSTER_ID = CCPU_TO_LE16(0x0601), //!<BACnet protocol tunnel cluster Id
+ THERMOSTAT_CLUSTER_ID = CCPU_TO_LE16(0x0201), //!<Thermostat cluster Id
+ /* Smart Energy Profile specific clusters */
+ PRICE_CLUSTER_ID = CCPU_TO_LE16(0x0700), //!<Price cluster Id
+ DEMAND_RESPONSE_AND_LOAD_CONTROL_CLUSTER_ID = CCPU_TO_LE16(0x0701), //!<Demand Response and Load Control cluster Id
+ SIMPLE_METERING_CLUSTER_ID = CCPU_TO_LE16(0x0702), //!<Simple Metering cluster Id
+ MESSAGE_CLUSTER_ID = CCPU_TO_LE16(0x0703), //!<Message Cluster Id
+ ZCL_KEY_ESTABLISHMENT_CLUSTER_ID = CCPU_TO_LE16(0x0800), //!<ZCL Key Establishment Cluster Id
+ /** Lighting */
+ COLOR_CONTROL_CLUSTER_ID = CCPU_TO_LE16(0x0300), //!<Color Control cluster id
+ /* Light Link Profile clusters */
+ ZLL_COMMISSIONING_CLUSTER_ID = CCPU_TO_LE16(0x1000) //!<ZLL Commissioning Cluster Id
+};
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/*************************************************************************//**
+ \brief ZCL Command options
+
+ For internal use
+*****************************************************************************/
+typedef struct
+{
+ uint8_t direction :1; //!<Direction sub-field (ZCL_FRAME_CONTROL_DIRECTION_CLIENT_TO_SERVER or ZCL_FRAME_CONTROL_DIRECTION_SERVER_TO_CLIENT)
+ uint8_t defaultResponse :1; //!<Should be 0 (#ZCL_FRAME_CONTROL_ENABLE_DEFAULT_RESPONSE) if the ZCL Default Response required and 0 (ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE) if no.
+ uint8_t waitingResponse :1; //!<Should be 1 (#ZCL_THERE_IS_RELEVANT_RESPONSE) if there is other relevant response specified for the command else 0 (#ZCL_THERE_IS_NO_RELEVANT_RESPONSE)
+ uint8_t ackRequest :1; //!<Is APS ACK requested
+ uint8_t reserved :4; //!<Reserved for future use
+} ZclCommandOptions_t;
+
+/*************************************************************************//**
+ \brief ZCL Cluster command descriptor as command Id and options
+
+ For internal use
+*****************************************************************************/
+typedef struct
+{
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*callback)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+} ZclCommand_t;
+
+BEGIN_PACK
+/*************************************************************************//**
+ \brief ZCL Cluster attribute descriptor
+
+ For internal use
+*****************************************************************************/
+typedef struct PACK
+{
+ ZCL_AttributeId_t id; //!<Attribute Id
+ uint8_t type; //!<Attribute data type
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value[1]; //!<Immediate attribute value
+} ZclAttribute_t;
+
+/*************************************************************************//**
+ \brief Extra fields of reportable attribute descriptor
+
+ For internal use
+*****************************************************************************/
+typedef struct PACK
+{
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+} ZclReportableAttributeTail_t;
+END_PACK
+
+#endif // _CLUSTERS_H
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/eccAux.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/eccAux.h
new file mode 100644
index 00000000..97d9f459
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/eccAux.h
@@ -0,0 +1,11 @@
+#ifndef _ECCAUX_H
+#define _ECCAUX_H
+
+#define YIELD_LEVEL 0
+int yield(void);
+
+extern unsigned char msgDigest[];
+
+#endif //#ifndef _ECCAUX_H
+
+//eof eccAux.h \ No newline at end of file
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/genericEcc.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/genericEcc.h
new file mode 100644
index 00000000..3d7b4120
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/genericEcc.h
@@ -0,0 +1,90 @@
+/***************************************************************************//**
+ \file genericEcc.h
+
+ \brief
+ Generic ECC API
+
+ \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:
+ 08.07.10 D. Loskutnikov - Created.
+*******************************************************************************/
+#ifndef _GENERICECC_H
+#define _GENERICECC_H
+
+/*******************************************************************************
+ Defines section
+*******************************************************************************/
+#define SECT163K1_COMPRESSED_PUBLIC_KEY_SIZE (22)
+#define SECT163K1_UNCOMPRESSED_PUBLIC_KEY_SIZE (43)
+#define SECT163K1_PRIVATE_KEY_SIZE (21)
+#define SECT163K1_CERTIFICATE_SIZE (48)
+#define SECT163K1_SHARED_SECRET_SIZE (21)
+#define SECT163K1_POINT_ORDER_SIZE (21)
+#define AES_MMO_HASH_SIZE (16)
+
+#define MCE_SUCCESS 0x00
+#define MCE_ERR_FAIL_VERIFY 0x01
+#define MCE_ERR_NULL_PRIVATE_KEY 0x02
+#define MCE_ERR_NULL_PUBLIC_KEY 0x03
+#define MCE_ERR_NULL_INPUT_BUF 0x04
+#define MCE_ERR_NULL_OUTPUT_BUF 0x05
+#define MCE_ERR_NULL_FUNC_PTR 0x06
+#define MCE_ERR_NULL_EPHEM_PRI_KEY 0x07
+#define MCE_ERR_NULL_EPHEM_PUB_KEY 0x08
+#define MCE_ERR_BAD_INPUT 0x09
+
+/*******************************************************************************
+ Prototypes section
+*******************************************************************************/
+typedef int GetRandomDataFunc(unsigned char *buffer, unsigned long sz);
+typedef int HashFunc(unsigned char *digest, unsigned long sz, unsigned char *data);
+typedef int YieldFunc(void);
+int aesMmoHash(unsigned char *digest, unsigned long sz, unsigned char *data);
+
+int ZSE_ECDSASign(unsigned char *privateKey,
+ unsigned char *msgDigest,
+ GetRandomDataFunc *GetRandomData,
+ unsigned char *r,
+ unsigned char *s,
+ YieldFunc *yield,
+ unsigned long yieldLevel);
+
+int ZSE_ECDSAVerify(unsigned char *publicKey,
+ unsigned char *msgDigest,
+ unsigned char *r,
+ unsigned char *s,
+ YieldFunc *yield,
+ unsigned long yieldLevel);
+
+int ZSE_ECCGenerateKey(unsigned char *privateKey,
+ unsigned char *publicKey,
+ GetRandomDataFunc *GetRandomData,
+ YieldFunc *yield,
+ unsigned long yieldLevel);
+
+int ZSE_ECCKeyBitGenerate(unsigned char *privateKey,
+ unsigned char *ephemeralPrivateKey,
+ unsigned char *ephemeralPublicKey,
+ unsigned char *remoteCertificate,
+ unsigned char *remoteEphemeralPublicKey,
+ unsigned char *caPublicKey,
+ unsigned char *keyBits,
+ HashFunc *Hash,
+ YieldFunc *yield,
+ unsigned long yieldLevel);
+
+int ZSE_ECQVReconstructPublicKey(unsigned char* certificate,
+ unsigned char* caPublicKey,
+ unsigned char* publicKey,
+ HashFunc *Hash,
+ YieldFunc *yield,
+ unsigned long yieldLevel);
+#endif //_GENERICECC_H
+// eof genericEcc.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/private/zclDbg.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/private/zclDbg.h
new file mode 100644
index 00000000..4468efa4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/private/zclDbg.h
@@ -0,0 +1,137 @@
+/************************************************************************//**
+ \file zclDbg.h
+
+ \brief
+ The header file describes ZCL Debug Module
+
+ The file describes the ZCL Debug Module
+
+ \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:
+ 02.12.08 A. Poptashov - Created.
+******************************************************************************/
+
+#ifndef _ZCLDBG_H
+#define _ZCLDBG_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <dbg.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+#if defined _SYS_ASSERT_ON_
+
+#define ZCL_SET_STATE(state, newState) (state) = (newState)
+#define ZCL_CHECK_STATE(state, checkState, nameOfAssert) \
+ assert((checkState) == (state), nameOfAssert)
+
+#else /* _SYS_ASSERT_ON_ */
+
+#define ZCL_SET_STATE(state, newState)
+#define ZCL_CHECK_STATE(state, waitState, nameOfAssert)
+#if defined assert
+#undef assert
+#endif /* assert */
+#define assert(condition, dbgCode) (void)0
+
+#endif /* _SYS_ASSERT_ON_ */
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+/******************************************************************************
+ Constants section
+******************************************************************************/
+typedef enum
+{
+ /***********************************
+ ZCL section. Range 0x8000 - 0x8fff
+ ************************************/
+
+ //ZCL Task Manager Id (0x8000 - 0x80ff)
+ ZCLTASKMANAGER_TASKHANDLER_0 = 0x8000,
+ //ZCL CAPS Id (0x8100 - 0x81ff)
+
+ //ZCL ZCL Id (0x8200 - 0x82ff)
+ ZCLGETCLUSTER_0 = 0x8200,
+ PARSEDATAIND_0 = 0x8201,
+ ZCLREPORTIND_0 = 0x8202,
+ DBG_ZCL_GET_TRUST_CENTER_ADDRESS = 0x8203,
+ ZCL_UNDEFINED_CLUSTER_IN_REQUEST = 0x8204,
+ ZCL_UNEXPECTED_ASDU_LENGTH = 0x8205,
+ UNKNOWN_DAT_TYPE_DESCR = 0x8206,
+ //ZCL Memory Manager (0x8300 - 0x83ff)
+ ZCL_DATAIND_0 = 0x8300,
+ ZCL_THERE_ARE_NO_BUFFERS = 0x8301,
+ //OTAU (0x8400 - 0x84ff)
+ ZCL_OTAU_NULL_POINTER_TO_INIT_STRUCTURE = 0x8400,
+ ZCL_OTAU_DOUBLE_START = 0x8401,
+ ZCL_OTAU_UNEXPECTED_SERVER_DISCOVERY = 0x8402,
+ ZCL_UNKNOWN_CUSTOM_MESSAGE = 0x8403,
+ ZCL_OTAU_UNKNOWN_SERVER_TRANSACTUION_ID = 0x8404,
+ ZCL_UNKNOWN_ISD_MESSAGE = 0x8405,
+ // KE
+ KE_WRONG_STATE_0 = 0x8500,
+ KE_WRONG_STATE_1 = 0x8501,
+ KE_WRONG_STATE_2 = 0x8502,
+ KE_WRONG_STATE_3 = 0x8503,
+ KE_WRONG_STATE_4 = 0x8504,
+ KE_WRONG_STATE_5 = 0x8505,
+
+ ZCL_MEMORY_CORRUPTION_0 = 0x8600,
+ ZCL_MEMORY_CORRUPTION_1 = 0x8601,
+ ZCL_MEMORY_CORRUPTION_2 = 0x8602,
+ ZCL_MEMORY_CORRUPTION_3 = 0x8603
+} ZclDbgCodeId_t;
+
+typedef enum
+{
+ OTAU_STOPPED_STATE,
+ OTAU_STARTED_STATE,
+ OTAU_OFD_INITIALIZATION_STATE,
+ OTAU_BROADCAST_MATCH_DESC_REQ,
+ OTAU_UNICAST_MATCH_DESC_REQ,
+ OTAU_SHORT_ADDR_REQ,
+ OTAU_EXT_ADDR_REQ,
+ OTAU_GET_TRUST_CENTRE_ADDR,
+ OTAU_GET_LINK_KEY,
+ OTAU_QUERY_NEXT_IMAGE_TRANSAC,
+ OTAU_WAITING_FOR_SERVER_DISCOVERY,
+ OTAU_ERASE_IMAGE,
+ OTAU_IMAGE_BLOCK_TRANSAC,
+ OTAU_IMAGE_PAGE_TRANSAC,
+ OTAU_WRITE_DATA_TO_FLASH,
+ OTAU_FLUSH_DATA_TO_FLASH,
+ OTAU_UPGRADE_END_TRANSAC,
+ OTAU_WAITING_FOR_UPGRADE_TIMEOUT,
+ OTAU_WAITING_FOR_UPGRADE_UNLIMITED,
+ OTAU_SWITCH_IMAGE
+} ZclOtauStateMachine_t;
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/******************************************************************************
+ Inline static functions section
+******************************************************************************/
+
+
+#endif //#ifndef _ZCLDBG_H
+
+//eof zclDbg.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 <types.h>
+#include <appFramework.h>
+#include <aps.h>
+
+/******************************************************************************
+ 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; //<! Describes type of attributes IDs
+typedef uint8_t ZCL_CommandId_t;
+typedef uint32_t ZCL_UTCTime_t;
+typedef uint32_t ZCL_Date_t;
+typedef uint16_t ZCL_ReportTime_t; // time for reporting in seconds
+
+/***************************************************************************//**
+\brief Enumerated status values used in the ZCL
+*******************************************************************************/
+typedef enum
+{
+ //! Operation was successful.
+ ZCL_SUCCESS_STATUS = 0x00,
+ //!Operation was not successful
+ ZCL_FAILURE_STATUS = 0x01,
+
+ //0x02 - 0x7d - Reserved
+ ZCL_INVALID_ATTRIBUTE_VALUE_STATUS = 0x02,
+ ZCL_TC_PERMISSION_TABLE_ERROR_STATUS = 0x03,
+ ZCL_APS_LINK_KEY_ERROR_STATUS = 0x04,
+
+ //!The sender of the command does not have authorization to carry out this command.
+ ZCL_NOT_AUTHORIZED_STATUS = 0x7e,
+ //!A reserved field/subfield/bit contains a nonzero value
+ ZCL_RESERVED_FIELD_NOT_ZERO_STATUS = 0x7f,
+ /*!The command appears to contain the wrong fields, as detected either by the
+ presence of one or more invalid field entries or by there being missing fields.
+ Command not carried out. Implementer has discretion as to whether to return
+ this error or ZCL_INVALID_FIELD_STATUS.*/
+ ZCL_MALFORMED_COMMAND_STATUS = 0x80,
+ /*!The specified cluster command is not supported on the device.Command not
+ carried out.*/
+ ZCL_UNSUP_CLUSTER_COMMAND_STATUS = 0x81,
+ /*!The specified general ZCL command is not supported on the device.*/
+ ZCL_UNSUP_GENERAL_COMMAND_STATUS = 0x82,
+ /*!A manufacturer specific unicast, cluster specific command was received
+ with an unknown manufacturer code, or the manufacturer code was recognized but
+ the command is not supported*/
+ ZCL_UNSUP_MANUF_CLUSTER_COMMAND = 0x83,
+ /*!A manufacturer specific unicast, ZCL specific command was received with an
+ unknown manufacturer code, or manufacturer code was recognized but the command
+ is not supported*/
+ ZCL_UNSUP_MANUF_GENERAL_COMMAND_STATUS = 0x84,
+ /*!At least one field of the command contains an incorrect value, according
+ to the specification the device is implemented to.*/
+ ZCL_INVALID_FIELD_STATUS = 0x85,
+ /*!The specified attribute does not exist on the device.*/
+ ZCL_UNSUPPORTED_ATTRIBUTE_STATUS = 0x86,
+ /*!Out of range error, or set to a reserved value. Attribute keeps its old
+ value.*/
+ ZCL_INVALID_VALUE_STATUS = 0x87,
+ /*!Attempt to write a read only attribute.*/
+ ZCL_READ_ONLY_STATUS = 0x88,
+ /*!An operation (e.g. an attempt to create an entry in a table) failed due
+ to an insufficient amount of free space available.*/
+ ZCL_INSUFFICIENT_SPACE_STATUS = 0x89,
+ /*!An attempt to create an entry in a table failed due to a duplicate entry
+ already being present in the table.*/
+ ZCL_DUPLICATE_EXISTS_STATUS = 0x8a,
+ /*!The requested information (e.g. table entry) could not be found.*/
+ ZCL_NOT_FOUND_STATUS = 0x8b,
+ /*!Periodic reports cannot be issued for this attribute.*/
+ ZCL_UNREPORTABLE_ATTRIBUTE_STATUS = 0x8c,
+ /*!The data type given for an attribute is incorrect. Command not carried out.*/
+ ZCL_INVALID_DATA_TYPE_STATUS = 0x8d,
+ /*!The selector for an attribute is incorrect.*/
+ ZCL_INVALID_SELECTOR_STATUS = 0x8e,
+ /*!A request has been made to read an attribute that the requester is not
+ authorized to read. No action taken.*/
+ ZCL_WRITE_ONLY_STATUS = 0x8f,
+ /*!Setting the requested values would put the device in an inconsistent state
+ on startup. No action taken.*/
+ ZCL_INCONSISTENT_STARTUP_STATE_STATUS = 0x90,
+ /*!An attempt has been made to write an attribute that is present but is
+ defined using an out-of-band method and not over the air.*/
+ ZCL_DEFINED_OUT_OF_BAND_STATUS = 0x91,
+ /*!Failed case when a otau client or a otau server decides to abort the upgrade process. */
+ ZCL_ABORT_STATUS = 0x95,
+ /*!Invalid OTA upgrade image (ex. failed signature validation or signer information check or CRC check) */
+ ZCL_INVALID_IMAGE_STATUS = 0x96,
+ /*!Server does not have data block available yet */
+ ZCL_WAIT_FOR_DATA_STATUS = 0x97,
+ /*!No OTA upgrade image available for a particular client */
+ ZCL_NO_IMAGE_AVAILABLE_STATUS = 0x98,
+ /*!The client still requires more OTA upgrade image files in order to successfully upgrade*/
+ ZCL_REQUIRE_MORE_IMAGE_STATUS = 0x99,
+
+ //0x97 - 0xbf - Reserved
+
+ /*!An operation was unsuccessful due to a hardware failure.*/
+ ZCL_HARDWARE_FAILURE_STATUS = 0xc0,
+ /*!An operation was unsuccessful due to a software failure.*/
+ ZCL_SOFTWARE_FAILURE_STATUS = 0xc1,
+ /*!An error occurred during calibration.*/
+ ZCL_CALIBRATION_ERROR_STATUS = 0xc2,
+
+ //0xc3 - 0xff - Reserved
+
+ ZCL_SENDING_ERROR_STATUS = 0xc3,
+ //ZCL_ATTRIBUTE_NOT_FOUND_STATUS,
+ ZCL_BAD_FRAME_STATUS = 0xc4,
+ //ZCL_WRONG_ATTRIBUTE_TYPE_STATUS,
+ ZCL_WRONG_RESPONSE_LENGTH_STATUS = 0xc5,
+ ZCL_END_PAYLOAD_REACHED_STATUS = 0xfd,
+ ZCL_MAX_PAYLOAD_REACHED_STATUS = 0xfe,
+ ZCL_INVALID_PARAMETER_STATUS = 0xff,
+
+} ZCL_Status_t;
+
+/********************************************************************************//**
+\brief ZigBee data types identifiers.
+
+ZigBee devices, such as thermostats, lamps, etc., are defined in terms of the
+attributes they contain, which can be written, read or reported using the
+ZCL commands. The following list defines the data types and formats that
+can be used for these attributes. Note that individual clusters, which may use
+different or new types, show valid values, ranges, and units for the attributes they
+represent.
+Each data type is allocated an 8-bit data type ID. The most significant 5 bits of this
+ID is used to divide the types into 32 type classes, and the least significant 3 bits
+specify a specific data type within this class.
+***********************************************************************************/
+typedef enum
+{
+ //Null
+ ZCL_NO_DATA_TYPE_ID = 0x00,
+
+ //General data
+ ZCL_8BIT_DATA_TYPE_ID = 0x08,
+ ZCL_16BIT_DATA_TYPE_ID = 0x09,
+ ZCL_24BIT_DATA_TYPE_ID = 0x0a,
+ ZCL_32BIT_DATA_TYPE_ID = 0x0b,
+ ZCL_40BIT_DATA_TYPE_ID = 0x0c,
+ ZCL_48BIT_DATA_TYPE_ID = 0x0d,
+ ZCL_56BIT_DATA_TYPE_ID = 0x0e,
+ ZCL_64BIT_DATA_TYPE_ID = 0x0f,
+
+ //Logical
+ ZCL_BOOLEAN_DATA_TYPE_ID = 0x10,
+
+ //Bitmap
+ ZCL_8BIT_BITMAP_DATA_TYPE_ID = 0x18,
+ ZCL_16BIT_BITMAP_DATA_TYPE_ID = 0x19,
+ ZCL_24BIT_BITMAP_DATA_TYPE_ID = 0x1a,
+ ZCL_32BIT_BITMAP_DATA_TYPE_ID = 0x1b,
+ ZCL_40BIT_BITMAP_DATA_TYPE_ID = 0x1c,
+ ZCL_48BIT_BITMAP_DATA_TYPE_ID = 0x1d,
+ ZCL_56BIT_BITMAP_DATA_TYPE_ID = 0x1e,
+ ZCL_64BIT_BITMAP_DATA_TYPE_ID = 0x1f,
+
+ //Unsigned integer
+ ZCL_U8BIT_DATA_TYPE_ID = 0x20,
+ ZCL_U16BIT_DATA_TYPE_ID = 0x21,
+ ZCL_U24BIT_DATA_TYPE_ID = 0x22,
+ ZCL_U32BIT_DATA_TYPE_ID = 0x23,
+ ZCL_U40BIT_DATA_TYPE_ID = 0x24,
+ ZCL_U48BIT_DATA_TYPE_ID = 0x25,
+ ZCL_U56BIT_DATA_TYPE_ID = 0x26,
+ ZCL_U64BIT_DATA_TYPE_ID = 0x27,
+
+ //Signed integer
+ ZCL_S8BIT_DATA_TYPE_ID = 0x28,
+ ZCL_S16BIT_DATA_TYPE_ID = 0x29,
+ ZCL_S24BIT_DATA_TYPE_ID = 0x2a,
+ ZCL_S32BIT_DATA_TYPE_ID = 0x2b,
+ ZCL_S40BIT_DATA_TYPE_ID = 0x2c,
+ ZCL_S48BIT_DATA_TYPE_ID = 0x2d,
+ ZCL_S56BIT_DATA_TYPE_ID = 0x2e,
+ ZCL_S64BIT_DATA_TYPE_ID = 0x2f,
+
+ //Enumeration
+ ZCL_8BIT_ENUM_DATA_TYPE_ID = 0x30,
+ ZCL_16BIT_ENUM_DATA_TYPE_ID = 0x31,
+
+ //Floating point
+ ZCL_FSEMI_PRECISION_DATA_TYPE_ID = 0x38,
+ ZCL_FSINGLE_PRECISION_DATA_TYPE_ID = 0x39,
+ ZCL_FDOUBLE_PRECISION_DATA_TYPE_ID = 0x3a,
+
+ //String
+ ZCL_OCTET_STRING_DATA_TYPE_ID = 0x41,
+ ZCL_CHARACTER_STRING_DATA_TYPE_ID = 0x42,
+ ZCL_LONG_OCTET_STRING_DATA_TYPE_ID = 0x43,
+ ZCL_LONG_CHARACTER_STRING_DATA_TYPE_ID = 0x44,
+
+ //Ordered sequence
+ ZCL_ARRAY_DATA_TYPE_ID = 0x48,
+ ZCL_STRUCTURE_DATA_TYPE_ID = 0x4c,
+
+ //Collection
+ ZCL_SET_DATA_TYPE_ID = 0x50,
+ ZCL_BAG_DATA_TYPE_ID = 0x51,
+
+ //Time
+ ZCL_TIME_OF_DAY_DATA_TYPE_ID = 0xe0,
+ ZCL_DATE_DATA_TYPE_ID = 0xe1,
+ ZCL_UTC_TIME_DATA_TYPE_ID = 0xe2,
+
+ //Identifier
+ ZCL_CLUSTER_ID_DATA_TYPE_ID = 0xe8,
+ ZCL_ATTRIBUTE_ID_DATA_TYPE_ID = 0xe9,
+ ZCL_BACNET_OID_DATA_TYPE_ID = 0xea,
+
+ //Misscellaneous
+ ZCL_IEEE_ADDRESS_DATA_TYPE_ID = 0xf0,
+ ZCL_128BIT_SECURITY_KEY_DATA_TYPE_ID = 0xf1,
+} ZCL_AttributeType_t;
+
+/***************************************************************************//**
+\brief The list of general ZCL commands.
+*******************************************************************************/
+typedef enum
+{
+ /*! Reading particular attributes' values from a remote device*/
+ ZCL_READ_ATTRIBUTES_COMMAND_ID = 0x00,
+ ZCL_READ_ATTRIBUTES_RESPONSE_COMMAND_ID = 0x01,
+
+/*Write attributes*/
+ /*! Modifying values of particular attributes on a remote device*/
+ ZCL_WRITE_ATTRIBUTES_COMMAND_ID = 0x02,
+ ZCL_WRITE_ATTRIBUTES_UNDIVIDED_COMMAND_ID = 0x03,
+ ZCL_WRITE_ATTRIBUTES_RESPONSE_COMMAND_ID = 0x04,
+ ZCL_WRITE_ATTRIBUTES_NO_RESPONSE_COMMAND_ID = 0x05,
+
+/*Configure reporting*/
+ ZCL_CONFIGURE_REPORTING_COMMAND_ID = 0x06,
+ ZCL_CONFIGURE_REPORTING_RESPONSE_COMMAND_ID = 0x07,
+
+/*Read reporting*/
+ ZCL_READ_REPORTING_CONFIGURATION_COMMAND_ID = 0x08,
+ ZCL_READ_REPORTING_CONFIGURATION_RESPONSE_COMMAND_ID = 0x09,
+
+/*Report attributes*/
+ /*! Reporting particular attributes to a remote device; that is,
+ sending current attributes' values*/
+ ZCL_REPORT_ATTRIBUTES_COMMAND_ID = 0x0a,
+
+/*Default response*/
+ ZCL_DEFAULT_RESPONSE_COMMAND_ID = 0x0b,
+
+/*Discover attributes*/
+ /*! Obtaining information (IDs and types) of attributes supported
+ by a particular cluster on a remote device*/
+ ZCL_DISCOVER_ATTRIBUTES_COMMAND_ID = 0x0c,
+ ZCL_DISCOVER_ATTRIBUTES_RESPONSE_COMMAND_ID = 0x0d,
+
+/*Read attributes structured*/
+ ZCL_READ_ATTRIBUTES_STRUCTURED_COMMAND_ID = 0x0e,
+
+/*Write attributes structured*/
+ ZCL_WRITE_ATTRIBUTES_STRUCTURED_COMMAND_ID = 0x0f,
+ ZCL_WRITE_ATTRIBUTES_STRUCTURED_RESPONSE_COMMAND_ID = 0x10
+} ZCL_GeneralCommandId_t;
+
+/***************************************************************************//**
+\brief Type describing possible ZSE Device IDs.
+*******************************************************************************/
+typedef enum
+{
+ /*! The Range Extender is a simple device that acts as a router for other devices. The
+ Range Extender device shall not be a ZigBee end device. A product that
+ implements the Range Extender device shall not implement any other devices
+ defined in this profile. This device shall only be used if the product is not intended
+ to have any other application, or if a private application is implemented that has
+ not been addressed by this profile.*/
+ ZSE_RANGE_EXTENDER_DEVICE_ID = 0x0008,
+ /*! The Energy Service Portal connects the energy supply company communication
+ network to the metering and energy management devices within the home. It
+ routes messages to and from the relevant end points. It may be installed within a
+ meter, thermostat, or In-Premise Display, or may be a standalone device, and it
+ will contain another non-ZigBee communication module (e.g. power-line carrier,
+ RF, GPRS, broadband Internet connection).*/
+ ZSE_ENERGY_SERVICE_PORTAL_DEVICE_ID = 0x0500,
+ /*!The Metering end device is a meter (electricity, gas, water, heat, etc.) that is fitted
+ with a ZigBee device. Depending on what is being metered, the device may be
+ capable of immediate (requested) reads or it will autonomously send readings
+ periodically. A Metering end device may also be capable of communicating
+ certain status indicators (e.g. battery low, tamper detected).*/
+ ZSE_METERING_DEVICE_DEVICE_ID = 0x0501,
+ /*! The In-Premise Display device will relay energy consumption data to the user by
+ way of a graphical or text display. The display may or may not be an interactive
+ device. At a minimum at least one of the following should be displayed: current
+ energy usage, a history over selectable periods, pricing information, or text
+ messages. As an interactive device, it can be used for returning simple messages
+ for interpretation by the recipient.*/
+ ZSE_IN_PREMISE_DISPLAY_DEVICE_ID = 0x0502,
+ /*! The PCT device shall provide the capability to control the premise heating and
+ cooling systems.*/
+ ZSE_PROGRAMMABLE_COMMUNICATING_THERMOSTAT_DEVICE_ID = 0x0503,
+ /*! The Load Control device is capable of receiving Demand Response and Load
+ Control events to manage consumption on a range of devices. Example devices
+ are water heaters, exterior lighting, and pool pumps.*/
+ ZSE_LOAD_CONTROL_DEVICE_DEVICE_ID = 0x0504,
+ /*! Smart Appliance devices on the ZigBee network can participate in energy
+ management activities. Examples of these are when Utilities initiate a demand
+ response or pricing event, or the appliance actively informs customers via inhome
+ displays of when or how energy is being used. In the latter case, scenarios
+ include: Washer switching to cold water during periods of higher energy costs;
+ Washer/Dryer/Oven/Hot Water Heater reporting cycle status;
+ Over temperature conditions in Freezers and Refrigerators.*/
+ ZSE_SMART_APPLIANCE_DEVICE_ID = 0x0505,
+ /*! The Prepayment Terminal device will allow utility customers or other users (e.g.
+ sub-metered tenants) to pay for consumption in discrete increments rather than
+ establishing a traditional billing agreement. The Prepayment Terminal device will
+ accept payment (e.g. credit card, code entry), display remaining balances, and
+ alert the user of a balance approaching zero, and may perform some or all of the
+ other functions described in In-Premise Display.*/
+ ZSE_PREPAYMENT_TERMINAL_DEVICE_ID = 0x0506,
+} ZSE_DeviceId_t;
+
+/***************************************************************************//**
+\brief Type describing possible HA Device Ids.
+*******************************************************************************/
+typedef enum
+{
+ /*! Home-Automation-Profile_r25 7.4.1 On/Off Light*/
+ HA_ON_OFF_LIGHT_DEVICE_ID = 0x0100,
+ /*! Home-Automation-Profile_r25 7.4.4 On/Off Light Switch*/
+ HA_ON_OFF_LIGHT_SWITCH_DEVICE_ID = 0x0103,
+ /*! Home-Automation-Profile_r25 7.4.5 Dimmer Switch*/
+ HA_DIMMER_SWITCH_DEVICE_ID = 0x0104,
+ /*! Home-Automation-Profile_r25 7.4.8 Occupancy Sensor*/
+ HA_OCCUPANCY_SENSOR_DEVICE_ID = 0x0107,
+ /*! Home-Automation-Profile_r25 7.3.7 Remote Control*/
+ HA_REMOTE_CONTROL_DEVICE_ID = 0x0006,
+ /*! Home-Automation-Profile_r25 7.4.2 Dimmable Light*/
+ HA_DIMMABLE_LIGHT_DEVICE_ID = 0x0101,
+ /*! Home-Automation-Profile_r25 7.6.2 Thermostat*/
+ HA_THERMOSTAT_DEVICE_ID = 0x0301,
+} HA_DeviceId_t;
+
+/***************************************************************************//**
+\brief Type describing possible ZLL Device Ids.
+*******************************************************************************/
+typedef enum
+{
+ /*! On/Off Light */
+ ZLL_ON_OFF_LIGHT_DEVICE_ID = 0x0000,
+ /*! On/off plug-in unit */
+ ZLL_ON_OFF_PLUGIN_UNIT_DEVICE_ID = 0x0010,
+ /*! Dimmable light */
+ ZLL_DIMMABLE_LIGHT_DEVICE_ID = 0x0100,
+ /*! Dimmable plug-in unit */
+ ZLL_DIMMABLE_PLUGIN_UNIT_DEVICE_ID = 0x0110,
+ /*! Color light */
+ ZLL_COLOR_LIGHT_DEVICE_ID = 0x0200,
+ /*! Color remote */
+ ZLL_COLOR_REMOTE_DEVICE_ID = 0x0800,
+ /*! Color scene remote */
+ ZLL_COLOR_SCENE_REMOTE_DEVICE_ID = 0x0810,
+ /*! Non-color remote */
+ ZLL_NON_COLOR_REMOTE_DEVICE_ID = 0x0820,
+ /*! Non-color scene remote */
+ ZLL_NON_COLOR_SCENE_REMOTE_DEVICE_ID = 0x0830,
+ /*! Control bridge */
+ ZLL_CONTROL_BRIDGE_DEVICE_ID = 0x0840,
+ /*! On/off sensor */
+ ZLL_ON_OFF_SENSOR_DEVICE_ID = 0x0850,
+} ZLL_DeviceId_t;
+
+/*************************************************************************//**
+ \brief ZCL event Ids
+*****************************************************************************/
+typedef enum
+{
+ ZCL_ATTRIBUTE_READ_EVENT_ID, //!< attribute read event
+ ZCL_ATTRIBUTE_WRITE_EVENT_ID, //!< attribute written event
+} ZCL_EventId_t;
+
+/*************************************************************************//**
+ \brief Reserved type to organize the queue of ZCL requests
+*****************************************************************************/
+typedef struct
+{
+ void *next;
+ uint8_t requestType;
+} ZCL_Service_t;
+
+/********************************************************************************//**
+\brief Type describing address fields of some attributes in ZCL
+***********************************************************************************/
+typedef struct
+{
+ APS_AddrMode_t addrMode; //!< address mode indicates which address shall be used
+ APS_Address_t addr; //!< address can be short, extended or group
+ ProfileId_t profileId; //!< profile identifier
+ Endpoint_t endpointId; //!< endpoint identifier
+ ClusterId_t clusterId; //!< cluster identifier
+ uint8_t clusterSide; //!< cluster side: server or client
+ uint16_t manufacturerSpecCode; //!< manufacturer specific code
+} ZCL_Addressing_t;
+
+/***************************************************************************//**
+\brief Type describing ZCL Cluster options.
+*******************************************************************************/
+typedef struct
+{
+ uint8_t type : 1;
+ uint8_t security : 1;
+ uint8_t reserved : 6;
+} ZCL_ClusterOptions_t;
+
+/***************************************************************************//**
+\brief Type describing ZCL's events on cluster's attribute.
+*******************************************************************************/
+typedef enum
+{
+ ZCL_READ_ATTRIBUTE_EVENT,
+ ZCL_WRITE_ATTRIBUTE_EVENT
+} ZCL_AttributeEvent_t;
+
+/***************************************************************************//**
+\brief Type describing ZCL Cluster.
+*******************************************************************************/
+typedef struct
+{
+ ClusterId_t id; //!< Cluster Id
+ ZCL_ClusterOptions_t options;
+ uint8_t attributesAmount; //!< Number of cluster attributes
+ uint8_t *attributes; //!< Cluster attribute descriptors
+ uint8_t commandsAmount; //!< Number of cluster-specific commands
+ uint8_t *commands; //!< Cluster-specific command descriptors
+ uint8_t isReporting; //!< Service field - if any automatic attribute reports are in progress
+ void (*ZCL_ReportInd)(ZCL_Addressing_t *addressing, uint8_t reportLength, uint8_t *reportPayload); //!< Callback for reporting events
+ void (*ZCL_AttributeEventInd)(ZCL_Addressing_t *addressing, ZCL_AttributeId_t attributeId, ZCL_AttributeEvent_t event); //!< Callback indicates action on cluster's attribute
+} ZCL_Cluster_t;
+
+/********************************************************************************//**
+\brief Type describing information which is necessary for put/get element to/from payload
+***********************************************************************************/
+typedef struct
+{
+ uint8_t id; //!< element id. Can be either ::ZCL_GeneralCommandId_t value or special cluster command id
+ uint8_t payloadLength; //!< payload length after adding a new element
+ uint8_t *payload; //!< payload pointer where an element is added.
+ void *content; //!< pointer to content (memory) which shall be added/filled to/from payload
+} ZCL_NextElement_t;
+
+/********************************************************************************//**
+\brief Type describing ZCL response
+***********************************************************************************/
+typedef struct
+{
+ ZCL_Status_t status; //!< status of command
+ uint8_t responseLength; //!< length of response payload
+ uint8_t *responsePayload; //!< pointer to response payload. Response payload can be parsed by ZCL_GetNextElement() function
+} ZCL_Response_t;
+
+typedef struct
+{
+ // Service structure
+ ZCL_Service_t service;
+ ZCL_Response_t response; //!< Response structure
+ void (*ZCL_Response)(ZCL_Response_t *resp); //!< callback for response
+ void (*ZCL_DefaultResponse)(ZCL_Response_t *resp); //!< callback for default response
+ ZCL_Addressing_t dstAddressing; //!< addressing of destination node
+ Endpoint_t endpointId; //!< endpoint id who is request initiator
+ uint8_t id; //!< command id
+ uint8_t requestLength; //!< request payload length
+ uint8_t defaultResponse; //!< default response bit state
+ uint8_t *requestPayload; //!< request payload. It can be filled by ZCL_PutNextElement() function.
+} ZCL_Request_t;
+
+BEGIN_PACK
+
+/********************************************************************************//**
+\brief Reporting record of an cluster attribute.
+***********************************************************************************/
+typedef struct PACK
+{
+ /*! The direction field specifies whether values of the attribute are be reported (0x00),
+ * or whether reports of the attribute are to be received (0x01).*/
+ uint8_t direction;
+ /*! If the direction field is 0x00, this field contains the identifier of the attribute
+ * that is to be reported. If instead the direction field is 0x01,
+ * the device shall expect reports of values of this attribute.*/
+ ZCL_AttributeId_t attributeId;
+ union PACK
+ {
+ struct PACK
+ {
+ /*! The Attribute data type field contains the data type of the attribute
+ * that is to be reported.*/
+ uint8_t attributeType;
+ /*! The minimum reporting interval field is 16-bits in length and shall contain
+ * the minimum interval, in seconds, between issuing reports of the specified attribute.*/
+ ZCL_ReportTime_t minReportInterval;
+ /*! The maximum reporting interval field is 16-bits in length and
+ * shall contain the maximum interval, in seconds, between issuing reports
+ * of the specified attribute.*/
+ ZCL_ReportTime_t maxReportInterval;
+ /*! The reportable change field shall contain the minimum change to the attribute
+ * that will result in a report being issued. This field is of variable length.
+ * For attributes with 'analog' data type the field has the same data type
+ * as the attribute.*/
+ uint8_t reportableChange[1];
+ };
+ /*! The timeout period field is 16-bits in length and shall contain the maximum
+ * expected time, in seconds, between received reports for the attribute specified
+ * in the attribute identifier field. If more time than this elapses between reports,
+ * this may be an indication that there is a problem with reporting.
+ * If this value is set to 0x0000, reports of the attribute are not subject to timeout.*/
+ ZCL_ReportTime_t timeoutPeriod;
+ };
+} ZCL_ReportRecord_t;
+
+/********************************************************************************//**
+\brief Type describing payload element of read request command.
+
+This type can be used to add one attribute entry to the read request payload.
+***********************************************************************************/
+typedef struct PACK
+{
+ ZCL_AttributeId_t id; //!< requested attribute id
+} ZCL_ReadAttributeReq_t;
+
+/********************************************************************************//**
+\brief Type describing payload element of response to read request command.
+
+This type can be used to get one attribute entry from the read response payload.
+***********************************************************************************/
+typedef struct PACK
+{
+ ZCL_AttributeId_t id; //!< requested attribute id
+ uint8_t status; //!< status of reading attribute operation
+ uint8_t type; //!< requested attribute type
+ uint8_t value[1]; //!< requested attribute value
+} ZCL_ReadAttributeResp_t;
+
+/********************************************************************************//**
+\brief Type describing payload element of write request command.
+
+This type can be used to add one attribute entry to the write request payload.
+***********************************************************************************/
+typedef struct PACK
+{
+ ZCL_AttributeId_t id; //!< requested attribute id
+ uint8_t type; //!< requested attribute type
+ uint8_t value[1]; //!< requested attribute value
+} ZCL_WriteAttributeReq_t;
+
+/********************************************************************************//**
+\brief Type describing payload element of response to write request command.
+
+This type can be used to get next writing status from the write response payload.
+***********************************************************************************/
+typedef struct PACK
+{
+ uint8_t status; //!< status of writing attribute operation
+ ZCL_AttributeId_t id; //!< requested attribute id
+} ZCL_WriteAttributeResp_t;
+
+/********************************************************************************//**
+\brief Type describing payload element of configure report request command.
+
+This type can be used to add one reporting record to the "configure report" request payload.
+***********************************************************************************/
+typedef struct PACK
+{
+ ZCL_ReportRecord_t record; //!< Reporting record
+} ZCL_ConfigureReportReq_t;
+
+typedef struct PACK
+{
+ /*! TBD */
+ uint8_t direction;
+ /*! TBD */
+ uint16_t attributeId;
+ union PACK
+ {
+ struct PACK
+ {
+ /*! TBD */
+ uint8_t attributeType;
+ /*! TBD */
+ uint16_t minReportingInterval;
+ /*! TBD */
+ uint16_t maxReportingInterval;
+ /*! TBD */
+ uint8_t reportableChange[1];
+ };
+ /*! TBD */
+ uint16_t timeoutPeriod;
+ };
+} ZCL_ConfigureReportingReq_t;
+
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint8_t direction;
+ uint16_t attributeId;
+} ZCL_ConfigureReportingResp_t;
+
+/********************************************************************************//**
+\brief Type describing payload element of response to configure report request command.
+
+This type can be used to get next status entry from the "configure report" response payload.
+***********************************************************************************/
+typedef struct PACK
+{
+ uint8_t status; //!< status of the configure reporting operation
+ uint8_t direction; //!< The direction field specifies whether values of the attribute are be reported (0x00), or whether reports of the attribute are to be received (0x01).
+ ZCL_AttributeId_t id; //!< requested attribute identifier
+} ZCL_ConfigureReportResp_t;
+
+/********************************************************************************//**
+\brief Type describing payload element of ZCL Read Reporting Configuration command.
+***********************************************************************************/
+typedef struct PACK
+{
+ uint8_t direction; //!< The direction field specifies whether values of the attribute are be reported (0x00), or whether reports of the attribute are to be received (0x01).
+ uint16_t attributeId; //!< requested attribute identifier
+} ZCL_ReadReportingConfigurationReq_t;
+
+/********************************************************************************//**
+\brief Type describing payload element of ZCL Read Reporting Configuration Response command.
+***********************************************************************************/
+typedef struct PACK
+{
+ /*! If the attribute is not implemented on the sender or receiver of the command,
+ * whichever is relevant (depending on direction), this field shall be set
+ * to UNSUPPORTED_ATTRIBUTE. If the attribute is supported, but is not capable of
+ * being reported, this field shall be set to UNREPORTABLE_ATTRIBUTE.
+ * Otherwise, this field shall be set to SUCCESS.*/
+ uint8_t status;
+ /*! The direction field specifies whether values of the attribute are reported (0x00),
+ * or whether reports of the attribute are received (0x01).*/
+ uint8_t direction;
+ /*! TBD */
+ uint16_t attributeId;
+ union PACK
+ {
+ struct PACK
+ {
+ /*! TBD */
+ uint8_t attributeType;
+ /*! TBD */
+ uint16_t minReportingInterval;
+ /*! TBD */
+ uint16_t maxReportingInterval;
+ /*! TBD */
+ uint8_t reportableChange[1];
+ };
+ /*! TBD */
+ uint16_t timeoutPeriod;
+ };
+} ZCL_ReadReportingConfigurationResp_t;
+
+/********************************************************************************//**
+\brief Type describing payload element of report command.
+
+This type can be used to get next reported attribute from the report payload.
+***********************************************************************************/
+typedef struct PACK
+{
+ ZCL_AttributeId_t id; //!< requested attribute id
+ uint8_t type; //!< requested attribute type
+ uint8_t value[1]; //!< requested attribute value
+} ZCL_Report_t;
+
+/********************************************************************************//**
+\brief Type describing payload of ZCL Default Response Command.
+***********************************************************************************/
+typedef struct PACK
+{
+ /*!The command identifier field is 8-bit in length and specifies the identifier
+ of the received command to which this command is a response.*/
+ uint8_t commandId;
+ /*!The status code field is 8-bit in length and specifies either SUCCESS or
+ the nature of the error that was detected in the receive command.*/
+ uint8_t statusCode;
+} ZCL_DefaultResp_t;
+
+/********************************************************************************//**
+\brief Type describing payload of ZCL Discovery Attributes Command.
+***********************************************************************************/
+typedef struct PACK
+{
+ /*!The start attribute identifier field is 16-bit in length and specifies
+ the value of the identifier at which to begin the attribute discovery.*/
+ ZCL_AttributeId_t startAttributeId;
+ /*!The maximum attribute identifiers field is 8-bit in length and specifies
+ the maximum number of attribute identifiers that are to be returned in the
+ resulting discovery attributes response command.*/
+ uint8_t maxAttributeIds;
+} ZCL_DiscoverAttributesReq_t;
+
+/********************************************************************************//**
+\brief Type describing payload the Attribute Report field of ZCL Discovery
+ Attributes Response Command.
+***********************************************************************************/
+typedef struct PACK
+{
+ ZCL_AttributeId_t attributeId; //!<Attribute identifier
+ uint8_t typeId; //!<Attribute data type Id
+} ZCL_DiscoverAttributesRespRec_t;
+
+/********************************************************************************//**
+\brief Type describing payload of ZCL Discovery Attributes Response Command.
+***********************************************************************************/
+typedef struct PACK
+{
+ /*!The discovery complete field is a boolean field. A value of 0 indicates
+ that there are more attributes to be discovered. A value of 1 indicates that
+ there are no more attributes to be discovered.*/
+ uint8_t discoveryComplete;
+ /*!Discovered attribute information*/
+ ZCL_DiscoverAttributesRespRec_t attributeInfo[1];
+} ZCL_DiscoverAttributesResp_t;
+
+END_PACK
+
+/*************************************************************************//**
+ \brief Type describing attribute events notification
+*****************************************************************************/
+typedef struct
+{
+ ZCL_Addressing_t addressing; //!< source addressing, source endpoint, destination cluster
+ uint8_t attributeId; //!< attribute id
+} ZCL_AttributeEventNtfy_t;
+
+/*************************************************************************//**
+ \brief Type describing parameter of ZCL_EventNtfy() function
+*****************************************************************************/
+typedef struct
+{
+ ZCL_EventId_t eventId; //!< event Id (e.g. ZCL_ATTRIBUTE_READ_EVENT_ID)
+ union
+ {
+ ZCL_AttributeEventNtfy_t attribute; //!< attribute event
+ } eventType;
+} ZCL_EventNtfy_t;
+
+/********************************************************************************//**
+\brief Type describing parameter of ZCL_RegisterEndpoint() function
+***********************************************************************************/
+typedef struct
+{
+ // Service structure
+ struct
+ {
+ APS_RegisterEndpointReq_t apsEndpoint;
+ uint8_t seqNum;
+ } service;
+
+ SimpleDescriptor_t simpleDescriptor; //!< Device endpoint Simple Descriptor
+ ZCL_Cluster_t *serverCluster; //!< Device server clusters
+ ZCL_Cluster_t *clientCluster; //!< Device client clusters
+} ZCL_DeviceEndpoint_t;
+
+/*************************************************************************//**
+ \brief ZCL Data Type Descriptor.
+ Describes the Data Type length in bytes and Data Type kind (Analog or Descrete).
+*****************************************************************************/
+typedef struct
+{
+ uint16_t length; //!<Length in bytes
+ /*!Kind of Data Type (Analog or Descrete). The #ZCL_DATA_TYPE_ANALOG_KIND or \n
+ !#ZCL_DATA_TYPE_DESCRETE_KIND should be used).*/
+ uint8_t kind;
+} ZCL_DataTypeDescriptor_t;
+
+/******************************************************************************
+ Inline functions section
+******************************************************************************/
+/********************************************************************************//**
+ \brief Gets Cluster Side the Incoming command is intended to.
+
+ \param[in] direction - incoming command direction
+ \return cluster side detected
+***********************************************************************************/
+INLINE uint8_t getDstClusterSideByIncommingCommandDirection(uint8_t direction)
+{
+ return direction;
+}
+
+/********************************************************************************//**
+ \brief Gets source Cluster Side by destination Cluster side.
+
+ \param[in] clusterSide - destination cluster's side
+ \return cluster side detected
+***********************************************************************************/
+INLINE uint8_t getSrcClusterSideByDstClusterSide(uint8_t clusterSide)
+{
+ return !clusterSide;
+}
+
+/********************************************************************************//**
+ \brief Gets destination Cluster Side by source Cluster side.
+
+ \param[in] clusterSide - source cluster's side
+ \return cluster side detected
+***********************************************************************************/
+INLINE uint8_t getDstClusterSideBySrcClusterSide(uint8_t clusterSide)
+{
+ return !clusterSide;
+}
+
+/********************************************************************************//**
+ \brief Gets outgoing command direction by destination Cluster side.
+
+ \param[in] clusterSide - destination cluster's side
+ \return command direction detected
+***********************************************************************************/
+INLINE uint8_t getOutgoingCommandDirectionByDstClusterSide(uint8_t clusterSide)
+{
+ return clusterSide;
+}
+
+/********************************************************************************//**
+ \brief Gets source Cluster side by direction of incoming command.
+
+ \param[in] direction - incoming command direction.
+ \return detected cluster side.
+***********************************************************************************/
+INLINE uint8_t getOwnClusterSideByIncomingCommandDirection(uint8_t direction)
+{
+ return direction;
+}
+
+/********************************************************************************//**
+ \brief Gets destination Cluster side by direction of outgoing command.
+
+ \param[in] direction - outgoing command direction.
+ \return detected cluster side.
+***********************************************************************************/
+INLINE uint8_t getDstClusterSideByOutgoingCommandDirection(uint8_t direction)
+{
+ return direction;
+}
+
+/******************************************************************************
+ Functions prototypes section
+******************************************************************************/
+/*********************************************************************************//**
+\brief Register device endpoint.
+
+This function registers a device endpoint to make ZCL know which devices types
+are used in applications and which clusters they support.
+
+\param[in] endpoint - contains device descriptor
+************************************************************************************/
+void ZCL_RegisterEndpoint(ZCL_DeviceEndpoint_t *endpoint);
+
+/*************************************************************************//**
+ \brief This function resets ZCL component.
+
+ \param[in] none
+*****************************************************************************/
+void ZCL_ResetReq(void);
+
+/*************************************************************************//**
+ \brief Finds attribute in ZCL and returns attribute value
+
+ \param[in] endpointId - endpoint on which cluster is registered
+ \param[in] clusterId - cluster unique identifier
+ \param[in] direction - detects the cluster's side (client or server)
+ \param[in] attrId - attribute unique identifier
+ \param[out] attrType - pointer to attribute type determined and returned
+ \param[out] attrValue - read out attribute value pointer
+
+ \return status of operation
+*****************************************************************************/
+ZCL_Status_t ZCL_ReadAttributeValue(Endpoint_t endpointId, ClusterId_t clusterId, uint8_t direction,
+ ZCL_AttributeId_t attrId, uint8_t *attrType, uint8_t *attrValue);
+
+/*************************************************************************//**
+ \brief Finds attribute in ZCL and rewrites its value by the new one
+ (to be used with local write request).
+
+ \param[in] endpointId - endpoint on which cluster is registered
+ \param[in] clusterId - cluster unique identifier
+ \param[in] direction - detects the cluster's side (client or server)
+ \param[in] attrId - attribute unique identifier
+ \param[in] attrType - type of the attribute to be set
+ \param[in] attrValue - pointer to attribute value to be set
+
+ \return status of operation
+*****************************************************************************/
+ZCL_Status_t ZCL_WriteAttributeValue(Endpoint_t endpointId, ClusterId_t clusterId, uint8_t direction,
+ ZCL_AttributeId_t attrId, uint8_t attrType, uint8_t *attrValue);
+
+/*************************************************************************//**
+ \brief Finds attribute in ZCL and rewrites its value by the new one
+ (to be used with remote write request).
+
+ \param[in] endpointId - endpoint on which cluster is registered
+ \param[in] clusterId - cluster unique identifier
+ \param[in] direction - detects the cluster's side (client or server)
+ \param[in] attrId - attribute unique identifier
+ \param[in] attrType - type of the attribute to be set
+ \param[in] attrValue - pointer to attribute value to be set
+
+ \return status of operation
+*****************************************************************************/
+ZCL_Status_t zclRemoteWriteAttributeValue(Endpoint_t endpointId, ClusterId_t clusterId, uint8_t direction,
+ ZCL_AttributeId_t attrId, uint8_t attrType, uint8_t *attrValue);
+
+/*************************************************************************//**
+ \brief Sends a general ZCL command related to attributes to a remote device
+
+ The function is used to read/write attributes from a remote device, to report
+ local attributes, and to discover attributes supported by a particular cluster
+ on a remote device.
+
+ Command's parameters include addressing information, calback functions, command's
+ ID, and the payload. The payload may be formed via the ZCL_PutNextElement() function
+ and an instance of ZCL_NextElement_t type. The command may be used to perform
+ actions on multiple attributes at a time; for example, to read several attributes
+ from a remote device.
+
+ Attribute related commands are usually send to specific short or extended addresses.
+ Sending such commands to bound devices (employing ::APS_NO_ADDRESS mode) may not
+ be as efficient, because in case of responses from more than one device the ZCL
+ component will process only the first one.
+
+ Upon receiving the response from the remote device, the callback function specified
+ in the \c req->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
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclBACnetProtocolTunnelCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclBACnetProtocolTunnelCluster.h
new file mode 100644
index 00000000..da679d3e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclBACnetProtocolTunnelCluster.h
@@ -0,0 +1,105 @@
+/***************************************************************************//**
+ \file zclBACnetProtocolTunnelCluster.h
+
+ \brief
+ The header file describes the ZCL BACnet Protocol Tunnel Cluster and its interface
+
+ The file describes the types and interface of the ZCL BACnet Protocol Tunnel 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:
+ 20.10.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLBACNETPROTOCOLTUNNELCLUSTER_H
+#define _ZCLBACNETPROTOCOLTUNNELCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+#include <zcl.h>
+#include <clusters.h>
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+/***************************************************************************//**
+ \brief ZCL BACnet Protocol Tunnel Cluster server side attributes amount
+*******************************************************************************/
+#define ZCL_BACNET_PRTOCOL_TUNNEL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 0
+/***************************************************************************//**
+ \brief ZCL BACnet Protocol Tunnel client side attributes amount
+*******************************************************************************/
+#define ZCL_BACNET_PRTOCOL_TUNNEL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+//There are no any attributes at the client side
+/***************************************************************************//**
+ \brief ZCL BACnet Protocol Tunnel Cluster derver side commands amount
+*******************************************************************************/
+#define ZCL_BACNET_PROTOCOL_TUNNEL_COMMANDS_AMOUNT 1
+/**
+ * \brief Generic tunnel client side commands identifiers.
+*/
+#define ZCL_BACNET_PROTOCOL_TRANSFER_NPDU_COMMAND_ID 0x00
+
+#define ZCL_DEFINE_BACNET_PROTOCOL_CLUSTER_TUNNEL_CLUSTER_COMMANDS(transferNPDUCommandInd) \
+ DEFINE_COMMAND(transferNPDUCommand, ZCL_BACNET_PROTOCOL_TRANSFER_NPDU_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), transferNPDUCommandInd)
+
+#define BACNET_PROTOCOL_TUNNEL_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = BACNET_PROTOCOL_TUNNEL_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_BACNET_PRTOCOL_TUNNEL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_BACNET_PROTOCOL_TUNNEL_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define BACNET_PROTOCOL_TUNNEL_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = BACNET_PROTOCOL_TUNNEL_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_BACNET_PRTOCOL_TUNNEL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_BACNET_PROTOCOL_TUNNEL_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_BACNET_PROTOCOL_TUNNEL_CLUSTER(cltype, clattributes, clcommands) BACNET_PROTOCOL_TUNNEL_CLUSTER##cltype(clattributes, clcommands)
+/*******************************************************************************
+ Types section
+*******************************************************************************/
+BEGIN_PACK
+/**
+ * \brief Transfer NPDU Command Payload format.
+*/
+typedef struct PACK
+{
+ uint8_t npdu[1]; //!<npdu octet string
+} ZCL_TransferNPDU_t;
+END_PACK
+/**
+ * \brief BACnet protocol tunnel cluster commands.
+*/
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*transferNPDUCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_TransferNPDU_t *payload);
+ } transferNPDUCommand;
+} ZCL_BACnetProtocolTunnelCommands_t;
+
+#endif /* _ZCLBACNETPROTOCOLTUNNELCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclBasicCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclBasicCluster.h
new file mode 100644
index 00000000..b21facc5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclBasicCluster.h
@@ -0,0 +1,259 @@
+/***************************************************************************//**
+ \file zclBasicCluster.h
+
+ \brief
+ The header file describes the ZCL Basic Cluster and its interface
+
+ The file describes the types and interface of the ZCL Basic 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:
+ 03.01.09 A. Potashov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLBASICCLUSTER_H
+#define _ZCLBASICCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster server side commands amount
+*******************************************************************************/
+#define ZCL_BASIC_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 2
+//The ZCLVersion and PowerSource attributes
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster derver side commands amount
+*******************************************************************************/
+#define ZCL_BASIC_CLUSTER_SERVER_COMMANDS_AMOUNT 0
+//There are no any commands at the server side
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster client side commands amount
+*******************************************************************************/
+#define ZCL_BASIC_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+//There are no any attributes at the client side
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster derver side commands amount
+*******************************************************************************/
+#define ZCL_BASIC_CLUSTER_CLIENT_COMMANDS_AMOUNT 0
+//There are no any commands at the client side
+
+
+//Atribute Ids of Basic Device Information Attribute Set at the server side
+//!ZCL Basic Cluster server side ZCLVersion attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_ZCL_VERSION_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+//!ZCL Basic Cluster server side ApplicationVersion attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_APPLICATION_VERSION_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+//!ZCL Basic Cluster server side StackVersion attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_STACK_VERSION_ATTRIBUTE_ID CCPU_TO_LE16(0x0002)
+//!ZCL Basic Cluster server side HWVersion attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_HW_VERSION_ATTRIBUTE_ID CCPU_TO_LE16(0x0003)
+//!ZCL Basic Cluster server side ManufacturerName attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_MANUFACTURER_NAME_ATTRIBUTE_ID CCPU_TO_LE16(0x0004)
+//!ZCL Basic Cluster server side ModelIdentifier attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_MODEL_IDENTIFIER_ATTRIBUTE_ID CCPU_TO_LE16(0x0005)
+//!ZCL Basic Cluster server side DateCode attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_DATE_CODE_ATTRIBUTE_ID CCPU_TO_LE16(0x0006)
+//!ZCL Basic Cluster server side PowerSource attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_POWER_SOURCE_ATTRIBUTE_ID CCPU_TO_LE16(0x0007)
+
+//Atribute Ids of Basic Device Settings Attribute Set at the server side
+//!ZCL Basic Cluster server side LocationDescription attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_LOCATION_DESCRIPTION_ATTRIBUTE_ID CCPU_TO_LE16(0x0010)
+//!ZCL Basic Cluster server side PhysicalEnvironment attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_PHYSICAL_ENVIRONMENT_ATTRIBUTE_ID CCPU_TO_LE16(0x0011)
+//!ZCL Basic Cluster server side DeviceEnabled attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_DEVICE_ENABLED_ATTRIBUTE_ID CCPU_TO_LE16(0x0012)
+//!ZCL Basic Cluster server side AlarmMask attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_ALARM_MASK_ATTRIBUTE_ID CCPU_TO_LE16(0x0013)
+
+//!ZCL Basic Cluster server side ResetToFactoryDeafaults commabd id
+#define ZCL_BASIC_CLUSTER_SERVER_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID 0x00
+
+/*******************************************************************************
+ Types section
+*******************************************************************************/
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster server side attributes defining macros
+
+ This macros should be used for ZCL Basic Cluster server side attributes defining.
+
+ \return None
+
+ \internal
+ //The typical usage is:
+ //Basic Cluster server side related attributes
+ ZCL_BasicClusterServerAttributes_t basicClusterAttributes = ZCL_DEFINE_BASIC_CLUSTER_SERVER_ATTRIBUTES();
+*******************************************************************************/
+#define ZCL_DEFINE_BASIC_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(zclVersion, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_ZCL_VERSION_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(powerSource, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_POWER_SOURCE_ATTRIBUTE_ID, ZCL_8BIT_ENUM_DATA_TYPE_ID)
+
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster server side defining macros
+
+ This macros should be used with #ZCL_DEFINE_BASIC_CLUSTER_SERVER_ATTRIBUTES for
+ ZCL Basic Cluster server side defining in application.
+
+ \param attributes - pointer to cluster server attributes (ZCL_BasicClusterServerAttributes_t)
+
+ \return None
+
+ \internal
+ //The typical code is:
+ //Basic Cluster server side related attributes
+ ZCL_BasicClusterServerAttributes_t basicClusterServerAttributes = DEFINE_ZCL_BASIC_CLUSTER_SERVER_ATTRIBUTES();
+ ZCL_Cluster_t myClusters[] =
+ {
+ ZCL_DEFINE_BASIC_CLUSTER_SERVER(&basicClusterServerAttributes),
+ //... Any other cluster defining ...
+ }
+*******************************************************************************/
+#define ZCL_DEFINE_BASIC_CLUSTER_SERVER(clattributes) \
+ { \
+ .id = BASIC_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_BASIC_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) clattributes, \
+ .commandsAmount = ZCL_BASIC_CLUSTER_SERVER_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster client side defining macros
+
+ This macros should be used for ZCL Basic Cluster client side defining in application.
+
+ \return None
+
+ \internal
+ //The typical code is:
+ ZCL_Cluster_t myClusters[] =
+ {
+ ZCL_DEFINE_BASIC_CLUSTER_CLIENT(),
+ //... Any other cluster defining ...
+ }
+*******************************************************************************/
+#define ZCL_DEFINE_BASIC_CLUSTER_CLIENT() \
+ { \
+ .id = BASIC_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_BASIC_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = NULL, \
+ .commandsAmount = ZCL_BASIC_CLUSTER_CLIENT_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+
+BEGIN_PACK
+/***************************************************************************//**
+ \brief
+ ZCL Basic Cluster server side attributes
+*******************************************************************************/
+typedef struct PACK
+{
+ //!Basic Device Information attribute set (Id == 0x00)
+
+ /*!ZCL Version attribute (Read only, M)
+ The ZCLVersion attribute is 8-bits in length and specifies the version number of
+ the ZigBee Cluster Library that all clusters on this endpoint conform to. For the
+ initial version of the ZCL, this attribute shall be set to 0x01.
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0000, #ZCL_BASIC_CLUSTER_SERVER_ZCL_VERSION_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (unsigned 8-bit integer, #ZCL_U8BIT_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value; //!<Attribute value (default 0x00)
+ } zclVersion;
+
+ /*!Power Source attribute (Read only, M)
+ The PowerSource attribute is 8-bits in length and specifies the source(s) of power
+ available to the device. Bits b0 of this attribute represent the primary power
+ source of the device and bit b7 indicates whether the device has a secondary power
+ source in the form of a battery backup.
+
+ Bits b0 of this attribute shall be set to one of the non-reserved values:
+ 0x00 - Unknown
+ 0x01 - Mains (single phase)
+ 0x02 - Mains (3 phase)
+ 0x03 - Battery
+ 0x04 - DC source
+ 0x05 - Emergency mains constantly powered
+ 0x06 - Emergency mains and transfer switch
+ 0x07-0x7f - Reserved
+
+ Bit b7 of this attribute shall be set to 1 if the device has a secondary power source
+ in the form of a battery backup. Otherwise, bit b7 shall be set to 0.
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0007, #ZCL_BASIC_CLUSTER_SERVER_POWER_SOURCE_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (8-bit enumeration, #ZCL_8BIT_ENUM_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value; //!<Attribute value (default 0x00)
+ } powerSource;
+
+ //!Basic Device Settings attribute set (Id == 0x01)
+} ZCL_BasicClusterServerAttributes_t;
+
+END_PACK
+
+#if 0
+// The ResetToFactoryDefaults command is optional now.
+/***************************************************************************//**
+ \brief
+ Describes the Basic Cluster server side commands
+
+ On receipt of this command, the device resets all the attributes of all its clusters to
+ their factory defaults.
+ Note that ZigBee networking functionality and any bindings are not affected by
+ this command.
+ This command does not have a payload.
+*******************************************************************************/
+typedef struct PACK
+{
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x00, #ZCL_BASIC_CLUSTER_SERVER_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID)
+ ZclCommandOptions_t options; //!<Command options (.direction should be equal to #ZCL_FRAME_CONTROL_DIRECTION_CLIENT_TO_SERVER)
+ /*!
+ \brief
+ Command indication handler
+ \param payloadLength - actual payload length in bytes (should be zero)
+ */
+ void (*resetToFactoryDefaults)(uint8_t payloadLength, uint8_t *payload);
+ } resetToFactoryDefaults;
+} BasicClusterServerCommands_t;
+#endif //#if 0
+
+
+#endif //#ifndef _ZCLBASICCLUSTER_H
+
+//eof zclBasicCluster.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclDemandResponseCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclDemandResponseCluster.h
new file mode 100644
index 00000000..a3b9e23c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclDemandResponseCluster.h
@@ -0,0 +1,351 @@
+/************************************************************************//**
+ \file zclDemandResponseCluster.h
+
+ \brief
+ The header file describes the Demand Response 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:
+ 03.02.09 A. Mandychev - Created.
+******************************************************************************/
+
+#ifndef _ZCLDEMANDRESPONSECLUSTER_H
+#define _ZCLDEMANDRESPONSECLUSTER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zcl.h>
+#include <clusters.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+/**
+ * \brief Demand Response Server Cluster attributes amount.
+*/
+#define DRLC_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Demand Response Client Cluster attributes amount.
+*/
+#define DRLC_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 4
+
+/**
+ * \brief Demand Response Cluster commands amount.
+*/
+#define DRLC_CLUSTER_COMMANDS_AMOUNT 5
+
+/**
+ * \brief Demand Response Server Cluster commands identifiers.
+*/
+#define LOAD_CONTROL_EVENT_COMMAND_ID 0x00
+#define CANCEL_LOAD_CONTROL_EVENT_COMMAND_ID 0x01
+#define CANCEL_ALL_LOAD_CONTROL_EVENTS_COMMAND_ID 0x02
+
+/**
+ * \brief Demand Response Client Cluster commands identifiers.
+*/
+#define REPORT_EVENT_STATUS_COMMAND_ID 0x00
+#define GET_SCHEDULED_EVENTS_COMMAND_ID 0x01
+
+/**
+ * \brief Report event status identifiers
+ */
+#define REPORT_EVENT_STATUS_COMMAND_RECEIVED 0x01
+#define REPORT_EVENT_STATUS_EVENT_STARTED 0x02
+#define REPORT_EVENT_STATUS_EVENT_COMPLETED 0x03
+#define REPORT_EVENT_STATUS_EVENT_CANCELED 0x06
+#define REPORT_EVENT_STATUS_INVALID_CANCEL_COMMAND_DEFAULT 0xF8
+
+#define DEFINE_DRLC_CLUSTER_COMMANDS(clLoadControlEventInd, \
+ clCancelLoadControlEventInd, \
+ clCancelAllLoadControlEventsInd, \
+ clReportEventStatusInd, \
+ clGetScheduledEventsInd) \
+ DEFINE_COMMAND(loadControlEventCommand, 0x00, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), clLoadControlEventInd), \
+ DEFINE_COMMAND(cancelLoadControlEventCommand, 0x01, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), clCancelLoadControlEventInd), \
+ DEFINE_COMMAND(cancelAllLoadControlEventsCommand, 0x02, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), clCancelAllLoadControlEventsInd), \
+ DEFINE_COMMAND(reportEventStatusCommand, 0x00, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), clReportEventStatusInd), \
+ DEFINE_COMMAND(getScheduledEventsCommand, 0x01, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), clGetScheduledEventsInd)
+
+
+
+
+#define DEFINE_DRLC_CLUSTER_CLIENT_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(utilityEnrolmentGroupAttr, ZCL_READWRITE_ATTRIBUTE, CCPU_TO_LE16(0x0000), ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(startRandomizeMinutesAttr, ZCL_READWRITE_ATTRIBUTE, CCPU_TO_LE16(0x0001), ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(endRandomizeMinutesAttr, ZCL_READWRITE_ATTRIBUTE, CCPU_TO_LE16(0x0002), ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(deviceClassValueAttr, ZCL_READONLY_ATTRIBUTE, CCPU_TO_LE16(0x0003), ZCL_16BIT_BITMAP_DATA_TYPE_ID)
+
+#define DRLC_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = DEMAND_RESPONSE_AND_LOAD_CONTROL_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = DRLC_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = NULL, \
+ .commandsAmount = DRLC_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *) clcommands \
+ }
+
+#define DRLC_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = DEMAND_RESPONSE_AND_LOAD_CONTROL_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = DRLC_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) clattributes, \
+ .commandsAmount = DRLC_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *) clcommands \
+ }
+
+#define DEFINE_DRLC_CLUSTER(cltype, clattributes, clcommands) \
+ DRLC_CLUSTER_##cltype(clattributes, clcommands)
+
+//! Signature type. AMI r15 profile spec., D.2.3.3.1.1.
+#define ZCL_ECDSA_SIGNATURE_TYPE 0x01
+//! Signature length. AMI r15 profile spec., D.2.3.3.1.1.
+#define REPORT_EVENT_STATUS_SIGNATURE_LENGTH 42
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+BEGIN_PACK
+
+/**
+ * \brief Device Class type.
+*/
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(8,(
+ uint16_t hvacCompressor : 1,
+ uint16_t stripHeaters : 1,
+ uint16_t waterHeater : 1,
+ uint16_t poolPump : 1,
+ uint16_t smartAppliances : 1,
+ uint16_t irrigationPump : 1,
+ uint16_t managedCommercAndIndustrLoads : 1,
+ uint16_t simpleMiscLoads : 1
+ ))
+ LITTLE_ENDIAN_OCTET(5,(
+ uint16_t exteriorLighting : 1,
+ uint16_t interiorLighting : 1,
+ uint16_t electricalVehicle : 1,
+ uint16_t generationSystem : 1,
+ uint16_t reserved : 4
+ ))
+} ZCL_DeviceClass_t;
+
+/**
+ * \brief Device Class type.
+*/
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(3,(
+ uint8_t randStartTime : 1,
+ uint8_t randEndTime : 1,
+ uint8_t reserved : 6
+ ))
+} ZCL_EventControl_t;
+
+/**
+ * \brief The Load Control Event Command Payload.
+*/
+typedef struct PACK
+{
+ uint32_t issuerEventId;
+ ZCL_DeviceClass_t deviceClass;
+ uint8_t utilityEnrolmentGroup;
+ uint32_t startTime;
+ uint16_t durationInMinutes;
+ uint8_t criticalityLevel;
+ uint8_t coolingTemperatureOffset;
+ uint8_t heatingTemperatureOffset;
+ uint16_t coolingTemperatureSetPoint;
+ uint16_t heatingTemperatureSetPoint;
+ int8_t avrgLoadAdjstPercentage;
+ uint8_t dutyCycle;
+ ZCL_EventControl_t eventControl;
+} ZCL_LoadControlEvent_t;
+
+/**
+ * \brief The Cancel Control type.
+*/
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(2,(
+ uint8_t randomizeEnd : 1,
+ uint8_t reserved : 7
+ ))
+} ZCL_CancelControl_t;
+
+/**
+ * \brief The Cancel Load Control Event Command Payload.
+*/
+typedef struct PACK
+{
+ uint32_t issuerEventId;
+ ZCL_DeviceClass_t deviceClass;
+ uint8_t utilityEnrolmentGroup;
+ ZCL_CancelControl_t cancelControl;
+ ZCL_UTCTime_t effectiveTime;
+} ZCL_CancelLoadControlEvent_t;
+
+typedef struct PACK
+{
+ ZCL_CancelControl_t cancelControl; // ZCL_U8BIT_BITMAP_TYPE_ID
+} ZCL_CancelAllLoadControlEvents_t;
+
+typedef struct PACK
+{
+ //! Utility Enrolment Group Attribute descriptor
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0200)
+ uint8_t type; //!<Attribute data type (8 bit Bitmap)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t utilityEnrolmentGroup;
+ } utilityEnrolmentGroupAttr;
+
+ //! Start Randomize Minutes Attribute descriptor
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0200)
+ uint8_t type; //!<Attribute data type (8 bit Bitmap)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t startRandomizeMinutes;
+ } startRandomizeMinutesAttr;
+
+ //! End Randomize Minutes Attribute descriptor
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0200)
+ uint8_t type; //!<Attribute data type (8 bit Bitmap)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t endRandomizeMinutes;
+ } endRandomizeMinutesAttr;
+
+ //! Device Class Value Attribute descriptor
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0200)
+ uint8_t type; //!<Attribute data type (8 bit Bitmap)
+ uint8_t properties; //!<Attribute properties bitmask
+ ZCL_DeviceClass_t deviceClassValue;
+ } deviceClassValueAttr;
+
+} ZCL_DemandResponseClientClusterAttributes_t;
+
+/**
+ * \brief Report event status type.
+*/
+typedef struct PACK
+{
+ uint32_t issuerEventId;
+ uint8_t eventStatus;
+ ZCL_UTCTime_t eventStatusTime;
+ uint8_t criticalityLevelApplied;
+ uint16_t coolingTemperatureSetPointApplied;
+ uint16_t heatingTemperatureSetPointApplied;
+ int8_t avrgLoadAdjstPercentageApplied;
+ uint8_t dutyCycleApplied;
+ ZCL_EventControl_t eventControl;
+ uint8_t signatureType;
+ uint8_t signature[REPORT_EVENT_STATUS_SIGNATURE_LENGTH];
+} ZCL_ReportEventStatus_t;
+
+/**
+ * \brief Get scheduled events type.
+*/
+typedef struct PACK
+{
+ ZCL_UTCTime_t startTime;
+ uint8_t numberOfEvents;
+} ZCL_GetScheduledEvents_t;
+
+END_PACK
+
+/**
+ * \brief ZCL Demand Response Cluster Commands.
+*/
+typedef struct
+{
+ //! Load Control Event 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 (*loadControlEvent)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_LoadControlEvent_t *payload);
+ } loadControlEventCommand;
+
+ //! Cancel Load Control Event 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 (*cancelLoadControlEvent)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_CancelLoadControlEvent_t *payload);
+ } cancelLoadControlEventCommand;
+
+ //! Confirm Key Data Request Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x02)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*cancelAllLoadControlEvents)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_CancelAllLoadControlEvents_t *payload);
+ } cancelAllLoadControlEventsCommand;
+ //! Report Event Status 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 (*reportEventStatus)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ReportEventStatus_t *payload);
+ } reportEventStatusCommand;
+
+ //! Confirm Key Data Request Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x02)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*getScheduledEvents)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetScheduledEvents_t *payload);
+ } getScheduledEventsCommand;
+
+} ZCL_DemandResponseAndLoadControlClusterCommands_t;
+
+#endif /*_ZCLDEMANDRESPONSECLUSTER_H*/
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclGenericTunnelCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclGenericTunnelCluster.h
new file mode 100644
index 00000000..93560a06
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclGenericTunnelCluster.h
@@ -0,0 +1,176 @@
+/***************************************************************************//**
+ \file zclGenericTunnelCluster.h
+
+ \brief
+ The header file describes the ZCL Generic Tunnel Cluster and its interface
+
+ The file describes the types and interface of the ZCL Generic Tunnel 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:
+ 20.10.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLGENERICTUNNELCLUSTER_H
+#define _ZCLGENERICTUNNELCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+#include <zcl.h>
+#include <clusters.h>
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+/***************************************************************************//**
+ \brief ZCL Generic Tunnel Cluster server side attributes amount
+*******************************************************************************/
+#define ZCL_GENERIC_TUNNEL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 3
+/***************************************************************************//**
+ \brief ZCL Generic Tunnel Cluster client side attributes amount
+*******************************************************************************/
+#define ZCL_GENERIC_TUNNEL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+//There are no any attributes at the client side
+/***************************************************************************//**
+ \brief ZCL Generic Tunnel Cluster derver side commands amount
+*******************************************************************************/
+#define ZCL_GENERIC_TUNNEL_COMMANDS_AMOUNT 3
+/**
+ * \brief Generic tunnel server side attributes identifiers.
+*/
+//!ZCL Generic tunnel server side MaximumIncomingTransferSize attribute id
+#define ZCL_GENERIC_TUNNEL_CLUSTER_SERVER_MITS_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+//!ZCL Generic tunnel server side MaximumOutgoingTransferSize attribute id
+#define ZCL_GENERIC_TUNNEL_CLUSTER_SERVER_MOTS_ATTRIBUTE_ID CCPU_TO_LE16(0x0002)
+//!ZCL Generic tunnel server side ProtocolAddress attribute id
+#define ZCL_GENERIC_TUNNEL_CLUSTER_SERVER_PROTOCOL_ADDR_ATTRIBUTE_ID CCPU_TO_LE16(0x0003)
+/**
+ * \brief Generic tunnel server side commands identifiers.
+*/
+#define ZCL_GENERIC_TUNNEL_MATCH_PROTOCOL_ADDRESS_RESPONSE_COMMAND_ID 0x00
+#define ZCL_GENERIC_TUNNEL_ADVERTISE_PROTOCOL_ADDRESS_COMMAND_ID 0x01
+/**
+ * \brief Generic tunnel client side commands identifiers.
+*/
+#define ZCL_GENERIC_TUNNEL_MATCH_PROTOCOL_ADDRESS_COMMAND_ID 0x00
+
+#define ZCL_DEFINE_GENERIC_TUNNEL_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(maximumIncomingTransferSize, ZCL_READONLY_ATTRIBUTE, ZCL_GENERIC_TUNNEL_CLUSTER_SERVER_MITS_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(maximumOutgoingTransferSize, ZCL_READONLY_ATTRIBUTE, ZCL_GENERIC_TUNNEL_CLUSTER_SERVER_MOTS_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(protocolAddress, ZCL_READWRITE_ATTRIBUTE, ZCL_GENERIC_TUNNEL_CLUSTER_SERVER_PROTOCOL_ADDR_ATTRIBUTE_ID, ZCL_OCTET_STRING_DATA_TYPE_ID)
+
+#define ZCL_DEFINE_GENERIC_TUNNEL_CLUSTER_COMMANDS(matchProtocolAddressCommandInd, matchProtocolAddressResponseCommandInd, advertiseProtocolAddressInd) \
+ DEFINE_COMMAND(matchProtocolAddressCommand, ZCL_GENERIC_TUNNEL_MATCH_PROTOCOL_ADDRESS_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), matchProtocolAddressCommandInd), \
+ DEFINE_COMMAND(matchProtocolAddressResponseCommand, ZCL_GENERIC_TUNNEL_MATCH_PROTOCOL_ADDRESS_RESPONSE_COMMAND_ID, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), matchProtocolAddressResponseCommandInd), \
+ DEFINE_COMMAND(advertiseProtocolAddress, ZCL_GENERIC_TUNNEL_ADVERTISE_PROTOCOL_ADDRESS_COMMAND_ID, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), advertiseProtocolAddressInd)
+
+#define GENERIC_TUNNEL_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = GENERIC_TUNNEL_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_GENERIC_TUNNEL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_GENERIC_TUNNEL_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define GENERIC_TUNNEL_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = GENERIC_TUNNEL_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_GENERIC_TUNNEL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_GENERIC_TUNNEL_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_GENERIC_TUNNEL_CLUSTER(cltype, clattributes, clcommands) GENERIC_TUNNEL_CLUSTER##cltype(clattributes, clcommands)
+/*******************************************************************************
+ Types section
+*******************************************************************************/
+BEGIN_PACK
+/**
+ * \brief Match Protocol Address Command Payload format.
+*/
+typedef struct PACK
+{
+ uint8_t address[1]; //!<address (octet string)
+} ZCL_MatchProtocolAddress_t;
+/**
+ * \brief Advertise Protocol Address Command Payload format.
+*/
+typedef struct PACK
+{
+ uint8_t address[1]; //!<address (octet string)
+} ZCL_AdvertiseProtocolAddress_t;
+/**
+ * \brief Generic tunnel cluster server attributes.
+*/
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } maximumIncomingTransferSize;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } maximumOutgoingTransferSize;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value[OCTET_STRING_MAX_SIZE];
+ } protocolAddress;
+} ZCL_GenericTunnelClusterServerAttributes_t;
+END_PACK
+/**
+ * \brief Generic tunnel cluster commands.
+*/
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*matchProtocolAddressCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_MatchProtocolAddress_t *payload);
+ } matchProtocolAddressCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*matchProtocolAddressResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } matchProtocolAddressResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*advertiseProtocolAddress)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AdvertiseProtocolAddress_t *payload);
+ } advertiseProtocolAddress;
+} ZCL_GenericTunnelClusterCommands_t;
+
+#endif /* _ZCLGENERICTUNNELCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclGroupsCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclGroupsCluster.h
new file mode 100644
index 00000000..43e233ca
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclGroupsCluster.h
@@ -0,0 +1,361 @@
+/***************************************************************************//**
+ \file zclGroupsCluster.h
+
+ \brief
+ The header file describes the ZCL Groups Cluster and its interface
+
+ The file describes the types and interface of the ZCL Groups 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:
+ 12.02.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLGROUPSCLUSTER_H
+#define _ZCLGROUPSCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/**
+ * \brief Groups Cluster group name support bit
+*/
+
+#define GROUP_NAME_SUPPORT_FLAG 0x80
+
+/**
+ * \brief Groups Cluster server attributes amount
+*/
+
+#define ZCL_GROUPS_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 1
+
+/**
+ * \brief Groups Cluster client attributes amount. Clinet doesn't have attributes.
+*/
+
+#define ZCL_GROUPS_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Groups Cluster commands amount
+*/
+
+#define ZCL_GROUPS_CLUSTER_COMMANDS_AMOUNT 10
+
+/**
+ * \brief Groups Cluster server's attributes identifiers
+*/
+
+#define ZCL_GROUPS_CLUSTER_NAME_SUPPORT_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+
+/**
+ * \brief Groups Cluster client's command identifiers
+*/
+
+#define ZCL_GROUPS_CLUSTER_ADD_GROUP_COMMAND_ID 0x00
+#define ZCL_GROUPS_CLUSTER_VIEW_GROUP_COMMAND_ID 0x01
+#define ZCL_GROUPS_CLUSTER_GET_GROUP_MEMBERSHIP_COMMAND_ID 0x02
+#define ZCL_GROUPS_CLUSTER_REMOVE_GROUP_COMMAND_ID 0x03
+#define ZCL_GROUPS_CLUSTER_REMOVE_ALL_GROUPS_COMMAND_ID 0x04
+#define ZCL_GROUPS_CLUSTER_ADD_GROUP_IF_IDENTIFYING_COMMAND_ID 0x05
+
+/**
+ * \brief Groups Cluster servers's command identifiers
+*/
+
+#define ZCL_GROUPS_CLUSTER_ADD_GROUP_RESPONSE_COMMAND_ID 0x00
+#define ZCL_GROUPS_CLUSTER_VIEW_GROUP_RESPONSE_COMMAND_ID 0x01
+#define ZCL_GROUPS_CLUSTER_GET_GROUP_MEMBERSHIP_RESPONSE_COMMAND_ID 0x02
+#define ZCL_GROUPS_CLUSTER_REMOVE_GROUP_RESPONSE_COMMAND_ID 0x03
+
+/**
+ * \brief Groups Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_GROUPS_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(nameSupport, ZCL_READONLY_ATTRIBUTE, ZCL_GROUPS_CLUSTER_NAME_SUPPORT_SERVER_ATTRIBUTE_ID, ZCL_8BIT_BITMAP_DATA_TYPE_ID)
+
+/**
+ * \brief On/Off Cluster define commands macros
+*/
+
+#define ZCL_DEFINE_GROUPS_CLUSTER_COMMANDS(addGroupCommandInd, viewGroupCommandInd, getGroupMembershipCommandInd, \
+ removeGroupCommandInd, removeAllGroupsCommandInd, addGroupIfIdentifyingCommandInd, \
+ addGroupResponseCommandInd, viewGroupResponseCommandInd, getGroupMembershipResponseCommandInd, \
+ removeGroupResponseCommandInd) \
+ DEFINE_COMMAND(addGroupCommand, ZCL_GROUPS_CLUSTER_ADD_GROUP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addGroupCommandInd), \
+ DEFINE_COMMAND(viewGroupCommand, ZCL_GROUPS_CLUSTER_VIEW_GROUP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ viewGroupCommandInd), \
+ DEFINE_COMMAND(getGroupMembershipCommand, ZCL_GROUPS_CLUSTER_GET_GROUP_MEMBERSHIP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ getGroupMembershipCommandInd), \
+ DEFINE_COMMAND(removeGroupCommand, ZCL_GROUPS_CLUSTER_REMOVE_GROUP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeGroupCommandInd), \
+ DEFINE_COMMAND(removeAllGroupsCommand, ZCL_GROUPS_CLUSTER_REMOVE_ALL_GROUPS_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeAllGroupsCommandInd), \
+ DEFINE_COMMAND(addGroupIfIdentifyingCommand, ZCL_GROUPS_CLUSTER_ADD_GROUP_IF_IDENTIFYING_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addGroupIfIdentifyingCommandInd), \
+ DEFINE_COMMAND(addGroupResponseCommand, ZCL_GROUPS_CLUSTER_ADD_GROUP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addGroupResponseCommandInd), \
+ DEFINE_COMMAND(viewGroupResponseCommand, ZCL_GROUPS_CLUSTER_VIEW_GROUP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ viewGroupResponseCommandInd), \
+ DEFINE_COMMAND(getGroupMembershipResponseCommand, ZCL_GROUPS_CLUSTER_GET_GROUP_MEMBERSHIP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ getGroupMembershipResponseCommandInd), \
+ DEFINE_COMMAND(removeGroupResponseCommand, ZCL_GROUPS_CLUSTER_REMOVE_GROUP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeGroupResponseCommandInd)
+
+/**
+ * \brief On/Off Cluster definition macros
+*/
+
+#define GROUPS_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = GROUPS_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_GROUPS_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_GROUPS_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define GROUPS_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = GROUPS_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_GROUPS_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_GROUPS_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_GROUPS_CLUSTER(cltype, clattributes, clcommands) \
+ GROUPS_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+BEGIN_PACK
+
+/**
+ * \brief Add Group Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t groupName[2];
+} ZCL_AddGroup_t;
+
+/**
+ * \brief View Group Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+} ZCL_ViewGroup_t;
+
+/**
+ * \brief Get Group Membership Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t groupCount;
+ uint16_t groupList[1];
+} ZCL_GetGroupMembership_t;
+
+/**
+ * \brief Remove Group Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+} ZCL_RemoveGroup_t;
+
+/**
+ * \brief Add Group if identifying Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t groupName[2];
+} ZCL_AddGroupIfIdentifying_t;
+
+/**
+ * \brief Add Group Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+} ZCL_AddGroupResponse_t;
+
+/**
+ * \brief View Group Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t groupName[2];
+} ZCL_ViewGroupResponse_t;
+
+/**
+ * \brief Get Group Membership Response Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t capacity;
+ uint8_t groupCount;
+ uint16_t groupList[1];
+} ZCL_GetGroupMembershipResponse_t;
+
+/**
+ * \brief Remove Group Command Response Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+} ZCL_RemoveGroupResponse_t;
+
+/**
+ * \brief Groups Cluster server's attributes
+ */
+
+typedef struct PACK
+{
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } nameSupport;
+} ZCL_GroupsClusterServerAttributes_t;
+
+END_PACK
+
+/**
+ * \brief Groups Cluster commands.
+ */
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addGroupCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddGroup_t * payload);
+ } addGroupCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*viewGroupCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ViewGroup_t * payload);
+ } viewGroupCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*getGroupMembershipCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetGroupMembership_t * payload);
+ } getGroupMembershipCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeGroupCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveGroup_t * payload);
+ } removeGroupCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeAllGroupsCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, void * payload);
+ } removeAllGroupsCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addGroupIfIdentifyingCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddGroupIfIdentifying_t * payload);
+ } addGroupIfIdentifyingCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addGroupResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddGroupResponse_t * payload);
+ } addGroupResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*viewGroupResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ViewGroupResponse_t * payload);
+ } viewGroupResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*getGroupMembershipResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetGroupMembershipResponse_t * payload);
+ } getGroupMembershipResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeGroupResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveGroupResponse_t * payload);
+ } removeGroupResponseCommand;
+} ZCL_GroupsClusterCommands_t;
+
+#endif /* _ZCLGROUPSCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclHumidityMeasurementCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclHumidityMeasurementCluster.h
new file mode 100644
index 00000000..afcc9f94
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclHumidityMeasurementCluster.h
@@ -0,0 +1,122 @@
+/*****************************************************************************
+ \file zclHumidityMeasurement.h
+
+ \brief
+ The file describes the types and interface of the
+ Relative Humidity Measurement 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:
+ 18.01.2010 I.Vagulin - Created
+******************************************************************************/
+
+
+#ifndef _ZCLHUMIDITYMEASUREMENT_H_
+#define _ZCLHUMIDITYMEASUREMENT_H_
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+#include <types.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+/**
+* \brief server attributes amount
+*/
+#define ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 3
+
+/**
+* \brief server commands amount
+*/
+#define ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_COMMANDS_AMOUNT 0
+
+/**
+* \brief client attributes amount
+*/
+#define ZCL_HUMIDITY_MEASUREMENT_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+* \brief client commands amount
+*/
+#define ZCL_HUMIDITY_MEASUREMENT_CLUSTER_CLIENT_COMMANDS_AMOUNT 0
+
+/**
+* \brief Supported attribue id
+*/
+#define ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_MEASURED_VALUE_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_MIN_MEASURED_VALUE_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+#define ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_MAX_MEASURED_VALUE_ATTRIBUTE_ID CCPU_TO_LE16(0x0002)
+
+/**
+ * \brief server define attributes macros
+*/
+#define ZCL_DEFINE_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_ATTRIBUTES(reportMin, reportMax) \
+ DEFINE_REPORTABLE_ATTRIBUTE(measuredValue, ZCL_READONLY_ATTRIBUTE, ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_MEASURED_VALUE_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID, reportMin, reportMax), \
+ DEFINE_ATTRIBUTE(minMeasuredValue, ZCL_READONLY_ATTRIBUTE, ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_MIN_MEASURED_VALUE_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(maxMeasuredValue, ZCL_READONLY_ATTRIBUTE, ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_MAX_MEASURED_VALUE_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID)
+
+#define ZCL_DEFINE_HUMIDITY_MEASUREMENT_CLUSTER_SERVER(clattributes) \
+ { \
+ .id = HUMIDITY_MEASUREMENT_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) (clattributes), \
+ .commandsAmount = ZCL_HUMIDITY_MEASUREMENT_CLUSTER_SERVER_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+#define ZCL_DEFINE_HUMIDITY_MEASUREMENT_CLUSTER_CLIENT() \
+ { \
+ .id = HUMIDITY_MEASUREMENT_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_HUMIDITY_MEASUREMENT_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = NULL, \
+ .commandsAmount = ZCL_HUMIDITY_MEASUREMENT_CLUSTER_CLIENT_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+typedef struct PACK {
+ struct PACK {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+ uint16_t reportableChange; //!<Reporting change field value
+ ZCL_ReportTime_t timeoutPeriod; //!<Timeout period field value
+ } measuredValue ;
+
+ struct PACK {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } minMeasuredValue ;
+
+ struct PACK {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } maxMeasuredValue ;
+} ZCL_HumidityMeasurementClusterAttributes_t ;
+END_PACK
+
+
+#endif /* _ZCLHUMIDITYMEASUREMENT_H_ */
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclIdentifyCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclIdentifyCluster.h
new file mode 100644
index 00000000..a1294c6a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclIdentifyCluster.h
@@ -0,0 +1,178 @@
+/***************************************************************************//**
+ \file zclIdentifyCluster.h
+
+ \brief
+ The header file describes the ZCL Identify Cluster and its interface
+
+ The file describes the types and interface of the ZCL Identify 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:
+ 11.03.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLIDENTIFYCLUSTER_H
+#define _ZCLIDENTIFYCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/**
+ * \brief Identify Server Cluster attributes amount.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 1
+
+/**
+ * \brief Identify Client Cluster attributes amount.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Identify Client Cluster commands amount.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_COMMANDS_AMOUNT 3
+
+/**
+ * \brief Identify Server Cluster attributes identifiers.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_IDENTIFY_TIME_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+
+/**
+ * \brief Identify Server Cluster commands identifiers.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_IDENTIFY_QUERY_RESPONSE_COMMAND_ID 0x00
+
+/**
+ * \brief Identify Client Cluster commands identifiers.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_IDENTIFY_COMMAND_ID 0x00
+#define ZCL_IDENTIFY_CLUSTER_IDENTIFY_QUERY_COMMAND_ID 0x01
+
+/*
+ *\brief ZCL Idetify Cluster server side attributes defining macros
+ */
+
+#define ZCL_DEFINE_IDENTIFY_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(identifyTime, ZCL_READWRITE_ATTRIBUTE, ZCL_IDENTIFY_CLUSTER_IDENTIFY_TIME_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID)
+
+/*
+ * \brief ZCL Identify Cluster commands defining macros
+ */
+
+#define IDENTIFY_CLUSTER_COMMANDS(identifyCommandInd, identifyQueryCommandInd, identifyQueryResponseCommandInd) \
+ DEFINE_COMMAND(identifyCommand, 0x00, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), identifyCommandInd), \
+ DEFINE_COMMAND(identifyQueryCommand, 0x01, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), identifyQueryCommandInd), \
+ DEFINE_COMMAND(identifyQueryResponseCommand, 0x00, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), identifyQueryResponseCommandInd)
+
+#define IDENTIFY_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = IDENTIFY_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_IDENTIFY_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_IDENTIFY_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+
+#define IDENTIFY_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = IDENTIFY_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_IDENTIFY_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_IDENTIFY_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+
+#define DEFINE_IDENTIFY_CLUSTER(cltype, clattributes, clcommands) IDENTIFY_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+BEGIN_PACK
+
+/**
+ * \brief Identify Command Payload format.
+*/
+typedef struct PACK
+{
+ uint16_t identifyTime;
+} ZCL_Identify_t;
+
+/**
+ * \brief Identify Query Response Payload format.
+*/
+
+typedef struct PACK
+{
+ uint16_t timeout;
+} ZCL_IdentifyQueryResponse_t;
+
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } identifyTime;
+} ZCL_IdentifyClusterAttributes_t;
+
+END_PACK
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*identifyCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_Identify_t *payload);
+ } identifyCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*identifyQueryCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } identifyQueryCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*identifyQueryResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_IdentifyQueryResponse_t *payload);
+ } identifyQueryResponseCommand;
+} ZCL_IdentifyClusterCommands_t;
+
+
+#endif
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclInt.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclInt.h
new file mode 100644
index 00000000..d984f38f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclInt.h
@@ -0,0 +1,46 @@
+/************************************************************************//**
+ \file zcl.h
+
+ \brief
+ The header file describes internal ZCL interface
+
+ The header file describes internal ZCL interface and types
+
+ \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:
+ 09.12.08 I. Fedina - Created.
+******************************************************************************/
+
+#ifndef _ZCLINT_H
+#define _ZCLINT_H
+
+#include <zcl.h>
+#include <clusters.h>
+
+BEGIN_PACK
+typedef struct PACK
+{
+ uint8_t status;
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t value[1];
+} ZclReadAttributeResp_t;
+
+typedef struct PACK
+{
+ uint8_t status;
+ ZCL_AttributeId_t id;
+} ZclWriteAttributeResp_t;
+END_PACK
+
+uint8_t zclGetSequenceNumber(Endpoint_t endpointId);
+ZclAttribute_t *zclGetNextAttribute(Endpoint_t endpoint, ClusterId_t clusterId, uint8_t direction, ZclAttribute_t *currentAttribute);
+
+#endif // _ZCL_INT_H
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclKeyEstablishmentCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclKeyEstablishmentCluster.h
new file mode 100644
index 00000000..4c9f843f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclKeyEstablishmentCluster.h
@@ -0,0 +1,529 @@
+/***************************************************************************//**
+ \file zclKeyEstablishmentCluster.h
+
+ \brief
+ The header file describes the ZCL Key Establishment Cluster and its interface
+
+ The file describes the types and interface of the ZCL Key Establishment 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:
+ 10.03.09 A. Potashov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLKEYESTABLISHMENTCLUSTER_H
+#define _ZCLKEYESTABLISHMENTCLUSTER_H
+
+/*!
+Attributes and commands necessary for managing secure communication between
+ZigBee devices.
+*/
+
+#ifdef _ZCL_SECURITY_
+#ifdef _CERTICOM_SECURITY_
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+#include <zclSecurityManager.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+#define ZCL_KE_INVALID_ENDPOINT APS_ZDO_ENDPOINT
+#define ZCL_KE_INVALID_SHORT_ADDRESS 0xffff
+#define ZCL_KE_INVALID_EXT_ADDRESS 0xffffffffffffffffLL
+
+
+//KE Cluster timeout settings
+#ifndef ZCL_KE_EPHEMERAL_DATA_GENERATE_TIME
+#define ZCL_KE_EPHEMERAL_DATA_GENERATE_TIME 0x10
+#endif
+
+#ifndef ZCL_KE_CONFIRM_KEY_GENERATE_TIME
+#define ZCL_KE_CONFIRM_KEY_GENERATE_TIME 0x10
+#endif
+
+//!This timeout (seconds) will be sent in Terminate KE Command
+#ifndef ZCL_KE_TERMINATE_KE_TIMEOUT
+#define ZCL_KE_TERMINATE_KE_TIMEOUT 50
+#endif
+
+//!This timeout (seconds) will be applied for commands receive wating with unspecified timeouts
+#ifndef ZCL_KE_TIMEOUT
+#define ZCL_KE_TIMEOUT 50
+#endif
+
+
+
+
+
+
+/***************************************************************************//**
+ \brief ZCL Key Establishment Cluster server side attributes amount
+*******************************************************************************/
+#define ZCL_KE_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 1
+
+/***************************************************************************//**
+ \brief ZCL Key Establishment Cluster client side attributes amount
+*******************************************************************************/
+#define ZCL_KE_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 1
+
+/***************************************************************************//**
+ \brief ZCL Key Establishment Cluster commands amount
+*******************************************************************************/
+#define ZCL_KE_CLUSTER_COMMANDS_AMOUNT 8
+
+//!Key Establishment Suite Attribute
+#define ZCL_KE_CLUSTER_SERVER_KEY_ESTABLISHMENT_SUITE_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+
+//!Key Establishment Suite Attribute
+#define ZCL_KE_CLUSTER_CLIENT_KEY_ESTABLISHMENT_SUITE_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+
+
+#define ZCL_KE_INITIATE_KEY_ESTABLISHMENT_REQUEST_COMMAND_ID 0x00
+#define ZCL_KE_EPHEMERAL_DATA_REQUEST_COMMAND_ID 0x01
+#define ZCL_KE_CONFIRM_KEY_DATA_REQUEST_COMMAND_ID 0x02
+#define ZCL_KE_TERMINATE_KEY_ESTABLISHMENT_COMMAND_ID 0x03
+
+#define ZCL_KE_INITIATE_KEY_ESTABLISHMENT_RESPONSE_COMMAND_ID 0x00
+#define ZCL_KE_EPHEMERAL_DATA_RESPONSE_COMMAND_ID 0x01
+#define ZCL_KE_CONFIRM_KEY_DATA_RESPONSE_COMMAND_ID 0x02
+
+
+#define ZCL_KE_CBKE_ECMQV_KEY_ESTABLISHMENT_SUITE_ID 0x0001
+
+
+/*******************************************************************************
+ Types section
+*******************************************************************************/
+
+/***************************************************************************//**
+ \brief ZCL Key Establishment Cluster server side attributes defining macros
+
+ This macros should be used for ZCL Key Establishment Cluster server side attributes defining.
+
+ \return None
+
+ \internal
+ //The typical usage is:
+ //Key Establishment Cluster server side related attributes
+ ZCL_EKClusterServerAttributes_t ekClusterServerAttributes = ZCL_DEFINE_EK_CLUSTER_SERVER_ATTRIBUTES();
+*******************************************************************************/
+#define ZCL_DEFINE_EK_CLUSTER_SERVER_ATTRIBUTES() \
+ {DEFINE_ATTRIBUTE(keyEstablishmentSuite, ZCL_READONLY_ATTRIBUTE, ZCL_KE_CLUSTER_SERVER_KEY_ESTABLISHMENT_SUITE_ATTRIBUTE_ID, ZCL_16BIT_ENUM_DATA_TYPE_ID)}
+
+
+/***************************************************************************//**
+ \brief ZCL Key Establishment Cluster client side attributes defining macros
+
+ This macros should be used for ZCL Key Establishment Cluster client side attributes defining.
+
+ \return None
+
+ \internal
+ //The typical usage is:
+ //Key Establishment Cluster client side related attributes
+ ZCL_EKClusterClientAttributes_t ekClusterClientAttributes = ZCL_DEFINE_EK_CLUSTER_CLIENT_ATTRIBUTES();
+*******************************************************************************/
+#define ZCL_DEFINE_EK_CLUSTER_CLIENT_ATTRIBUTES() \
+ {DEFINE_ATTRIBUTE(keyEstablishmentSuite, ZCL_READONLY_ATTRIBUTE, ZCL_KE_CLUSTER_CLIENT_KEY_ESTABLISHMENT_SUITE_ATTRIBUTE_ID, ZCL_16BIT_ENUM_DATA_TYPE_ID)}
+
+#define DEFINE_INITIATE_KEY_ESTABLISHMENT_REQUEST(initiateKeyEstablishmentReqInd) \
+ DEFINE_COMMAND(initiateKeyEstablishmentReq, ZCL_KE_INITIATE_KEY_ESTABLISHMENT_REQUEST_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ initiateKeyEstablishmentReqInd)
+
+#define DEFINE_INITIATE_KEY_ESTABLISHMENT_RESPONSE(initiateKeyEstablishmentRespInd) \
+ DEFINE_COMMAND(initiateKeyEstablishmentResp, ZCL_KE_INITIATE_KEY_ESTABLISHMENT_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ initiateKeyEstablishmentRespInd)
+
+#define DEFINE_EPHEMERAL_DATA_REQUEST(ephemeralDataReqInd) \
+ DEFINE_COMMAND(ephemeralDataReq, ZCL_KE_EPHEMERAL_DATA_REQUEST_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ ephemeralDataReqInd)
+
+#define DEFINE_EPHEMERAL_DATA_RESPONSE(ephemeralDataRespInd) \
+ DEFINE_COMMAND(ephemeralDataResp, ZCL_KE_EPHEMERAL_DATA_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ ephemeralDataRespInd)
+
+#define DEFINE_CONFIRM_KEY_DATA_REQUEST(confirmKeyDataReqInd) \
+ DEFINE_COMMAND(confirmKeyDataReq, ZCL_KE_CONFIRM_KEY_DATA_REQUEST_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ confirmKeyDataReqInd)
+
+#define DEFINE_CONFIRM_KEY_DATA_RESPONSE(confirmKeyDataRespInd) \
+ DEFINE_COMMAND(confirmKeyDataResp, ZCL_KE_CONFIRM_KEY_DATA_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ confirmKeyDataRespInd)
+
+#define DEFINE_TERMINATE_KEY_ESTABLISHMENT_SERVER_PART(terminateKeyEstablishmentReqIndServerPart) \
+ DEFINE_COMMAND(terminateKeyEstablishmentReqServerPart, ZCL_KE_TERMINATE_KEY_ESTABLISHMENT_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ terminateKeyEstablishmentReqIndServerPart)
+
+#define DEFINE_TERMINATE_KEY_ESTABLISHMENT_CLIENT_PART(terminateKeyEstablishmentReqIndClientPart) \
+ DEFINE_COMMAND(terminateKeyEstablishmentReqClientPart, ZCL_KE_TERMINATE_KEY_ESTABLISHMENT_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ terminateKeyEstablishmentReqIndClientPart)
+
+#define KE_CLUSTER_COMMANDS(initiateKeyEstablishmentReqInd, initiateKeyEstablishmentRespInd, \
+ ephemeralDataReqInd, ephemeralDataRespInd, confirmKeyDataReqInd, confirmKeyDataRespInd, \
+ terminateKeyEstablishmentReqIndServerPart, terminateKeyEstablishmentReqIndClientPart) \
+ DEFINE_INITIATE_KEY_ESTABLISHMENT_REQUEST(initiateKeyEstablishmentReqInd), \
+ DEFINE_INITIATE_KEY_ESTABLISHMENT_RESPONSE(initiateKeyEstablishmentRespInd), \
+ DEFINE_EPHEMERAL_DATA_REQUEST(ephemeralDataReqInd), \
+ DEFINE_EPHEMERAL_DATA_RESPONSE(ephemeralDataRespInd), \
+ DEFINE_CONFIRM_KEY_DATA_REQUEST(confirmKeyDataReqInd), \
+ DEFINE_CONFIRM_KEY_DATA_RESPONSE(confirmKeyDataRespInd), \
+ DEFINE_TERMINATE_KEY_ESTABLISHMENT_SERVER_PART(terminateKeyEstablishmentReqIndServerPart), \
+ DEFINE_TERMINATE_KEY_ESTABLISHMENT_CLIENT_PART(terminateKeyEstablishmentReqIndClientPart) \
+
+/***************************************************************************//**
+ \brief ZCL Key Establishment Cluster server side defining macros
+
+ This macros should be used with #ZCL_DEFINE_EK_CLUSTER_SERVER_ATTRIBUTES and
+ #ZCL_DEFINE_EK_CLUSTER_SERVER_COMMANDS for ZCL Key Establishment Cluster server
+ side defining.
+
+ \param attributes - pointer to cluster server attributes (ZCL_KEClusterServerAttributes_t)
+ \param commands - pointer to cluster server commands (ZCL_KEServerCommands_t)
+
+ \return None
+
+ \internal
+ //The typical code is:
+ //Key Establishment Cluster server side related attributes and commands
+ ZCL_KEClusterServerAttributes_t keClusterServerAttributes = ZCL_DEFINE_EK_CLUSTER_SERVER_ATTRIBUTES();
+ ZCL_KEClusterServerCommands_t keClusterServerCommands = ZCL_DEFINE_EK_CLUSTER_SERVER_COMMANDS(handler1, handler2, handler3, handlerv);
+ ZCL_Cluster_t ekClusterServer = ZCL_DEFINE_KE_CLUSTER_SERVER(&keClusterServerAttributes, &keClusterServerCommands);
+*******************************************************************************/
+#define ZCL_DEFINE_KE_CLUSTER_SERVER(clattributes, clcommands) \
+ { \
+ .id = ZCL_KEY_ESTABLISHMENT_CLUSTER_ID, \
+ .options = \
+ { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY, \
+ .reserved = 0, \
+ }, \
+ .attributesAmount = ZCL_KE_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) clattributes, \
+ .commandsAmount = ZCL_KE_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *) clcommands \
+ }
+
+
+
+/***************************************************************************//**
+ \brief ZCL Key Establishment Cluster client side defining macros
+
+ This macros should be used with #ZCL_DEFINE_EK_CLUSTER_CLIENT_ATTRIBUTES and
+ #ZCL_DEFINE_EK_CLUSTER_CLIENT_COMMANDS for ZCL Key Establishment Cluster client
+ side defining.
+
+ \param attributes - pointer to cluster client attributes (ZCL_KEClusterClientAttributes_t)
+ \param commands - pointer to cluster client commands (ZCL_KEClientCommands_t)
+
+ \return None
+
+ \internal
+ //The typical code is:
+ //Key Establishment Cluster client side related attributes and commands
+ ZCL_KEClusterClientAttributes_t keClusterClientAttributes = ZCL_DEFINE_EK_CLUSTER_CLIENT_ATTRIBUTES();
+ ZCL_KEClusterClientCommands_t keClusterClientCommands = ZCL_DEFINE_EK_CLUSTER_CLIENT_COMMANDS(handler1, handler2, handler3, handlerv);
+ ZCL_Cluster_t ekClusterClient = ZCL_DEFINE_KE_CLUSTER_Client(&keClusterClientAttributes, &keClusterClientCommands);
+*******************************************************************************/
+#define ZCL_DEFINE_KE_CLUSTER_CLIENT(clattributes, clcommands) \
+ { \
+ .id = ZCL_KEY_ESTABLISHMENT_CLUSTER_ID, \
+ .options = \
+ { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY, \
+ .reserved = 0, \
+ }, \
+ .attributesAmount = ZCL_KE_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) clattributes, \
+ .commandsAmount = ZCL_KE_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *) clcommands \
+ }
+
+BEGIN_PACK
+/***************************************************************************//**
+ \brief
+ ZCL Key Establishment Cluster server side attributes
+*******************************************************************************/
+typedef struct PACK
+{
+ //!Information attribute set (Id == 0x00)
+
+ /*!KeyEstablishmentSuite attribute (Read only, M)
+ The KeyEstablishmentSuite attribute is 16-bits in length and specifies all the
+ cryptographic schemes for key establishment on the device. A device shall set the
+ corresponding bit to 1 for every cryptographic scheme that is supports. All other
+ cryptographic schemes and reserved bits shall be set to 0.
+
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0000, #ZCL_KE_CLUSTER_SERVER_KEY_ESTABLISHMENT_SUITE_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (16-bit enumeration, #ZZCL_16BIT_ENUM_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint16_t value; //!<Attribute value (default 0x0000)
+ } keyEstablishmentSuite;
+} ZCL_KEClusterServerAttributes_t;
+END_PACK
+
+BEGIN_PACK
+/***************************************************************************//**
+ \brief
+ ZCL Key Establishment Cluster client side attributes
+*******************************************************************************/
+typedef struct PACK
+{
+ //!Information attribute set (Id == 0x00)
+
+ /*!KeyEstablishmentSuite attribute (Read only, M)
+ The KeyEstablishmentSuite attribute is 16-bits in length and specifies all the
+ cryptographic schemes for key establishment on the device. A device shall set the
+ corresponding bit to 1 for every cryptographic scheme that is supports. All other
+ cryptographic schemes and reserved bits shall be set to 0.
+
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0000, #ZCL_KE_CLUSTER_CLIENT_KEY_ESTABLISHMENT_SUITE_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (16-bit enumeration, #ZZCL_16BIT_ENUM_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint16_t value; //!<Attribute value (default 0x0000)
+ } keyEstablishmentSuite;
+} ZCL_KEClusterClientAttributes_t;
+END_PACK
+
+
+BEGIN_PACK
+
+/***************************************************************************//**
+ \brief
+ ZCL Initiate Key Establishment command
+*******************************************************************************/
+typedef struct PACK
+{
+ /*!This will be type of KeyEstablishment that the initiator is requesting for
+ the Key Establishment Cluster. For CBKE-ECMQV this will be 0x0001.
+ */
+ uint16_t keyEstablishmentSuite;
+ /*!This value indicates approximately how long the initiator device will take
+ in seconds to generate the Ephemeral Data Request command. The valid range is
+ 0x00 to 0xFE.
+ */
+ uint8_t ephemeralDataGenerateTime;
+ /*!This value indicates approximately how long the initiator device will take
+ in seconds to generate the Confirm Key Request command. The valid range is
+ 0x00 to 0xFE.
+ */
+ uint8_t confirmKeyGenerateTime;
+ /*!For keyEstablishmentSuite = 0x0001 (CBKE), the identify field shall be the
+ block of octets containing the implicit certificate CERTU.
+ */
+ uint8_t identify[48];
+} ZCL_InitiateKeyEstablishmentCommand_t;
+
+
+/***************************************************************************//**
+ \brief
+ ZCL Confirm Key Request and ZCL Confirm Key Response commands
+*******************************************************************************/
+typedef struct PACK
+{
+ /*!Secure Message Authentication Code field which shall be the octet-string
+ representation of MACU or MACV.
+ */
+ uint8_t mac[16];
+} ZCL_ConfirmKeyCommand_t;
+
+
+typedef enum
+{
+ //0x00 - Reserved
+
+ /*!The Issuer field whithin the key establishment partner's certificate is
+ unknown to the sending device, and it has terminated the key establishment.
+ */
+ ZCL_TKE_UNKNOWN_ISSUER_STATUS = 0x01,
+ /*!The device could not confirm that is shares the same key with the
+ corresponding device and has terminated the key establishment.
+ */
+ ZCL_TKE_BAD_KEY_CONFIRM_STATUS = 0x02,
+ /*!The device received a bad messagefrom the corresponding device (e.g. message
+ whith bad data, an out of sequence number, or a message with a bad format)
+ and has terminated the key establishment.
+ */
+ ZCL_TKE_BAD_MESSAGE_STATUS = 0x03,
+ /*!The device does not currently have the internal resources necessary to
+ perform key establishment and has terminated the exchange.
+ */
+ ZCL_TKE_NO_RESOURCES_STATUS = 0x04,
+ /*!The device does not support the specified key establishment suite in the
+ partner's Initiate Key Establishment message.
+ */
+ ZCL_TKE_UNSUPPORTED_SUITE_STATUS = 0x05,
+
+ /*For internal use only*/
+ ZCL_TKE_NO_STATUS = 0xff
+ //0x06 - 0xFF - Reserved
+} ZCL_TKEStatus_t;
+
+
+/***************************************************************************//**
+ \brief
+ ZCL Terminate Key Establishment command
+*******************************************************************************/
+typedef struct PACK
+{
+ /*!
+ Status code indicates the key establishment termination reason.
+ #ZCL_TEKStatus_t values should be used.
+ */
+ uint8_t statusCode;
+ /*!This value indicates the minimum amount of time in seconds the initiator
+ device should wait befor trying to initiate key establishment again. The valid
+ range is 0x00 to 0xFE.
+ */
+ uint8_t waitTime;
+ /*!This value will be set the value of the KeyEstablishmentSuite attribute.
+ It indicates the list of key exchange methods that the device supports.
+ */
+ uint16_t keyEstablishmentSuite;
+} ZCL_TerminateKeyEstablishmentCommand_t;
+
+
+/***************************************************************************//**
+ \brief
+ ZCL Ephemeral Data Request and ZCL Ephemeral Data Request commands
+
+ The Ephemeral Data Request command allows a device to communicate its
+ ephemeral data to another device and request that the device send back
+ its own ephemeral data.
+
+ The Ephemeral Data Response command allows a device to communicate its
+ ephemeral data to another device and request that the device send back
+ its own ephemeral data.
+*******************************************************************************/
+typedef struct PACK
+{
+ /*!
+ Ephemeral Data (QEU, QEV)
+ */
+ uint8_t data[22];
+} ZCL_EphemeralDataCommand_t;
+
+END_PACK
+
+/***************************************************************************//**
+ \brief
+ ZCL Key Establishment Cluster Commands
+*******************************************************************************/
+typedef struct
+{
+ //!Initiate Key Establishment Request Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*indHandler)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_InitiateKeyEstablishmentCommand_t *payload);
+ } initiateKeyEstablishmentReq;
+
+ //!Initiate Key Establishment Response Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*indHandler)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_InitiateKeyEstablishmentCommand_t *payload);
+ } initiateKeyEstablishmentResp;
+
+ //!Ephemeral Data Request Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*indHandler)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_EphemeralDataCommand_t *payload);
+ } ephemeralDataReq;
+
+ //!Ephemeral Data Response Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*indHandler)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_EphemeralDataCommand_t *payload);
+ } ephemeralDataResp;
+
+ //!Confirm Key Data Request Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*indHandler)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ConfirmKeyCommand_t *payload);
+ } confirmKeyDataReq;
+
+ //!Confirm Key Data Response Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*indHandler)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ConfirmKeyCommand_t *payload);
+ } confirmKeyDataResp;
+
+ //!Terminate Key Establishment Command descriptor (server part)
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*indHandler)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_TerminateKeyEstablishmentCommand_t *payload);
+ } terminateKeyEstablishmentReqServerPart;
+
+ //!Terminate Key Establishment Command descriptor (client part)
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*indHandler)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_TerminateKeyEstablishmentCommand_t *payload);
+ } terminateKeyEstablishmentReqClientPart;
+} ZCL_KEClusterCommands_t;
+
+/***************************************************************************//**
+ \brief Finds KE Certificate descriptor for the device with particular address
+
+ \param subject - device's address which certificate is looking for
+ \return pointer to KE Certificate descriptor if it was found, NULL otherwise
+*******************************************************************************/
+ZclCertificate_t *keGetCertificate(ExtAddr_t subject);
+
+/*************************************************************************************//**
+\brief Return server or client cluster descriptor for external use.
+
+Use this function if you want register KE cluster on endpoint.
+
+\param[in] server - If true returns server descriptor otherwise client descriptor.
+******************************************************************************************/
+ZCL_Cluster_t* keGetClusterDescriptor(uint8_t server);
+
+#endif //#ifdef _CERTICOM_SECURITY_
+#endif //#ifdef _ZCL_SECURITY_
+#endif //#ifndef _ZCLKEYESTABLISHMENTCLUSTER_H
+
+//eof zclKeyEstablishmentCluster.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclLevelControlCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclLevelControlCluster.h
new file mode 100644
index 00000000..827ce9d7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclLevelControlCluster.h
@@ -0,0 +1,286 @@
+/***************************************************************************//**
+ \file zclLevelControlCluster.h
+
+ \brief
+ Interface and types of Level Control 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:
+ 22.06.10 D.Loskutnikov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLLEVELCONTROLCLUSTER_H
+#define _ZCLLEVELCONTROLCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/**
+ * \brief Amount of Level Control cluster server's attributes
+*/
+#define ZCL_LEVEL_CONTROL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 1
+
+/**
+ * \brief Client doesn't have attributes.
+*/
+#define ZCL_LEVEL_CONTROL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Level Control Cluster commands amount
+*/
+
+#define ZCL_LEVEL_CONTROL_CLUSTER_COMMANDS_AMOUNT 8
+
+/**
+ * \brief Level Control Cluster server's attributes identifiers
+*/
+
+#define ZCL_LEVEL_CONTROL_CLUSTER_CURRENT_LEVEL_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_LEVEL_CONTROL_CLUSTER_REMAINING_TIME_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+#define ZCL_LEVEL_CONTROL_CLUSTER_ON_OFF_TRANSITION_TIME_ATTRIBUTE_ID CCPU_TO_LE16(0x0010)
+#define ZCL_LEVEL_CONTROL_CLUSTER_ON_LEVEL_ATTRIBUTE_ID CCPU_TO_LE16(0x0011)
+
+/**
+ * \brief On/Off Cluster client's command identifiers
+*/
+
+#define ZCL_LEVEL_CONTROL_CLUSTER_MOVE_TO_LEVEL_COMMAND_ID 0x00
+#define ZCL_LEVEL_CONTROL_CLUSTER_MOVE_COMMAND_ID 0x01
+#define ZCL_LEVEL_CONTROL_CLUSTER_STEP_COMMAND_ID 0x02
+#define ZCL_LEVEL_CONTROL_CLUSTER_STOP_COMMAND_ID 0x03
+#define ZCL_LEVEL_CONTROL_CLUSTER_MOVE_TO_LEVEL_W_ONOFF_COMMAND_ID 0x04
+#define ZCL_LEVEL_CONTROL_CLUSTER_MOVE_W_ONOFF_COMMAND_ID 0x05
+#define ZCL_LEVEL_CONTROL_CLUSTER_STEP_W_ONOFF_COMMAND_ID 0x06
+#define ZCL_LEVEL_CONTROL_CLUSTER_STOP_W_ONOFF_COMMAND_ID 0x07
+
+/**
+ * \brief Level Control Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_LEVEL_CONTROL_CLUSTER_SERVER_MANDATORY_ATTRIBUTES(min, max) \
+ DEFINE_REPORTABLE_ATTRIBUTE(currentLevel, ZCL_READONLY_ATTRIBUTE, ZCL_LEVEL_CONTROL_CLUSTER_CURRENT_LEVEL_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID, min, max)
+
+#define ZCL_DEFINE_LEVEL_CONTROL_CLUSTER_SERVER_OPTIONAL_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(remainingTime, ZCL_READONLY_ATTRIBUTE, ZCL_LEVEL_CONTROL_CLUSTER_REMAINING_TIME_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(onOffTransitionTime, ZCL_READWRITE_ATTRIBUTE, ZCL_LEVEL_CONTROL_CLUSTER_ON_OFF_TRANSITION_TIME_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(onLevel, ZCL_READWRITE_ATTRIBUTE, ZCL_LEVEL_CONTROL_CLUSTER_ON_LEVEL_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID)
+
+
+/**
+ * \brief Level Control Cluster define commands macros
+*/
+
+#define ZCL_DEFINE_LEVEL_CONTROL_CLUSTER_COMMANDS(moveToLevelCommandInd,\
+ moveCommandInd,\
+ stepCommandInd,\
+ stopCommandInd,\
+ moveToLevelWOnOffCommandInd,\
+ moveWOnOffCommandInd,\
+ stepWOnOffCommandInd,\
+ stopWOnOffCommandInd)\
+ DEFINE_COMMAND(moveToLevelCommand, ZCL_LEVEL_CONTROL_CLUSTER_MOVE_TO_LEVEL_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ moveToLevelCommandInd), \
+ DEFINE_COMMAND(moveCommand, ZCL_LEVEL_CONTROL_CLUSTER_MOVE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ moveCommandInd), \
+ DEFINE_COMMAND(stepCommand, ZCL_LEVEL_CONTROL_CLUSTER_STEP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ stepCommandInd), \
+ DEFINE_COMMAND(stopCommand, ZCL_LEVEL_CONTROL_CLUSTER_STOP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ stopCommandInd), \
+ DEFINE_COMMAND(moveToLevelWOnOffCommand, ZCL_LEVEL_CONTROL_CLUSTER_MOVE_TO_LEVEL_W_ONOFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ moveToLevelWOnOffCommandInd), \
+ DEFINE_COMMAND(moveWOnOffCommand, ZCL_LEVEL_CONTROL_CLUSTER_MOVE_W_ONOFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ moveWOnOffCommandInd), \
+ DEFINE_COMMAND(stepWOnOffCommand, ZCL_LEVEL_CONTROL_CLUSTER_STEP_W_ONOFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ stepWOnOffCommandInd), \
+ DEFINE_COMMAND(stopWOnOffCommand, ZCL_LEVEL_CONTROL_CLUSTER_STOP_W_ONOFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ stopWOnOffCommandInd)
+
+/**
+ * \brief Level Control Cluster definition macros
+*/
+
+#define LEVEL_CONTROL_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = LEVEL_CONTROL_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_LEVEL_CONTROL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_LEVEL_CONTROL_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define LEVEL_CONTROL_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = LEVEL_CONTROL_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_LEVEL_CONTROL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_LEVEL_CONTROL_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_LEVEL_CONTROL_CLUSTER(cltype, clattributes, clcommands) \
+ LEVEL_CONTROL_CLUSTER_##cltype(clattributes, clcommands)
+
+#define DEFINE_LEVEL_CONTROL_CLUSTER_EXTENSION_FIELD_SET(value) \
+ .clusterId = LEVEL_CONTROL_CLUSTER_ID, \
+ .length = sizeof(uint8_t), \
+ .currentLevel = value
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+
+/**
+ * \brief Move To Level Command Payload format.
+ */
+typedef struct PACK
+{
+ uint8_t level;
+ uint16_t transitionTime;
+} ZCL_MoveToLevel_t;
+
+/**
+ * \brief Move Command Payload format.
+ */
+typedef struct PACK
+{
+ uint8_t moveMode;
+ uint8_t rate;
+} ZCL_Move_t;
+
+/**
+ * \brief Step Command Payload format.
+ */
+typedef struct PACK
+{
+ uint8_t stepMode;
+ uint8_t stepSize;
+ uint16_t transitionTime;
+} ZCL_Step_t;
+
+/**
+ * \brief Level Control Cluster server's attributes
+*/
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+ uint8_t reportableChange; //!<Reporting change field value
+ ZCL_ReportTime_t timeoutPeriod; //!<Timeout period field value
+ } currentLevel;
+} ZCL_LevelControlClusterServerAttributes_t;
+
+/**
+ * \brief Level Control Cluster extension field set
+ */
+typedef struct PACK
+{
+ uint16_t clusterId;
+ uint8_t length;
+ uint8_t currentLevel;
+} ZCL_LevelControlSceneExtensionFields_t;
+
+END_PACK
+
+/**
+ * \brief Level Control Cluster clients's commands.
+*/
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*moveToLevelCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } moveToLevelCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*moveCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } moveCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*stepCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } stepCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*stopCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } stopCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*moveToLevelWOnOffCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } moveToLevelWOnOffCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*moveWOnOffCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } moveWOnOffCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*stepWOnOffCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } stepWOnOffCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*stopWOnOffCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } stopWOnOffCommand;
+} ZCL_LevelControlClusterCommands_t;
+
+#endif /* _ZCLLEVELCONTROLCLUSTER_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMem.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMem.h
new file mode 100644
index 00000000..01321f26
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMem.h
@@ -0,0 +1,62 @@
+/************************************************************************//**
+ \file zclMem.h
+
+ \brief
+ The header file describes the ZCL memory structure
+
+ The file describes the structure of ZCL memory
+
+ \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:
+ 03.12.08 I. Fedina - Created.
+******************************************************************************/
+
+#ifndef _ZCLMEM_H
+#define _ZCLMEM_H
+
+#include <queue.h>
+#include <appTimer.h>
+
+typedef enum
+{
+ ZCL_IDLE_STATE,
+ ZCL_REQUEST_STATE,
+ ZCL_WAITING_FOR_CONFIRM_STATE,
+ ZCL_WAITING_FOR_RESPONSE_STATE,
+ ZCL_CONFIRM_STATE,
+} ZclState_t;
+
+
+/*
+ * Describes ZCL memory structure
+ * */
+typedef struct
+{
+ ZclState_t state;
+ QueueDescriptor_t requestQueue;
+ uint8_t *request;
+ HAL_AppTimer_t waitTimer;
+ HAL_AppTimer_t reportTimer;
+} ZclMem_t;
+
+/*
+ * ZCL memory global object
+ * */
+extern ZclMem_t zclMem;
+
+/*
+ * Function returns point to ZCL memory object
+ * */
+static inline ZclMem_t * zclMemReq()
+{
+ return ((ZclMem_t *)&zclMem);
+}
+
+#endif // _ZCLMEM_H
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMemoryManager.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMemoryManager.h
new file mode 100644
index 00000000..46017dc4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMemoryManager.h
@@ -0,0 +1,90 @@
+/************************************************************************//**
+ \file zclMemoryManager.h
+
+ \brief
+ The header file describes the ZCL Memory Manager interface
+
+ \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 _ZCLMEMORYMANAGER_H
+#define _ZCLMEMORYMANAGER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <aps.h>
+#include <appFramework.h>
+#include <macAddr.h>
+#include <zcl.h>
+#include <dbg.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef union
+{
+ APS_DataReq_t apsDataReq;
+ APS_DataInd_t apsDataInd;
+} ZclMmPrimitive_t;
+
+typedef struct
+{
+ TOP_GUARD
+ uint8_t header[APS_ASDU_OFFSET]; // Auxiliary header (required by stack)
+ uint8_t asdu[ZCL_MAX_ASDU_SIZE]; // ASDU content
+#if (APS_AFFIX_LENGTH - APS_ASDU_OFFSET)
+ uint8_t footer[APS_AFFIX_LENGTH - APS_ASDU_OFFSET]; //Auxiliary footer (required by stack)
+#endif
+ BOTTOM_GUARD
+} ZclMmFrame_t;
+
+typedef enum
+{
+ ZCL_MM_BUFFER_FREE = 0x00,
+ ZCL_MM_BUFFER_BUSY = 0x01
+} ZclMmBufferBusy_t;
+
+typedef struct
+{
+ ZclMmPrimitive_t primitive;
+ ZclMmFrame_t frame;
+} ZclMmBuffer_t;
+
+typedef struct
+{
+ uint8_t busy; //ZclMmBufferBusy_t should be used
+ ZclMmBuffer_t buf;
+} ZclMmBufferDescriptor_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/*************************************************************************//**
+\brief Looks for and return free zcl memory buffer
+
+\return pointer to memory buffer or NULL if there is no free buffer.
+*****************************************************************************/
+ZclMmBuffer_t *zclMmGetMem(void);
+
+/*************************************************************************//**
+\brief Makes free zcl busy buffer
+
+\param[in] mem - pointer to used zcl buffer
+*****************************************************************************/
+void zclMmFreeMem(ZclMmBuffer_t *mem);
+
+#endif //#ifndef _ZCLMEMORYMANAGER_H
+
+
+//eof zclMemoryManager.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMessagingCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMessagingCluster.h
new file mode 100644
index 00000000..4e0e11cb
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclMessagingCluster.h
@@ -0,0 +1,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
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOTAUCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOTAUCluster.h
new file mode 100644
index 00000000..32b0b9d0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOTAUCluster.h
@@ -0,0 +1,564 @@
+/**************************************************************************//**
+ \file zclOTAUCluster.h
+
+ \brief The header file describes the OTAU cluster interface.
+ ZigBee Document 095264r17.
+ Revision 17 Version 0.7 March 14, 2010
+
+ \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:
+ 15.01.10 A. Khromykh - Created.
+*******************************************************************************/
+#ifndef _ZCLOTAUCLUSTER_H
+#define _ZCLOTAUCLUSTER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zcl.h>
+#include <clusters.h>
+#include <ofdExtMemory.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+//#define _OTAU_DEBUG_
+
+/***************************************************************************//**
+ \brief ZCL OTAU Cluster atrebutes
+*******************************************************************************/
+#define ZCL_OTAU_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 0
+#define ZCL_OTAU_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 2
+
+/***************************************************************************//**
+ \brief ZCL OTAU Cluster commands amount
+*******************************************************************************/
+#define ZCL_OTAU_CLUSTER_COMMANDS_AMOUNT 7
+
+//!ZCL OTAU Cluster client side attributes id
+#define ZCL_OTAU_CLUSTER_CLIENT_UPGRADE_SERVER_ID 0x0000
+#define ZCL_OTAU_CLUSTER_CLIENT_IMAGE_UPGRADE_STATUS_ID 0x0006
+
+#define DEFINE_OTAU_CLIENT_ATTRIBUTES \
+ DEFINE_ATTRIBUTE(upgradeServerIEEEAddr, ZCL_READONLY_ATTRIBUTE, ZCL_OTAU_CLUSTER_CLIENT_UPGRADE_SERVER_ID, ZCL_IEEE_ADDRESS_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(imageUpgradeStatus, ZCL_READONLY_ATTRIBUTE, ZCL_OTAU_CLUSTER_CLIENT_IMAGE_UPGRADE_STATUS_ID, ZCL_8BIT_ENUM_DATA_TYPE_ID)
+
+#define OTAU_HEADER_STRING_SIZE 32
+
+// OTAU commands
+// list of commands id
+#define QUERY_NEXT_IMAGE_REQUEST_ID 0x01
+#define QUERY_NEXT_IMAGE_RESPONSE_ID 0x02
+#define IMAGE_BLOCK_REQUEST_ID 0x03
+#define IMAGE_PAGE_REQUEST_ID 0x04
+#define IMAGE_BLOCK_RESPONSE_ID 0x05
+#define UPGRADE_END_REQUEST_ID 0x06
+#define UPGRADE_END_RESPONSE_ID 0x07
+
+#define DEFINE_QUERY_NEXT_IMAGE_REQUEST(queryNextImageReqInd) \
+ DEFINE_COMMAND(queryNextImageReq, QUERY_NEXT_IMAGE_REQUEST_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ queryNextImageReqInd)
+
+#define DEFINE_QUERY_NEXT_IMAGE_RESPONSE(queryNextImageRespInd) \
+ DEFINE_COMMAND(queryNextImageResp, QUERY_NEXT_IMAGE_RESPONSE_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ queryNextImageRespInd)
+
+#define DEFINE_IMAGE_BLOCK_REQUEST(imageBlockReqInd) \
+ DEFINE_COMMAND(imageBlockReq, IMAGE_BLOCK_REQUEST_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ imageBlockReqInd)
+
+#define DEFINE_IMAGE_PAGE_REQUEST(imagePageReqInd) \
+ DEFINE_COMMAND(imagePageReq, IMAGE_PAGE_REQUEST_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ imagePageReqInd)
+
+#define DEFINE_IMAGE_BLOCK_RESPONSE(imageBlockRespInd) \
+ DEFINE_COMMAND(imageBlockResp, IMAGE_BLOCK_RESPONSE_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ imageBlockRespInd)
+
+#define DEFINE_UPGRADE_END_REQUEST(upgradeEndReqInd) \
+ DEFINE_COMMAND(upgradeEndReq, UPGRADE_END_REQUEST_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ upgradeEndReqInd)
+
+#define DEFINE_UPGRADE_END_RESPONSE(upgradeEndRespInd) \
+ DEFINE_COMMAND(upgradeEndResp, UPGRADE_END_RESPONSE_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ upgradeEndRespInd)
+
+#define OTAU_COMMANDS(queryNextImageReqInd, queryNextImageRespInd, imageBlockReqInd, imagePageReqInd, \
+ imageBlockRespInd, upgradeEndReqInd, upgradeEndRespInd) \
+ DEFINE_QUERY_NEXT_IMAGE_REQUEST(queryNextImageReqInd), \
+ DEFINE_QUERY_NEXT_IMAGE_RESPONSE(queryNextImageRespInd), \
+ DEFINE_IMAGE_BLOCK_REQUEST(imageBlockReqInd), \
+ DEFINE_IMAGE_PAGE_REQUEST(imagePageReqInd), \
+ DEFINE_IMAGE_BLOCK_RESPONSE(imageBlockRespInd), \
+ DEFINE_UPGRADE_END_REQUEST(upgradeEndReqInd), \
+ DEFINE_UPGRADE_END_RESPONSE(upgradeEndRespInd)
+
+/***************************************************************************//**
+ \brief ZCL OTAU Cluster server side defining macros
+
+ \param attributes - pointer to cluster server attributes (ZCL_OtauClusterClientAttributes_t)
+ or NULL if there are no attributes
+ \param clcommands - pointer to cluster server commands
+ or NULL if there are no commands
+
+ \return None
+*******************************************************************************/
+#define OTAU_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = OTAU_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_DEFAULT_CLUSTER_SECURITY, \
+ .reserved = 0}, \
+ .attributesAmount = ZCL_OTAU_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) clattributes, \
+ .commandsAmount = ZCL_OTAU_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *) clcommands \
+ }
+
+/***************************************************************************//**
+ \brief ZCL OTAU Cluster client side defining macros
+
+ \param attributes - pointer to cluster client attributes (ZCL_OtauClusterClientAttributes_t)
+ or NULL if there are no attributes
+ \param clcommands - pointer to cluster client commands
+ or NULL if there are no commands
+
+ \return None
+*******************************************************************************/
+#define OTAU_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = OTAU_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_DEFAULT_CLUSTER_SECURITY, \
+ .reserved = 0}, \
+ .attributesAmount = ZCL_OTAU_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) clattributes, \
+ .commandsAmount = ZCL_OTAU_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *) clcommands \
+ }
+
+#define DEFINE_OTAU_CLUSTER(cltype, clattributes, clcommands) OTAU_CLUSTER_##cltype(clattributes, clcommands)
+/*******************************************************************************
+ Types section
+*******************************************************************************/
+typedef uint8_t OtauHeaderString_t[OTAU_HEADER_STRING_SIZE];
+
+typedef enum PACK
+{
+ OTAU_SERVER_HAS_BEEN_FOUND,
+ OTAU_SERVER_HAS_NOT_BEEN_FOUND,
+ OTAU_SERVER_HAS_BEEN_LOST,
+ OTAU_OFD_DRIVER_ERROR,
+ OTAU_SERVER_RECEIVED_MALFORMED_COMMAND,
+ OTAU_SERVER_NO_IMAGE_AVAILABLE,
+ OTAU_SERVER_RECEIVED_UNSUPPORTED_COMMAND,
+ OTAU_SERVER_RECEIVED_UNKNOWN_STATUS,
+ OTAU_SERVER_IS_NOT_AUTHORIZED_TO_UPDATE,
+ OTAU_DOWNLOAD_STARTED,
+ OTAU_DOWNLOAD_ABORTED,
+ OTAU_DOWNLOAD_FINISHED,
+ OTAU_DEVICE_SHALL_CHANGE_IMAGE,
+ OTAU_ISD_IMAGE_CACHE_IS_FOUND,
+ OTAU_ISD_HARDWARE_FAULT,
+ OTAU_ISD_COMMUNICATION_LOST,
+ OTAU_MAX_MESSAGE_NUMBER
+} ZCL_OtauAction_t;
+
+typedef void (* ZCL_OtauStatInd_t)(ZCL_OtauAction_t action);
+
+typedef enum
+{
+ OTAU_ZB_STACK_VERSION_2006 = 0x0000,
+ OTAU_ZB_STACK_VERSION_2007 = 0x0001,
+ OTAU_ZB_STACK_VERSION_PRO = 0x0002,
+ OTAU_ZB_STACK_VERSION_IP = 0x0003,
+ OTAU_FAKE_VERSION = 0xFFFF
+} ZCL_OtauZigbeeStackVersion_t;
+
+typedef enum
+{
+ OTAU_SPECIFIC_IMAGE_TYPE = 0x0000,
+ OTAU_SECURITY_CREDENTIAL_TYPE = 0xFFC0,
+ OTAU_CONFIGURATION_TYPE = 0xFFC1,
+ OTAU_LOG_TYPE = 0xFFC2,
+ OTAU_WILD_CARD_TYPE = 0xFFFF
+} ZCL_OtauImageType_t;
+
+typedef enum
+{
+ OTAU_UPGRADE_IMAGE = 0x0000,
+ OTAU_ECDSA_SIGNATURE = 0x0001,
+ OTAU_ECDSA_SIGNING_CERTIFICATE = 0x0002,
+ OTAU_FAKE_NUMBER = 0xFFFF
+} ZCL_OtauTagID_t;
+
+BEGIN_PACK
+typedef enum PACK
+{
+ OTAU_NORMAL,
+ OTAU_DOWNLOAD_IN_PROGRESS,
+ OTAU_DOWNLOAD_COMPLETE,
+ OTAU_WAITING_TO_UPGRADE,
+ OTAU_COUNT_DOWN,
+ OTAU_WAIT_FOR_MORE
+} ZCL_ImageUpdateStatus_t;
+
+typedef union PACK
+{
+ uint16_t memAlloc;
+ struct PACK
+ {
+ uint16_t securityCredentialVersionPresent : 1;
+ uint16_t deviceSpecificFile : 1;
+ uint16_t hardwareVersionPresent : 1;
+ uint16_t reserved : 13;
+ };
+} ZCL_OtauHeaderFieldControl_t;
+
+typedef struct PACK
+{
+ ZCL_OtauTagID_t tagID;
+ uint32_t lengthField;
+} ZCL_OtauSubElementHeader_t;
+
+typedef union PACK
+{
+ uint32_t memAlloc;
+ struct PACK
+ {
+ uint8_t appRelease;
+ uint8_t appBuild;
+ uint8_t stackRelease;
+ uint8_t stackBuild;
+ };
+} ZCL_OtauFirmwareVersion_t;
+
+/***************************************************************************//**
+ \brief
+ ZCL OTAU upgrade image header
+*******************************************************************************/
+typedef struct PACK
+{
+ uint32_t magicNumber;
+ uint16_t headerVersion;
+ uint16_t headerLength;
+ ZCL_OtauHeaderFieldControl_t fieldControl;
+ uint16_t manufacturerId;
+ uint16_t imageType;
+ ZCL_OtauFirmwareVersion_t firmwareVersion;
+ ZCL_OtauZigbeeStackVersion_t zigbeeStackVersion;
+ OtauHeaderString_t headerString;
+ uint32_t totalImageSize;
+} ZCL_OtauUpgradeImageHeader_t;
+
+/***************************************************************************//**
+ \brief
+ ZCL OTAU Cluster attributes.
+ Currently, all attributes are client side attributes (only stored on the client).
+*******************************************************************************/
+typedef struct PACK
+{
+ /*!
+ \brief The attribute is used to store the IEEE address of the upgrade server
+ resulted from the discovery of the upgrade server's identity. If the value is set
+ to a non-zero value and corresponds to an IEEE address of a device that is no longer
+ accessible, a device may choose to discover a new Upgrade Server depending on its own
+ security policies. The attribute is mandatory because it serves as a placeholder in a case
+ where the client is programmed, during manufacturing time, its upgrade server ID.
+ In addition, the attribute is used to identify the current upgrade server the client is using
+ in a case where there are multiple upgrade servers in the network. The attribute is also helpful
+ in a case when a client has temporarily lost connection to the network (for example, via a reset
+ or a rejoin), it shall try to rediscover the upgrade server via network address discovery using
+ the IEEE address stored in the attribute. By default the value is 0xffffffffffffffff, which is
+ an invalid IEEE address. The attribute is a client-side attribute and stored on the client.
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0000)
+ uint8_t type; //!<Attribute type (ExtAddr_t - 64-bit) (typeId = 0xf0, #ZCL_IEEE_ADDRESS_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ ExtAddr_t value; //!<Attribute value (default none)
+ } upgradeServerIEEEAddr;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0006)
+ uint8_t type; //!<Attribute type (ZCL_ImageUpdateStatus_t - 8-bit enum) (typeId = 0x30)
+ uint8_t properties; //!<Attribute properties bitmask
+ ZCL_ImageUpdateStatus_t value; //!<Attribute value (default none)
+ } imageUpgradeStatus;
+} ZCL_OtauClusterClientAttributes_t;
+END_PACK
+
+/***************************************************************************//**
+ \brief
+ ZCL OTAU Cluster commands.
+*******************************************************************************/
+BEGIN_PACK
+/**
+ * \brief Control field of query next image request.
+*/
+typedef struct PACK
+{
+ uint8_t hardwareVersionPresent : 1;
+ uint8_t reserved : 7;
+} ZCL_QueryNextImageReqControlField_t;
+
+/**
+ * \brief Query Next Image Request Command.
+*/
+typedef struct PACK
+{
+ ZCL_QueryNextImageReqControlField_t controlField;
+ uint16_t manufacturerId;
+ ZCL_OtauImageType_t imageType;
+ ZCL_OtauFirmwareVersion_t currentFirmwareVersion;
+} ZCL_OtauQueryNextImageReq_t;
+
+/**
+ * \brief Query Next Image Response Command.
+*/
+typedef struct PACK
+{
+ ZCL_Status_t status;
+ uint16_t manufacturerId;
+ ZCL_OtauImageType_t imageType;
+ ZCL_OtauFirmwareVersion_t currentFirmwareVersion;
+ uint32_t imageSize;
+} ZCL_OtauQueryNextImageResp_t;
+
+/**
+ * \brief Control field of image block request.
+*/
+typedef struct PACK
+{
+ uint8_t reqNodeIeeeAddrPresent : 1;
+ uint8_t reserved : 7;
+} ZCL_QueryImageBlockReqControlField_t;
+
+
+/**
+ * \brief Image Block Request Command.
+*/
+typedef struct PACK
+{
+ ZCL_QueryImageBlockReqControlField_t controlField;
+ uint16_t manufacturerId;
+ ZCL_OtauImageType_t imageType;
+ ZCL_OtauFirmwareVersion_t firmwareVersion;
+ uint32_t fileOffset;
+ uint8_t maxDataSize;
+} ZCL_OtauImageBlockReq_t;
+
+/**
+ * \brief Image Block Response Command.
+*/
+typedef struct PACK
+{
+ ZCL_Status_t status;
+ union PACK
+ {
+ struct PACK
+ {
+ uint16_t manufacturerId;
+ ZCL_OtauImageType_t imageType;
+ ZCL_OtauFirmwareVersion_t firmwareVersion;
+ uint32_t fileOffset;
+ uint8_t dataSize;
+ uint8_t imageData[OFD_BLOCK_SIZE];
+ };
+ struct PACK
+ {
+ uint32_t currentTime;
+ uint32_t requestTime;
+ };
+ };
+} ZCL_OtauImageBlockResp_t;
+
+/**
+ * \brief Upgrade End Request Command.
+*/
+typedef struct PACK
+{
+ ZCL_Status_t status;
+ uint16_t manufacturerId;
+ ZCL_OtauImageType_t imageType;
+ ZCL_OtauFirmwareVersion_t firmwareVersion;
+} ZCL_OtauUpgradeEndReq_t;
+
+/**
+ * \brief Upgrade End Response Command.
+*/
+typedef struct PACK
+{
+ uint16_t manufacturerId;
+ ZCL_OtauImageType_t imageType;
+ ZCL_OtauFirmwareVersion_t firmwareVersion;
+ uint32_t currentTime;
+ uint32_t upgradeTime;
+} ZCL_OtauUpgradeEndResp_t;
+END_PACK
+
+/**
+ * \brief Image Page Request Command.
+*/
+typedef struct PACK
+{
+ ZCL_OtauImageBlockReq_t imageBlockRequest;
+ uint16_t pageSize;
+ uint16_t responseSpacing;
+} ZCL_OtauImagePageReq_t;
+
+/**
+ * \brief ZCL OTAU Cluster Commands
+ */
+typedef struct
+{
+ //! Query Next Image Request Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (* pQueryNextImageReqInd)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_OtauQueryNextImageReq_t *payload);
+ } queryNextImageReq;
+
+ //! Query Next Image Response Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (* pQueryNextImageRespInd)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_OtauQueryNextImageResp_t *payload);
+ } queryNextImageResp;
+
+ //! Image Block Request Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (* pImageBlockReqInd)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_OtauImageBlockReq_t *payload);
+ } imageBlockReq;
+
+ //! Image Page Request Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (* pImagePageReqInd)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_OtauImagePageReq_t *payload);
+ } imagePageReq;
+
+ //! Image Block Response Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (* pImageBlockRespInd)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_OtauImageBlockResp_t *payload);
+ } imageBlockResp;
+
+ //! Upgrade End Request Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (* pUpgradeEndReqInd)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_OtauUpgradeEndReq_t *payload);
+ } upgradeEndReq;
+
+ //! Upgrade End Response Command descriptor
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (* pUpgradeEndRespInd)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_OtauUpgradeEndResp_t *payload);
+ } upgradeEndResp;
+} ZCL_OtauClusterCommands_t;
+
+/**//**
+ \brief Initialization parameters for OTAU service
+ */
+typedef struct
+{
+/** \brief Cluster side. Must be chosen from: \n
+ ZCL_SERVER_CLUSTER_TYPE \n
+ ZCL_CLIENT_CLUSTER_TYPE */
+ uint8_t clusterSide;
+/** \brief Endpoint for cluster. */
+ Endpoint_t otauEndpoint;
+/** \brief Profile ID, that uses otau service. */
+ ProfileId_t profileId;
+/** \brief Current firmware version. Parameter is valid only for client. */
+ ZCL_OtauFirmwareVersion_t firmwareVersion;
+} ZCL_OtauInitParams_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/***************************************************************************//**
+\brief Gets Otau's cluster
+
+\return Otau's client cluster
+******************************************************************************/
+ZCL_Cluster_t ZCL_GetOtauClientCluster(void);
+
+/***************************************************************************//**
+\brief Gets Otau's cluster
+
+\return Otau's server cluster
+******************************************************************************/
+ZCL_Cluster_t ZCL_GetOtauServerCluster(void);
+
+/***************************************************************************//**
+\brief OTAU parametres initialization. Start server discovery procedure
+ on client side or start server.
+
+\param[in] pInitParam - pointer to init structure.
+\param[in] ind - indication for OTAU actions \n
+("ind" can be NULL if indication is not required.)
+
+\return Service status
+******************************************************************************/
+ZCL_Status_t ZCL_StartOtauService(ZCL_OtauInitParams_t *pInitParam, ZCL_OtauStatInd_t ind);
+
+/***************************************************************************//**
+\brief Stop OTAU service. (It is not implemented for client)
+
+\param[in] pInitParam - pointer to init structure.
+
+\return Service status
+******************************************************************************/
+ZCL_Status_t ZCL_StopOtauService(ZCL_OtauInitParams_t *pInitParam);
+
+/***************************************************************************//**
+\brief Checks whether OTAU cluster is busy or not.
+
+\return true - if OTAU cluster is busy, false - otherwise.
+******************************************************************************/
+bool zclIsOtauBusy(void);
+
+/***************************************************************************//**
+\brief The server may send an unsolicited Upgrade End Response command to the client.
+This may be used for example if the server wants to synchronize the upgrade
+on multiple clients simultaneously.
+
+\param[in] addressing - pointer to structure with addressing information;
+\param[in] resp - pointer to upgrade end response payload
+
+\return true - data is sending, false - server is busy.
+******************************************************************************/
+bool ZCL_UnsolicitedUpgradeEndResp(ZCL_Addressing_t *addressing, ZCL_OtauUpgradeEndResp_t *resp);
+
+#endif /* _ZCLOTAUCLUSTER_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOccupancySensingCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOccupancySensingCluster.h
new file mode 100644
index 00000000..167c43b5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOccupancySensingCluster.h
@@ -0,0 +1,155 @@
+/***************************************************************************//**
+ \file zclOccupancySensingCluster.h
+
+ \brief
+ The header file describes the ZCL Occupancy Sensing Cluster and its interface
+
+ The file describes the types and interface of the ZCL Occupancy Sensing Configuration 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:
+ 12.02.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLOCCUPANCYSENSINGCLUSTER_H
+#define _ZCLOCCUPANCYSENSINGCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+/**
+ * \brief Occupancy Sensing cluster attributes values
+*/
+
+#define OCCUPANCY_ATTRIBUTE_VALUE_OCCUPIED 1
+#define OCCUPANCY_ATTRIBUTE_VALUE_UNOCCUPIED 0
+
+#define OCCUPANYC_SENSOR_TYPE_ATTRIBUTE_VALUE_PIR 0x00
+#define OCCUPANYC_SENSOR_TYPE_ATTRIBUTE_VALUE_ULTRASONIC 0x01
+#define OCCUPANYC_SENSOR_TYPE__ATTRIBITE_VALUE_PIR_AND_ULTRASONIC 0x02
+
+/**
+ * \brief Occupancy Sensing Cluster server attributes amount
+*/
+
+#define ZCL_OCCUPANCY_SENSING_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 2
+
+/**
+ * \brief Occupancy Sensing Cluster client attributes amount. Clinet doesn't have attributes.
+*/
+
+#define ZCL_OCCUPANCY_SENSING_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT 0
+
+/**
+ * \brief On/Off Switch Configuration Cluster commands amount
+*/
+
+#define ZCL_OCCUPANCY_SENSING_CLUSTER_COMMANDS_AMOUNT 0
+
+/**
+ * \brief Occupancy Sensing Cluster server's attributes identifiers
+*/
+
+#define ZCL_OCCUPANCY_SENSING_CLUSTER_OCCUPANCY_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_OCCUPANCY_SENSING_CLUSTER_OCCUPANCY_SENSOR_TYPE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+
+/**
+ * \brief Occupancy Sensing Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_OCCUPANCY_SENSING_CLUSTER_SERVER_ATTRIBUTES(min, max) \
+ DEFINE_REPORTABLE_ATTRIBUTE(occupancy, ZCL_READONLY_ATTRIBUTE, ZCL_OCCUPANCY_SENSING_CLUSTER_OCCUPANCY_SERVER_ATTRIBUTE_ID, ZCL_8BIT_BITMAP_DATA_TYPE_ID, min, max), \
+ DEFINE_ATTRIBUTE(occupancySensorType, ZCL_READONLY_ATTRIBUTE, ZCL_OCCUPANCY_SENSING_CLUSTER_OCCUPANCY_SENSOR_TYPE_SERVER_ATTRIBUTE_ID, ZCL_8BIT_ENUM_DATA_TYPE_ID)
+
+/**
+ * \brief Occupancy Sensing Cluster definition macros
+*/
+
+#define OCCUPANCY_SENSING_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = OCCUPANCY_SENSING_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_OCCUPANCY_SENSING_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_OCCUPANCY_SENSING_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define OCCUPANCY_SENSING_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = OCCUPANCY_SENSING_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_OCCUPANCY_SENSING_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_OCCUPANCY_SENSING_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_OCCUPANCY_SENSING_CLUSTER(cltype, clattributes, clcommands) \
+ OCCUPANCY_SENSING_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+BEGIN_PACK
+
+/**
+ * \brief On/Off Switch Configuration Cluster server's attributes
+*/
+
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+ uint8_t reportableChange; //!<Reporting change field value
+ ZCL_ReportTime_t timeoutPeriod; //!<Timeout period field value
+ } occupancy;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } occupancySensorType;
+} ZCL_OccupancySensingClusterServerAttributes_t;
+
+END_PACK
+
+
+#endif /* _ZCLOCCUPANCYSENSINGCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOnOffCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOnOffCluster.h
new file mode 100644
index 00000000..5eec8fb9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOnOffCluster.h
@@ -0,0 +1,200 @@
+/***************************************************************************//**
+ \file zclOnOffCluster.h
+
+ \brief
+ The header file describes the ZCL On/Off Cluster and its interface
+
+ The file describes the types and interface of the ZCL On/Off 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:
+ 12.02.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLONOFFCLUSTER_H
+#define _ZCLONOFFCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/**
+ * \brief On/Off Cluster server attributes amount
+*/
+
+#define ZCL_ONOFF_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 1
+
+/**
+ * \brief On/Off Cluster client attributes amount. Clinet doesn't have attributes.
+*/
+
+#define ZCL_ONOFF_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT 0
+
+/**
+ * \brief On/Off Cluster commands amount
+*/
+
+#define ZCL_ONOFF_CLUSTER_COMMANDS_AMOUNT 3
+
+/**
+ * \brief On/Off Cluster server's attributes identifiers
+*/
+
+#define ZCL_ONOFF_CLUSTER_ONOFF_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+
+/**
+ * \brief On/Off Cluster client's command identifiers
+*/
+
+#define ZCL_ONOFF_CLUSTER_OFF_COMMAND_ID 0x00
+#define ZCL_ONOFF_CLUSTER_ON_COMMAND_ID 0x01
+#define ZCL_ONOFF_CLUSTER_TOGGLE_COMMAND_ID 0x02
+
+/**
+ * \brief On/Off Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_ONOFF_CLUSTER_SERVER_ATTRIBUTES(min, max) \
+ DEFINE_REPORTABLE_ATTRIBUTE(onOff, ZCL_READONLY_ATTRIBUTE, ZCL_ONOFF_CLUSTER_ONOFF_SERVER_ATTRIBUTE_ID, ZCL_BOOLEAN_DATA_TYPE_ID, min, max)
+
+/**
+ * \brief On/Off Cluster define commands macros
+*/
+
+#define ZCL_DEFINE_ONOFF_CLUSTER_COMMANDS(onCommandInd, offCommandInd, toggleCommandInd) \
+ DEFINE_COMMAND(onCommand, ZCL_ONOFF_CLUSTER_ON_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ onCommandInd), \
+ DEFINE_COMMAND(offCommand, ZCL_ONOFF_CLUSTER_OFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ offCommandInd), \
+ DEFINE_COMMAND(toggleCommand, ZCL_ONOFF_CLUSTER_TOGGLE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ toggleCommandInd)
+
+/**
+ * \brief On/Off Cluster definition macros
+*/
+
+#define ONOFF_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = ONOFF_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_ONOFF_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_ONOFF_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define ONOFF_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = ONOFF_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_ONOFF_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_ONOFF_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_ONOFF_CLUSTER(cltype, clattributes, clcommands) \
+ ONOFF_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+BEGIN_PACK
+
+/**
+ * \brief On/Off Cluster server's attributes
+*/
+
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ bool value;
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+ bool reportableChange; //!<Reporting change field value
+ ZCL_ReportTime_t timeoutPeriod; //!<Timeout period field value
+ } onOff;
+} ZCL_OnOffClusterServerAttributes_t;
+
+/**
+ * \brief On/Off Cluster extension field set
+ */
+typedef struct PACK
+{
+ uint16_t clusterId;
+ uint8_t length;
+ bool onOffValue;
+} ZCL_OnOffClusterExtensionFieldSet_t;
+
+END_PACK
+
+/**
+ * \brief On/Off Cluster clients's commands.
+*/
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*onCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t * payload);
+ } onCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*offCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t * payload);
+ } offCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*toggleCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t * payload);
+ } toggleCommand;
+} ZCL_OnOffClusterCommands_t;
+
+#define DEFINE_ONOFF_CLUSTER_EXTENSION_FIELD_SET(value) \
+ .clusterId = ONOFF_CLUSTER_ID, \
+ .length = sizeof(uint8_t), \
+ .onOffValue = value
+
+#endif /* _ZCLONOFFCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOnOffSwitchConfigurationCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOnOffSwitchConfigurationCluster.h
new file mode 100644
index 00000000..97c1c57a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOnOffSwitchConfigurationCluster.h
@@ -0,0 +1,150 @@
+/***************************************************************************//**
+ \file zclOnOffSwitchConfigurationCluster.h
+
+ \brief
+ The header file describes the ZCL On/Off Switch Configuration Cluster and its interface
+
+ The file describes the types and interface of the ZCL On/Off Switch Configuration 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:
+ 12.02.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLONOFFSWITCHCONFIGURATIONCLUSTER_H
+#define _ZCLONOFFSWITCHCONFIGURATIONCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+/**
+ * \brief On/Off Switch Configuration attributes values
+*/
+
+#define SWITCH_TYPE_ATTRIBUTE_VALUE_TOGGLE 0x00
+#define SWITCH_TYPE_ATTRIBUTE_VALUE_MOMENTARY 0x01
+
+#define SWITCH_ACTIONS_ATTRIBUTE_VALUE_ON_OFF 0x00
+#define SWITCH_ACTIONS_ATTRIBUTE_VALUE_OFF_ON 0x01
+#define SWITCH_ACTIONS_ATTRIBITE_VALUE_TOGGLE_TOGGLE 0x02
+
+/**
+ * \brief On/Off Switch Configuration Cluster server attributes amount
+*/
+
+#define ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 2
+
+/**
+ * \brief On/Off Switch Configuration Cluster client attributes amount. Clinet doesn't have attributes.
+*/
+
+#define ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT 0
+
+/**
+ * \brief On/Off Switch Configuration Cluster commands amount
+*/
+
+#define ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_COMMANDS_AMOUNT 0
+
+/**
+ * \brief On/Off Switch Configuration Cluster server's attributes identifiers
+*/
+
+#define ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_SWITCH_TYPE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_SWITCH_ACTIONS_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0010)
+
+/**
+ * \brief On/Off Switch Configuration Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_ONOFF_SWITCH_CONFIGURATION_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(switchType, ZCL_READONLY_ATTRIBUTE, ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_SWITCH_TYPE_SERVER_ATTRIBUTE_ID, ZCL_8BIT_ENUM_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(switchActions, ZCL_READWRITE_ATTRIBUTE, ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_SWITCH_ACTIONS_SERVER_ATTRIBUTE_ID, ZCL_8BIT_ENUM_DATA_TYPE_ID)
+
+
+/**
+ * \brief On/Off Switch Configuration Cluster definition macros
+*/
+
+#define ONOFF_SWITCH_CONFIGURATION_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = ONOFF_SWITCH_CONFIGURATION_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define ONOFF_SWITCH_CONFIGURATION_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = ONOFF_SWITCH_CONFIGURATION_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_ONOFF_SWITCH_CONFIGURATION_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_ONOFF_SWITCH_CONFIGURATION_CLUSTER(cltype, clattributes, clcommands) \
+ ONOFF_SWITCH_CONFIGURATION_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+BEGIN_PACK
+
+/**
+ * \brief On/Off Switch Configuration Cluster server's attributes
+ */
+
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } switchType;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } switchActions;
+} ZCL_OnOffSwitchConfigurationClusterServerAttributes_t;
+
+END_PACK
+
+#endif /* _ZCLONOFFSWITCHCONFIGURATIONCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOtauDiscovery.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOtauDiscovery.h
new file mode 100644
index 00000000..54365690
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOtauDiscovery.h
@@ -0,0 +1,100 @@
+/**************************************************************************//**
+ \file zclOTAUCluster.h
+
+ \brief Declaration of the private OTAU interface
+
+ \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:
+ 13.05.10 A. Khromykh - Created.
+*******************************************************************************/
+#ifndef _ZCLOTAUDISCOVERY_H
+#define _ZCLOTAUDISCOVERY_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zcl.h>
+#include <clusters.h>
+#include <zdo.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef union
+{
+ ZDO_ZdpReq_t zdpOtauReq;
+#ifdef _ZCL_SECURITY_
+ APS_RequestKeyReq_t apsKeyReq;
+#endif // _ZCL_SECURITY_
+ ZCL_Request_t zclCommandReq;
+} OtauReqMemory_t;
+
+typedef union
+{
+ ZCL_OtauQueryNextImageReq_t uQueryNextImageReq;
+ ZCL_OtauImageBlockReq_t uImageBlockReq;
+ ZCL_OtauImagePageReq_t uImagePageReq;
+ ZCL_OtauUpgradeEndReq_t uUpgradeEndReq;
+} OtauZclReqMemory_t;
+
+typedef struct
+{
+ uint32_t imageInternalLength;
+ uint8_t internalAddressStatus;
+ uint32_t currentFileOffset;
+ uint8_t currentDataSize;
+ uint32_t imageRemainder;
+ uint32_t imagePageOffset;
+} OtauImageAuxVar_t;
+
+/***************************************************************************//**
+ \brief
+ ZCL OTAU Cluster parametres.
+*******************************************************************************/
+typedef struct
+{
+ uint32_t imageSize;
+ uint8_t imageBlockData[OFD_BLOCK_SIZE];
+ uint8_t *imagePageData;
+
+} ZclOtauClientImageBuffer_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/***************************************************************************//**
+\brief Restart poll timer
+
+\param[in] period - timer fired time
+\param[in] cb - pointer to fired method
+******************************************************************************/
+void otauStartGenericTimer(uint32_t period, void (* cb)(void));
+
+/***************************************************************************//**
+\brief Restart discovery service with context gap
+******************************************************************************/
+void otauStartPollDiscovery(void);
+
+/***************************************************************************//**
+\brief Entry point to client process
+******************************************************************************/
+void otauClientEntryPoint(void);
+
+/***************************************************************************//**
+\brief Start discovery of upgrade server
+******************************************************************************/
+void ZCL_OtauUpgradeServerDiscovery(void);
+
+/***************************************************************************//**
+\brief Server IEEE addresses request
+******************************************************************************/
+void otauServerExtAddrReq(void);
+
+#endif /* _ZCLOTAUDISCOVERY_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOtauManager.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOtauManager.h
new file mode 100644
index 00000000..ad091491
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOtauManager.h
@@ -0,0 +1,180 @@
+/**************************************************************************//**
+ \file zclOTAUManager.h
+
+ \brief Declaration of the OTAU manager interface
+
+ \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:
+ 16.05.11 A. Khromykh - Created.
+*******************************************************************************/
+#ifndef _ZCLOTAUMANAGER_H
+#define _ZCLOTAUMANAGER_H
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef struct
+{ /* memory for storage of server discovery result */
+ struct
+ {
+ void *next;
+ } service;
+
+ bool busy;
+ Endpoint_t serverEndpoint;
+ ShortAddr_t serverShortAddress;
+ ExtAddr_t serverExtAddress;
+} ZclOtauDiscoveryResult_t;
+
+typedef struct
+{
+ struct
+ {
+ void *next;
+ } service;
+
+ bool busy;
+ uint8_t id;
+ ZCL_Addressing_t addressing;
+ ZCL_Request_t zclCommandReq;
+
+ union
+ {
+ ZCL_OtauQueryNextImageReq_t queryNextImageReq;
+ ZCL_OtauQueryNextImageResp_t queryNextImageResp;
+ ZCL_OtauImageBlockReq_t imageBlockReq;
+ ZCL_OtauImageBlockResp_t imageBlockResp;
+ ZCL_OtauUpgradeEndReq_t upgradeEndReq;
+ ZCL_OtauUpgradeEndResp_t upgradeEndResp;
+ };
+ ZCL_OtauImagePageReq_t imagePageReq;
+} ZclOtauServerTransac_t;
+
+typedef struct
+{
+ uint32_t fileOffset;
+ uint16_t size;
+} ZclOtauMissedBlockResponses_t;
+
+typedef struct
+{
+ uint8_t quantity;
+ uint8_t internalBlockOffset;
+ bool blockGetting;
+ ZclOtauMissedBlockResponses_t *missedBlockResponses;
+} otauMissedBlocksBuffer_t;
+
+typedef struct
+{
+ OtauReqMemory_t reqMem;
+ OtauZclReqMemory_t zclReqMem;
+ HAL_AppTimer_t genericTimer;
+ HAL_AppTimer_t pageRequestTimer;
+ ZclOtauClientImageBuffer_t otauParam;
+ OtauImageAuxVar_t imageAuxParam;
+ OFD_MemoryAccessParam_t memParam;
+ ZCL_OtauFirmwareVersion_t newFirmwareVersion;
+
+ uint8_t discoveredServerAmount;
+ ZclOtauDiscoveryResult_t *discoveredServerMem;
+
+ uint16_t pageReminderSize;
+ otauMissedBlocksBuffer_t missedBlocks;
+} ZCL_OtauClientMem_t;
+
+typedef struct
+{
+ ZCL_Request_t unsolicitedReq;
+ ZCL_OtauUpgradeEndResp_t unsolicitedUpgradeEndResp;
+
+ uint8_t transacAmount;
+ ZclOtauServerTransac_t *serverTransac;
+ uint16_t pageReminderSize;
+} ZCL_OtauServerMem_t;
+
+typedef struct
+{
+ ZCL_OtauStatInd_t otauInd;
+ ZCL_OtauInitParams_t initParam;
+ union
+ {
+ ZCL_OtauClientMem_t clientMem;
+ ZCL_OtauServerMem_t serverMem;
+ };
+} ZclOtauMem_t;
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+/** zclOtauMem is defined in zclOtauManager.c */
+extern ZclOtauMem_t zclOtauMem;
+extern bool isOtauBusy;
+
+/******************************************************************************
+ Inline functions section
+******************************************************************************/
+INLINE ZclOtauMem_t* zclGetOtauMem(void)
+{
+ return &zclOtauMem;
+}
+
+INLINE ZCL_OtauClientMem_t* zclGetOtauClientMem(void)
+{
+ return &zclOtauMem.clientMem;
+}
+
+INLINE ZCL_OtauServerMem_t* zclGetOtauServerMem(void)
+{
+ return &zclOtauMem.serverMem;
+}
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/***************************************************************************//**
+\brief Lift otau cluster action for customer.
+
+\param[in] action - the OTAU action for a customer.
+******************************************************************************/
+void zclRaiseCustomMessage (const ZCL_OtauAction_t action);
+
+/***************************************************************************//**
+\brief Start otau client service
+******************************************************************************/
+void zclStartOtauClient(void);
+
+/***************************************************************************//**
+\brief Start otau server service
+******************************************************************************/
+void zclStartOtauServer(void);
+
+/***************************************************************************//**
+\brief Stop otau server service
+******************************************************************************/
+void zclStopOtauServer(void);
+
+/***************************************************************************//**
+\brief Clear otau server memory.
+******************************************************************************/
+void zclClearOtauServerMemory(void);
+
+/***************************************************************************//**
+\brief Clear otau client memory.
+******************************************************************************/
+void zclClearOtauClientMemory(void);
+
+/***************************************************************************//**
+\brief Find empty cell in memory pool.
+
+\return pointer to empty cell.
+******************************************************************************/
+ZclOtauServerTransac_t * zclFindEmptyCell(void);
+
+#endif /* _ZCLOTAUMANAGER_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclParser.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclParser.h
new file mode 100644
index 00000000..141d5b1f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclParser.h
@@ -0,0 +1,445 @@
+/************************************************************************//**
+ \file zclParser.h
+
+ \brief
+ The header file describes the ZCL Parser interface
+
+ The file describes the interface and types of ZCL Parser
+
+ \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:
+ 02.12.08 A. Potashov - Created.
+******************************************************************************/
+
+#ifndef _ZCLPARSER_H
+#define _ZCLPARSER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+//#include <zclDbg.h>
+#include <zcl.h>
+#include <zclMemoryManager.h>
+#include <queue.h>
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+/*ZCL Header Frame Type sub-field value*/
+#define ZCL_FRAME_CONTROL_FRAME_TYPE_UNIVERSAL_COMMAND 0x00
+#define ZCL_FRAME_CONTROL_FRAME_TYPE_SPECIFIC_COMMAND 0x01
+
+/*ZCL Header Manufacturer Specific sub-field value*/
+#define ZCL_FRAME_CONTROL_MANUFACTURER_NONSPECIFIC 0x00
+#define ZCL_FRAME_CONTROL_MANUFACTURER_SPECIFIC 0x01
+
+#define ZCL_FRAME_SIMPLE_HEADER_LENGTH 3
+#define ZCL_FRAME_HEADER_MANUFACTURER_CODE_LENGTH 2
+#define ZCL_FRAME_HEADER_WITH_MANUFACTURER_CODE_LENGTH \
+ (ZCL_FRAME_SIMPLE_HEADER_LENGTH + ZCL_FRAME_HEADER_MANUFACTURER_CODE_LENGTH)
+
+#ifndef ZCL_STANDARD_REQ_TYPE
+#define ZCL_STANDARD_REQ_TYPE ZCL_FRAME_CONTROL_FRAME_TYPE_UNIVERSAL_COMMAND
+#endif
+#ifndef ZCL_SPECIAL_REQ_TYPE
+#define ZCL_SPECIAL_REQ_TYPE ZCL_FRAME_CONTROL_FRAME_TYPE_SPECIFIC_COMMAND
+#endif
+
+#ifndef ZCL_MAX_STANDARD_DATA_TYPE_SIZE
+#define ZCL_MAX_STANDARD_DATA_TYPE_SIZE 8
+#endif
+
+/*************************************************************************//**
+ \brief Defines the Descrete Kind of ZCL Data Type (used in #ZCL_DataTypeDescriptor_t)
+*****************************************************************************/
+#ifndef ZCL_DATA_TYPE_DESCRETE_KIND
+#define ZCL_DATA_TYPE_DESCRETE_KIND 0x00
+#endif
+
+/*************************************************************************//**
+ \brief Defines the Analog Kind of ZCL Data Type (used in #ZCL_DataTypeDescriptor_t)
+*****************************************************************************/
+#ifndef ZCL_DATA_TYPE_ANALOG_KIND
+#define ZCL_DATA_TYPE_ANALOG_KIND 0x01
+#endif
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+typedef enum
+{
+ ZCL_PARSER_IDLE_STATE,
+ ZCL_PARSER_RECEIVED_PACKET_STATE,
+ ZCL_PARSER_SENDING_RESPONSE_STATE,
+} ZclParserState_t;
+
+typedef struct
+{
+ //ZclParserState_t state;
+ uint8_t dataIndAmount;
+ QueueDescriptor_t dataIndQueue;
+} ZclParserMem_t;
+
+BEGIN_PACK
+typedef struct PACK
+{
+ union PACK
+ {
+ struct PACK
+ {
+ LITTLE_ENDIAN_OCTET(5,(
+ uint8_t frameType :2, //Frame type sub-field
+ uint8_t manufacturerSpecific :1, //Manufacturer specific sub-field
+ uint8_t direction :1, //Direction sub-field
+ uint8_t defaultResponse :1, //Disable default response sub-field
+ uint8_t reserved :3 //Reserved bits. Must have a zero value
+ ))
+ };
+ uint8_t uint8;
+ };
+} ZclFrameControlField_t;
+
+typedef struct PACK
+{
+ ZclFrameControlField_t frameControl;
+ uint16_t manufacturerCode;
+ uint8_t sequenceNumber;
+ uint8_t commandId;
+} ZclFrameHeader_t;
+
+typedef struct PACK
+{
+ ZclFrameHeader_t header;
+ uint8_t payload[1];
+} ZclFrame_t;
+
+/******************************************************************************
+ Read Attributes commands
+******************************************************************************/
+/** \brief ZCL read attributes command record */
+typedef struct PACK
+{
+ uint16_t attributeId;
+} ZclReadAttributesRecord_t;
+
+/** \brief ZCL Read attributes command payload */
+typedef struct PACK
+{
+ ZclReadAttributesRecord_t records[1];
+} ZclReadAttributesCommand_t;
+
+typedef struct PACK
+{
+ uint8_t elementType;
+ uint16_t elementsAmount;
+ struct PACK
+ {
+ uint8_t value[1];
+ } elements[1];
+} ZclReadAttributesResponseArraySetBagValue_t;
+
+typedef struct PACK
+{
+ uint16_t elementsAmount;
+ struct PACK
+ {
+ uint8_t elementType;
+ uint8_t value[1];
+ } elements [1];
+} ZclReadAttributesResponseStructValue_t;
+
+/** \brief ZCL read attributes response command record */
+typedef struct PACK
+{
+ ZCL_AttributeId_t attributeId;
+ uint8_t status;
+ uint8_t type;
+ union PACK
+ {
+ uint8_t simpleValue[1];
+ ZclReadAttributesResponseArraySetBagValue_t arraySetBagValue;
+ ZclReadAttributesResponseStructValue_t structValue;
+ };
+} ZclReadAttributesResponseRecord_t;
+
+/** \brief ZCL read attributes response command payload */
+typedef struct PACK
+{
+ ZclReadAttributesResponseRecord_t records[1];
+} ZclReadAttributesResponseCommand_t;
+
+/******************************************************************************
+ Write Attributes commands
+******************************************************************************/
+/** \brief ZCL write attributes command record */
+typedef struct PACK
+{
+ ZCL_AttributeId_t attributeId;
+ uint8_t type;
+ uint8_t value[1];
+} ZclWriteAttributesRecord_t;
+
+/** \brief ZCL Wrire attributes command payload */
+typedef struct PACK
+{
+ ZclWriteAttributesRecord_t records[1];
+} ZclWriteAttributesCommand_t;
+
+/** \brief ZCL Wrire attributes undivided command payload */
+typedef ZclWriteAttributesCommand_t ZclWriteAttributesUndividedCommand_t;
+
+/** \brief ZCL Wrire attributes no response command payload */
+typedef ZclWriteAttributesCommand_t ZclWriteAttributesNoResponseCommand_t;
+
+/** \brief ZCL write attributes response command record */
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t attributeId;
+} ZclWriteAttributesResponseRecord_t;
+
+/** \brief ZCL Wrire attributes response command payload */
+typedef struct PACK
+{
+ ZclWriteAttributesResponseRecord_t records[1];
+} ZclWriteAttributesResponseCommand_t;
+
+/******************************************************************************
+ Configure reporting command
+******************************************************************************/
+/** \brief ZCL configure reporting command record */
+typedef struct PACK
+{
+ uint8_t direction;
+ uint16_t attributeId;
+ uint16_t minimumReportingInterval;
+ uint16_t maximumReportingInterval;
+ uint8_t reportableChange[1];
+ uint16_t timeoutPeriod;
+} ZclConfigureReportingRecord_t;
+
+/** \brief ZCL configure reporting command payload */
+typedef struct PACK
+{
+ ZclConfigureReportingRecord_t records[1];
+} ZclConfigureReportingCommand_t;
+
+/** \brief ZCL configure reporting response command record */
+typedef struct PACK
+{
+ uint8_t status;
+ uint8_t direction;
+ uint16_t attributeId;
+} ZclConfigureReportingResponseRecord_t;
+
+/** \brief ZCL configure reporting response command payload */
+typedef struct PACK
+{
+ ZclConfigureReportingResponseRecord_t records[1];
+} ZclConfigureReportingResponseCommand_t;
+
+END_PACK
+
+typedef struct
+{
+ ZCL_GeneralCommandId_t commandId;
+ void *primitive;
+} ZclBuffer_t;
+
+typedef enum
+{
+ ZCL_PARSER_SUCCESS_STATUS = 0,
+ ZCL_PARSER_UNKNOWN_COMMAND_STATUS = 1,
+ ZCL_PARSER_BAD_FORMAT_STATUS = 2,
+ ZCL_PARSER_INVALID_PARAMETER_STATUS = 3
+} ZclParserStatus_t;
+
+typedef enum
+{
+ ZCL_REQUEST_TYPE,
+ ZCL_RESPONSE_TYPE,
+ ZCL_EVENT_TYPE,
+ ZCL_UNSPECIFIED_COMMAND_TYPE
+} ZCL_CommandType_t;
+
+typedef struct
+{
+ uint8_t headerLength;
+ uint8_t payloadLength;
+ uint8_t frameType;
+ uint8_t direction;
+ uint8_t defaultResponse;
+ uint8_t manufacturerSpecific;
+ uint16_t manufacturerCode;
+ uint8_t sequenceNumber;
+ uint8_t commandId;
+ uint8_t *header;
+ uint8_t *payload;
+} ZclFrameDescriptor_t;
+
+typedef struct
+{
+ ZclFrameDescriptor_t *frameDescriptor;
+ APS_DataInd_t *ind;
+ ZCL_Status_t commandStatus;
+ bool noApsSecurity;
+ bool relevantResponse;
+} ZclAuxParseData_t;
+
+/******************************************************************************
+ Constants section
+******************************************************************************/
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+/**************************************************************************//**
+\brief ZCL memory global object
+******************************************************************************/
+extern ZclParserMem_t zclParserMem;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/*************************************************************************//**
+ \brief Reset parser queue and clear memory.
+*****************************************************************************/
+void zclParserInit(void);
+
+/**************************************************************************//**
+\brief Form zcl header.
+
+\param[in] - dataReq - pointer to data request;
+\param[in] - reqType - type of the request;
+\param[in] - direction - cluster\server side;
+\param[in] - commandId - zcl command identification;
+\param[in] - defaultResponse - presence or absence of the default responde;
+\param[in] - manufacSpecCode - manufacturer specific code;
+\return header length
+******************************************************************************/
+uint8_t zclFormRequest(APS_DataReq_t *dataReq, uint8_t reqType, uint8_t direction, uint8_t commandId, uint8_t defaultResponse, uint16_t manufacSpecCode);
+
+/*************************************************************************//**
+ \brief Response has been received.
+
+ \param[in] auxData - pointer to structure with command payload and
+ descriptor of received command frame.
+*****************************************************************************/
+void zclResponseInd(ZclAuxParseData_t *auxData);
+
+/*************************************************************************//**
+\brief Routine of Read Reporting Configuration Command.
+
+\param[in] apsDataInd - pointer to aps payload
+\param[in] frameDescriptor - pointer to parsed data structure from payload
+*****************************************************************************/
+void zclReadReportingConfigurationHandler(APS_DataInd_t *apsDataInd, ZclFrameDescriptor_t *frameDescriptor);
+
+/*************************************************************************//**
+\brief Routine of Configure Reporting Command.
+
+\param[in] apsDataInd - pointer to aps payload
+\param[in] frameDescriptor - pointer to parsed data structure from payload
+*****************************************************************************/
+void zclConfigureReportingHandler(APS_DataInd_t *apsDataInd, ZclFrameDescriptor_t *frameDescriptor);
+
+/*************************************************************************//**
+ \brief Report has been received.
+
+ \param[in] apsData - report payload
+ \param[in] frameDesc - descriptor of received report frame
+*****************************************************************************/
+void zclReportInd(APS_DataInd_t *apsData, ZclFrameDescriptor_t *frameDescriptor);
+
+/*************************************************************************//**
+ \brief Special cluster command has been received.
+
+ \param[in] auxData - pointer to structure with command payload and
+ descriptor of received command frame.
+*****************************************************************************/
+void zclCommandInd(ZclAuxParseData_t *auxData);
+
+/*************************************************************************//**
+ \brief The attribute has been read or written.
+
+ \param[in] apsDataInd - attribute payload
+ \param[in] direction - direction
+ \param[in] event - event type
+ \param[in] attributeId - attribute identifier
+*****************************************************************************/
+void zclAttributeEventInd(APS_DataInd_t *apsDataInd, uint8_t direction, ZCL_AttributeEvent_t event, ZCL_AttributeId_t attributeId);
+
+/*************************************************************************//**
+ \brief Configuration has been received.
+
+ \param[in] apsData - configuration payload
+ \param[in] frameDesc - descriptor of received report frame
+*****************************************************************************/
+void zclConfigurationInd(APS_DataInd_t *apsData, ZclFrameDescriptor_t *frameDesc);
+
+/*************************************************************************//**
+ \brief Indication from CAPS.
+
+ \param[in] ind - buffer for data indication.
+*****************************************************************************/
+void zclDataInd(APS_DataInd_t *ind);
+
+/*************************************************************************//**
+ \brief Security Type get by Cluster Id function and by endpointId, on which
+ was registered cluster.
+ Returns Security Type should be used with ClusterId specified
+ \param[in] clusterId - cluster identifier
+ \param[in] endpointId - end point identifier
+ \return ZCL_NETWORK_KEY_CLUSTER_SECURITY - NWK Key Security should be used
+ ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY - APS Link Key Security
+ shoud be used.
+ If cluster is unknown, security key will be determined by security mode,
+ i.e. ZCL_NETWORK_KEY_CLUSTER_SECURITY for Standard Security,
+ ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY for High Security.
+*****************************************************************************/
+uint8_t zclGetSecurityTypeByClusterId(ClusterId_t clusterId, Endpoint_t endpointId);
+
+/**************************************************************************//**
+ \brief Get next registered ZCL endpoint descriptor by previous.
+
+ \param[in] prev - previous ZCL endpoint descriptor pointer.It is must be non NULL
+ sequential access required if. And it is must be NULL the
+ first descriptor as registered endpoints queue head element
+ access required if.
+
+ \return Valid ZCL endpoint descriptor pointer descriptor found if,
+ NULL - other case.
+ ******************************************************************************/
+ZCL_DeviceEndpoint_t* zclNextEndpoint(ZCL_DeviceEndpoint_t *prev);
+
+/*************************************************************************//**
+ \brief Find endpoint descriptor by endpoint id.
+
+ \param[in] endpointId - endpoint unique identifier.
+ \return endpoint descriptor if found, NULL otherwise.
+*****************************************************************************/
+ZCL_DeviceEndpoint_t *zclGetEndpoint(Endpoint_t endpointId);
+
+/******************************************************************************
+ Inline static functions section
+******************************************************************************/
+/******************************************************************************
+\brief Function returns point to ZCL memory object
+******************************************************************************/
+static inline ZclParserMem_t *zclParserMemReq(void)
+{
+ return ((ZclParserMem_t *)&zclParserMem);
+}
+
+#endif //#ifndef _ZCLPARSER_H
+
+//eof zclParser.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPowerConfigurationCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPowerConfigurationCluster.h
new file mode 100644
index 00000000..eccbb372
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPowerConfigurationCluster.h
@@ -0,0 +1,107 @@
+/*****************************************************************************
+ \file zclPowerConfigurationCluster.h
+
+ \brief
+ The file describes the types and interface of the Power Configuration 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:
+ 18.01.2010 I.Vagulin - Created
+******************************************************************************/
+
+
+#ifndef _ZCLPOWERCONFIGURATIONCLUSTER_H_
+#define _ZCLPOWERCONFIGURATIONCLUSTER_H_
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+#include <types.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+/**
+* \brief server attributes amount
+*/
+#define ZCL_POWER_CONFIGURATION_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 2
+
+/**
+* \brief server commands amount
+*/
+#define ZCL_POWER_CONFIGURATION_CLUSTER_SERVER_COMMANDS_AMOUNT 0
+
+/**
+* \brief client attributes amount
+*/
+#define ZCL_POWER_CONFIGURATION_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+* \brief client commands amount
+*/
+#define ZCL_POWER_CONFIGURATION_CLUSTER_CLIENT_COMMANDS_AMOUNT 0
+
+
+/**
+* \brief Supported attribue id
+*/
+#define ZCL_POWER_CONFIGURATION_CLUSTER_SERVER_MAINS_VOLTAGE_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_POWER_CONFIGURATION_CLUSTER_SERVER_MAINS_FREQUENCY_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+
+/**
+ * \brief server define attributes macros
+*/
+#define ZCL_DEFINE_POWER_CONFIGURATION_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(mainsVoltage, ZCL_READONLY_ATTRIBUTE, ZCL_POWER_CONFIGURATION_CLUSTER_SERVER_MAINS_VOLTAGE_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(mainsFrequency, ZCL_READONLY_ATTRIBUTE, ZCL_POWER_CONFIGURATION_CLUSTER_SERVER_MAINS_FREQUENCY_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID)
+
+#define ZCL_DEFINE_POWER_CONFIGURATION_CLUSTER_SERVER(clattributes) \
+ { \
+ .id = POWER_CONFIGURATION_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_POWER_CONFIGURATION_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) (clattributes), \
+ .commandsAmount = ZCL_POWER_CONFIGURATION_CLUSTER_SERVER_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+#define ZCL_DEFINE_POWER_CONFIGURATION_CLUSTER_CLIENT() \
+ { \
+ .id = POWER_CONFIGURATION_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_POWER_CONFIGURATION_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = NULL, \
+ .commandsAmount = ZCL_POWER_CONFIGURATION_CLUSTER_CLIENT_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+typedef struct PACK {
+ struct PACK {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } mainsVoltage ;
+
+ struct PACK {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } mainsFrequency ;
+} ZCL_PowerConfigurationClusterAttributes_t ;
+END_PACK
+
+#endif /* _ZCLPOWERCONFIGURATIONCLUSTER_H_ */
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPriceCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPriceCluster.h
new file mode 100644
index 00000000..0769596b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPriceCluster.h
@@ -0,0 +1,267 @@
+/************************************************************************//**
+ \file zclPriceCluster.h
+
+ \brief
+ The header file describes the Price 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:
+ 05.02.09 A. Mandychev - Changed.
+******************************************************************************/
+
+#ifndef _ZCLPRICECLUSTER_H
+#define _ZCLPRICECLUSTER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zcl.h>
+#include <clusters.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+/**
+\brief Macros defines duration of Publish Price command,
+ * which means 'until change'.
+ * According to ZB AMI Spec r15, D.4.2.4.1.1, page 197.
+*/
+#define PUBLISH_PRICE_DURATION_UNTIL_CHANGED (0xFFFF)
+
+/**
+\brief Macros defines start time of Publish Price command,
+ * which means 'now'.
+ * According to ZB AMI Spec r15, D.4.2.4.1.1, page 197.
+*/
+#define PUBLISH_PRICE_START_TIME_NOW (0x0000)
+
+/**
+\brief Macros defines Price Ratio field special value,
+ * which means 'not used'.
+ * According to ZB AMI Spec r15, D.4.2.4.1.1, page 198.
+*/
+#define PUBLISH_PRICE_PRICE_RATIO_IS_NOT_USED (0xFF)
+
+/**
+\brief Macros defines Generation Price Ratio field special value,
+ * which means 'not used'.
+ * According to ZB AMI Spec r15, D.4.2.4.1.1, page 198.
+*/
+#define PUBLISH_PRICE_GENERATION_PRICE_RATIO_IS_NOT_USED (0xFF)
+
+/**
+\brief Macros defines Generation Price field special value,
+ * which means 'not used'.
+ * According to ZB AMI Spec r15, D.4.2.4.1.1, page 198.
+*/
+#define PUBLISH_PRICE_GENERATION_PRICE_IS_NOT_USED (0xFFFFFFFF)
+
+/**
+\brief Macros defines Number Of Block Thresholds field special value,
+ * which means 'not used'.
+ * According to ZigBee-095310r23ZB, page 65.
+*/
+#define PUBLISH_NUMBER_OF_BLOCK_THRESHOLDS_IS_NOT_USED (0xFF)
+
+/**
+\brief Macros defines Price Control field special value,
+ * which means 'not used'.
+ * According to ZigBee-095310r23ZB, page 65.
+*/
+#define PUBLISH_PRICE_CONTROL_IS_NOT_USED (0x00)
+
+/**
+\brief Macros defines Standing Charge field special value,
+ * which means 'not used'.
+ * According to ZigBee-095310r23ZB, page 65.
+*/
+#define PUBLISH_STANDING_CHARGE_IS_NOT_USED (0xFFFFFFFF)
+
+/**
+ * \brief Price Server Cluster attributes amount.
+*/
+#define PRICE_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Price Client Cluster attributes amount.
+*/
+#define PRICE_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Price Client Cluster commands amount.
+*/
+#define PRICE_CLUSTER_COMMANDS_AMOUNT 3
+
+/**
+ * \brief Price Server Cluster commands identifiers.
+*/
+#define PUBLISH_PRICE_COMMAND_ID 0x00
+
+/**
+ * \brief Price Client Cluster commands identifiers.
+*/
+#define GET_CURRENT_PRICE_COMMAND_ID 0x00
+#define GET_SCHEDULED_PRICES_COMMAND_ID 0x01
+
+#define RATE_LABEL_MAX_LEN 12
+
+/*
+#define DEMAND_RESPONSE_CLUSTER_SERVER_COMMANDS(publishPriceInd) \
+ DEFINE_COMMAND(publishPriceCommand, 0x00, COMMAND_OPTIONS(SERVER_TO_CLIENT), publishPriceInd)
+
+
+#define DEMAND_RESPONSE_CLUSTER_CLIENT_COMMANDS(getCurrentPriceInd) \
+ DEFINE_COMMAND(getCurrentPriceCommand, 0x00, COMMAND_OPTIONS(CLIENT_TO_SERVER), getCurrentPriceInd)
+*/
+
+#define PRICE_CLUSTER_COMMANDS(getCurrentPriceInd, publishPriceInd, getScheduledPricesInd) \
+ DEFINE_COMMAND(getCurrentPriceCommand, 0x00, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), getCurrentPriceInd), \
+ DEFINE_COMMAND(publishPriceCommand, 0x00, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), publishPriceInd), \
+ DEFINE_COMMAND(getScheduledPricesCommand, GET_SCHEDULED_PRICES_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), getScheduledPricesInd)
+
+#define PRICE_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = PRICE_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = PRICE_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = PRICE_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+
+#define PRICE_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = PRICE_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = PRICE_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = PRICE_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+#define DEFINE_PRICE_CLUSTER(cltype, clattributes, clcommands) PRICE_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+/**
+ * \brief Publish Price Command Payload format.
+*/
+typedef struct PACK
+{
+ uint32_t providerId;
+ uint8_t rateLabelLength;
+ uint8_t rateLabel[RATE_LABEL_MAX_LEN];
+ uint32_t issuerEventId;
+ ZCL_UTCTime_t currentTime;
+ uint8_t unitOfMeasure;
+ uint16_t currency;
+ struct PACK
+ {
+ LITTLE_ENDIAN_OCTET(2,(
+ uint8_t priceTrailDigit : 4,
+ uint8_t priceTier : 4
+ ))
+ } priceTrailDigitPriceTier;
+ struct PACK
+ {
+ LITTLE_ENDIAN_OCTET(2,(
+ uint8_t numberOfPriceTiers : 4,
+ uint8_t registerTier : 4
+ ))
+ } numberOfPriceTiersRegisterTier;
+ ZCL_UTCTime_t startTime;
+ uint16_t durationInMinutes;
+ uint32_t price;
+ uint8_t priceRatio;
+ uint32_t generationPrice;
+ uint8_t generationPriceRatio;
+ uint32_t alternateCostDelivered;
+ uint8_t alternateCostUnit;
+ uint8_t alternateCostTrailingDigit;
+ uint8_t numberOfBlockThresholds;
+ uint8_t priceControl;
+ uint32_t standingCharge;
+} ZCL_PublishPrice_t;
+
+/**
+ * \brief Get Current Price Command Payload format.
+*/
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(2,(
+ uint8_t requestorRxOnWhenIdle :1, //!<The requestor Rx On When Idle sub-field
+ uint8_t reserved :7 //!<Reserved field
+ ))
+} ZCL_GetCurrentPrice_t;
+
+/**
+ * \brief Get Scheduled Prices Command Payload format.
+*/
+typedef struct PACK
+{
+ ZCL_UTCTime_t startTime;
+ uint8_t numberOfEvents;
+} ZCL_GetScheduledPrices_t;
+END_PACK
+
+
+/**
+ * \brief ZCL Price Cluster Commands
+ */
+typedef struct
+{
+ //! Get Current Price 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 (*getCurrentPrice)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetCurrentPrice_t *payload);
+ } getCurrentPriceCommand;
+
+ //! Get Scheduled Prices 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 octets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*getScheduledPrices)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetScheduledPrices_t *payload);
+ } getScheduledPricesCommand;
+
+ //! Publish Price 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 (*publishPrice)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_PublishPrice_t *payload);
+ } publishPriceCommand;
+
+} ZCL_PriceClusterCommands_t;
+
+
+
+#endif // _ZCLPRICECLUSTER_H
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclScenesCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclScenesCluster.h
new file mode 100644
index 00000000..eb8a5ad8
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclScenesCluster.h
@@ -0,0 +1,487 @@
+/***************************************************************************//**
+ \file zclScenesCluster.h
+
+ \brief
+ The header file describes the ZCL Scenes Cluster and its interface
+
+ The file describes the types and interface of the ZCL Scenes 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:
+ 12.02.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLSCENESCLUSTER_H
+#define _ZCLSCENESCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/**
+ * \brief Scenes Cluster scene name support bit
+*/
+
+#define SCENE_NAME_SUPPORT_FLAG 0x80
+
+/**
+ * \brief Scenes Cluster server attributes amount
+*/
+
+#define ZCL_SCENES_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 5
+
+/**
+ * \brief Scenes Cluster client attributes amount. Clinet doesn't have attributes.
+*/
+
+#define ZCL_SCENES_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT 0
+
+/**
+ * \brief Scenes Cluster commands amount
+*/
+
+#define ZCL_SCENES_CLUSTER_COMMANDS_AMOUNT 13
+
+/**
+ * \brief Scenes Cluster server's attributes identifiers
+*/
+
+#define ZCL_SCENES_CLUSTER_SCENE_COUNT_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_SCENES_CLUSTER_CURRENT_SCENE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+#define ZCL_SCENES_CLUSTER_CURRENT_GROUP_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0002)
+#define ZCL_SCENES_CLUSTER_SCENE_VALID_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0003)
+#define ZCL_SCENES_CLUSTER_NAME_SUPPORT_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0004)
+
+/**
+ * \brief Scenes Cluster client's command identifiers
+*/
+
+#define ZCL_SCENES_CLUSTER_ADD_SCENE_COMMAND_ID 0x00
+#define ZCL_SCENES_CLUSTER_VIEW_SCENE_COMMAND_ID 0x01
+#define ZCL_SCENES_CLUSTER_REMOVE_SCENE_COMMAND_ID 0x02
+#define ZCL_SCENES_CLUSTER_REMOVE_ALL_SCENES_COMMAND_ID 0x03
+#define ZCL_SCENES_CLUSTER_STORE_SCENE_COMMAND_ID 0x04
+#define ZCL_SCENES_CLUSTER_RECALL_SCENE_COMMAND_ID 0x05
+#define ZCL_SCENES_CLUSTER_GET_SCENE_MEMBERSHIP_COMMAND_ID 0x06
+
+/**
+ * \brief Scenes Cluster servers's command identifiers
+*/
+
+#define ZCL_SCENES_CLUSTER_ADD_SCENE_RESPONSE_COMMAND_ID 0x00
+#define ZCL_SCENES_CLUSTER_VIEW_SCENE_RESPONSE_COMMAND_ID 0x01
+#define ZCL_SCENES_CLUSTER_REMOVE_SCENE_RESPONSE_COMMAND_ID 0x02
+#define ZCL_SCENES_CLUSTER_REMOVE_ALL_SCENES_RESPONSE_COMMAND_ID 0x03
+#define ZCL_SCENES_CLUSTER_STORE_SCENE_RESPONSE_COMMAND_ID 0x04
+#define ZCL_SCENES_CLUSTER_GET_SCENE_MEMBERSHIP_RESPONSE_COMMAND_ID 0x06
+
+
+/**
+ * \brief Scenes Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_SCENES_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(sceneCount, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_SCENE_COUNT_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(currentScene, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_CURRENT_SCENE_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(currentGroup, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_CURRENT_GROUP_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(sceneValid, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_SCENE_VALID_SERVER_ATTRIBUTE_ID, ZCL_BOOLEAN_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(nameSupport, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_NAME_SUPPORT_SERVER_ATTRIBUTE_ID, ZCL_8BIT_BITMAP_DATA_TYPE_ID)
+
+
+/**
+ * \brief On/Off Cluster define commands macros
+*/
+
+#define ZCL_DEFINE_SCENES_CLUSTER_COMMANDS(addSceneCommandInd, viewSceneCommandInd, removeSceneCommandInd, \
+ removeAllScenesCommandInd, storeSceneCommandInd, recallSceneCommandInd, \
+ getSceneMembershipCommandInd, addSceneResponseCommandInd, viewSceneResponseCommandInd, \
+ removeSceneResponseCommandInd, removeAllScenesResponseCommandInd, storeSceneResponseCommandInd, \
+ getSceneMembershipResponseInd) \
+ DEFINE_COMMAND(addSceneCommand, ZCL_SCENES_CLUSTER_ADD_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addSceneCommandInd), \
+ DEFINE_COMMAND(viewSceneCommand, ZCL_SCENES_CLUSTER_VIEW_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ viewSceneCommandInd), \
+ DEFINE_COMMAND(removeSceneCommand, ZCL_SCENES_CLUSTER_REMOVE_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeSceneCommandInd), \
+ DEFINE_COMMAND(removeAllScenesCommand, ZCL_SCENES_CLUSTER_REMOVE_ALL_SCENES_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeAllScenesCommandInd), \
+ DEFINE_COMMAND(storeSceneCommand, ZCL_SCENES_CLUSTER_STORE_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ storeSceneCommandInd), \
+ DEFINE_COMMAND(recallSceneCommand, ZCL_SCENES_CLUSTER_RECALL_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ recallSceneCommandInd), \
+ DEFINE_COMMAND(getSceneMembershipCommand, ZCL_SCENES_CLUSTER_GET_SCENE_MEMBERSHIP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ getSceneMembershipCommandInd), \
+ DEFINE_COMMAND(addSceneResponseCommand, ZCL_SCENES_CLUSTER_ADD_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addSceneResponseCommandInd), \
+ DEFINE_COMMAND(viewSceneResponseCommand, ZCL_SCENES_CLUSTER_VIEW_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ viewSceneResponseCommandInd), \
+ DEFINE_COMMAND(removeSceneResponseCommand, ZCL_SCENES_CLUSTER_REMOVE_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeSceneResponseCommandInd), \
+ DEFINE_COMMAND(removeAllScenesResponseCommand, ZCL_SCENES_CLUSTER_REMOVE_ALL_SCENES_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeAllScenesResponseCommandInd), \
+ DEFINE_COMMAND(storeSceneResponseCommand, ZCL_SCENES_CLUSTER_STORE_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ storeSceneResponseCommandInd), \
+ DEFINE_COMMAND(getSceneMembershipResponse, ZCL_SCENES_CLUSTER_GET_SCENE_MEMBERSHIP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ getSceneMembershipResponseInd)
+
+
+/**
+ * \brief Scene Cluster definition macros
+*/
+
+#define SCENES_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = SCENES_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_SCENES_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_SCENES_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define SCENES_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = SCENES_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_SCENES_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_SCENES_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_SCENES_CLUSTER(cltype, clattributes, clcommands) \
+ SCENES_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+
+/**
+ * \brief Add Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+ uint16_t transitionTime;
+ uint8_t sceneNameAndExtField[1];
+} ZCL_AddScene_t;
+
+/**
+ * \brief View Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_ViewScene_t;
+
+/**
+ * \brief Remove Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_RemoveScene_t;
+
+/**
+ * \brief Remove All Scenes Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+} ZCL_RemoveAllScenes_t;
+
+/**
+ * \brief Store Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_StoreScene_t;
+
+/**
+ * \brief Recall Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_RecallScene_t;
+
+/**
+ * \brief Get Scene Membership Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+} ZCL_GetSceneMembership_t;
+
+/**
+ * \brief Add Scene Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_AddSceneResponse_t;
+
+/**
+ * \brief View Scene Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+ uint16_t transitionTime;
+ uint8_t nameAndExtField[1]; // string sceneName, extension field.
+} ZCL_ViewSceneResponse_t;
+
+/**
+ * \brief Remove Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_RemoveSceneResponse_t;
+
+/**
+ * \brief Remove All Scenes Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+} ZCL_RemoveAllScenesResponse_t;
+
+/**
+ * \brief Store Scene Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_StoreSceneResponse_t;
+
+/**
+ * \brief Get Scene Membership Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint8_t capacity;
+ uint16_t groupId;
+ uint8_t sceneCount;
+ uint8_t sceneList[1];
+} ZCL_GetSceneMembershipResponse_t;
+
+/**
+ * \brief Scene Cluster server's attributes
+ */
+
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } sceneCount;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } currentScene;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } currentGroup;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ bool value;
+ } sceneValid;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } nameSupport;
+} ZCL_SceneClusterServerAttributes_t;
+
+END_PACK
+
+/**
+ * \brief Scene Cluster commands.
+ */
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddScene_t * payload);
+ } addSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*viewSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ViewScene_t * payload);
+ } viewSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveScene_t * payload);
+ } removeSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeAllScenesCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveAllScenes_t * payload);
+ } removeAllScenesCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*storeSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_StoreScene_t * payload);
+ } storeSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*recallSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RecallScene_t * payload);
+ } recallSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*getSceneMembershipCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetSceneMembership_t * payload);
+ } getSceneMembershipCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddSceneResponse_t * payload);
+ } addSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*viewSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ViewSceneResponse_t * payload);
+ } viewSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveSceneResponse_t * payload);
+ } removeSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeAllScenesResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveAllScenesResponse_t * payload);
+ } removeAllScenesResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*storeSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_StoreSceneResponse_t * payload);
+ } storeSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*getSceneMembershipResponse)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetSceneMembershipResponse_t * payload);
+ } getSceneMembershipResponse;
+} ZCL_ScenesClusterCommands_t;
+
+
+#endif /* _ZCLSCENESCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclSecurityManager.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclSecurityManager.h
new file mode 100644
index 00000000..e91cd669
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclSecurityManager.h
@@ -0,0 +1,190 @@
+/***************************************************************************//**
+ \file zclSecurityManager.h
+
+ \brief
+ The header file describes the ZCL Security Manager and its interface
+
+ The file describes the types and interface of the ZCL Security Manager
+
+ \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:
+ 17.03.09 A. Potashov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLSECURITYMANAGER_H
+#define _ZCLSECURITYMANAGER_H
+
+#ifdef _ZCL_SECURITY_
+#include <zcl.h>
+#include <zdo.h>
+#include <genericEcc.h>
+
+typedef enum
+{
+ ZCL_SECURITY_STATUS_SUCCESS = 0x00,
+#ifdef _CERTICOM_SECURITY_
+ ZCL_SECURITY_STATUS_DISCOVERY_FAIL = 0x01,
+ ZCL_SECURITY_STATUS_APS_BINDING_FAIL = 0x02,
+ ZCL_SECURITY_STATUS_TIMEOUT = 0x03,
+ ZCL_SECURITY_STATUS_TERMINATED = 0x04,
+ ZCL_SECURITY_STATUS_SEND_COMMAND_FAIL = 0x05,
+ ZCL_SECURITY_STATUS_INVALID_SETTINGS = 0x06,
+#endif //#ifdef _CERTICOM_SECURITY_
+} ZCL_SecurityStatus_t;
+
+
+/*************************************************************************//**
+ Status of ZCL operation
+ \brief
+ Used to return status of ZCL operation.
+*****************************************************************************/
+/*
+typedef enum
+{
+ ZCL_SUCCESS_STATUS = 0x00,
+ ZCL_UNSUPPORTED_ATTRIBUTE_STATUS = 0x01,
+ ZCL_INVALID_ATTRIBUTE_VALUE_STATUS = 0x02,
+ ZCL_TC_PERMISSION_TABLE_ERROR_STATUS = 0x03,
+ ZCL_APS_LINK_KEY_ERROR_STATUS = 0x04
+} ZCL_Status_t;
+*/
+
+BEGIN_PACK
+
+typedef struct PACK
+{
+ ExtAddr_t addr; //!<Destination node 64-bit IEEE address
+ uint8_t key[SECURITY_KEY_SIZE]; //!<APS Link Key
+} ZCL_LinkKeyDesc_t;
+
+typedef struct PACK
+{
+ ProfileId_t profileId;
+ uint8_t additional[8];
+} ZclKEProfileAttributeData_t;
+
+typedef struct PACK
+{
+ uint8_t publicReconstrKey[SECT163K1_COMPRESSED_PUBLIC_KEY_SIZE]; //22-byte
+ ExtAddr_t subject; //8-bytes
+ ExtAddr_t issuer; //8-byte
+ ZclKEProfileAttributeData_t profileAttributeData; //10-byte
+} ZclCertificate_t;
+
+#ifdef _CERTICOM_SECURITY_
+typedef struct PACK
+{
+ uint8_t publicKey[SECT163K1_COMPRESSED_PUBLIC_KEY_SIZE]; //!<CA Public Key shared between all nodes in network
+ uint8_t privateKey[SECT163K1_PRIVATE_KEY_SIZE]; //!<Node secret key
+ uint8_t certificate[SECT163K1_CERTIFICATE_SIZE ]; //!<Node certificate derived from CA
+} ZCL_CertificateDesc_t;
+
+typedef struct PACK
+{
+ uint8_t publicKey[SECT163K1_COMPRESSED_PUBLIC_KEY_SIZE]; //!<CA Public Key shared between all nodes in network
+ uint8_t privateKey[SECT163K1_PRIVATE_KEY_SIZE]; //!<Node secret key
+ ZclCertificate_t certificate; //!<Node certificate derived from CA
+} ZCL_KECertificateDescriptor_t;
+
+#endif //#ifdef _CERTICOM_SECURITY_
+
+END_PACK
+
+
+/*************************************************************************//**
+ Security variable identifier type
+ \brief
+ Used by functions ZCL_Set and ZCL_Get. To define variable to write or read.
+*****************************************************************************/
+typedef enum
+{
+#ifdef _CERTICOM_SECURITY_
+ /* Certificate for Key Establishment */
+ ZCL_CERTIFICATE_DESC_ID = 0x00,
+#endif //#ifdef _CERTICOM_SECURITY_
+ /* Link key descriptor*/
+ ZCL_LINK_KEY_DESC_ID = 0x01,
+ /* Not used */
+ ZCL_REMOVE_LINK_KEY_ID = 0x02,
+#ifdef _CERTICOM_SECURITY_
+ /* Endpoint asssigned for Key Establishment cluster */
+ ZCL_KE_ACTIVE_ENDPOINT_ID = 0x03,
+#endif //#ifdef _CERTICOM_SECURITY_
+ /* Network key */
+ ZCL_NETWORK_KEY_ID = 0x04
+} ZCL_SecurityAttrId_t;
+
+typedef union
+{
+#ifdef _CERTICOM_SECURITY_
+ ZCL_CertificateDesc_t *certificateDesc; //Used with ZCL_CERTIFICATE_DESC_ID
+ Endpoint_t endpoint; //Used with ZCL_KE_ACTIVE_ENDPOINT_ID
+#endif //#ifdef _CERTICOM_SECURITY_
+ ZCL_LinkKeyDesc_t *linkKeyDesc; //Used with ZCL_LINK_KEY_DESC_ID
+ uint8_t *networkKey; //Used with ZCL_NETWORK_KEY_ID
+ ExtAddr_t extAddr; //Used with ZCL_REMOVE_LINK_KEY_ID
+} ZCL_SecurityAttrValue_t;
+
+typedef struct
+{
+ ZCL_SecurityAttrId_t id;
+ uint8_t length;
+ ZCL_SecurityAttrValue_t value;
+} ZCL_SecurityAttr_t;
+
+typedef struct
+{
+ ZCL_SecurityAttr_t attr;
+ ZCL_Status_t status;
+} ZCL_Set_t;
+
+typedef struct
+{
+ ZCL_SecurityAttr_t attr;
+ ZCL_Status_t status;
+} ZCL_Get_t;
+
+typedef struct
+{
+ ZCL_SecurityStatus_t status;
+} ZCL_StartSecurityConf_t;
+
+typedef struct
+{
+ ZCL_StartSecurityConf_t confirm;
+ void (* ZCL_StartSecurityConf)(ZCL_StartSecurityConf_t *conf);
+} ZCL_StartSecurityReq_t;
+//API
+
+extern bool keSrvMode;
+extern Endpoint_t clKEEndpoint;
+extern Endpoint_t srvKEEndpoint;
+
+void ZCL_ResetSecurity(void);
+
+void ZCL_Set(ZCL_Set_t *req);
+
+void ZCL_Get(ZCL_Get_t *req);
+
+void ZCL_StartSecurityReq(ZCL_StartSecurityReq_t *req);
+
+#ifdef _CERTICOM_SECURITY_
+/*************************************************************************************//**
+ \brief Notifies that Key Establishment is finished with status specified in parameters.
+
+ \param status - status of Key Establishment.
+******************************************************************************************/
+void keNotification(ZCL_SecurityStatus_t status);
+#endif
+
+#endif //#ifdef _ZCL_SECURITY_
+#endif //#ifndef _ZCLSECURITYMANAGER_H
+
+//eof zclSecurityManager.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclSimpleMeteringCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclSimpleMeteringCluster.h
new file mode 100644
index 00000000..e96f8043
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclSimpleMeteringCluster.h
@@ -0,0 +1,175 @@
+/************************************************************************//**
+ \file zclMemoryManager.h
+
+ \brief
+ The header file describes the ZCL Simple Metering Cluster
+
+ The header file describes the ZCL Simple Metering 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 _SIMPLEMETERINGCLUSTER_H
+#define _SIMPLEMETERINGCLUSTER_H
+
+#include <zcl.h>
+#include <clusters.h>
+
+#define CURRENT_SUMMATION_DELIVERED_ATTRIBUTE_ID 0x00
+
+/*************************************************************************//**
+ \brief Simple Metering Cluster attributes amount
+*****************************************************************************/
+#define SIMPLE_METERING_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+#define SIMPLE_METERING_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 5
+
+/*************************************************************************//**
+ \brief Simple Metering Cluster commands amount
+*****************************************************************************/
+#define SIMPLE_METERING_CLUSTER_CLIENT_COMMANDS_AMOUNT 0
+#define SIMPLE_METERING_CLUSTER_SERVER_COMMANDS_AMOUNT 0
+
+#define DEFINE_SIMPLE_METERING_SERVER_ATTRIBUTES(min, max) \
+ DEFINE_REPORTABLE_ATTRIBUTE(currentSummationDelivered, ZCL_READONLY_ATTRIBUTE, CCPU_TO_LE16(0x0000), ZCL_U48BIT_DATA_TYPE_ID, min, max), \
+ DEFINE_ATTRIBUTE(meterStatus, ZCL_READONLY_ATTRIBUTE, CCPU_TO_LE16(0x0200), ZCL_8BIT_BITMAP_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(unitofMeasure, ZCL_READONLY_ATTRIBUTE, CCPU_TO_LE16(0x0300), ZCL_8BIT_ENUM_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(summationFormatting, ZCL_READONLY_ATTRIBUTE, CCPU_TO_LE16(0x0303), ZCL_8BIT_BITMAP_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(meteringDeviceType, ZCL_READONLY_ATTRIBUTE, CCPU_TO_LE16(0x0306), ZCL_8BIT_ENUM_DATA_TYPE_ID)
+
+#define SIMPLE_METERING_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = SIMPLE_METERING_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = SIMPLE_METERING_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = SIMPLE_METERING_CLUSTER_CLIENT_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+#define SIMPLE_METERING_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = SIMPLE_METERING_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = SIMPLE_METERING_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = SIMPLE_METERING_CLUSTER_SERVER_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+#define DEFINE_SIMPLE_METERING_CLUSTER(cltype, clattributes, clcommands) SIMPLE_METERING_CLUSTER_##cltype(clattributes, clcommands)
+
+BEGIN_PACK
+
+/*************************************************************************//**
+ \brief ZCL Simple Metering Cluster Descriptor
+
+ For internal use
+*****************************************************************************/
+typedef struct PACK
+{
+ //!Reading information attribute set (Id = 0x00)
+ //!Current Summation Delivered Attribute descriptor
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0000)
+ uint8_t type; //!<Attribute data type (Unsignet 48 bit Integer)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value[6]; //!<Attribute value
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+ uint8_t reportableChange[6]; //!<Reporting change field value
+ ZCL_ReportTime_t timeoutPeriod; //!<Timeout period field value
+ } currentSummationDelivered;
+
+ //!Meter status attribute set (Id = 0x02)
+ //!Meter Status Attribute descriptor
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0200)
+ uint8_t type; //!<Attribute data type (8 bit Bitmap)
+ uint8_t properties; //!<Attribute properties bitmask
+ //!Attribute value
+ struct PACK
+ {
+ LITTLE_ENDIAN_OCTET(8,(
+ uint8_t checkMeter :1, //!<Check Meter
+ uint8_t lowBattery :1, //!<Low Battery
+ uint8_t tamperDetect :1, //!<Tamper Detect
+ uint8_t powerFailure :1, //!<Power Failure
+ uint8_t powerQuality :1, //!<Power Quality
+ uint8_t leakDetect :1, //!<Leak Detect
+ uint8_t serviceDisconnectOpen :1, //!<Service Disconnect Open
+ uint8_t reserved :1 //!<Reserved
+ ))
+ } value;
+ } meterStatus;
+
+ //!Formating attribute set (Id = 0x03)
+ //!UnitofMeasure Attribute descriptor
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0300)
+ uint8_t type; //!<Attribute type (8-bit Enumeration)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value; //!<Attribute value
+ } unitofMeasure;
+
+ //!Summation Formatting Attribute descriptor
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0303)
+ uint8_t type; //!<Attribute type (8 bit Bitmap)
+ uint8_t properties; //!<Attribute properties bitmask
+ /**
+ \brief Attribute value
+ Summation Formatting provides a method to properly decipher the number of digits
+ and the decimal location of the values found in the Summation Information Set
+ of the attributes.
+ */
+ struct PACK
+ {
+ LITTLE_ENDIAN_OCTET(3,(
+ uint8_t right :3, //!<Number of Digits to the right of the Decimal Point
+ uint8_t left :4, //!<Number of Digits to the left of the Decimal Point
+ uint8_t zeros :1 //!<If set, suppress leading zeros
+ ))
+ } value;
+ } summationFormatting;
+
+ //!Metering Device Type Attribute descriptor
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0306)
+ uint8_t type; //!<Attribute type (8 bit Bitmap)
+ uint8_t properties; //!<Attribute properties bitmask
+ /**
+ \brief Attribute value
+ MeteringDeviceType provides a lable for identifying of metering device present.
+ The attribute are enumerated values presenting Energy, GAs, Water, Thermal, and
+ mirrored metering device.
+ */
+ struct PACK
+ {
+ LITTLE_ENDIAN_OCTET(6,(
+ uint8_t electricMetering :1, //!<Electric Metering (0)
+ uint8_t gasMetering :1, //!<Gas Metering (1)
+ uint8_t waterMetering :1, //!<Water Metering (2)
+ uint8_t thermalMetering :1, //!<Thermal Metering (3)
+ uint8_t pressureMetering :1, //!<Pressure Metering (4)
+ uint8_t reserved :3 //!<Reserved
+ ))
+ } value;
+ } meteringDeviceType;
+} SimpleMeteringServerClusterAttributes_t;
+END_PACK
+#endif // _SIMPLEMETERINGCLUSTER_H
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTaskManager.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTaskManager.h
new file mode 100644
index 00000000..9e4e7ffc
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTaskManager.h
@@ -0,0 +1,71 @@
+/************************************************************************//**
+ \file zclTaskManager.h
+
+ \brief
+ The header file describes the public interface of ZCL Task Manager
+
+ The file describes the public interface and types of ZCL Task Manager
+
+ \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 (BitCloudTMs).
+
+ \internal
+ History:
+ 01.12.08 A. Poptashov - Created.
+******************************************************************************/
+
+#ifndef _ZCLTASKMANAGER_H
+#define _ZCLTASKMANAGER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include "types.h"
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/** Identifiers of ZCL task handlers. */
+typedef enum _ZclTaskId_t
+{
+ ZCL_CAPS_TASK_ID,
+ ZCL_SUBTASK_ID,
+ ZCL_PARSER_TASK_ID,
+ ZCL_TASKS_SIZE
+} ZclTaskId_t;
+
+/** Bit array of ZCL task. If bit is '1' the task is posted. */
+typedef uint8_t ZclTaskBitMask_t;
+
+/** Type of iterator for task identifiers. */
+typedef uint8_t ZclTaskIdIter_t;
+
+/******************************************************************************
+ External variables section
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/*************************************************************************//**
+ \brief ZCL Task Manager post task function
+ \param[in] taskId - Determines the task Id to be posted (ZclTaskId_t should be used)
+*****************************************************************************/
+void zclPostTask(ZclTaskId_t taskId);
+
+/*************************************************************************//**
+ \brief Task Manager task handler function
+*****************************************************************************/
+void ZCL_TaskHandler(void);
+
+#endif //#ifndef _ZCLTASKMANAGER_H
+
+//eof zclTaskManager.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTemperatureMeasurementCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTemperatureMeasurementCluster.h
new file mode 100644
index 00000000..813313d9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTemperatureMeasurementCluster.h
@@ -0,0 +1,121 @@
+/*****************************************************************************
+ \file zclTemperatureMeasurement.h
+
+ \brief
+ The file describes the types and interface of the Temperature Measurement 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:
+ 18.01.2010 I.Vagulin - Created
+******************************************************************************/
+
+
+#ifndef _ZCLTEMPERATUREMEASUREMENT_H_
+#define _ZCLTEMPERATUREMEASUREMENT_H_
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+#include <types.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+/**
+* \brief server attributes amount
+*/
+#define ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 3
+
+/**
+* \brief server commands amount
+*/
+#define ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_COMMANDS_AMOUNT 0
+
+/**
+* \brief client attributes amount
+*/
+#define ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+* \brief client commands amount
+*/
+#define ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_CLIENT_COMMANDS_AMOUNT 0
+
+/**
+* \brief Supported attribue id
+*/
+#define ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_MEASURED_VALUE_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_MIN_MEASURED_VALUE_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+#define ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_MAX_MEASURED_VALUE_ATTRIBUTE_ID CCPU_TO_LE16(0x0002)
+
+/**
+ * \brief server define attributes macros
+*/
+#define ZCL_DEFINE_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_ATTRIBUTES(reportMin, reportMax) \
+ DEFINE_REPORTABLE_ATTRIBUTE(measuredValue, ZCL_READONLY_ATTRIBUTE, ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_MEASURED_VALUE_ATTRIBUTE_ID, ZCL_S16BIT_DATA_TYPE_ID, reportMin, reportMax), \
+ DEFINE_ATTRIBUTE(minMeasuredValue, ZCL_READONLY_ATTRIBUTE, ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_MIN_MEASURED_VALUE_ATTRIBUTE_ID, ZCL_S16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(maxMeasuredValue, ZCL_READONLY_ATTRIBUTE, ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_MAX_MEASURED_VALUE_ATTRIBUTE_ID, ZCL_S16BIT_DATA_TYPE_ID)
+
+#define ZCL_DEFINE_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER(clattributes) \
+ { \
+ .id = TEMPERATURE_MEASUREMENT_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) (clattributes), \
+ .commandsAmount = ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_SERVER_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+#define ZCL_DEFINE_TEMPERATURE_MEASUREMENT_CLUSTER_CLIENT() \
+ { \
+ .id = TEMPERATURE_MEASUREMENT_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = NULL, \
+ .commandsAmount = ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_CLIENT_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+typedef struct PACK {
+ struct PACK {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ int16_t value;
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+ int16_t reportableChange; //!<Reporting change field value
+ ZCL_ReportTime_t timeoutPeriod; //!<Timeout period field value
+ } measuredValue ;
+
+ struct PACK {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ int16_t value;
+ } minMeasuredValue ;
+
+ struct PACK {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ int16_t value;
+ } maxMeasuredValue ;
+} ZCL_TemperatureMeasurementClusterAttributes_t ;
+END_PACK
+
+
+#endif /* _ZCLTEMPERATUREMEASUREMENT_H_ */
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclThermostatCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclThermostatCluster.h
new file mode 100644
index 00000000..c88f7cbd
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclThermostatCluster.h
@@ -0,0 +1,214 @@
+/***************************************************************************//**
+ \file zclThermostatCluster.h
+
+ \brief
+ The header file describes the ZCL Thermostat Cluster and its interface
+
+ The file describes the types and interface of the ZCL Thermostat 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:
+ 01.07.10 A. Egorov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLTHERMOSTATCLUSTER_H
+#define _ZCLTHERMOSTATCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/***************************************************************************//**
+\brief Thermostat Cluster server attributes amount
+*******************************************************************************/
+
+#define ZCL_THERMOSTAT_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 5
+
+/***************************************************************************//**
+\brief Thermostat Cluster client attributes amount. Clinet doesn't have attributes
+*******************************************************************************/
+
+#define ZCL_THERMOSTAT_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT 0
+
+/***************************************************************************//**
+\brief Thermostat Cluster commands amount
+*******************************************************************************/
+
+#define ZCL_THERMOSTAT_CLUSTER_COMMANDS_AMOUNT 1
+
+/***************************************************************************//**
+\brief Thermostat Cluster server's attributes identifiers
+*******************************************************************************/
+
+#define ZCL_THERMOSTAT_CLUSTER_LOCAL_TEMPERATURE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_THERMOSTAT_CLUSTER_OCCUPIED_COOLING_SETPOINT_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0011)
+#define ZCL_THERMOSTAT_CLUSTER_OCCUPIED_HEATING_SETPOINT_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0012)
+#define ZCL_THERMOSTAT_CLUSTER_CONTROL_SEQUENCE_OF_OPERATION_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x001b)
+#define ZCL_THERMOSTAT_CLUSTER_SYSTEM_MODE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x001c)
+
+/***************************************************************************//**
+\brief Thermostat Cluster client's command identifiers
+*******************************************************************************/
+
+#define ZCL_THERMOSTAT_CLUSTER_SETPOINT_RAISE_LOWER_COMMAND_ID 0x00
+
+/***************************************************************************//**
+\brief Thermostat Cluster server define attributes macros
+*******************************************************************************/
+
+#define ZCL_DEFINE_THERMOSTAT_CLUSTER_SERVER_ATTRIBUTES(min, max) \
+ DEFINE_REPORTABLE_ATTRIBUTE(localTemperature, ZCL_READONLY_ATTRIBUTE, ZCL_THERMOSTAT_CLUSTER_LOCAL_TEMPERATURE_SERVER_ATTRIBUTE_ID, ZCL_S16BIT_DATA_TYPE_ID, min, max),\
+ DEFINE_ATTRIBUTE(occupiedCoolingSetpoint, ZCL_READWRITE_ATTRIBUTE, ZCL_THERMOSTAT_CLUSTER_OCCUPIED_COOLING_SETPOINT_SERVER_ATTRIBUTE_ID, ZCL_S16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(occupiedHeatingSetpoint, ZCL_READWRITE_ATTRIBUTE, ZCL_THERMOSTAT_CLUSTER_OCCUPIED_HEATING_SETPOINT_SERVER_ATTRIBUTE_ID, ZCL_S16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(controlSequenceofOperation, ZCL_READWRITE_ATTRIBUTE, ZCL_THERMOSTAT_CLUSTER_CONTROL_SEQUENCE_OF_OPERATION_SERVER_ATTRIBUTE_ID, ZCL_8BIT_ENUM_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(systemMode, ZCL_READWRITE_ATTRIBUTE, ZCL_THERMOSTAT_CLUSTER_SYSTEM_MODE_SERVER_ATTRIBUTE_ID, ZCL_8BIT_ENUM_DATA_TYPE_ID)
+
+
+/***************************************************************************//**
+\brief Thermostat Cluster define commands macros
+*******************************************************************************/
+
+#define ZCL_DEFINE_THERMOSTAT_CLUSTER_COMMANDS(setpointCommandInd) \
+ DEFINE_COMMAND(setpointCommand, ZCL_THERMOSTAT_CLUSTER_SETPOINT_RAISE_LOWER_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ setpointCommandInd)
+
+
+/***************************************************************************//**
+\brief Thermostat Cluster definition macros
+*******************************************************************************/
+
+#define THERMOSTAT_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = THERMOSTAT_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_THERMOSTAT_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_THERMOSTAT_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define THERMOSTAT_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = THERMOSTAT_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_THERMOSTAT_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_THERMOSTAT_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_THERMOSTAT_CLUSTER(cltype, clattributes, clcommands) \
+ THERMOSTAT_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+
+/***************************************************************************//**
+\brief Setpoint Raise/Lower Command Payload format
+*******************************************************************************/
+typedef struct PACK
+{
+ int8_t mode;
+ int8_t amount;
+} ZCL_SetpointRaiseLower_t;
+
+/***************************************************************************//**
+\brief Thermostat Cluster server's attributes
+*******************************************************************************/
+
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ int16_t value;
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+ int16_t reportableChange; //!<Reporting change field value
+ ZCL_ReportTime_t timeoutPeriod; //!<Timeout period field value
+ } localTemperature ;
+
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ int16_t value;
+ } occupiedCoolingSetpoint;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ int16_t value;
+ } occupiedHeatingSetpoint;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ int8_t value;
+ } controlSequenceofOperation;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ int8_t value;
+ } systemMode;
+} ZCL_ThermostatClusterServerAttributes_t;
+
+END_PACK
+
+/***************************************************************************//**
+\brief Thermostat Cluster commands
+*******************************************************************************/
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*setpointCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_SetpointRaiseLower_t * payload);
+ } setpointCommand;
+} ZCL_ThermostatClusterCommands_t;
+
+
+#endif /* _ZCLTHERMOSTATCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTimeCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTimeCluster.h
new file mode 100644
index 00000000..d2e30218
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclTimeCluster.h
@@ -0,0 +1,220 @@
+/***************************************************************************//**
+ \file zclTimeCluster.h
+
+ \brief
+ The header file describes the ZCL Time Cluster and its interface
+
+ The file describes the types and interface of the ZCL Time 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:
+ 02.01.09 A. Potashov - Created.
+*******************************************************************************/
+#ifndef _ZCLTIMECLUSTER_H
+#define _ZCLTIMECLUSTER_H
+
+/*!
+This cluster provides a basic interface to a real-time clock. The clock time may be
+read and also written, in order to synchronize the clock (as close as practical) to a
+time standard. This time standard is the number of seconds since 0 hrs 0 mins 0
+sec on 1st January 2000 UTC (Universal Coordinated Time).
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/***************************************************************************//**
+ \brief ZCL Time Cluster server side commands amount
+*******************************************************************************/
+#define ZCL_TIME_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 2
+//The Time and TimeStatus attributes
+
+/***************************************************************************//**
+ \brief ZCL Time Cluster client side commands amount
+*******************************************************************************/
+#define ZCL_TIME_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+//There is no any attributes at client cluster side
+
+/***************************************************************************//**
+ \brief ZCL Time Cluster commands amount
+*******************************************************************************/
+#define ZCL_TIME_CLUSTER_COMMANDS_AMOUNT 0
+//There is no any commands at client cluster side
+
+
+//!ZCL Time Cluster server side Time attribute id
+#define ZCL_TIME_CLUSTER_SERVER_TIME_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+//!ZCL Time Cluster server side TimeStatus attribute id
+#define ZCL_TIME_CLUSTER_SERVER_TIME_STATUS_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+//!ZCL Time Cluster server side TimeZone attribute id
+#define ZCL_TIME_CLUSTER_SERVER_TIME_ZONE_ATTRIBUTE_ID CCPU_TO_LE16(0x0002)
+//!ZCL Time Cluster server side DstStart attribute id
+#define ZCL_TIME_CLUSTER_SERVER_DST_START_ATTRIBUTE_ID CCPU_TO_LE16(0x0003)
+//!ZCL Time Cluster server side DstEnd attribute id
+#define ZCL_TIME_CLUSTER_SERVER_DST_END_ATRIBUTE_ID CCPU_TO_LE16(0x0004)
+//!ZCL Time Cluster server side DstShift attribute id
+#define ZCL_TIME_CLUSTER_SERVER_DST_SHIFT_ATTRIBUTE_ID CCPU_TO_LE16(0x0005)
+//!ZCL Time Cluster server side StandardTime attribute id
+#define ZCL_TIME_CLUSTER_SERVER_STANDARD_TIME_ATTRIBUTE_ID CCPU_TO_LE16(0x0006)
+//!ZCL Time Cluster server side LocalTime attribute id
+#define ZCL__TIME_CLUSTER_SERVER_LOCAL_TIME_ATTRIBUTE_ID CCPU_TO_LE16(0x0007)
+
+
+/***************************************************************************//**
+ \brief ZCL Time Cluster server side attributes defining macros
+
+ This macros should be used for ZCL Time Cluster server side attributes defining.
+
+ \return None
+
+ \internal
+ //The typical usage is:
+ //Time Cluster server side related attributes
+ ZCL_TimeClusterServerAttributes_t timeClusterAttributes = ZCL_DEFINE_TIME_CLUSTER_SERVER_ATTRIBUTES();
+*******************************************************************************/
+#define ZCL_DEFINE_TIME_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(time, ZCL_READWRITE_ATTRIBUTE, ZCL_TIME_CLUSTER_SERVER_TIME_ATTRIBUTE_ID, ZCL_UTC_TIME_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(timeStatus, ZCL_READWRITE_ATTRIBUTE, ZCL_TIME_CLUSTER_SERVER_TIME_STATUS_ATTRIBUTE_ID, ZCL_8BIT_BITMAP_DATA_TYPE_ID) \
+
+/***************************************************************************//**
+ \brief ZCL Time Cluster server side defining macros
+
+ This macros should be used with #DEFINE_ZCL_TIME_CLUSTER_SERVER_ATTRIBUTES for
+ ZCL Time Cluster server side defining in application.
+
+ \param attributes - pointer to cluster server attributes (ZCL_TimeClusterServerAttributes_t)
+
+ \return None
+
+ \internal
+ //The typical code is:
+ //Time Cluster server side related attributes
+ ZCL_TimeClusterServerAttributes_t timeClusterServerAttributes = DEFINE_ZCL_TIME_CLUSTER_SERVER_ATTRIBUTES();
+ ZCL_Cluster_t myClusters[] =
+ {
+ ZCL_DEFINE_TIME_CLUSTER_SERVER(&timeClusterServerAttributes),
+ //... Any other cluster defining ...
+ }
+*******************************************************************************/
+#define TIME_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = TIME_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_TIME_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) clattributes, \
+ .commandsAmount = ZCL_TIME_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *) clcommands \
+ }
+
+/***************************************************************************//**
+ \brief ZCL Time Cluster client side defining macros
+
+ This macros should be used for ZCL Time Cluster client side defining in application.
+
+ \return None
+
+ \internal
+ //The typical code is:
+ ZCL_Cluster_t myClusters[] =
+ {
+ ZCL_DEFINE_TIME_CLUSTER_CLIENT(),
+ //... Any other cluster defining ...
+ }
+*******************************************************************************/
+#define TIME_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = TIME_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY }, \
+ .attributesAmount = ZCL_TIME_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) clattributes, \
+ .commandsAmount = ZCL_TIME_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *) clcommands \
+ }
+
+#define DEFINE_TIME_CLUSTER(cltype, clattributes, clcommands) TIME_CLUSTER_##cltype(clattributes, clcommands)
+
+/*******************************************************************************
+ Types section
+*******************************************************************************/
+
+BEGIN_PACK
+/***************************************************************************//**
+ \brief
+ ZCL Time Cluster attributes
+*******************************************************************************/
+typedef struct PACK
+{
+ /*!
+ \brief Time attribute (R/W, M)
+
+ The Time attribute is 32-bits in length and holds the time value of a real time
+ clock. This attribute has data type UTCTime, but note that it may not actually be
+ synchronised to UTC - see discussion of the TimeStatus attribute below.
+ If the Master bit of the TimeStatus attribute has a value of 0, writing to this
+ attribute shall set the real time clock to the written value, otherwise it cannot be
+ written. The value 0xffffffff indicates an invalid time.
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0000)
+ uint8_t type; //!<Attribute type (UTCTime - 32-bit) (typeId = 0xe2, #ZCL_UTC_TIME_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ ZCL_UTCTime_t value; //!<Attribute value (default none)
+ } time;
+
+ /*!
+ \brief TimeStatus attribute (R/W, M)
+
+ The Master and Synchronized bits together provide information on how closely
+ the Time attribute conforms to the time standard.
+ The Master bit specifies whether the real time clock corresponding to the Time
+ attribute is internally set to the time standard. This bit is not writeable
+ if a value is written to the TimeStatus attribute, this bit does not change.
+ The Synchronized bit specifies whether Time has been set over the network to
+ synchronize it (as close as may be practical) to the time standard. This
+ bit must be explicitly written to indicate this i.e. it is not set automatically on
+ writing to the Time attribute. If the Master bit is 1, the value of this bit is 0.
+ If both the Master and Synchronized bits are 0, the real time clock has no defined
+ relationship to the time standard (e.g. it may record the number of seconds since
+ the device was initialized).
+ The MasterZoneDst bit specifies whether the TimeZone, DstStart, DstEnd and
+ DstShift attributes are set internally to correct values for the location of the clock.
+ If not, these attributes need to be set over the network. This bit is not writeable if
+ a value is written to the TimeStatus attribute, this bit does not change.
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0001)
+ uint8_t type; //!<Attribute type (8-bit bitmap, typeId = 0x18, #ZCL_8BIT_BITMAP_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ struct PACK //!<Attribute value (default 0b00000000)
+ {
+ LITTLE_ENDIAN_OCTET(4,(
+ uint8_t master :1, //!<Master bit (1 - master clock, 0 - not master clock)
+ uint8_t synchronized :1, //!<Synchronized bit (1- synchronized, 0 - not synchronized)
+ uint8_t masterZoneDst :1, //!<MasterZoneDst bit (1 - master for Time Zone and DST, 0 - not master for Time Zone and DST)
+ uint8_t reserved :5 //!<Reserved field
+ ))
+ } value;
+ } timeStatus;
+} ZCL_TimeClusterServerAttributes_t;
+END_PACK
+#endif // #ifndef _ZCLTIMECLUSTER_H
+
+//eof zclTimeCluster.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZll.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZll.h
new file mode 100644
index 00000000..66753adf
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZll.h
@@ -0,0 +1,155 @@
+/**************************************************************************//**
+ \file zclZll.h
+
+ \brief
+ ZigBee Light Link (ZLL) functions interface.
+
+ \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:
+ 17.03.10 A. Taradov - Created.
+******************************************************************************/
+#ifndef _ZCLZLL_H
+#define _ZCLZLL_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <intrpData.h>
+#include <zcl.h>
+#include <clusters.h>
+#include <zclZllFrameFormat.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+/* Default network parameters, for debug purpose */
+#define ZCL_ZLL_DEFAULT_WORKING_CHANNEL 0x0f
+
+/* ZLL Profile Constants */
+#define APLC_INTERPAN_TRANS_ID_LIFE_TIME 8000 // aplcInterPANTransIdLifeTime
+#define APLC_MAX_PERMIT_JOIN_DURATION 60000 // aplcMaxPermitJoinDuration
+#define APLC_MIN_STARTUP_DELAY_TIME 2000 // aplcMinStartupDelayTime
+#define APLC_RX_WINDOW_DURATIO 5000 // aplcRxWindowDuration
+#define APLC_SCAN_TIMEBASE_DURATION 250 // aplcScanTimeBaseDuration
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum _ZCL_ZllStatus_t
+{
+ ZCL_ZLL_SUCCESS_STATUS = 0x00,
+ ZCL_ZLL_SCAN_RESULT_STATUS = 0xf0,
+ ZCL_ZLL_SCAN_FINISHED_STATUS = 0xf1,
+ ZCL_ZLL_SCAN_ABORTED_STATUS = 0xf2,
+ ZCL_ZLL_IDENTIFY_START_STATUS = 0xf3,
+ ZCL_ZLL_IDENTIFY_STOP_STATUS = 0xf4,
+ ZCL_ZLL_INVALID_SCENARIO_STATUS = 0xf5,
+} ZCL_ZllStatus_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Reset the ZLL layer
+
+This function should be called prior to using any ZLL features. The only
+function called before ZLL reset is ZCL_ZllIbSetAppData(), which provides
+memory that will be used to store application data.
+
+The function restores ZLL and stack parameters from EEPROM as well as
+applicaiton data.
+******************************************************************************/
+void ZCL_ZllReset(void);
+
+/**************************************************************************//**
+\brief Get next output sequence number
+\returns next output sequence number.
+******************************************************************************/
+uint8_t ZCL_ZllGetSeq(void);
+
+/**************************************************************************//**
+\brief Generate new Transaction Identifier and start transaction timer for it
+******************************************************************************/
+void ZCL_ZllGenerateTransactionId(void);
+
+/**************************************************************************//**
+\brief Get current Transaction Identifier
+\returns Current Transaction Identifier.
+******************************************************************************/
+uint32_t ZCL_ZllTransactionId(void);
+
+/**************************************************************************//**
+\brief Generate new Response Identifier
+******************************************************************************/
+void ZCL_ZllGenerateResponseId(void);
+
+/**************************************************************************//**
+\brief Set Response Identifier to specified value
+\param[in] rid - Response Identifier value to be set
+******************************************************************************/
+void ZCL_ZllSetResponseId(uint32_t rid);
+
+/**************************************************************************//**
+\brief Get current Response Identifier
+\returns Current Response Identifier.
+******************************************************************************/
+uint32_t ZCL_ZllResponseId(void);
+
+/**************************************************************************//**
+\brief Get other device's address (after Scan Request has been received)
+\returns Other device's extended address.
+******************************************************************************/
+uint64_t ZCL_ZllOtherDeviceAddress(void);
+
+/**************************************************************************//**
+\brief Check if Scan Response has already been received from the device
+\returns true if Scan Response has already been received from the device.
+******************************************************************************/
+bool ZCL_ZllDublicateRejection(ExtAddr_t ieee);
+
+/**************************************************************************//**
+\brief Assign a new address from the range of free addresses
+\returns Newly assigned address or 0 in case of an error.
+******************************************************************************/
+ShortAddr_t ZCL_ZllAssignAddress(void);
+
+/**************************************************************************//**
+\brief Assign a new group ID from the range of free group IDs
+\returns Newly assigned group ID or 0 in case of an error.
+******************************************************************************/
+uint16_t ZCL_ZllAssignGroupId(void);
+
+/**************************************************************************//**
+\brief Check if the device is in the Factory New state
+
+A router in ZLL applications loses its factory new state after it receives the
+ZLL start network request during commissioning. An end device becomes not a
+factory new device after it commissions the first router, thus creating its own
+network, or joins an existing network through another end device (this is called
+touch link between end devices).
+
+The application may switch a device back to the factory new state by calling the
+ZCL_ZllResetToFactoryNewRequest() function.
+
+\returns Factory New status: \c true if the device is in the Factory New state
+******************************************************************************/
+bool ZCL_ZllIsFactoryNew(void);
+
+/**************************************************************************//**
+\brief Get other device's address (after Scan Request has been received)
+\param[in] header - pointer to the header to be filled
+\param[in] commandId - command ID to be set in the header
+******************************************************************************/
+void zclZllFillFrameHeader(ZclZllFrameHeader_t *header, ZclZllCommandId_t commandId);
+
+#endif // _ZCLZLL_H
+
+// eof zclZll.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllBasicCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllBasicCluster.h
new file mode 100644
index 00000000..1c74eddb
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllBasicCluster.h
@@ -0,0 +1,308 @@
+/***************************************************************************//**
+ \file zclZllBasicCluster.h
+
+ \brief
+ The header file describes the ZLL Basic Cluster and its interface
+
+ \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:
+ 03.01.09 A. Potashov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLZLLBASICCLUSTER_H
+#define _ZCLZLLBASICCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster server side commands amount
+*******************************************************************************/
+#define ZCL_BASIC_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 9
+//The ZCLVersion and PowerSource attributes
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster derver side commands amount
+*******************************************************************************/
+#define ZCL_BASIC_CLUSTER_SERVER_COMMANDS_AMOUNT 0
+//There are no any commands at the server side
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster client side commands amount
+*******************************************************************************/
+#define ZCL_BASIC_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+//There are no any attributes at the client side
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster derver side commands amount
+*******************************************************************************/
+#define ZCL_BASIC_CLUSTER_CLIENT_COMMANDS_AMOUNT 0
+//There are no any commands at the client side
+
+
+//Atribute Ids of Basic Device Information Attribute Set at the server side
+//!ZCL Basic Cluster server side ZCLVersion attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_ZCL_VERSION_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+//!ZCL Basic Cluster server side ApplicationVersion attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_APPLICATION_VERSION_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+//!ZCL Basic Cluster server side StackVersion attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_STACK_VERSION_ATTRIBUTE_ID CCPU_TO_LE16(0x0002)
+//!ZCL Basic Cluster server side HWVersion attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_HW_VERSION_ATTRIBUTE_ID CCPU_TO_LE16(0x0003)
+//!ZCL Basic Cluster server side ManufacturerName attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_MANUFACTURER_NAME_ATTRIBUTE_ID CCPU_TO_LE16(0x0004)
+//!ZCL Basic Cluster server side ModelIdentifier attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_MODEL_IDENTIFIER_ATTRIBUTE_ID CCPU_TO_LE16(0x0005)
+//!ZCL Basic Cluster server side DateCode attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_DATE_CODE_ATTRIBUTE_ID CCPU_TO_LE16(0x0006)
+//!ZCL Basic Cluster server side PowerSource attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_POWER_SOURCE_ATTRIBUTE_ID CCPU_TO_LE16(0x0007)
+
+//Atribute Ids of Basic Device Settings Attribute Set at the server side
+//!ZCL Basic Cluster server side LocationDescription attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_LOCATION_DESCRIPTION_ATTRIBUTE_ID CCPU_TO_LE16(0x0010)
+//!ZCL Basic Cluster server side PhysicalEnvironment attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_PHYSICAL_ENVIRONMENT_ATTRIBUTE_ID CCPU_TO_LE16(0x0011)
+//!ZCL Basic Cluster server side DeviceEnabled attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_DEVICE_ENABLED_ATTRIBUTE_ID CCPU_TO_LE16(0x0012)
+//!ZCL Basic Cluster server side AlarmMask attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_ALARM_MASK_ATTRIBUTE_ID CCPU_TO_LE16(0x0013)
+
+//!ZLL Basic Cluster server side SWBuildID attribute id
+#define ZCL_BASIC_CLUSTER_SERVER_SW_BUILD_ID_ATTRIBUTE_ID CCPU_TO_LE16(0x4000)
+
+//!ZCL Basic Cluster server side ResetToFactoryDeafaults commabd id
+#define ZCL_BASIC_CLUSTER_SERVER_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID 0x00
+
+/*******************************************************************************
+ Types section
+*******************************************************************************/
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster server side attributes defining macros
+
+ This macros should be used for ZCL Basic Cluster server side attributes defining.
+
+ \return None
+
+ \internal
+ //The typical usage is:
+ //Basic Cluster server side related attributes
+ ZCL_BasicClusterServerAttributes_t basicClusterAttributes = ZCL_DEFINE_BASIC_CLUSTER_SERVER_ATTRIBUTES();
+*******************************************************************************/
+#define ZCL_DEFINE_BASIC_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(zclVersion, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_ZCL_VERSION_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID),\
+ DEFINE_ATTRIBUTE(applicationVersion, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_APPLICATION_VERSION_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(stackVersion, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_STACK_VERSION_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(hwVersion, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_HW_VERSION_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(manufacturerName, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_MANUFACTURER_NAME_ATTRIBUTE_ID, ZCL_OCTET_STRING_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(modelIdentifier, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_MODEL_IDENTIFIER_ATTRIBUTE_ID, ZCL_OCTET_STRING_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(dateCode, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_DATE_CODE_ATTRIBUTE_ID, ZCL_OCTET_STRING_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(powerSource, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_POWER_SOURCE_ATTRIBUTE_ID, ZCL_8BIT_ENUM_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(swBuildId, ZCL_READONLY_ATTRIBUTE, ZCL_BASIC_CLUSTER_SERVER_SW_BUILD_ID_ATTRIBUTE_ID, ZCL_OCTET_STRING_DATA_TYPE_ID)
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster server side defining macros
+
+ This macros should be used with #ZCL_DEFINE_BASIC_CLUSTER_SERVER_ATTRIBUTES for
+ ZCL Basic Cluster server side defining in application.
+
+ \param attributes - pointer to cluster server attributes (ZCL_BasicClusterServerAttributes_t)
+
+ \return None
+
+ \internal
+ //The typical code is:
+ //Basic Cluster server side related attributes
+ ZCL_BasicClusterServerAttributes_t basicClusterServerAttributes = DEFINE_ZCL_BASIC_CLUSTER_SERVER_ATTRIBUTES();
+ ZCL_Cluster_t myClusters[] =
+ {
+ ZCL_DEFINE_BASIC_CLUSTER_SERVER(&basicClusterServerAttributes),
+ //... Any other cluster defining ...
+ }
+*******************************************************************************/
+#define ZCL_DEFINE_BASIC_CLUSTER_SERVER(clattributes) \
+ { \
+ .id = BASIC_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_BASIC_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *) clattributes, \
+ .commandsAmount = ZCL_BASIC_CLUSTER_SERVER_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+/***************************************************************************//**
+ \brief ZCL Basic Cluster client side defining macros
+
+ This macros should be used for ZCL Basic Cluster client side defining in application.
+
+ \return None
+
+ \internal
+ //The typical code is:
+ ZCL_Cluster_t myClusters[] =
+ {
+ ZCL_DEFINE_BASIC_CLUSTER_CLIENT(),
+ //... Any other cluster defining ...
+ }
+*******************************************************************************/
+#define ZCL_DEFINE_BASIC_CLUSTER_CLIENT() \
+ { \
+ .id = BASIC_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY, .ackRequest = 1}, \
+ .attributesAmount = ZCL_BASIC_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = NULL, \
+ .commandsAmount = ZCL_BASIC_CLUSTER_CLIENT_COMMANDS_AMOUNT, \
+ .commands = NULL \
+ }
+
+
+BEGIN_PACK
+/***************************************************************************//**
+ \brief
+ ZCL Basic Cluster server side attributes
+*******************************************************************************/
+typedef struct PACK
+{
+ //!Basic Device Information attribute set (Id == 0x00)
+
+ /*!ZCL Version attribute (Read only, M)
+ The ZCLVersion attribute is 8-bits in length and specifies the version number of
+ the ZigBee Cluster Library that all clusters on this endpoint conform to. For the
+ initial version of the ZCL, this attribute shall be set to 0x01.
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0000, #ZCL_BASIC_CLUSTER_SERVER_ZCL_VERSION_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (unsigned 8-bit integer, #ZCL_U8BIT_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value; //!<Attribute value (default 0x00)
+ } zclVersion;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0001, #ZCL_BASIC_CLUSTER_SERVER_APPLICATION_VERSION_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (unsigned 8-bit integer, #ZCL_U8BIT_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value; //!<Attribute value (default 0x00)
+ } applicationVersion;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0002, #ZCL_BASIC_CLUSTER_SERVER_STACK_VERSION_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (unsigned 8-bit integer, #ZCL_U8BIT_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value; //!<Attribute value (default 0x00)
+ } stackVersion;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0003, #ZCL_BASIC_CLUSTER_SERVER_HW_VERSION_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (unsigned 8-bit integer, #ZCL_U8BIT_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value; //!<Attribute value (default 0x00)
+ } hwVersion;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0004, #ZCL_BASIC_CLUSTER_SERVER_MANUFACTURER_NAME_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (octet string, #ZCL_OCTET_STRING_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value[8]; //!<Attribute value
+ } manufacturerName;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0005, #ZCL_BASIC_CLUSTER_SERVER_MODEL_IDENTIFIER_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (octet string, #ZCL_OCTET_STRING_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value[8]; //!<Attribute value
+ } modelIdentifier;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0006, #ZCL_BASIC_CLUSTER_SERVER_DATE_CODE_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (octet string, #ZCL_OCTET_STRING_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value[8]; //!<Attribute value
+ } dateCode;
+
+ /*!Power Source attribute (Read only, M)
+ The PowerSource attribute is 8-bits in length and specifies the source(s) of power
+ available to the device. Bits b0 of this attribute represent the primary power
+ source of the device and bit b7 indicates whether the device has a secondary power
+ source in the form of a battery backup.
+
+ Bits b0 of this attribute shall be set to one of the non-reserved values:
+ 0x00 - Unknown
+ 0x01 - Mains (single phase)
+ 0x02 - Mains (3 phase)
+ 0x03 - Battery
+ 0x04 - DC source
+ 0x05 - Emergency mains constantly powered
+ 0x06 - Emergency mains and transfer switch
+ 0x07-0x7f - Reserved
+
+ Bit b7 of this attribute shall be set to 1 if the device has a secondary power source
+ in the form of a battery backup. Otherwise, bit b7 shall be set to 0.
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x0007, #ZCL_BASIC_CLUSTER_SERVER_POWER_SOURCE_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (8-bit enumeration, #ZCL_8BIT_ENUM_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value; //!<Attribute value (default 0x00)
+ } powerSource;
+
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id; //!<Attribute Id (0x4000, #ZCL_BASIC_CLUSTER_SERVER_SW_BUILD_ID_ATTRIBUTE_ID)
+ uint8_t type; //!<Attribute type (octet string, #ZCL_OCTET_STRING_DATA_TYPE_ID)
+ uint8_t properties; //!<Attribute properties bitmask
+ uint8_t value[8]; //!<Attribute value
+ } swBuildId;
+
+ //!Basic Device Settings attribute set (Id == 0x01)
+} ZCL_BasicClusterServerAttributes_t;
+
+END_PACK
+
+#endif // _ZCLZLLBASICCLUSTER_H
+
+//eof zclZllBasicCluster.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllColorControlCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllColorControlCluster.h
new file mode 100644
index 00000000..941f0f62
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllColorControlCluster.h
@@ -0,0 +1,1004 @@
+/************************************************************************//**
+ \file zclZllColorControlCluster.h
+
+ \brief
+ The header file describes the ZLL Color 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:
+ 07.07.11 A. Razinkov - Created.
+******************************************************************************/
+
+#ifndef _ZCLZLLCOLORCONTROLCLUSTER_H
+#define _ZCLZLLCOLORCONTROLCLUSTER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zcl.h>
+#include <clusters.h>
+
+/******************************************************************************
+ Defines section
+******************************************************************************/
+
+/**
+ * \brief ZLL Server Cluster attributes amount.
+*/
+#define ZCL_COLOR_CONTROL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 32
+
+/**
+ * \brief ZLL Client Cluster attributes amount.
+*/
+#define ZCL_COLOR_CONTROL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief ZLL Cluster server's attributes identifiers
+*/
+
+#define ZCL_ZLL_CLUSTER_CURRENT_HUE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_ZLL_CLUSTER_CURRENT_SATURATION_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+#define ZCL_ZLL_CLUSTER_REMAINING_TIME_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0002)
+#define ZCL_ZLL_CLUSTER_CURRENT_X_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0003)
+#define ZCL_ZLL_CLUSTER_CURRENT_Y_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0004)
+#define ZCL_ZLL_CLUSTER_COLOR_MODE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0008)
+#define ZCL_ZLL_CLUSTER_NUMBER_OF_PRIMARIES_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0010)
+#define ZCL_ZLL_CLUSTER_PRIMARY_1_X_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0011)
+#define ZCL_ZLL_CLUSTER_PRIMARY_1_Y_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0012)
+#define ZCL_ZLL_CLUSTER_PRIMARY_1_INTENSITY_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0013)
+#define ZCL_ZLL_CLUSTER_PRIMARY_2_X_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0015)
+#define ZCL_ZLL_CLUSTER_PRIMARY_2_Y_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0016)
+#define ZCL_ZLL_CLUSTER_PRIMARY_2_INTENSITY_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0017)
+#define ZCL_ZLL_CLUSTER_PRIMARY_3_X_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0019)
+#define ZCL_ZLL_CLUSTER_PRIMARY_3_Y_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x001A)
+#define ZCL_ZLL_CLUSTER_PRIMARY_3_INTENSITY_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x001B)
+#define ZCL_ZLL_CLUSTER_PRIMARY_4_X_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0020)
+#define ZCL_ZLL_CLUSTER_PRIMARY_4_Y_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0021)
+#define ZCL_ZLL_CLUSTER_PRIMARY_4_INTENSITY_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0022)
+#define ZCL_ZLL_CLUSTER_PRIMARY_5_X_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0024)
+#define ZCL_ZLL_CLUSTER_PRIMARY_5_Y_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0025)
+#define ZCL_ZLL_CLUSTER_PRIMARY_5_INTENSITY_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0026)
+#define ZCL_ZLL_CLUSTER_PRIMARY_6_X_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0028)
+#define ZCL_ZLL_CLUSTER_PRIMARY_6_Y_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0029)
+#define ZCL_ZLL_CLUSTER_PRIMARY_6_INTENSITY_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x002A)
+/* Additional attributes */
+#define ZCL_ZLL_CLUSTER_ENHANCED_CURRENT_HUE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4000)
+#define ZCL_ZLL_CLUSTER_ENHANCED_COLOR_MODE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4001)
+#define ZCL_ZLL_CLUSTER_COLOR_LOOP_ACTIVE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4002)
+#define ZCL_ZLL_CLUSTER_COLOR_LOOP_DIRECTION_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4003)
+#define ZCL_ZLL_CLUSTER_COLOR_LOOP_TIME_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4004)
+#define ZCL_ZLL_CLUSTER_COLOR_LOOP_START_ENHANCED_HUE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4005)
+#define ZCL_ZLL_CLUSTER_COLOR_LOOP_STOP_ENHANCED_HUE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4006)
+
+#define DEFINE_COLOR_CONTROL_CLUSTER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(currentHue, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_CURRENT_HUE_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(currentSaturation, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_CURRENT_SATURATION_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(remainingTime, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_REMAINING_TIME_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(currentX, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_CURRENT_X_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(currentY, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_CURRENT_Y_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(colorMode, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_COLOR_MODE_SERVER_ATTRIBUTE_ID, ZCL_8BIT_ENUM_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(numberOfPrimaries, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_NUMBER_OF_PRIMARIES_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary1X, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_1_X_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary1Y, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_1_Y_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary1XIntensity, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_1_INTENSITY_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary2X, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_2_X_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary2Y, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_2_Y_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary2XIntensity, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_2_INTENSITY_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary3X, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_3_X_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary3Y, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_3_Y_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary3XIntensity, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_3_INTENSITY_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary4X, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_4_X_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary4Y, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_4_Y_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary4XIntensity, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_4_INTENSITY_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary5X, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_5_X_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary5Y, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_5_Y_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary5XIntensity, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_5_INTENSITY_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary6X, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_6_X_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary6Y, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_6_Y_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(primary6XIntensity, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_PRIMARY_6_INTENSITY_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(enhancedCurrentHue, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_ENHANCED_CURRENT_HUE_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(enhancedColorMode, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_ENHANCED_COLOR_MODE_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(colorLoopActive, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_COLOR_LOOP_ACTIVE_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(colorLoopDirection, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_COLOR_LOOP_DIRECTION_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(colorLoopTime, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_COLOR_LOOP_TIME_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(colorLoopStartEnhancedHue, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_COLOR_LOOP_START_ENHANCED_HUE_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(colorLoopStopEnhancedHue, ZCL_READONLY_ATTRIBUTE, ZCL_ZLL_CLUSTER_COLOR_LOOP_STOP_ENHANCED_HUE_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID)
+
+/**
+ * \brief ZLL Client Cluster commands amount.
+*/
+#define ZCL_COLOR_CONTROL_CLUSTER_COMMANDS_AMOUNT 16
+
+/**
+ * \brief ZLL Client Cluster commands identifiers.
+*/
+#define MOVE_TO_HUE_COMMAND_ID 0x00
+#define MOVE_HUE_COMMAND_ID 0x01
+#define STEP_HUE_COMMAND_ID 0x02
+#define MOVE_TO_SATURATION_COMMAND_ID 0x03
+#define MOVE_SATURATION_COMMAND_ID 0x04
+#define STEP_SATURATION_COMMAND_ID 0x05
+#define MOVE_TO_HUE_AND_SATURATION_COMMAND_ID 0x06
+#define MOVE_TO_COLOR_COMMAND_ID 0x07
+#define MOVE_COLOR_COMMAND_ID 0x08
+#define STEP_COLOR_COMMAND_ID 0x09
+/* Additional commands */
+#define ENHANCED_MOVE_TO_HUE_COMMAND_ID 0x40
+#define ENHANCED_MOVE_HUE_COMMAND_ID 0x41
+#define ENHANCED_STEP_HUE_COMMAND_ID 0x42
+#define ENHANCED_MOVE_TO_HUE_AND_SATURATION_COMMAND_ID 0x43
+#define COLOR_LOOP_SET_COMMAND_ID 0x44
+#define STOP_MOVE_STEP_COMMAND_ID 0x47
+
+
+#define ZCL_COLOR_CONTROL_CLUSTER_COMMANDS(moveToHueInd, \
+ moveHueInd, \
+ stepHueInd, \
+ moveToSaturationInd, \
+ moveSaturationInd, \
+ stepSaturationInd, \
+ moveToHueAndSaturationInd, \
+ moveToColorInd, \
+ moveColorInd, \
+ stepColorInd, \
+ enhancedMoveToHueInd, \
+ enhancedMoveHueInd, \
+ enhancedStepHueInd, \
+ enhancedMoveToHueAndSaturationInd, \
+ colorLoopSetInd, \
+ stopMoveStepInd) \
+ DEFINE_COMMAND(moveToHueCommand, MOVE_TO_HUE_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), moveToHueInd), \
+ DEFINE_COMMAND(moveHueCommand, MOVE_HUE_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), moveHueInd), \
+ DEFINE_COMMAND(stepHueCommand, STEP_HUE_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), stepHueInd), \
+ DEFINE_COMMAND(moveToSaturationCommand, MOVE_TO_SATURATION_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), moveToSaturationInd), \
+ DEFINE_COMMAND(moveSaturationCommand, MOVE_SATURATION_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), moveSaturationInd), \
+ DEFINE_COMMAND(stepSaturationCommand, STEP_SATURATION_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), stepSaturationInd), \
+ DEFINE_COMMAND(moveToHueAndSaturationCommand, MOVE_TO_HUE_AND_SATURATION_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), moveToHueAndSaturationInd), \
+ DEFINE_COMMAND(moveToColorCommand, MOVE_TO_COLOR_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), moveToColorInd), \
+ DEFINE_COMMAND(moveColorCommand, MOVE_COLOR_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), moveColorInd), \
+ DEFINE_COMMAND(stepColorCommand, STEP_COLOR_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), stepColorInd), \
+ DEFINE_COMMAND(enhancedMoveToHueCommand, ENHANCED_MOVE_TO_HUE_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), enhancedMoveToHueInd), \
+ DEFINE_COMMAND(enhancedMoveHueCommand, ENHANCED_MOVE_HUE_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), enhancedMoveHueInd), \
+ DEFINE_COMMAND(enhancedStepHueCommand, ENHANCED_STEP_HUE_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), enhancedStepHueInd), \
+ DEFINE_COMMAND(enhancedMoveToHueAndSaturationCommand, ENHANCED_MOVE_TO_HUE_AND_SATURATION_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), enhancedMoveToHueAndSaturationInd), \
+ DEFINE_COMMAND(colorLoopSetCommand, COLOR_LOOP_SET_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), colorLoopSetInd), \
+ DEFINE_COMMAND(stopMoveStepCommand, STOP_MOVE_STEP_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), stopMoveStepInd)
+
+#define ZLL_COLOR_CONTROL_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = COLOR_CONTROL_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_COLOR_CONTROL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_COLOR_CONTROL_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+
+#define ZLL_COLOR_CONTROL_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = COLOR_CONTROL_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_COLOR_CONTROL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_COLOR_CONTROL_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+#define DEFINE_COLOR_CONTROL_CLUSTER(cltype, clattributes, clcommands) ZLL_COLOR_CONTROL_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+BEGIN_PACK
+/***************************************************************************//**
+ \brief
+ ZCL Color Control Cluster server side attributes
+*******************************************************************************/
+typedef struct PACK
+{
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } currentHue;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } currentSaturation;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } remainingTime;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } currentX;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } currentY;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } colorMode;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } numberOfPrimaries;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary1X;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary1Y;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } primary1XIntensity;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary2X;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary2Y;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } primary2XIntensity;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary3X;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary3Y;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } primary3XIntensity;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary4X;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary4Y;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } primary4XIntensity;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary5X;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary5Y;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } primary5XIntensity;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary6X;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } primary6Y;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } primary6XIntensity;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } enhancedCurrentHue;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } enhancedColorMode;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } colorLoopActive;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } colorLoopDirection;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } colorLoopTime;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } colorLoopStartEnhancedHue;
+
+ /*!TBD
+ */
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } colorLoopStopEnhancedHue;
+
+} ZCL_ColorControlClusterServerAttributes_t;
+
+END_PACK
+
+/**
+ * \brief MoveToHue command direction values
+*/
+typedef enum _ZCL_ZllMoveToHueDirection_t
+{
+ ZCL_ZLL_MOVE_TO_HUE_DIRECTION_SHORTEST_DISTANCE = 0x00,
+ ZCL_ZLL_MOVE_TO_HUE_DIRECTION_LONGEST_DISTANCE = 0x01,
+ ZCL_ZLL_MOVE_TO_HUE_DIRECTION_UP = 0x02,
+ ZCL_ZLL_MOVE_TO_HUE_DIRECTION_DOWN = 0x03,
+} ZCL_ZllMoveToHueDirection_t;
+
+/**
+ * \brief MoveHue command moveMode values
+*/
+typedef enum _ZCL_ZllMoveHueMoveMode_t
+{
+ ZCL_ZLL_MOVE_HUE_MOVE_MODE_STOP = 0x00,
+ ZCL_ZLL_MOVE_HUE_MOVE_MODE_UP = 0x01,
+ ZCL_ZLL_MOVE_HUE_MOVE_MODE_DOWN = 0x03,
+} ZCL_ZllMoveHueMoveMode_t;
+
+/**
+ * \brief StepHue command stepMode values
+*/
+typedef enum _ZCL_ZllStepHueStepMode_t
+{
+ ZCL_ZLL_STEP_HUE_STEP_MODE_UP = 0x01,
+ ZCL_ZLL_STEP_HUE_STEP_MODE_DOWN = 0x03,
+} ZCL_ZllStepHueStepMode_t;
+
+/**
+ * \brief MoveSaturation command moveMode values
+*/
+typedef enum _ZCL_ZllMoveSaturationMoveMode_t
+{
+ ZCL_ZLL_MOVE_SATURATION_MOVE_MODE_STOP = 0x00,
+ ZCL_ZLL_MOVE_SATURATION_MOVE_MODE_UP = 0x01,
+ ZCL_ZLL_MOVE_SATURATION_MOVE_MODE_DOWN = 0x03,
+} ZCL_ZllMoveSaturationMoveMode_t;
+
+/**
+ * \brief StepSaturation command stepMode values
+*/
+typedef enum _ZCL_ZllStepSaturationStepMode_t
+{
+ ZCL_ZLL_STEP_SATURATION_STEP_MODE_UP = 0x01,
+ ZCL_ZLL_STEP_SATURATION_STEP_MODE_DOWN = 0x03,
+} ZCL_ZllStepSaturationStepMode_t;
+
+/**
+ * \brief ColorLoopSet command action values
+*/
+typedef enum _ZCL_ZllColorLoopSetAction_t
+{
+ ZCL_ZLL_COLOR_LOOP_SET_ACTION_DEACTIVATE = 0x00,
+ ZCL_ZLL_COLOR_LOOP_SET_ACTION_ACTIVATE = 0x01,
+ ZCL_ZLL_COLOR_LOOP_SET_ACTION_ACTIVATE_ENHANCED = 0x02,
+} ZCL_ZllColorLoopSetAction_t;
+
+/**
+ * \brief ColorLoopSet command direction values
+*/
+typedef enum _ZCL_ZllColorLoopSetDirection_t
+{
+ ZCL_ZLL_COLOR_LOOP_SET_DIRECTION_DECREMENT_HUE = 0x00,
+ ZCL_ZLL_COLOR_LOOP_SET_DIRECTION_INCREMENT_HUE = 0x01,
+} ZCL_ZllColorLoopSetDirection_t;
+
+/**
+ * \brief EnhancedColorMode values
+*/
+typedef enum _ZCL_ZllEnhancedColorMode_t
+{
+ ZCL_ZLL_CURRENT_HUE_AND_CURRENT_SATURATION = 0x00,
+ ZCL_ZLL_CURRENT_X_AND_CURRENT_Y = 0x01,
+ ZCL_ZLL_COLOR_TEMPERATURE = 0x02,
+ ZCL_ZLL_ENHANCED_CURRENT_HUE_AND_CURRENT_SATURATION = 0x03,
+} ZCL_ZllEnhancedColorMode_t;
+
+BEGIN_PACK
+/**
+ * \brief MoveToHue command payload format
+*/
+typedef struct PACK _ZCL_ZllMoveToHueCommand_t
+{
+ uint8_t hue;
+ uint8_t direction;
+ uint16_t transitionTime;
+} ZCL_ZllMoveToHueCommand_t;
+
+/**
+ * \brief MoveHue command payload format
+*/
+typedef struct PACK _ZCL_ZllMoveHueCommand_t
+{
+ uint8_t moveMode;
+ uint8_t rate;
+} ZCL_ZllMoveHueCommand_t;
+
+/**
+ * \brief StepHue command payload format
+*/
+typedef struct PACK _ZCL_ZllStepHueCommand_t
+{
+ uint8_t stepMode;
+ uint8_t stepSize;
+ uint8_t transitionTime; /* uint16_t ? */
+} ZCL_ZllStepHueCommand_t;
+
+/**
+ * \brief MoveToSaturation command payload format
+*/
+typedef struct PACK _ZCL_ZllMoveToSaturationCommand_t
+{
+ uint8_t saturation;
+ uint16_t transitionTime;
+} ZCL_ZllMoveToSaturationCommand_t;
+
+/**
+ * \brief MoveSaturation command payload format
+*/
+typedef struct PACK _ZCL_ZllMoveSaturationCommand_t
+{
+ uint8_t moveMode;
+ uint8_t rate;
+} ZCL_ZllMoveSaturationCommand_t;
+
+/**
+ * \brief StepSaturation command payload format
+*/
+typedef struct PACK _ZCL_ZllStepSaturationCommand_t
+{
+ uint8_t stepMode;
+ uint8_t stepSize;
+ uint8_t transitionTime; /* uint16_t ? */
+} ZCL_ZllStepSaturationCommand_t;
+
+/**
+ * \brief MoveToHueAndSaturation command payload format
+*/
+typedef struct PACK _ZCL_ZllMoveToHueAndSaturationCommand_t
+{
+ uint8_t hue;
+ uint8_t saturation;
+ uint16_t transitionTime;
+} ZCL_ZllMoveToHueAndSaturationCommand_t;
+
+/**
+ * \brief MoveToColor command payload format
+*/
+typedef struct PACK _ZCL_ZllMoveToColorCommand_t
+{
+ uint16_t colorX;
+ uint16_t colorY;
+ uint16_t transitionTime;
+} ZCL_ZllMoveToColorCommand_t;
+
+/**
+ * \brief MoveColor command payload format
+*/
+typedef struct PACK _ZCL_ZllMoveColorCommand_t
+{
+ int16_t rateX;
+ int16_t rateY;
+} ZCL_ZllMoveColorCommand_t;
+
+/**
+ * \brief StepColor command payload format
+*/
+typedef struct PACK _ZCL_ZllStepColorCommand_t
+{
+ int16_t stepX;
+ int16_t stepY;
+ uint16_t transitionTime;
+} ZCL_ZllStepColorCommand_t;
+
+/**
+ * \brief EnhancedMoveToHue command payload format
+*/
+typedef struct PACK _ZCL_ZllEnhancedMoveToHueCommand_t
+{
+ uint16_t enhancedHue;
+ uint8_t direction;
+ uint16_t transitionTime;
+} ZCL_ZllEnhancedMoveToHueCommand_t;
+
+/**
+ * \brief EnhancedMoveHue command payload format
+*/
+typedef struct PACK _ZCL_ZllEnhancedMoveHueCommand_t
+{
+ uint8_t moveMode;
+ uint16_t rate;
+} ZCL_ZllEnhancedMoveHueCommand_t;
+
+/**
+ * \brief EnhancedStepHue command payload format
+*/
+typedef struct PACK _ZCL_ZllEnhancedStepHueCommand_t
+{
+ uint8_t stepMode;
+ uint16_t stepSize;
+ uint16_t transitionTime;
+} ZCL_ZllEnhancedStepHueCommand_t;
+
+/**
+ * \brief EnhancedMoveToHueAndSaturation command payload format
+*/
+typedef struct PACK _ZCL_ZllEnhancedMoveToHueAndSaturationCommand_t
+{
+ uint16_t enhancedHue;
+ uint8_t saturation;
+ uint16_t transitionTime;
+} ZCL_ZllEnhancedMoveToHueAndSaturationCommand_t;
+
+/**
+ * \brief ColorLoopSet command payload format
+*/
+typedef struct PACK _ZCL_ZllColorLoopSetCommand_t
+{
+ uint8_t updateFlags;
+ uint8_t action;
+ uint8_t direction;
+ uint16_t time;
+ uint16_t startHue;
+} ZCL_ZllColorLoopSetCommand_t;
+
+/**
+ * \brief Color Control Cluster extension field set
+ */
+typedef struct PACK
+{
+ uint16_t clusterId;
+ uint8_t length;
+ uint16_t currentX;
+ uint16_t currentY;
+ uint16_t enhancedCurrentHue;
+ uint16_t currentSaturation;
+} ZCL_ColorControlClusterExtensionFieldSet_t;
+
+END_PACK
+
+/**
+ * \brief Color Control cluster commands
+ */
+typedef struct _ZCL_ZllColorControlClusterCommands_t
+{
+ //! MoveToHue 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 (*moveToHue)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllMoveToHueCommand_t *payload);
+ } moveToHueCommand;
+
+ //! MoveHue 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 (*moveHue)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllMoveHueCommand_t *payload);
+ } moveHueCommand;
+
+ //! StepHue command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x02)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*stepHue)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllStepHueCommand_t *payload);
+ } stepHueCommand;
+
+ //! MoveToSaturation command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x03)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*moveToSaturation)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllMoveToSaturationCommand_t *payload);
+ } moveToSaturationCommand;
+
+ //! MoveSaturation command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x04)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*moveSaturation)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllMoveSaturationCommand_t *payload);
+ } moveSaturationCommand;
+
+ //! StepSaturation command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x05)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*stepSaturation)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllStepSaturationCommand_t *payload);
+ } stepSaturationCommand;
+
+ //! MoveToHueAndSaturation command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x06)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*moveToHueAndSaturation)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllMoveToHueAndSaturationCommand_t *payload);
+ } moveToHueAndSaturationCommand;
+
+ //! MoveToColor command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x07)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*moveToColor)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllMoveToColorCommand_t *payload);
+ } moveToColorCommand;
+
+ //! MoveColor command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x08)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*moveColor)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllMoveColorCommand_t *payload);
+ } moveColorCommand;
+
+ //! StepColor command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x09)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*stepColor)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllStepColorCommand_t *payload);
+ } stepColorCommand;
+
+ /* Additional commands */
+
+ //! EnhancedMoveToHue command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x40)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*enhancedMoveToHue)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllEnhancedMoveToHueCommand_t *payload);
+ } enhancedMoveToHueCommand;
+
+ //! EnhancedMoveHue command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x41)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*enhancedMoveHue)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllEnhancedMoveHueCommand_t *payload);
+ } enhancedMoveHueCommand;
+
+ //! EnhancedStepHue command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x42)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*enhancedStepHue)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllEnhancedStepHueCommand_t *payload);
+ } enhancedStepHueCommand;
+
+ //! EnhancedMoveToHueAndSaturation command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x43)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*enhancedMoveToHueAndSaturation)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllEnhancedMoveToHueAndSaturationCommand_t *payload);
+ } enhancedMoveToHueAndSaturationCommand;
+
+ //! ColorLoopSet command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x44)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload
+ \return none
+ */
+ ZCL_Status_t (*colorLoopSet)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ZllColorLoopSetCommand_t *payload);
+ } colorLoopSetCommand;
+
+ //! StopMoveStep command descriptor
+ struct
+ {
+ ZCL_CommandId_t id; //!<Command Id (0x47)
+ ZclCommandOptions_t options; //!<Command options
+ /**
+ \brief Command indication handler
+ \param payloadLength - length of payload in cotets
+ \param payload - payload, (no one for this command)
+ \return none
+ */
+ ZCL_Status_t (*stopMoveStep)(ZCL_Addressing_t *addressing, uint8_t payloadLength, void *payload);
+ } stopMoveStepCommand;
+} ZCL_ColorControlClusterCommands_t;
+
+#endif // _ZCLZLLCOLORCONTROLCLUSTER_H
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllCommissioningCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllCommissioningCluster.h
new file mode 100644
index 00000000..75fd07cd
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllCommissioningCluster.h
@@ -0,0 +1,228 @@
+/***************************************************************************//**
+ \file zclZllCommissioningCluster.h
+
+ \brief
+ The header file describes the ZLL Commissioning Cluster and its interface
+
+ \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:
+ 04.07.11 A. Taradov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLZLLCOMISSIONINGCLUSTER_H
+#define _ZCLZLLCOMISSIONINGCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/**
+ * \brief Commissioning Server Cluster attributes amount.
+*/
+
+#define ZCL_COMMISSIONING_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Commissioning Client Cluster attributes amount.
+*/
+
+#define ZCL_COMMISSIONING_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Commissioning Client Cluster commands amount.
+*/
+
+#define ZCL_COMMISSIONING_CLUSTER_COMMANDS_AMOUNT 5
+
+/**
+ * \brief Commissioning Server Cluster commands identifiers.
+*/
+
+#define ZCL_COMMISSIONING_CLUSTER_ENDPOINT_INFORMATION_COMMAND_ID 0x40
+#define ZCL_COMMISSIONING_CLUSTER_GET_GROUP_IDENTIFIERS_RESPONSE_COMMAND_ID 0x41
+#define ZCL_COMMISSIONING_CLUSTER_GET_ENDPOINT_LIST_RESPONSE_COMMAND_ID 0x42
+
+/**
+ * \brief Commissioning Client Cluster commands identifiers.
+*/
+
+#define ZCL_COMMISSIONING_CLUSTER_GET_GROUP_IDENTIFIERS_COMMAND_ID 0x41
+#define ZCL_COMMISSIONING_CLUSTER_GET_ENDPOINT_LIST_COMMAND_ID 0x42
+
+/*
+ * \brief ZCL Commissioning Cluster commands defining macros
+ */
+
+#define ZCL_DEFINE_COMMISSIONING_CLUSTER_COMMANDS(getGroupIdentifiersInd, getEndpointListInd, \
+ endpointInformationResponseInd, getGroupIdentifiersResponseInd, getEndpointListResponseInd) \
+ DEFINE_COMMAND(getGroupIdentifiersCommand, 0x41, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), getGroupIdentifiersInd), \
+ DEFINE_COMMAND(getEndpointListCommand, 0x42, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), getEndpointListInd), \
+ DEFINE_COMMAND(endpointInformationResponseCommand, 0x40, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), endpointInformationResponseInd), \
+ DEFINE_COMMAND(getGroupIdentifiersResponseCommand, 0x41, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), getGroupIdentifiersResponseInd), \
+ DEFINE_COMMAND(getEndpointListResponseCommand, 0x42, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), getEndpointListResponseInd)
+
+
+#define COMMISSIONING_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = ZLL_COMMISSIONING_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_COMMISSIONING_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_COMMISSIONING_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+
+#define COMMISSIONING_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = ZLL_COMMISSIONING_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_COMMISSIONING_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_COMMISSIONING_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+
+#define DEFINE_COMMISSIONING_CLUSTER(cltype, clattributes, clcommands) COMMISSIONING_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+BEGIN_PACK
+
+/**
+ * \brief Get Group Identifiers command format
+*/
+typedef struct PACK
+{
+ uint8_t startIndex;
+} ZCL_GetGroupIdentifiers_t;
+
+/**
+ * \brief Get Endpoint List command format
+*/
+typedef struct PACK
+{
+ uint8_t startIndex;
+} ZCL_GetEndpointList_t;
+
+/**
+ * \brief Endpoint Information Response command format
+*/
+typedef struct PACK
+{
+ uint64_t ieeeAddress;
+ uint16_t networkAddress;
+ uint8_t endpointId;
+ uint16_t profileId;
+ uint16_t deviceId;
+ uint8_t version;
+} ZCL_EndpointInformationResponse_t;
+
+/**
+ * \brief Group Information Record format
+*/
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t groupType;
+} ZCL_GroupInformationRecord_t;
+
+/**
+ * \brief Endpoint Information Record format
+*/
+typedef struct PACK
+{
+ uint16_t networkAddress;
+ uint8_t endpointId;
+ uint16_t profileId;
+ uint16_t deviceId;
+ uint8_t version;
+} ZCL_EndpointInformationRecord_t;
+
+/**
+ * \brief Get Group Identifiers Response command format
+*/
+typedef struct PACK
+{
+ uint8_t total;
+ uint8_t startIndex;
+ uint8_t count;
+ ZCL_GroupInformationRecord_t recordList[5];
+} ZCL_GetGroupIdentifiersResponse_t;
+
+/**
+ * \brief Get Endpoint List Response command format
+*/
+typedef struct PACK
+{
+ uint8_t total;
+ uint8_t startIndex;
+ uint8_t count;
+ ZCL_EndpointInformationRecord_t recordList[1];
+} ZCL_GetEndpointListResponse_t;
+
+END_PACK
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*getGroupIdentifiersCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetGroupIdentifiers_t *payload);
+ } getGroupIdentifiersCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*getEndpointListCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetEndpointList_t *payload);
+ } getEndpointListCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*endpointInformationResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_EndpointInformationResponse_t *payload);
+ } endpointInformationResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*getGroupIdentifiersResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetGroupIdentifiersResponse_t *payload);
+ } getGroupIdentifiersResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*getEndpointListResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetEndpointListResponse_t *payload);
+ } getEndpointListResponseCommand;
+} ZCL_CommissioningClusterCommands_t;
+
+
+#endif // _ZCLZLLCOMISSIONINGCLUSTER_H
+
+// eof zclZllCommissioningCluster.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllFrameFormat.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllFrameFormat.h
new file mode 100644
index 00000000..e09d3023
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllFrameFormat.h
@@ -0,0 +1,265 @@
+/**************************************************************************//**
+ \file zclZllFrameFormat.h
+
+ \brief
+ Inter-PAN commands frame formats for ZLL.
+
+ \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:
+ 16.03.10 A. Taradov - Created.
+******************************************************************************/
+#ifndef _ZCLZLLFRAMEFORMAT_H
+#define _ZCLZLLFRAMEFORMAT_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <sspCommon.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+#define MAX_DEVICE_INFO_ENTRIES_NUMBER 1
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum _ZclZllCommandId_t
+{
+ ZCL_ZLL_SCAN_REQUEST_COMMAND_ID = 0x00,
+ ZCL_ZLL_SCAN_RESPONSE_COMMAND_ID = 0x01,
+ ZCL_ZLL_DEVICE_INFO_REQUEST_COMMAND_ID = 0x02,
+ ZCL_ZLL_DEVICE_INFO_RESPONSE_COMMAND_ID = 0x03,
+ ZCL_ZLL_IDENTIFY_REQUEST_COMMAND_ID = 0x06,
+ ZCL_ZLL_RESET_TO_FACTORY_NEW_REQUEST_COMMAND_ID = 0x07,
+ ZCL_ZLL_NETWORK_START_REQUEST_COMMAND_ID = 0x10,
+ ZCL_ZLL_NETWORK_START_RESPONSE_COMMAND_ID = 0x11,
+ ZCL_ZLL_NETWORK_JOIN_ROUTER_REQUEST_COMMAND_ID = 0x12,
+ ZCL_ZLL_NETWORK_JOIN_ROUTER_RESPONSE_COMMAND_ID = 0x13,
+ ZCL_ZLL_NETWORK_JOIN_ENDDEVICE_REQUEST_COMMAND_ID = 0x14,
+ ZCL_ZLL_NETWORK_JOIN_ENDDEVICE_RESPONSE_COMMAND_ID = 0x15,
+ ZCL_ZLL_NETWORK_UPDATE_REQUEST_COMMAND_ID = 0x16,
+} ZclZllCommandId_t;
+
+BEGIN_PACK
+typedef struct PACK
+{
+ struct
+ {
+ uint8_t frameType : 2; /*! Frame type sub-field */
+ uint8_t manufacturerSpecific : 1; /*! Manufacturer specific sub-field */
+ uint8_t direction : 1; /*! Direction sub-field */
+ uint8_t defaultResponse : 1; /*! Disable default response sub-field */
+ uint8_t reserved : 3; /*! Reserved bits. Must have a zero value */
+ } frameControl;
+ uint8_t seq;
+ uint8_t commandId;
+} ZclZllFrameHeader_t;
+
+typedef struct PACK
+{
+ uint8_t logicalType : 2;
+ uint8_t rxOnWhenIdle : 1;
+ uint8_t reserved : 5;
+} ZclZllZigBeeInfo_t;
+
+typedef struct PACK
+{
+ uint8_t factoryNew : 1;
+ uint8_t addressAssignment : 1;
+ uint8_t compoundDevice : 1;
+ uint8_t relayedScanRequest : 1;
+ uint8_t touchLinkInitiator : 1;
+ uint8_t touchLinkTimeWindow : 1; /*! This field is reserved in Scan Request frame */
+ uint8_t reserved : 2;
+} ZclZllInfo_t;
+
+typedef struct PACK
+{
+ uint64_t ieeeAddress;
+ uint8_t endpoint;
+ uint16_t profileId;
+ uint16_t deviceId;
+ uint8_t version;
+ uint8_t groupIds;
+ uint8_t sort;
+} ZclZllDeviceInfoEntry_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ ZclZllZigBeeInfo_t zigBeeInfo;
+ ZclZllInfo_t zllInfo;
+} ZclZllScanRequestFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint8_t rssiCorrection;
+ ZclZllZigBeeInfo_t zigBeeInfo;
+ ZclZllInfo_t zllInfo;
+ uint16_t keyBitMask;
+ uint32_t responseId;
+ uint64_t extPanId;
+ uint8_t nwkUpdateId;
+ uint8_t channel;
+ uint16_t panId;
+ uint16_t networkAddress;
+ uint8_t numberSubDevices;
+ uint8_t totalGroupIds;
+ // next fields are present only if numberSubDevices == 1
+ union
+ {
+ struct
+ {
+ uint8_t endpoint;
+ uint16_t profileId;
+ uint16_t deviceId;
+ uint8_t version;
+ uint8_t groupIds;
+ };
+ uint64_t ieeeRelayerScanRequest1;
+ };
+ /*! This field is present only if zllInfo.relayedScanRequest == 1 */
+ uint64_t ieeeRelayerScanRequest2;
+} ZclZllScanResponseFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint8_t startIndex;
+} ZclZllDeviceInfoRequestFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint8_t numberSubDevices;
+ uint8_t startIndex;
+ uint8_t count;
+ ZclZllDeviceInfoEntry_t entries[MAX_DEVICE_INFO_ENTRIES_NUMBER];
+} ZclZllDeviceInfoResponseFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint16_t identifyTime;
+} ZclZllIdentifyRequestFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+} ZclZllResetToFactoryNewRequestFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint64_t extendedPanId;
+ uint8_t keyIndex;
+ uint8_t encryptedNwkKey[SECURITY_KEY_SIZE];
+ uint8_t channel;
+ uint16_t panId;
+ uint16_t nwkAddress;
+ uint16_t groupIdsBegin;
+ uint16_t groupIdsEnd;
+ uint16_t freeNwkAddressRangeBegin;
+ uint16_t freeNwkAddressRangeEnd;
+ uint16_t freeGroupIdRangeBegin;
+ uint16_t freeGroupIdRangeEnd;
+ uint64_t edIeeeAddress;
+ uint16_t edNwkAddress;
+} ZclZllNetworkStartRequestFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint8_t status;
+ uint64_t extendedPanId;
+ uint8_t nwkUpdateId;
+ uint8_t channel;
+ uint16_t panId;
+} ZclZllNetworkStartResponseFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint64_t extendedPanId;
+ uint8_t keyIndex;
+ uint8_t encryptedNwkKey[SECURITY_KEY_SIZE];
+ uint8_t nwkUpdateId;
+ uint8_t channel;
+ uint16_t panId;
+ uint16_t nwkAddress;
+ uint16_t groupIdsBegin;
+ uint16_t groupIdsEnd;
+ uint16_t freeNwkAddressRangeBegin;
+ uint16_t freeNwkAddressRangeEnd;
+ uint16_t freeGroupIdRangeBegin;
+ uint16_t freeGroupIdRangeEnd;
+} ZclZllNetworkJoinRouterRequestFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint8_t status;
+} ZclZllNetworkJoinRouterResponseFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint64_t extendedPanId;
+ uint8_t keyIndex;
+ uint8_t encryptedNwkKey[SECURITY_KEY_SIZE];
+ uint8_t nwkUpdateId;
+ uint8_t channel;
+ uint16_t panId;
+ uint16_t nwkAddress;
+ uint16_t groupIdsBegin;
+ uint16_t groupIdsEnd;
+ uint16_t freeNwkAddressRangeBegin;
+ uint16_t freeNwkAddressRangeEnd;
+ uint16_t freeGroupIdRangeBegin;
+ uint16_t freeGroupIdRangeEnd;
+} ZclZllNetworkJoinEndDeviceRequestFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint8_t status;
+} ZclZllNetworkJoinEndDeviceResponseFrame_t;
+
+typedef struct PACK
+{
+ ZclZllFrameHeader_t header;
+ uint32_t transactionId;
+ uint64_t extendedPanId;
+ uint8_t nwkUpdateId;
+ uint8_t channel;
+ uint16_t panId;
+ uint16_t nwkAddress;
+} ZclZllNetworkUpdateRequestFrame_t;
+
+END_PACK
+
+#endif // _ZCLZLLFRAMEFORMAT_H
+
+// eof zclZllFrameFormat.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllGroupsCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllGroupsCluster.h
new file mode 100644
index 00000000..b265c49b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllGroupsCluster.h
@@ -0,0 +1,363 @@
+/***************************************************************************//**
+ \file zclZllGroupsCluster.h
+
+ \brief
+ The header file describes the ZCL ZLL Groups Cluster and its interface
+
+ The file describes the types and interface of the ZCL Groups 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:
+ 12.02.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLZLLGROUPSCLUSTER_H
+#define _ZCLZLLGROUPSCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+#define MAX_GROUPS_IN_GROUP_MEMBERSHIP_RESPONSE 5
+
+/**
+ * \brief Groups Cluster group name support bit
+*/
+
+#define GROUP_NAME_SUPPORT_FLAG 0x80
+
+/**
+ * \brief Groups Cluster server attributes amount
+*/
+
+#define ZCL_GROUPS_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 1
+
+/**
+ * \brief Groups Cluster client attributes amount. Clinet doesn't have attributes.
+*/
+
+#define ZCL_GROUPS_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Groups Cluster commands amount
+*/
+
+#define ZCL_GROUPS_CLUSTER_COMMANDS_AMOUNT 10
+
+/**
+ * \brief Groups Cluster server's attributes identifiers
+*/
+
+#define ZCL_GROUPS_CLUSTER_NAME_SUPPORT_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+
+/**
+ * \brief Groups Cluster client's command identifiers
+*/
+
+#define ZCL_GROUPS_CLUSTER_ADD_GROUP_COMMAND_ID 0x00
+#define ZCL_GROUPS_CLUSTER_VIEW_GROUP_COMMAND_ID 0x01
+#define ZCL_GROUPS_CLUSTER_GET_GROUP_MEMBERSHIP_COMMAND_ID 0x02
+#define ZCL_GROUPS_CLUSTER_REMOVE_GROUP_COMMAND_ID 0x03
+#define ZCL_GROUPS_CLUSTER_REMOVE_ALL_GROUPS_COMMAND_ID 0x04
+#define ZCL_GROUPS_CLUSTER_ADD_GROUP_IF_IDENTIFYING_COMMAND_ID 0x05
+
+/**
+ * \brief Groups Cluster servers's command identifiers
+*/
+
+#define ZCL_GROUPS_CLUSTER_ADD_GROUP_RESPONSE_COMMAND_ID 0x00
+#define ZCL_GROUPS_CLUSTER_VIEW_GROUP_RESPONSE_COMMAND_ID 0x01
+#define ZCL_GROUPS_CLUSTER_GET_GROUP_MEMBERSHIP_RESPONSE_COMMAND_ID 0x02
+#define ZCL_GROUPS_CLUSTER_REMOVE_GROUP_RESPONSE_COMMAND_ID 0x03
+
+/**
+ * \brief Groups Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_GROUPS_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(nameSupport, ZCL_READONLY_ATTRIBUTE, ZCL_GROUPS_CLUSTER_NAME_SUPPORT_SERVER_ATTRIBUTE_ID, ZCL_8BIT_BITMAP_DATA_TYPE_ID)
+
+/**
+ * \brief On/Off Cluster define commands macros
+*/
+
+#define ZCL_DEFINE_GROUPS_CLUSTER_COMMANDS(addGroupCommandInd, viewGroupCommandInd, getGroupMembershipCommandInd, \
+ removeGroupCommandInd, removeAllGroupsCommandInd, addGroupIfIdentifyingCommandInd, \
+ addGroupResponseCommandInd, viewGroupResponseCommandInd, getGroupMembershipResponseCommandInd, \
+ removeGroupResponseCommandInd) \
+ DEFINE_COMMAND(addGroupCommand, ZCL_GROUPS_CLUSTER_ADD_GROUP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addGroupCommandInd), \
+ DEFINE_COMMAND(viewGroupCommand, ZCL_GROUPS_CLUSTER_VIEW_GROUP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ viewGroupCommandInd), \
+ DEFINE_COMMAND(getGroupMembershipCommand, ZCL_GROUPS_CLUSTER_GET_GROUP_MEMBERSHIP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ getGroupMembershipCommandInd), \
+ DEFINE_COMMAND(removeGroupCommand, ZCL_GROUPS_CLUSTER_REMOVE_GROUP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeGroupCommandInd), \
+ DEFINE_COMMAND(removeAllGroupsCommand, ZCL_GROUPS_CLUSTER_REMOVE_ALL_GROUPS_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeAllGroupsCommandInd), \
+ DEFINE_COMMAND(addGroupIfIdentifyingCommand, ZCL_GROUPS_CLUSTER_ADD_GROUP_IF_IDENTIFYING_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addGroupIfIdentifyingCommandInd), \
+ DEFINE_COMMAND(addGroupResponseCommand, ZCL_GROUPS_CLUSTER_ADD_GROUP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addGroupResponseCommandInd), \
+ DEFINE_COMMAND(viewGroupResponseCommand, ZCL_GROUPS_CLUSTER_VIEW_GROUP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ viewGroupResponseCommandInd), \
+ DEFINE_COMMAND(getGroupMembershipResponseCommand, ZCL_GROUPS_CLUSTER_GET_GROUP_MEMBERSHIP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ getGroupMembershipResponseCommandInd), \
+ DEFINE_COMMAND(removeGroupResponseCommand, ZCL_GROUPS_CLUSTER_REMOVE_GROUP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeGroupResponseCommandInd)
+
+/**
+ * \brief On/Off Cluster definition macros
+*/
+
+#define GROUPS_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = GROUPS_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_GROUPS_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_GROUPS_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define GROUPS_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = GROUPS_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_GROUPS_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_GROUPS_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_GROUPS_CLUSTER(cltype, clattributes, clcommands) \
+ GROUPS_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+BEGIN_PACK
+
+/**
+ * \brief Add Group Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t groupName[1];
+} ZCL_AddGroup_t;
+
+/**
+ * \brief View Group Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+} ZCL_ViewGroup_t;
+
+/**
+ * \brief Get Group Membership Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t groupCount;
+ uint16_t groupList[1];
+} ZCL_GetGroupMembership_t;
+
+/**
+ * \brief Remove Group Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+} ZCL_RemoveGroup_t;
+
+/**
+ * \brief Add Group if identifying Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t groupName[1];
+} ZCL_AddGroupIfIdentifying_t;
+
+/**
+ * \brief Add Group Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+} ZCL_AddGroupResponse_t;
+
+/**
+ * \brief View Group Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t groupName[1];
+} ZCL_ViewGroupResponse_t;
+
+/**
+ * \brief Get Group Membership Response Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t capacity;
+ uint8_t groupCount;
+ uint16_t groupList[MAX_GROUPS_IN_GROUP_MEMBERSHIP_RESPONSE];
+} ZCL_GetGroupMembershipResponse_t;
+
+/**
+ * \brief Remove Group Command Response Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+} ZCL_RemoveGroupResponse_t;
+
+/**
+ * \brief Groups Cluster server's attributes
+ */
+
+typedef struct PACK
+{
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } nameSupport;
+} ZCL_GroupsClusterServerAttributes_t;
+
+END_PACK
+
+/**
+ * \brief Groups Cluster commands.
+ */
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addGroupCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddGroup_t * payload);
+ } addGroupCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*viewGroupCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ViewGroup_t * payload);
+ } viewGroupCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*getGroupMembershipCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetGroupMembership_t * payload);
+ } getGroupMembershipCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeGroupCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveGroup_t * payload);
+ } removeGroupCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeAllGroupsCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, void * payload);
+ } removeAllGroupsCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addGroupIfIdentifyingCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddGroupIfIdentifying_t * payload);
+ } addGroupIfIdentifyingCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addGroupResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddGroupResponse_t * payload);
+ } addGroupResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*viewGroupResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ViewGroupResponse_t * payload);
+ } viewGroupResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*getGroupMembershipResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetGroupMembershipResponse_t * payload);
+ } getGroupMembershipResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeGroupResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveGroupResponse_t * payload);
+ } removeGroupResponseCommand;
+} ZCL_GroupsClusterCommands_t;
+
+#endif /* _ZCLZLLGROUPSCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllIB.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllIB.h
new file mode 100644
index 00000000..f3904c0e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllIB.h
@@ -0,0 +1,171 @@
+/**************************************************************************//**
+ \file zclZllIB.h
+
+ \brief
+ ZLL Information Base interface.
+
+ \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:
+ 18.03.10 A. Taradov - Created.
+******************************************************************************/
+#ifndef _ZCLZLLIB_H
+#define _ZCLZLLIB_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <aps.h>
+#include <zclZllFrameFormat.h>
+#include <zclZllIB.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+// Device Information Table entry
+typedef struct _DitEntry_t
+{
+ uint64_t ieee;
+ uint8_t ep;
+ uint16_t profileId;
+ uint16_t deviceId;
+ uint8_t version;
+ uint8_t groupIds;
+ uint8_t sort;
+} ZCL_ZllDitEntry_t;
+
+typedef struct _ZCL_ZllDevice_t
+{
+ uint8_t factoryNew;
+ uint8_t channel;
+ PanId_t panId;
+ ExtPanId_t extPanId;
+ ShortAddr_t nwkAddr;
+ ExtAddr_t extAddr;
+ ShortAddr_t freeNwkAddressRangeBegin;
+ ShortAddr_t freeNwkAddressRangeEnd;
+ uint16_t freeGroupIdRangeBegin;
+ uint16_t freeGroupIdRangeEnd;
+ uint16_t groupIdsBegin;
+ uint16_t groupIdsEnd;
+ uint8_t nwkKey[SECURITY_KEY_SIZE];
+} ZCL_ZllDevice_t;
+
+typedef struct _ZCL_ZllIb_t
+{
+ ZCL_ZllDevice_t device;
+ ZclZllZigBeeInfo_t zigBeeInfo;
+ ZclZllInfo_t zllInfo;
+ ZCL_ZllDitEntry_t *dit;
+ uint8_t ditSize;
+ uint8_t numberSubDevices;
+ uint8_t totalGroupIds;
+ MAC_CapabilityInf_t capabilityInf;
+ uint8_t *appData;
+ uint16_t appDataSize;
+} ZCL_ZllIb_t;
+
+/******************************************************************************
+ Global variables
+******************************************************************************/
+extern ZCL_ZllIb_t zclZllIB;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Initialize Information Base and restore ZLL parameters and
+application data
+
+This function is invoked by the ZCL_ZllReset() function and therefore should
+not be called by the user directly.
+
+The function restores ZLL parameters and application data from EEPROM and sets
+the restored network and stack parameters in Configuration Server as well.
+******************************************************************************/
+void ZCL_ZllIbReset(void);
+
+/**************************************************************************//**
+\brief Set application data that should be saved and restored
+
+This function specifies the memory which is used to store and restore
+application data. The data will be saved in EEPROM when the ZCL_ZllIbSave()
+function is called, and restored when ZCL_ZllIbReset() or ZCL_ZllReset()
+functions are called (ZCL_ZllReset() invokes ZCL_ZllIbReset()).
+
+This function should be called before ZCL_ZllIbReset() or ZCL_ZllReset() to
+specify the memory to which application data will be restored.
+
+Application data may be any abstract data. However, keeping network and
+stack parameters in application data is unnecunnecessary, because they are
+maintained by ZLL.
+
+\param[in] data - application data
+\param[in] button - button number
+******************************************************************************/
+void ZCL_ZllIbSetAppData(uint8_t *data, uint16_t size);
+
+/**************************************************************************//**
+\brief Save ZLL parameters and application data in EEPROM
+
+The functions saves ZLL parameters and application data in EEPROM so that
+they can be restored after device is reset. ZLL parameters are stored inside
+the stack in the instance of the ZCL_ZllDevice_t type. This function should
+be called each time after the application data is modofied.
+******************************************************************************/
+void ZCL_ZllIbSave(void);
+
+/**************************************************************************//**
+\brief Reset ZLL parameters to factory new settings and store them into EEPROM
+******************************************************************************/
+void ZCL_ZllIbResetToFactoryNew(void);
+
+/**************************************************************************//**
+\brief Set Device Information Table
+
+Device Information Table contains entries desribing logical device type
+implemented on the device. However, most frequently the table has only one entry.
+Since the table stores static information about application functionality, it is
+not writtern into EEPROM, but is typically configured each time the application
+starts.
+
+The following example shows how to fill a table with a single entry:
+
+\code
+\\Global definition of the Device Information table
+ZCL_ZllDitEntry_t deviceInfoTable[DEVICE_INFO_TABLE_ENTRIES];
+...
+CS_ReadParameter(CS_UID_ID, &deviceInfoTable[0].ieee); //Read extended address from the Configuration Server
+deviceInfoTable[0].ep = APP_ENDPOINT_COLOR_SCENE_REMOTE;
+deviceInfoTable[0].profileId = APP_PROFILE_ID;
+deviceInfoTable[0].deviceId = APP_DEVICE_ID;
+deviceInfoTable[0].version = APP_VERSION;
+deviceInfoTable[0].groupIds = APP_GROUP_IDS; //The number of group IDs
+deviceInfoTable[0].sort = 0;
+ZCL_ZllIbSetDeviceInfoTable(deviceInfoTable, 1);
+\endcode
+
+Note that all constants starting with APP_ should be defined by the
+application.
+
+\param[in] dit - pointer to the Device Information table
+\param[in] size - number of entries in the table
+******************************************************************************/
+void ZCL_ZllIbSetDeviceInfoTable(ZCL_ZllDitEntry_t dit[], uint8_t size);
+
+#endif // _ZCLZLLIB_H
+
+// eof zclZllIB.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllIdentifyCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllIdentifyCluster.h
new file mode 100644
index 00000000..ad27466e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllIdentifyCluster.h
@@ -0,0 +1,215 @@
+/***************************************************************************//**
+ \file zclZllIdentifyCluster.h
+
+ \brief
+ The header file describes the ZLL Identify Cluster and its interface
+
+ \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:
+ 04.07.11 A. Taradov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLZLLIDENTIFYCLUSTER_H
+#define _ZCLZLLIDENTIFYCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/**
+ * \brief Identify Server Cluster attributes amount.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 1
+
+/**
+ * \brief Identify Client Cluster attributes amount.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Identify Client Cluster commands amount.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_COMMANDS_AMOUNT 4
+
+/**
+ * \brief Identify Server Cluster attributes identifiers.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_IDENTIFY_TIME_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+
+/**
+ * \brief Identify Server Cluster commands identifiers.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_IDENTIFY_QUERY_RESPONSE_COMMAND_ID 0x00
+
+/**
+ * \brief Identify Client Cluster commands identifiers.
+*/
+
+#define ZCL_IDENTIFY_CLUSTER_IDENTIFY_COMMAND_ID 0x00
+#define ZCL_IDENTIFY_CLUSTER_IDENTIFY_QUERY_COMMAND_ID 0x01
+#define ZCL_IDENTIFY_CLUSTER_TRIGGER_EFFECT_COMMAND_ID 0x40
+
+/*
+ *\brief ZCL Idetify Cluster server side attributes defining macros
+ */
+
+#define ZCL_DEFINE_IDENTIFY_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(identifyTime, ZCL_READWRITE_ATTRIBUTE, ZCL_IDENTIFY_CLUSTER_IDENTIFY_TIME_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID)
+
+/*
+ * \brief ZCL Identify Cluster commands defining macros
+ */
+
+#define IDENTIFY_CLUSTER_COMMANDS(identifyCommandInd, identifyQueryCommandInd, triggerEffectCommandInd, identifyQueryResponseCommandInd) \
+ DEFINE_COMMAND(identifyCommand, 0x00, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), identifyCommandInd), \
+ DEFINE_COMMAND(identifyQueryCommand, 0x01, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), identifyQueryCommandInd), \
+ DEFINE_COMMAND(triggerEffectCommand, 0x40, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), triggerEffectCommandInd), \
+ DEFINE_COMMAND(identifyQueryResponseCommand, 0x00, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), identifyQueryResponseCommandInd)
+
+#define IDENTIFY_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = IDENTIFY_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_IDENTIFY_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_IDENTIFY_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+
+#define IDENTIFY_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+ { \
+ .id = IDENTIFY_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_IDENTIFY_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_IDENTIFY_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+ }
+
+#define DEFINE_IDENTIFY_CLUSTER(cltype, clattributes, clcommands) IDENTIFY_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+/**
+ * \brief Possible values for the Effect Identifier field.
+*/
+enum
+{
+ ZCL_EFFECT_IDENTIFIER_BLINK = 0x00,
+ ZCL_EFFECT_IDENTIFIER_BREATHE = 0x01,
+ ZCL_EFFECT_IDENTIFIER_OKAY = 0x02,
+ ZCL_EFFECT_IDENTIFIER_CHANNEL_CHANGE = 0x0b,
+ ZCL_EFFECT_IDENTIFIER_FINISH_EFFECT = 0xfe,
+ ZCL_EFFECT_IDENTIFIER_STOP_EFFECT = 0xff,
+};
+
+/**
+ * \brief Possible values for the Effect Variant field.
+*/
+enum
+{
+ ZCL_EFFECT_VARIANT_DEFAULT = 0x00,
+};
+
+BEGIN_PACK
+
+/**
+ * \brief Identify Command Payload format.
+*/
+typedef struct PACK
+{
+ uint16_t identifyTime;
+} ZCL_Identify_t;
+
+/**
+ * \brief Trigger Effect Command Payload format.
+*/
+typedef struct PACK
+{
+ uint8_t effectIdentifier;
+ uint8_t effectVariant;
+} ZCL_TriggerEffect_t;
+
+/**
+ * \brief Identify Query Response Payload format.
+*/
+typedef struct PACK
+{
+ uint16_t timeout;
+} ZCL_IdentifyQueryResponse_t;
+
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } identifyTime;
+} ZCL_IdentifyClusterAttributes_t;
+
+END_PACK
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*identifyCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_Identify_t *payload);
+ } identifyCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*identifyQueryCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } identifyQueryCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*triggerEffectCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_TriggerEffect_t *payload);
+ } triggerEffectCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t (*identifyQueryResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_IdentifyQueryResponse_t *payload);
+ } identifyQueryResponseCommand;
+} ZCL_IdentifyClusterCommands_t;
+
+
+#endif // _ZCLZLLIDENTIFYCLUSTER_H
+
+// eof zclZllIdentifyCluster.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllInterPan.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllInterPan.h
new file mode 100644
index 00000000..471f8a48
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllInterPan.h
@@ -0,0 +1,71 @@
+/**************************************************************************//**
+ \file zclZllInterPan.h
+
+ \brief
+ ZLL Inter-PAN operation interface.
+
+ \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:
+ 17.03.10 A. Taradov - Created.
+******************************************************************************/
+#ifndef _ZCLZLLINTERPAN_H
+#define _ZCLZLLINTERPAN_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zclZll.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef struct _ZCL_ZllInterPanStartConf_t
+{
+ ZCL_ZllStatus_t status;
+} ZCL_ZllInterPanStartConf_t;
+
+typedef struct _ZCL_ZllInterPanStartReq_t
+{
+ ZCL_ZllInterPanStartConf_t confirm;
+ void (*ZCL_ZllInterPanStartConf)(ZCL_ZllInterPanStartConf_t *conf);
+} ZCL_ZllInterPanStartReq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Reset ZLL Inter-PAN module
+******************************************************************************/
+void ZCL_ZllInterPanReset(void);
+
+/**************************************************************************//**
+\brief Prepare stack for Inter-PAN operation
+
+The function prepares the device for Inter-PAN communication. It is required
+for starting network scan (invoked by the ZCL_ZllScanReq() function).
+
+The function is executed asynchronously. Invocation of the callback function
+provided in the \c req->ZCL_ZllInterPanStartConf field indicates request
+completion. If the request has been successful (the reported status equals
+::ZCL_ZLL_SUCCESS_STATUS) ZigBee network features become unavailable.
+
+To restore normal stack operation, when Inter-PAN data exchange has finished,
+call the ZDO_ResetNetworkReq() function.
+******************************************************************************/
+void ZCL_ZllInterPanStartReq(ZCL_ZllInterPanStartReq_t *req);
+
+#endif // _ZCLZLLINTERPAN_H
+
+// eof zclZllInterPan.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllLevelControlCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllLevelControlCluster.h
new file mode 100644
index 00000000..0bd8caa2
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllLevelControlCluster.h
@@ -0,0 +1,297 @@
+/***************************************************************************//**
+ \file zclZllLevelControlCluster.h
+
+ \brief
+ Interface and types of Level Control 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:
+ 22.06.10 D.Loskutnikov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLZLLLEVELCONTROLCLUSTER_H
+#define _ZCLZLLLEVELCONTROLCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+#define ZLL_LEVEL_CONTROL_UP_DIRECTION 0x00
+#define ZLL_LEVEL_CONTROL_DOWN_DIRECTION 0x01
+
+/**
+ * \brief Amount of Level Control cluster server's attributes
+*/
+#define ZCL_LEVEL_CONTROL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 1
+
+/**
+ * \brief Client doesn't have attributes.
+*/
+#define ZCL_LEVEL_CONTROL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0
+
+/**
+ * \brief Level Control Cluster commands amount
+*/
+
+#define ZCL_LEVEL_CONTROL_CLUSTER_COMMANDS_AMOUNT 8
+
+/**
+ * \brief Level Control Cluster server's attributes identifiers
+*/
+
+#define ZCL_LEVEL_CONTROL_CLUSTER_CURRENT_LEVEL_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_LEVEL_CONTROL_CLUSTER_REMAINING_TIME_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+#define ZCL_LEVEL_CONTROL_CLUSTER_ON_OFF_TRANSITION_TIME_ATTRIBUTE_ID CCPU_TO_LE16(0x0010)
+#define ZCL_LEVEL_CONTROL_CLUSTER_ON_LEVEL_ATTRIBUTE_ID CCPU_TO_LE16(0x0011)
+
+/**
+ * \brief On/Off Cluster client's command identifiers
+*/
+
+#define ZCL_LEVEL_CONTROL_CLUSTER_MOVE_TO_LEVEL_COMMAND_ID 0x00
+#define ZCL_LEVEL_CONTROL_CLUSTER_MOVE_COMMAND_ID 0x01
+#define ZCL_LEVEL_CONTROL_CLUSTER_STEP_COMMAND_ID 0x02
+#define ZCL_LEVEL_CONTROL_CLUSTER_STOP_COMMAND_ID 0x03
+#define ZCL_LEVEL_CONTROL_CLUSTER_MOVE_TO_LEVEL_W_ONOFF_COMMAND_ID 0x04
+#define ZCL_LEVEL_CONTROL_CLUSTER_MOVE_W_ONOFF_COMMAND_ID 0x05
+#define ZCL_LEVEL_CONTROL_CLUSTER_STEP_W_ONOFF_COMMAND_ID 0x06
+#define ZCL_LEVEL_CONTROL_CLUSTER_STOP_W_ONOFF_COMMAND_ID 0x07
+
+/**
+ * \brief Level Control Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_LEVEL_CONTROL_CLUSTER_SERVER_MANDATORY_ATTRIBUTES(min, max) \
+ DEFINE_REPORTABLE_ATTRIBUTE(currentLevel, ZCL_READONLY_ATTRIBUTE, ZCL_LEVEL_CONTROL_CLUSTER_CURRENT_LEVEL_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID, min, max), \
+ DEFINE_ATTRIBUTE(remainingTime, ZCL_READONLY_ATTRIBUTE, ZCL_LEVEL_CONTROL_CLUSTER_REMAINING_TIME_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID)
+
+#define ZCL_DEFINE_LEVEL_CONTROL_CLUSTER_SERVER_OPTIONAL_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(onOffTransitionTime, ZCL_LEVEL_CONTROL_CLUSTER_ON_OFF_TRANSITION_TIME_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(onLevel, ZCL_LEVEL_CONTROL_CLUSTER_ON_LEVEL_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID)
+
+
+/**
+ * \brief Level Control Cluster define commands macros
+*/
+
+#define ZCL_DEFINE_LEVEL_CONTROL_CLUSTER_COMMANDS(moveToLevelCommandInd,\
+ moveCommandInd,\
+ stepCommandInd,\
+ stopCommandInd,\
+ moveToLevelWOnOffCommandInd,\
+ moveWOnOffCommandInd,\
+ stepWOnOffCommandInd,\
+ stopWOnOffCommandInd)\
+ DEFINE_COMMAND(moveToLevelCommand, ZCL_LEVEL_CONTROL_CLUSTER_MOVE_TO_LEVEL_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ moveToLevelCommandInd), \
+ DEFINE_COMMAND(moveCommand, ZCL_LEVEL_CONTROL_CLUSTER_MOVE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ moveCommandInd), \
+ DEFINE_COMMAND(stepCommand, ZCL_LEVEL_CONTROL_CLUSTER_STEP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ stepCommandInd), \
+ DEFINE_COMMAND(stopCommand, ZCL_LEVEL_CONTROL_CLUSTER_STOP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ stopCommandInd), \
+ DEFINE_COMMAND(moveToLevelWOnOffCommand, ZCL_LEVEL_CONTROL_CLUSTER_MOVE_TO_LEVEL_W_ONOFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ moveToLevelWOnOffCommandInd), \
+ DEFINE_COMMAND(moveWOnOffCommand, ZCL_LEVEL_CONTROL_CLUSTER_MOVE_W_ONOFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ moveWOnOffCommandInd), \
+ DEFINE_COMMAND(stepWOnOffCommand, ZCL_LEVEL_CONTROL_CLUSTER_STEP_W_ONOFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ stepWOnOffCommandInd), \
+ DEFINE_COMMAND(stopWOnOffCommand, ZCL_LEVEL_CONTROL_CLUSTER_STOP_W_ONOFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ stopWOnOffCommandInd)
+
+/**
+ * \brief Level Control Cluster definition macros
+*/
+
+#define LEVEL_CONTROL_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = LEVEL_CONTROL_CLUSTER_ID, \
+ .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_LEVEL_CONTROL_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_LEVEL_CONTROL_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define LEVEL_CONTROL_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = LEVEL_CONTROL_CLUSTER_ID, \
+ .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY}, \
+ .attributesAmount = ZCL_LEVEL_CONTROL_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_LEVEL_CONTROL_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_LEVEL_CONTROL_CLUSTER(cltype, clattributes, clcommands) \
+ LEVEL_CONTROL_CLUSTER_##cltype(clattributes, clcommands)
+
+#define DEFINE_LEVEL_CONTROL_CLUSTER_EXTENSION_FIELD_SET(value) \
+ .clusterId = LEVEL_CONTROL_CLUSTER_ID, \
+ .length = sizeof(uint8_t), \
+ .currentLevel = value
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+
+/**
+ * \brief Move To Level Command Payload format.
+ */
+typedef struct PACK
+{
+ uint8_t level;
+ uint16_t transitionTime;
+} ZCL_MoveToLevel_t;
+
+/**
+ * \brief Move Command Payload format.
+ */
+typedef struct PACK
+{
+ uint8_t moveMode;
+ uint8_t rate;
+} ZCL_Move_t;
+
+/**
+ * \brief Step Command Payload format.
+ */
+typedef struct PACK
+{
+ uint8_t stepMode;
+ uint8_t stepSize;
+ uint16_t transitionTime;
+} ZCL_Step_t;
+
+/**
+ * \brief Level Control Cluster server's attributes
+*/
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+ uint8_t reportableChange; //!<Reporting change field value
+ ZCL_ReportTime_t timeoutPeriod; //!<Timeout period field value
+ } currentLevel;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } remainingTime;
+} ZCL_LevelControlClusterServerAttributes_t;
+
+/**
+ * \brief Level Control Cluster extension field set
+ */
+typedef struct PACK
+{
+ uint16_t clusterId;
+ uint8_t length;
+ uint8_t currentLevel;
+} ZCL_LevelControlClusterExtensionFieldSet_t;
+
+END_PACK
+
+/**
+ * \brief Level Control Cluster clients's commands.
+*/
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*moveToLevelCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } moveToLevelCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*moveCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } moveCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*stepCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } stepCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*stopCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } stopCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*moveToLevelWOnOffCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } moveToLevelWOnOffCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*moveWOnOffCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } moveWOnOffCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*stepWOnOffCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } stepWOnOffCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*stopWOnOffCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t *payload);
+ } stopWOnOffCommand;
+} ZCL_LevelControlClusterCommands_t;
+
+#endif /* _ZCLZLLLEVELCONTROLCLUSTER_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllMisc.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllMisc.h
new file mode 100644
index 00000000..219ed2ee
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllMisc.h
@@ -0,0 +1,95 @@
+/**************************************************************************//**
+ \file zclZllMisc.h
+
+ \brief
+ ZLL miscellaneous functionality interface.
+
+ \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:
+ 19.03.10 A. Taradov - Created.
+******************************************************************************/
+#ifndef _ZCLZLLMISC_H
+#define _ZCLZLLMISC_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zclZll.h>
+#include <zclZllIB.h>
+#include <intrpData.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+#define ZCL_ZLL_USE_DEFAULT_IDENTIFY_TIME 0xffff
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Identify notification
+
+The function shall be implemented by the application. The ZLL component
+calls this function when an indetify request is received (sent from a remote
+device with the ZCL_ZllIdentifyRequest() function).
+
+Receiving this notification, a router is expected to somehow identify itself
+for the user; for example, a lighting device may blink.
+
+\param[in] status - notification status
+\param[in] time - identification time
+******************************************************************************/
+extern void ZCL_ZllIdentifyInd(ZCL_ZllStatus_t status, uint16_t time);
+
+/**************************************************************************//**
+\brief Reset ZLL miscellaneous module
+******************************************************************************/
+void ZCL_ZllMiscReset(void);
+
+/**************************************************************************//**
+\brief Send Identify Request command
+
+The function sends an identify request to the destination device specified
+with its extended address. On the destination device ZCL_ZllIdentifyInd() is
+called by the stack to indicate identify command reception. The device that
+sends the request should first select the destination device, using the
+ZCL_ZllSelectDeviceReq() function.
+
+The function is used during ZLL commissioning via touch link to allow the
+application to drop the commissioning procedure if something goes wrong
+(for example, the user discovers that wrong device has been selected).
+
+\param[in] addr - destination device extended address pointer
+\param[in] identifyTime - time in 1/10ths of a seconds
+\returns true if the command has been sent
+******************************************************************************/
+bool ZCL_ZllIdentifyRequest(ExtAddr_t *addr, uint16_t identifyTime);
+
+/**************************************************************************//**
+\brief Reset the device to Factory New state
+\param[in] addr - destination short address
+\returns true if command was sent.
+******************************************************************************/
+bool ZCL_ZllResetToFactoryNewRequest(ShortAddr_t addr);
+
+/**************************************************************************//**
+\brief INTRP-DATA.indication primitive
+\param[in] ind - indication parameters
+******************************************************************************/
+void ZCL_ZllMiscDataInd(INTRP_DataInd_t *ind);
+
+#endif // _ZCLZLLMISC_H
+
+// eof zclZllMisc.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllNetwork.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllNetwork.h
new file mode 100644
index 00000000..adece9aa
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllNetwork.h
@@ -0,0 +1,114 @@
+/**************************************************************************//**
+ \file zclZllNetwork.h
+
+ \brief
+ ZLL network functionality interface.
+
+ \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:
+ 22.03.10 A. Taradov - Created.
+******************************************************************************/
+#ifndef _ZCLZLLNETWORK_H
+#define _ZCLZLLNETWORK_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zclZll.h>
+#include <zclZllIB.h>
+#include <zclZllScan.h>
+#include <intrpData.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef struct _ZCL_ZllStartNetworkConf_t
+{
+ ZCL_ZllStatus_t status;
+} ZCL_ZllStartNetworkConf_t;
+
+typedef struct _ZCL_ZllStartNetworkReq_t
+{
+ ZCL_ZllStartNetworkConf_t confirm;
+ ZCL_ZllScanDeviceInfo_t *otherDevice;
+ void (*ZCL_ZllStartNetworkConf)(ZCL_ZllStartNetworkConf_t *conf);
+} ZCL_ZllStartNetworkReq_t;
+
+/*! Select ZLL device confirm parameters */
+typedef struct _ZCL_SelectDeviceConf_t
+{
+ /* Operation status */
+ ZCL_ZllStatus_t status;
+} ZCL_SelectDeviceConf_t;
+
+/*! Select ZLL device request parameters */
+typedef struct _ZCL_ZllSelectDeviceReq_t
+{
+ /*! Selected device information */
+ ZCL_ZllScanDeviceInfo_t *deviceInfo;
+ /*! MAC-SET.request primitive */
+ MAC_SetReq_t macSetReq;
+ /*! Confirm callback pointer */
+ void (*ZCL_ZllSelectDeviceConf)(ZCL_SelectDeviceConf_t *conf);
+ /*! Select ZLL device confirm info */
+ ZCL_SelectDeviceConf_t confirm;
+} ZCL_ZllSelectDeviceReq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Reset ZLL network module.
+******************************************************************************/
+void ZCL_ZllNetworkReset(void);
+
+/**************************************************************************//**
+\brief Send ZLL start network request. Should be called only by end devices.
+
+The function sends an Inter-PAN command containing network parameters to
+the selected router. The router is notified about receiving network parameters
+via ZCL_ZllStartInd() (this function should be implemented on the router).
+Upon receiving such indication the router is expected to rejoin the nework,
+using ZDO functions. The end device that has issued the request should also
+rejoin the network to join the router.
+
+The device to which the ZLL start network request will be sent is set
+with the ZCL_ZllSelectDeviceReq() function.
+
+\param req - request parameters
+******************************************************************************/
+void ZCL_ZllStartNetworkReq(ZCL_ZllStartNetworkReq_t *req);
+
+/**************************************************************************//**
+\brief INTRP-DATA.indication primitive
+\param[in] ind - indication parameters
+******************************************************************************/
+void ZCL_ZllNetworkDataInd(INTRP_DataInd_t *ind);
+
+/**************************************************************************//**
+\brief Select a device discovered during scanning
+
+Using this function, the application specifies a device to which it will
+send an identify request and a start network request. Information about the
+device that should be provided for this function is received during network
+scan (performed by ZCL_ZllScanReq()).
+
+\param[in] req - request parameters
+******************************************************************************/
+void ZCL_ZllSelectDeviceReq(ZCL_ZllSelectDeviceReq_t *req);
+
+#endif // _ZCLZLLNETWORK_H
+
+// eof zclZllNetwork.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllOnOffCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllOnOffCluster.h
new file mode 100644
index 00000000..f16eaf1e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllOnOffCluster.h
@@ -0,0 +1,281 @@
+/***************************************************************************//**
+ \file zclZllOnOffCluster.h
+
+ \brief
+ The header file describes the ZLL On/Off Cluster and its interface
+
+ \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:
+ 21.03.11 A. Taradov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLZLLONOFFCLUSTER_H
+#define _ZCLZLLONOFFCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+#define ZCL_ON_OFF_CLUSTER_ACCEPT_ONLY_WHEN_ON 0x01
+
+/**
+ * \brief On/Off Cluster server attributes amount
+*/
+
+#define ZCL_ONOFF_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 4
+
+/**
+ * \brief On/Off Cluster client attributes amount. Clinet doesn't have attributes.
+*/
+
+#define ZCL_ONOFF_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT 0
+
+/**
+ * \brief On/Off Cluster commands amount
+*/
+
+#define ZCL_ONOFF_CLUSTER_COMMANDS_AMOUNT 6
+
+/**
+ * \brief On/Off Cluster server's attributes identifiers
+*/
+
+#define ZCL_ONOFF_CLUSTER_ONOFF_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_ONOFF_CLUSTER_GLOBAL_SCENE_CONTROL_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4000)
+#define ZCL_ONOFF_CLUSTER_ON_TIME_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4001)
+#define ZCL_ONOFF_CLUSTER_OFF_WAIT_TIME_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x4002)
+
+/**
+ * \brief On/Off Cluster client's command identifiers
+*/
+
+#define ZCL_ONOFF_CLUSTER_OFF_COMMAND_ID 0x00
+#define ZCL_ONOFF_CLUSTER_ON_COMMAND_ID 0x01
+#define ZCL_ONOFF_CLUSTER_TOGGLE_COMMAND_ID 0x02
+#define ZCL_ONOFF_CLUSTER_OFF_WITH_EFFECT_COMMAND_ID 0x40
+#define ZCL_ONOFF_CLUSTER_ON_WITH_RECALL_GLOBAL_SCENE_COMMAND_ID 0x41
+#define ZCL_ONOFF_CLUSTER_ON_WITH_TIMED_OFF_COMMAND_ID 0x42
+
+/**
+ * \brief On/Off Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_ONOFF_CLUSTER_SERVER_ATTRIBUTES(min, max) \
+ DEFINE_REPORTABLE_ATTRIBUTE(onOff, ZCL_READONLY_ATTRIBUTE, ZCL_ONOFF_CLUSTER_ONOFF_SERVER_ATTRIBUTE_ID, ZCL_BOOLEAN_DATA_TYPE_ID, min, max), \
+ DEFINE_ATTRIBUTE(globalSceneControl, ZCL_READONLY_ATTRIBUTE, ZCL_ONOFF_CLUSTER_GLOBAL_SCENE_CONTROL_SERVER_ATTRIBUTE_ID, ZCL_BOOLEAN_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(onTime, ZCL_READONLY_ATTRIBUTE, ZCL_ONOFF_CLUSTER_ON_TIME_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(offWaitTime, ZCL_READONLY_ATTRIBUTE, ZCL_ONOFF_CLUSTER_OFF_WAIT_TIME_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID)
+
+/**
+ * \brief On/Off Cluster define commands macros
+*/
+
+#define ZCL_DEFINE_ONOFF_CLUSTER_COMMANDS(onCommandInd, offCommandInd, toggleCommandInd, offWithEffectInd, onWithRecallGlobalSceneInd, onWithTimedOffInd) \
+ DEFINE_COMMAND(onCommand, ZCL_ONOFF_CLUSTER_ON_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE, ZCL_COMMAND_NO_ACK), \
+ onCommandInd), \
+ DEFINE_COMMAND(offCommand, ZCL_ONOFF_CLUSTER_OFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE, ZCL_COMMAND_NO_ACK), \
+ offCommandInd), \
+ DEFINE_COMMAND(toggleCommand, ZCL_ONOFF_CLUSTER_TOGGLE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE, ZCL_COMMAND_NO_ACK), \
+ toggleCommandInd), \
+ DEFINE_COMMAND(offWithEffectCommand, ZCL_ONOFF_CLUSTER_OFF_WITH_EFFECT_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE, ZCL_COMMAND_NO_ACK), \
+ offWithEffectInd), \
+ DEFINE_COMMAND(onWithRecallGlobalSceneCommand, ZCL_ONOFF_CLUSTER_ON_WITH_RECALL_GLOBAL_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE, ZCL_COMMAND_NO_ACK), \
+ onWithRecallGlobalSceneInd), \
+ DEFINE_COMMAND(onWithTimedOffCommand, ZCL_ONOFF_CLUSTER_ON_WITH_TIMED_OFF_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_FRAME_CONTROL_DISABLE_DEFAULT_RESPONSE, ZCL_COMMAND_NO_ACK), \
+ onWithTimedOffInd)
+
+/**
+ * \brief On/Off Cluster definition macros
+*/
+
+#define ONOFF_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = ONOFF_CLUSTER_ID, \
+ .options = \
+ { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY, \
+ .reserved = 0, \
+ }, \
+ .attributesAmount = ZCL_ONOFF_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_ONOFF_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define ONOFF_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = ONOFF_CLUSTER_ID, \
+ .options = \
+ { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_NETWORK_KEY_CLUSTER_SECURITY, \
+ .reserved = 0, \
+ }, \
+ .attributesAmount = ZCL_ONOFF_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_ONOFF_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_ONOFF_CLUSTER(cltype, clattributes, clcommands) \
+ ONOFF_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+BEGIN_PACK
+
+/**
+ * \brief On/Off Cluster server's attributes
+*/
+
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ bool value;
+ ZCL_ReportTime_t reportCounter; //!<For internal use only
+ ZCL_ReportTime_t minReportInterval; //!<Minimum reporting interval field value
+ ZCL_ReportTime_t maxReportInterval; //!<Maximum reporting interval field value
+ bool reportableChange; //!<Reporting change field value
+ ZCL_ReportTime_t timeoutPeriod; //!<Timeout period field value
+ } onOff;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ bool value;
+ } globalSceneControl;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } onTime;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } offWaitTime;
+} ZCL_OnOffClusterServerAttributes_t;
+
+/**
+ * \brief On/Off Cluster extension field set
+ */
+typedef struct PACK
+{
+ uint16_t clusterId;
+ uint8_t length;
+ bool onOffValue;
+} ZCL_OnOffClusterExtensionFieldSet_t;
+
+typedef struct PACK
+{
+ uint8_t effectIdentifier;
+ uint8_t effectVariant;
+} ZCL_OffWithEffect_t;
+
+typedef struct PACK
+{
+ uint8_t onOffControl;
+ uint16_t onTime;
+ uint16_t offWaitTime;
+} ZCL_OnWithTimedOff_t;
+
+END_PACK
+
+/**
+ * \brief On/Off Cluster clients's commands.
+*/
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*onCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t * payload);
+ } onCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*offCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t * payload);
+ } offCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*toggleCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t * payload);
+ } toggleCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*offWithEffectCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_OffWithEffect_t * payload);
+ } offWithEffectCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*onWithRecallGlobalSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, uint8_t * payload);
+ } onWithRecallGlobalSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*onWithTimedOffCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_OnWithTimedOff_t * payload);
+ } onWithTimedOffCommand;
+
+} ZCL_OnOffClusterCommands_t;
+
+#define DEFINE_ONOFF_CLUSTER_EXTENSION_FIELD_SET(value) \
+ .clusterId = ONOFF_CLUSTER_ID, \
+ .length = sizeof(uint8_t), \
+ .onOffValue = value
+
+#endif /* _ZCLZLLONOFFCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllScan.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllScan.h
new file mode 100644
index 00000000..9ccd82c9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllScan.h
@@ -0,0 +1,109 @@
+/**************************************************************************//**
+ \file zclZllScan.h
+
+ \brief
+ ZLL Scan functions interface.
+
+ \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:
+ 17.03.10 A. Taradov - Created.
+******************************************************************************/
+#ifndef _ZCLZLLSCAN_H
+#define _ZCLZLLSCAN_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zclZll.h>
+#include <zclZllIB.h>
+#include <intrpData.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+typedef struct _ZCL_ZllScanDeviceInfo_t
+{
+ // Device Information Table entry
+ uint64_t ieee;
+ uint8_t ep;
+ uint16_t profileId;
+ uint16_t deviceId;
+ uint8_t version;
+ uint8_t groupIds;
+ uint8_t sort;
+
+ // Common fields
+ uint8_t rssiCorrection;
+ ZclZllZigBeeInfo_t zigBeeInfo;
+ ZclZllInfo_t zllInfo;
+ uint16_t keyBitMask;
+ uint32_t responseId;
+ uint64_t extPanId;
+ uint8_t nwkUpdateId;
+ uint8_t channel;
+ uint16_t panId;
+ uint16_t networkAddress;
+ uint8_t numberSubDevices;
+ uint8_t totalGroupIds;
+ uint64_t ieeeRelayerScanRequest;
+ int8_t rssi;
+} ZCL_ZllScanDeviceInfo_t;
+
+typedef struct _ZCL_ZllScanConf_t
+{
+ ZCL_ZllScanDeviceInfo_t info;
+ ZCL_ZllStatus_t status;
+ bool stopScan;
+} ZCL_ZllScanConf_t;
+
+typedef struct _ZCL_ZllScanReq_t
+{
+ ZCL_ZllScanConf_t confirm;
+ void (*ZCL_ZllScanConf)(ZCL_ZllScanConf_t *conf);
+} ZCL_ZllScanReq_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Reset ZLL Scan.
+******************************************************************************/
+void ZCL_ZllScanReset(void);
+
+/**************************************************************************//**
+\brief ZLL Scan request. Should be called only by end devices.
+
+The function is called on end devices to discover other devices by scanning
+supported radio channels. Before calling this function the device should be
+prepared to handle Inter-PAN messages: call the ZCL_ZllInterPanStartReq()
+function first.
+
+The callback function specified in the parameters is called once for
+each discovered device.
+
+\param req - request parameters
+******************************************************************************/
+void ZCL_ZllScanReq(ZCL_ZllScanReq_t *req);
+
+/**************************************************************************//**
+\brief INTRP-DATA.indication primitive
+\param[in] ind - indication parameters
+******************************************************************************/
+void ZCL_ZllScanReqDataInd(INTRP_DataInd_t *ind);
+
+#endif // _ZCLZLLSCAN_H
+
+// eof zclZllScan.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllScenesCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllScenesCluster.h
new file mode 100644
index 00000000..2bf4b100
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllScenesCluster.h
@@ -0,0 +1,648 @@
+/***************************************************************************//**
+ \file zclScenesCluster.h
+
+ \brief
+ The header file describes the ZCL Scenes Cluster and its interface
+
+ The file describes the types and interface of the ZCL Scenes 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:
+ 12.02.09 D. Kasyanov - Created.
+*******************************************************************************/
+
+#ifndef _ZCLSCENESCLUSTER_H
+#define _ZCLSCENESCLUSTER_H
+
+/*!
+Attributes and commands for determining basic information about a device,
+setting user device information such as location, enabling a device and resetting it
+to factory defaults.
+*/
+
+/*******************************************************************************
+ Includes section
+*******************************************************************************/
+
+#include <zcl.h>
+#include <clusters.h>
+#include <zclZllOnOffCluster.h>
+#include <zclZllLevelControlCluster.h>
+#include <zclZllColorControlCluster.h>
+
+/*******************************************************************************
+ Define(s) section
+*******************************************************************************/
+
+/**
+ * \brief Scenes Cluster scene name support bit
+*/
+
+#define ZCL_SCENES_CLUSTER_NAME_SUPPORT_FLAG 0x80
+
+#define ZCL_SCENES_CLUSTER_COPY_ALL_SCENES 0x01
+
+/**
+ * \brief Scenes Cluster server attributes amount
+*/
+
+#define ZCL_SCENES_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 5
+
+/**
+ * \brief Scenes Cluster client attributes amount. Clinet doesn't have attributes.
+*/
+
+#define ZCL_SCENES_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT 0
+
+/**
+ * \brief Scenes Cluster commands amount
+*/
+
+#define ZCL_SCENES_CLUSTER_COMMANDS_AMOUNT 19
+
+/**
+ * \brief Scenes Cluster server's attributes identifiers
+*/
+
+#define ZCL_SCENES_CLUSTER_SCENE_COUNT_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0000)
+#define ZCL_SCENES_CLUSTER_CURRENT_SCENE_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0001)
+#define ZCL_SCENES_CLUSTER_CURRENT_GROUP_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0002)
+#define ZCL_SCENES_CLUSTER_SCENE_VALID_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0003)
+#define ZCL_SCENES_CLUSTER_NAME_SUPPORT_SERVER_ATTRIBUTE_ID CCPU_TO_LE16(0x0004)
+
+/**
+ * \brief Scenes Cluster client's command identifiers
+*/
+
+#define ZCL_SCENES_CLUSTER_ADD_SCENE_COMMAND_ID 0x00
+#define ZCL_SCENES_CLUSTER_VIEW_SCENE_COMMAND_ID 0x01
+#define ZCL_SCENES_CLUSTER_REMOVE_SCENE_COMMAND_ID 0x02
+#define ZCL_SCENES_CLUSTER_REMOVE_ALL_SCENES_COMMAND_ID 0x03
+#define ZCL_SCENES_CLUSTER_STORE_SCENE_COMMAND_ID 0x04
+#define ZCL_SCENES_CLUSTER_RECALL_SCENE_COMMAND_ID 0x05
+#define ZCL_SCENES_CLUSTER_GET_SCENE_MEMBERSHIP_COMMAND_ID 0x06
+#define ZCL_SCENES_CLUSTER_ENHANCED_ADD_SCENE_COMMAND_ID 0x40
+#define ZCL_SCENES_CLUSTER_ENHANCED_VIEW_SCENE_COMMAND_ID 0x41
+#define ZCL_SCENES_CLUSTER_COPY_SCENE_COMMAND_ID 0x42
+
+/**
+ * \brief Scenes Cluster servers's command identifiers
+*/
+
+#define ZCL_SCENES_CLUSTER_ADD_SCENE_RESPONSE_COMMAND_ID 0x00
+#define ZCL_SCENES_CLUSTER_VIEW_SCENE_RESPONSE_COMMAND_ID 0x01
+#define ZCL_SCENES_CLUSTER_REMOVE_SCENE_RESPONSE_COMMAND_ID 0x02
+#define ZCL_SCENES_CLUSTER_REMOVE_ALL_SCENES_RESPONSE_COMMAND_ID 0x03
+#define ZCL_SCENES_CLUSTER_STORE_SCENE_RESPONSE_COMMAND_ID 0x04
+#define ZCL_SCENES_CLUSTER_GET_SCENE_MEMBERSHIP_RESPONSE_COMMAND_ID 0x06
+#define ZCL_SCENES_CLUSTER_ENHANCED_ADD_SCENE_RESPONSE_COMMAND_ID 0x40
+#define ZCL_SCENES_CLUSTER_ENHANCED_VIEW_SCENE_RESPONSE_COMMAND_ID 0x41
+#define ZCL_SCENES_CLUSTER_COPY_SCENE_RESPONSE_COMMAND_ID 0x42
+
+/**
+ * \brief Scenes Cluster server define attributes macros
+*/
+
+#define ZCL_DEFINE_SCENES_CLUSTER_SERVER_ATTRIBUTES() \
+ DEFINE_ATTRIBUTE(sceneCount, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_SCENE_COUNT_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(currentScene, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_CURRENT_SCENE_SERVER_ATTRIBUTE_ID, ZCL_U8BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(currentGroup, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_CURRENT_GROUP_SERVER_ATTRIBUTE_ID, ZCL_U16BIT_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(sceneValid, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_SCENE_VALID_SERVER_ATTRIBUTE_ID, ZCL_BOOLEAN_DATA_TYPE_ID), \
+ DEFINE_ATTRIBUTE(nameSupport, ZCL_READONLY_ATTRIBUTE, ZCL_SCENES_CLUSTER_NAME_SUPPORT_SERVER_ATTRIBUTE_ID, ZCL_8BIT_BITMAP_DATA_TYPE_ID)
+
+
+/**
+ * \brief On/Off Cluster define commands macros
+*/
+
+#define ZCL_DEFINE_SCENES_CLUSTER_SERVER_COMMANDS(addSceneCommandInd, viewSceneCommandInd, removeSceneCommandInd, \
+ removeAllScenesCommandInd, storeSceneCommandInd, recallSceneCommandInd, \
+ getSceneMembershipCommandInd, enhancedAddSceneCommandInd, enhancedViewSceneCommandInd, copySceneCommandInd) \
+ DEFINE_COMMAND(addSceneCommand, ZCL_SCENES_CLUSTER_ADD_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addSceneCommandInd), \
+ DEFINE_COMMAND(viewSceneCommand, ZCL_SCENES_CLUSTER_VIEW_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ viewSceneCommandInd), \
+ DEFINE_COMMAND(removeSceneCommand, ZCL_SCENES_CLUSTER_REMOVE_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeSceneCommandInd), \
+ DEFINE_COMMAND(removeAllScenesCommand, ZCL_SCENES_CLUSTER_REMOVE_ALL_SCENES_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeAllScenesCommandInd), \
+ DEFINE_COMMAND(storeSceneCommand, ZCL_SCENES_CLUSTER_STORE_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ storeSceneCommandInd), \
+ DEFINE_COMMAND(recallSceneCommand, ZCL_SCENES_CLUSTER_RECALL_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ recallSceneCommandInd), \
+ DEFINE_COMMAND(getSceneMembershipCommand, ZCL_SCENES_CLUSTER_GET_SCENE_MEMBERSHIP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ getSceneMembershipCommandInd), \
+ DEFINE_COMMAND(enhancedAddSceneCommand, ZCL_SCENES_CLUSTER_ENHANCED_ADD_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ enhancedAddSceneCommandInd), \
+ DEFINE_COMMAND(enhancedViewSceneCommand, ZCL_SCENES_CLUSTER_ENHANCED_VIEW_SCENE_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ enhancedViewSceneCommandInd), \
+ DEFINE_COMMAND(copySceneCommand, ZCL_SCENES_CLUSTER_GET_SCENE_MEMBERSHIP_COMMAND_ID, \
+ COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ copySceneCommandInd)
+
+#define ZCL_DEFINE_SCENES_CLUSTER_CLIENT_COMMANDS(addSceneResponseCommandInd, viewSceneResponseCommandInd, \
+ removeSceneResponseCommandInd, removeAllScenesResponseCommandInd, storeSceneResponseCommandInd, \
+ getSceneMembershipResponseCommandInd, enhancedAddSceneResponseCommandInd, enhancedViewSceneResponseCommandInd, \
+ copySceneResponseCommandInd) \
+ DEFINE_COMMAND(addSceneResponseCommand, ZCL_SCENES_CLUSTER_ADD_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ addSceneResponseCommandInd), \
+ DEFINE_COMMAND(viewSceneResponseCommand, ZCL_SCENES_CLUSTER_VIEW_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ viewSceneResponseCommandInd), \
+ DEFINE_COMMAND(removeSceneResponseCommand, ZCL_SCENES_CLUSTER_REMOVE_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeSceneResponseCommandInd), \
+ DEFINE_COMMAND(removeAllScenesResponseCommand, ZCL_SCENES_CLUSTER_REMOVE_ALL_SCENES_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ removeAllScenesResponseCommandInd), \
+ DEFINE_COMMAND(storeSceneResponseCommand, ZCL_SCENES_CLUSTER_STORE_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ storeSceneResponseCommandInd), \
+ DEFINE_COMMAND(getSceneMembershipResponseCommand, ZCL_SCENES_CLUSTER_GET_SCENE_MEMBERSHIP_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ getSceneMembershipResponseCommandInd), \
+ DEFINE_COMMAND(enhancedAddSceneResponseCommand, ZCL_SCENES_CLUSTER_ENHANCED_ADD_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ enhancedAddSceneResponseCommandInd), \
+ DEFINE_COMMAND(enhancedViewSceneResponseCommand, ZCL_SCENES_CLUSTER_ENHANCED_VIEW_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ enhancedViewSceneResponseCommandInd), \
+ DEFINE_COMMAND(copySceneResponseCommand, ZCL_SCENES_CLUSTER_COPY_SCENE_RESPONSE_COMMAND_ID, \
+ COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), \
+ copySceneResponseCommandInd)
+
+/**
+ * \brief Scene Cluster definition macros
+*/
+
+#define SCENES_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = SCENES_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_CLIENT_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_SCENES_CLUSTER_CLIENT_ATTRIBTUES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_SCENES_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define SCENES_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \
+{ \
+ .id = SCENES_CLUSTER_ID, \
+ .options = { \
+ .type = ZCL_SERVER_CLUSTER_TYPE, \
+ .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY, \
+ }, \
+ .attributesAmount = ZCL_SCENES_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \
+ .attributes = (uint8_t *)clattributes, \
+ .commandsAmount = ZCL_SCENES_CLUSTER_COMMANDS_AMOUNT, \
+ .commands = (uint8_t *)clcommands \
+}
+
+#define DEFINE_SCENES_CLUSTER(cltype, clattributes, clcommands) \
+ SCENES_CLUSTER_##cltype(clattributes, clcommands)
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+BEGIN_PACK
+
+/**
+ * \brief Add Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+ uint16_t transitionTime;
+ uint8_t name[1];
+} ZCL_AddScene_t;
+
+/**
+ * \brief View Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_ViewScene_t;
+
+/**
+ * \brief Remove Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_RemoveScene_t;
+
+/**
+ * \brief Remove All Scenes Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+} ZCL_RemoveAllScenes_t;
+
+/**
+ * \brief Store Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_StoreScene_t;
+
+/**
+ * \brief Recall Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_RecallScene_t;
+
+/**
+ * \brief Get Scene Membership Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+} ZCL_GetSceneMembership_t;
+
+/**
+ * \brief Enhanced Add Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+ uint16_t transitionTime;
+ uint8_t name[1];
+ ZCL_OnOffClusterExtensionFieldSet_t onOffClusterExtFields;
+ ZCL_LevelControlClusterExtensionFieldSet_t levelControlClusterExtFields;
+ ZCL_ColorControlClusterExtensionFieldSet_t colorControlClusterExtFields;
+} ZCL_EnhancedAddScene_t;
+
+/**
+ * \brief Enhanced View Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_EnhancedViewScene_t;
+
+/**
+ * \brief Copy Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t mode;
+ uint16_t groupIdFrom;
+ uint16_t sceneIdFrom;
+ uint16_t groupIdTo;
+ uint16_t sceneIdTo;
+} ZCL_CopyScene_t;
+
+/**
+ * \brief Add Scene Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_AddSceneResponse_t;
+
+/**
+ * \brief View Scene Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+ uint16_t transitionTime;
+ uint8_t nameAndExtField[1]; // string sceneName, extension field.
+} ZCL_ViewSceneResponse_t;
+
+/**
+ * \brief Remove Scene Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_RemoveSceneResponse_t;
+
+/**
+ * \brief Remove All Scenes Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+} ZCL_RemoveAllScenesResponse_t;
+
+/**
+ * \brief Store Scene Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_StoreSceneResponse_t;
+
+/**
+ * \brief Get Scene Membership Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint8_t capacity;
+ uint16_t groupId;
+ uint8_t sceneCount;
+ uint8_t sceneList[16];
+} ZCL_GetSceneMembershipResponse_t;
+
+/**
+ * \brief Enhanced Add Scene Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+} ZCL_EnhancedAddSceneResponse_t;
+
+/**
+ * \brief Enhanced View Scene Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupId;
+ uint8_t sceneId;
+ uint16_t transitionTime;
+ uint8_t name[1];
+ ZCL_OnOffClusterExtensionFieldSet_t onOffClusterExtFields;
+ ZCL_LevelControlClusterExtensionFieldSet_t levelControlClusterExtFields;
+ ZCL_ColorControlClusterExtensionFieldSet_t colorControlClusterExtFields;
+} ZCL_EnhancedViewSceneResponse_t;
+
+/**
+ * \brief Copy Scene Response Command Payload format.
+ */
+
+typedef struct PACK
+{
+ uint8_t status;
+ uint16_t groupIdFrom;
+ uint16_t sceneIdFrom;
+ uint16_t groupIdTo;
+ uint16_t sceneIdTo;
+} ZCL_CopySceneResponse_t;
+
+/**
+ * \brief Extension Fields Set format
+ */
+
+typedef struct PACK
+{
+ uint16_t clusterId;
+ uint8_t length;
+} ZCL_ExtensionFieldSets_t;
+
+/**
+ * \brief Scene Cluster server's attributes
+ */
+
+typedef struct PACK
+{
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } sceneCount;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } currentScene;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint16_t value;
+ } currentGroup;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ bool value;
+ } sceneValid;
+
+ struct PACK
+ {
+ ZCL_AttributeId_t id;
+ uint8_t type;
+ uint8_t properties;
+ uint8_t value;
+ } nameSupport;
+} ZCL_SceneClusterServerAttributes_t;
+
+END_PACK
+
+/**
+ * \brief Scene Cluster commands.
+ */
+
+typedef struct
+{
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddScene_t * payload);
+ } addSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*viewSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ViewScene_t * payload);
+ } viewSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveScene_t * payload);
+ } removeSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeAllScenesCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveAllScenes_t * payload);
+ } removeAllScenesCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*storeSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_StoreScene_t * payload);
+ } storeSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*recallSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RecallScene_t * payload);
+ } recallSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*getSceneMembershipCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetSceneMembership_t * payload);
+ } getSceneMembershipCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*enhancedAddSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_EnhancedAddScene_t * payload);
+ } enhancedAddSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*enhancedViewSceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_EnhancedViewScene_t * payload);
+ } enhancedViewSceneCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*copySceneCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_CopyScene_t * payload);
+ } copySceneCommand;
+
+ // responses
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*addSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_AddSceneResponse_t * payload);
+ } addSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*viewSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_ViewSceneResponse_t * payload);
+ } viewSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveSceneResponse_t * payload);
+ } removeSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*removeAllScenesResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_RemoveAllScenesResponse_t * payload);
+ } removeAllScenesResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*storeSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_StoreSceneResponse_t * payload);
+ } storeSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*getSceneMembershipResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_GetSceneMembershipResponse_t * payload);
+ } getSceneMembershipResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*enhancedAddSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_EnhancedAddSceneResponse_t * payload);
+ } enhancedAddSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*enhancedViewSceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_EnhancedViewSceneResponse_t * payload);
+ } enhancedViewSceneResponseCommand;
+
+ struct
+ {
+ ZCL_CommandId_t id;
+ ZclCommandOptions_t options;
+ ZCL_Status_t(*copySceneResponseCommand)(ZCL_Addressing_t *addressing, uint8_t payloadLength, ZCL_CopySceneResponse_t * payload);
+ } copySceneResponseCommand;
+} ZCL_ScenesClusterCommands_t;
+
+
+#endif /* _ZCLSCENESCLUSTER_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllSecurity.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllSecurity.h
new file mode 100644
index 00000000..6dee63df
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclZllSecurity.h
@@ -0,0 +1,63 @@
+/**************************************************************************//**
+ \file zclZllSecurity.h
+
+ \brief
+ Functions and constants used by the ZLL security module.
+
+ \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:
+ 22.06.11 A. Taradov - Created.
+******************************************************************************/
+#ifndef _ZCLZLLSECURITY_H
+#define _ZCLZLLSECURITY_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <sspCommon.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+#define ZCL_ZLL_DEVELOPMENT_KEY_INDEX 0
+#define ZCL_ZLL_MASTER_KEY_INDEX 4
+#define ZCL_ZLL_CERTIFICATION_KEY_INDEX 15
+
+//#define ZCL_ZLL_SUPPORTED_KEY_INDEX ZCL_ZLL_CERTIFICATION_KEY_INDEX
+//#define ZCL_ZLL_SUPPORTED_SECURITY_KEYS (1u << ZCL_ZLL_SUPPORTED_KEY_INDEX)
+
+#define ZCL_ZLL_SUPPORTED_KEY_INDEX ZCL_ZLL_DEVELOPMENT_KEY_INDEX
+#define ZCL_ZLL_SUPPORTED_SECURITY_KEYS (1u << ZCL_ZLL_DEVELOPMENT_KEY_INDEX)
+
+/*! Certification key */
+#define ZCL_ZLL_SECURITY_KEY "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Encrypt security key
+\param[in] text - key to be encrypted
+\param[in] callback - function to be called after encryption is finished
+******************************************************************************/
+void zclZllEncryptKey(uint8_t text[SECURITY_BLOCK_SIZE], void (*callback)(void));
+
+/**************************************************************************//**
+\brief Decrypt security key
+\param[in] text - key to be decrypted
+\param[in] callback - function to be called after decryption is finished
+******************************************************************************/
+void zclZllDecryptKey(uint8_t text[SECURITY_BLOCK_SIZE], void (*callback)(void));
+
+#endif // _ZCLZLLSECURITY_H
+
+// eof zclZllSecurity.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/appFramework.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/appFramework.h
new file mode 100644
index 00000000..7924d250
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/appFramework.h
@@ -0,0 +1,310 @@
+/***********************************************************************//**
+ \file appFramework.h
+
+ \brief The header file describes the types of ZDP and descriptors
+
+ \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
+*******************************************************************/
+
+/******************************************************************************
+* The header file contains ZIGBEE type definitions*/
+
+#ifndef _APPFRAMEWORK_H
+#define _APPFRAMEWORK_H
+
+#include <types.h>
+#include <bcEndian.h>
+#include <mac.h>
+#include <queue.h>
+
+#define ZDP_USER_DESC_FIELD_SIZE 16
+
+// These defines are used only during preprocessor phase. Please use DeviceType_t enumeration values instead.
+#define DEV_TYPE_COORDINATOR 0
+#define DEV_TYPE_ROUTER 1
+#define DEV_TYPE_ENDDEVICE 2
+
+/********************************************************************************
+* Base types
+********************************************************************************/
+typedef uint8_t Endpoint_t;
+typedef uint16_t ProfileId_t;
+typedef uint16_t ClusterId_t;
+typedef uint16_t GroupAddr_t;
+typedef uint8_t StackProfile_t;
+
+
+/********************************************************************************
+* Zigbee APFW types definition
+********************************************************************************/
+
+BEGIN_PACK
+//!\brief Node descriptor
+/*! Mandatory for each node. */
+typedef struct PACK
+{
+ LITTLE_ENDIAN_OCTET(4, (
+ /*! Device role:\n
+ 000 - ::DEVICE_TYPE_COORDINATOR,\n
+ 001 - ::DEVICE_TYPE_ROUTER,\n
+ 010 - ::DEVICE_TYPE_END_DEVICE,\n
+ 011-111 - reserved.*/
+ uint8_t logicalType : 3,
+ /*! Specifies whether a complex descriptor is available on this device. */
+ uint8_t complexDescriptorAvailable: 1,
+ /*! Specifies whether a user descriptor is available on this device. */
+ uint8_t userDescriptorAvailable: 1,
+ /*! Reserved. */
+ uint8_t reserved: 3
+ ))
+
+ LITTLE_ENDIAN_OCTET(2, (
+ /*! APS capability flags. Not supported (always set to 0). */
+ uint8_t apsFlags : 3,
+ /*! Bit mask for supported frequency bands.\n
+ Bit 0: 868 - 868.6 MHz\n
+ Bit 1: Reserved\n
+ Bit 2: 902 - 928 MHz\n
+ Bit 3: 2400 - 2483.5 MHz\n
+ Bit 4: Reserved. */
+ uint8_t frequencyBand : 5
+ ))
+
+ /*! MAC capability flags.\n
+ Bit 0: is the node capable of becoming an alternate PAN coordinator\n
+ Bit 1: device type (full-function vs. reduced-function device)\n
+ Bit 2: is the device mains-powered \n
+ Bit 3: is the receiver enabled when the device is idle \n
+ Bits 4-5: Reserved\n
+ Bit 6: is MAC security enabled \n
+ Bit 7: Always equals 1. */
+ MAC_CapabilityInf_t macCapbFlags;
+
+ /*! 16-bit manufacturer code allocated by the ZigBee Alliance. */
+ uint16_t manufacturerCode;
+
+ /*! Maximum size of the network sub-layer data unit (NSDU) for this node, in octets.
+ Valid range is 0x00-0x7f. */
+ uint8_t maxBufferSize;
+
+ /*! Maximum size of the application sub-layer data unit (ASDU) that can be
+ transferred to this node in one single message transfer, in octets.
+ Valid range is 0x0000-0x7fff. May exceed the maxBufferSize value through the
+ use of fragmentation. */
+ uint16_t maxTransferSize;
+
+ /*! Bit mask denoting the system server capabilities of this node.\n
+ Used to facilitate discovery of particular system servers by other nodes.\n
+ Bit 0: Primary Trust Center\n
+ Bit 1: Backup Trust Center\n
+ Bit 2: Primary Binding Table Cache\n
+ Bit 3: Backup Binding Table Cache\n
+ Bit 4: Primary Discovery Cache\n
+ Bit 5: Backup Discovery Cache\n
+ Bit 6: Network Manager\n
+ Bits 7-15: Reserved. */
+ uint16_t serverMask;
+
+ /*! Maximum size of the application sub-layer data unit (ASDU) that can be
+ transferred from this node in one single message transfer, in octets.
+ Valid range is 0x0000-0x7fff. */
+ uint16_t maxOutcTransferSize;
+
+ /*! Descriptor capabilities bit mask.
+ Bit 0: Extended Active Endpoint list available\n
+ Bit 1: Extended Simple Descriptor list available\n
+ Bits 2-7: Reserved. */
+ uint8_t descriptorCapabilityField;
+} NodeDescriptor_t;
+
+//!\brief Power descriptor
+/*! Mandatory for each node. */
+typedef struct PACK
+{
+/*! Specifies the current sleep/power-saving mode of the node.\n
+0000 - Receiver synchronized with the 'receiver on when idle' subfield of the node descriptor.\n
+0001 - Receiver comes on periodically as defined by the node power descriptor.\n
+0010 - Receiver comes on when stimulated, e.g. by a user pressing a button.\n
+0011-1111 - Reserved. */
+ uint8_t currentPowerMode : 4;
+/*! Specifies the power sources available on this node.\n
+0 - Constant (mains) power\n
+1 - Rechargeable battery\n
+2 - Disposable battery\n
+3 - Reserved. */
+ uint8_t availablePowerSources : 4;
+/*! Specifies the power source being currently used by the node.\n
+0 - Constant (mains) power\n
+1 - Rechargeable battery\n
+2 - Disposable battery\n
+3 - Reserved. */
+ uint8_t currentPowerSource : 4;
+/*! Specifies the level of charge of the power source.\n
+0000 - Critical\n
+0100 - 33%\n
+1000 - 66%\n
+1100 - 100%\n
+All other values - Reserved. */
+ uint8_t currentPowerSourceLevel : 4;
+} PowerDescriptor_t;
+
+//!\brief Simple Descriptor
+/*! Mandatory for each endpoint present in the node. */
+typedef struct PACK
+{
+/*! ID of the endpoint within the node to which this description refers.
+Applications shall only use endpoints 1-240. */
+ Endpoint_t endpoint;
+/*! Profile that is supported on this endpoint. */
+ ProfileId_t AppProfileId;
+/*! Device description supported on this endpoint. */
+ uint16_t AppDeviceId;
+/*! Version of the device description supported on this endpoint. */
+ uint8_t AppDeviceVersion : 4;
+/*! Reserved. */
+ uint8_t Reserved : 4;
+/*! Number of input clusters supported on this endpoint. If 0, the
+application input cluster list field shall not be included. */
+ uint8_t AppInClustersCount;
+/*! List of input clusters supported on this endpoint. */
+ ClusterId_t* AppInClustersList;
+/*! Number of output clusters supported on this endpoint. If 0, the
+application output cluster list field shall not be included. */
+ uint8_t AppOutClustersCount;
+/*! List of output clusters supported on this endpoint. */
+ ClusterId_t* AppOutClustersList;
+} SimpleDescriptor_t;
+
+//!\brief User descriptor.
+/*! Used optionally. */
+typedef struct PACK
+{
+ uint8_t FieldLength;
+/*! Human-readable character string that allows the user to identify the device. */
+ uint8_t FieldName[ZDP_USER_DESC_FIELD_SIZE];
+} UserDescriptor_t;
+
+END_PACK
+
+/*! Intended for specifying device role. */
+typedef enum
+{
+ DEVICE_TYPE_COORDINATOR = DEV_TYPE_COORDINATOR,
+ DEVICE_TYPE_ROUTER = DEV_TYPE_ROUTER,
+ DEVICE_TYPE_END_DEVICE = DEV_TYPE_ENDDEVICE
+} DeviceType_t;
+
+/*! Intended for specifying NodeDescriptor_t::macCapbFlags field. */
+enum
+{
+ MAC_CAP_ALTERNATE_PAN_COORDINATOR = 0x01,
+ MAC_CAP_DEVICE_TYPE_FFD = 0x02,
+ MAC_CAP_POWER_SOURCE_MAINS = 0x04,
+ MAC_CAP_RX_ON_WHEN_IDLE = 0x08,
+ MAC_CAP_SECURITY_CAPABLE = 0x40,
+ MAC_CAP_ALLOCATE_ADDRESS = 0x80 // always set for rev13
+};
+
+/*! Intended for specifying NodeDescriptor_t::serverMask field. */
+enum
+{
+ SERVER_MASK_NO_SERVER = 0x0000,
+ SERVER_MASK_PRIMARY_TRUST_CENTER = 0x0001,
+ SERVER_MASK_BACKUP_TRUST_CENTER = 0x0002,
+ SERVER_MASK_PRIMARY_BINDING_TABLE_CACHE = 0x0004,
+ SERVER_MASK_BACKUP_BINDING_TABLE_CACHE = 0x0008,
+ SERVER_MASK_PRIMARY_DISCOVERY_CACHE = 0x0010,
+ SERVER_MASK_BACKUP_DISCOVERY_CACHE = 0x0020,
+ SERVER_MASK_NETWORK_MANAGER = 0x0040
+};
+
+/*! Intended for specifying NodeDescriptor_t::descriptorCapabilityField field. */
+enum
+{
+ EXT_LIST_ACTIVE_EP = 0x01,
+ EXT_LIST_SIMPLE_DESC = 0x02
+};
+
+/*! Intended for specifying PowerDescriptor_t::currentPowerMode field. */
+typedef enum
+{
+ RECEIVER_SYNCRONIZED_WHEN_ON_IDLE = 0,
+ RECEIVER_COMES_PERIODICALLY = 1,
+ RECEIVER_COMES_WHEN_STIMULATED = 2
+ //RESERVED = 0xF /* all other values */
+} PowerMode_t;
+
+/*! Intended for specifying PowerDescriptor_t::availablePowerSources
+and PowerDescriptor_t::currentPowerSource fields. */
+typedef enum
+{
+ MAINS_POWER = 0x1,
+ RECHARGEABLE_BATTERY = 0x2,
+ DISPOSABLE_BATTERY = 0x4,
+ //RESERVED
+} PowerSource_t;
+
+/*! Intended for specifying PowerDescriptor_t::currentPowerSourceLevel field. */
+typedef enum
+{
+ CRITICAL_0 = 0,
+ PERCENT_33 = 4,
+ PERCENT_66 = 8,
+ PERCENT_100 = 0xC
+ //RESERVED = 0xFF; /* all over values */
+} PowerSourceLevel_t;
+
+
+/*! Intended for specifying ComplexDescriptorField_t::CompressedXMLTag field. */
+enum
+{
+ TAG_LANGUAGE_AND_CHARACTER_SET = 0001,
+ TAG_MANUFACTURER_NAME = 0010,
+ TAG_MODEL_NAME = 0011,
+ TAG_SERIAL_NUMBER = 0100,
+ TAG_DEVICE_URL = 0101,
+ TAG_ICON = 0110,
+ TAG_ICON_URL = 0111,
+};
+
+//!\brief Complex Descriptor field.
+typedef struct
+{
+/*! Field type.\n
+Possible values:\n
+0x00 - Reserved\n
+0x01 - ISO 639-1 language code\n
+0x02 - Manufacturer name\n
+0x03 - Model name\n
+0x04 - Serial number\n
+0x05 - Device URL\n
+0x06 - Icon\n
+0x07 - Icon URL\n
+0x08-0xFF - Reserved. */
+ uint8_t CompressedXMLTag;
+/*! Field contents. */
+ uint8_t* pDataField;
+} ComplexDescriptorField_t;
+
+
+//!\brief Complex Descriptor.
+/*! Used optionally.\n
+Consists of compressed XML tags.\n
+The overall length shall be less than or equal to apscMaxDescriptorSize.*/
+typedef struct
+{
+/*! Field count. */
+ uint8_t FieldCount;
+/*! List of fields. */
+ ComplexDescriptorField_t* pFields;
+} ComplexDescriptor_t;
+
+#endif /* _APPFRAMEWORK_H */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoBinding.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoBinding.h
new file mode 100644
index 00000000..3ae2cc93
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoBinding.h
@@ -0,0 +1,46 @@
+/**************************************************************************//**
+ \file zdoBinding.h
+
+ \brief Internal interface of ZDO binding functionality.
+
+ \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:
+ 2011-03-17 Max Gekk - Created.
+ Last change:
+ $Id: zdoBinding.h 17448 2011-06-09 13:53:59Z ataradov $
+ ******************************************************************************/
+#if !defined _ZDO_BINDING_H
+#define _ZDO_BINDING_H
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Prepare Bind or Unbind ZDP request.
+ ******************************************************************************/
+void zdoUnbindBindRequestCreate(void);
+
+/**************************************************************************//**
+ \brief Process an incoming Bind or Unbind request and send response.
+ ******************************************************************************/
+void zdoUnbindBindInd(void);
+
+/**************************************************************************//**
+ \brief Prepare ZDP Mgmt Bind request. Init APS_DataReq_t structure.
+ ******************************************************************************/
+void zdoMgmtBindRequestCreate(void);
+
+/**************************************************************************//**
+ \brief Process an incoming Mgmt Bind request and send response.
+ ******************************************************************************/
+void zdoMgmtBindInd(void);
+
+#endif /* _ZDO_BINDING_H */
+/** eof zdoBinding.h */
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoDbg.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoDbg.h
new file mode 100644
index 00000000..8121410e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoDbg.h
@@ -0,0 +1,129 @@
+/************************************************************************//**
+ \file zdoDbg.h
+
+ \brief ZDO assert codes
+
+ \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.07.09 A. Taradov - Refactoring
+ 29.10.09 A. Taradov - Refactoring
+******************************************************************************/
+
+#ifndef _ZDODBG_H
+#define _ZDODBG_H
+
+#include <dbg.h>
+
+typedef enum _ZdoDbgCode_t
+{
+ ZDO_NULL_CONFIRM_MESSAGE = 0x5001,
+ ZDO_UNKNOWN_STATE_MESSAGE = 0x5004,
+ ZDO_UNEXPECTED_FAIL_CONFIRM_MESSAGE = 0x5005,
+ ZDO_UNKNOWN_NETWORK_START_TYPE_MESSAGE = 0x5006,
+ ZDO_STACK_RESET_FAIL_MESSAGE = 0x5007,
+ ZDO_UNKNOWN_ZDP_CLUSTER_MESSAGE = 0x5008,
+ ZDO_ILLEGAL_ADDRESS_MODE_MESSAGE = 0x5009,
+ ZDO_UNKNOWN_SECURITY_KEY_MESSAGE = 0x500A,
+ ZDO_UNEXPECTED_CALLBACK = 0x500B,
+ ZDO_NULL_CALLBACK_SET_TX_POWER_CONF_0 = 0x500E,
+ ZDO_NULL_CALLBACK_SET_TX_POWER_CONF_1 = 0x500F,
+ ZDO_NULL_CALLBACK_ENDTOENDAPPKEY_CONF = 0x5010,
+ ZDO_ZDP_MANAGER_QUEUE_EMPTY = 0x5013,
+ ZDO_INVALID_ZDP_REQUEST_STATE = 0x5014,
+ ZDO_DISCOVERY_MANAGER_UNKNOWN_REQ_CLUSTER = 0x5015,
+ ZDO_BIND_MANAGER_UNKNOWN_REQ_CLUSTER = 0x5016,
+ ZDO_NODE_MANAGER_UNKNOWN_REQ_CLUSTER = 0x5017,
+ ZDO_DISCOVERY_MANAGER_UNKNOWN_RESP_CLUSTER = 0x5018,
+ ZDO_BIND_MANAGER_UNKNOWN_RESP_CLUSTER = 0x5019,
+ ZDO_NODE_MANAGER_UNKNOWN_RESP_CLUSTER = 0x5020,
+ ZDO_NODE_MANAGER_INVALID_SRC_ADDR_MODE = 0x5021,
+
+ ZDO_SECURITY_MANAGER_0 = 0x5030,
+
+ ZDO_NWK_MANAGER_0 = 0x5040,
+
+ ZDO_START_NETWORK_0 = 0x5050,
+ ZDO_START_NETWORK_1 = 0x5051,
+ ZDO_START_NETWORK_2 = 0x5052,
+ ZDO_START_NETWORK_3 = 0x5053,
+ ZDO_START_NETWORK_4 = 0x5054,
+ ZDO_START_NETWORK_5 = 0x5055,
+ ZDO_START_NETWORK_6 = 0x5056,
+ ZDO_START_NETWORK_7 = 0x5057,
+ ZDO_START_NETWORK_8 = 0x5058,
+ ZDO_START_NETWORK_9 = 0x5059,
+ ZDO_START_NETWORK_10 = 0x505a,
+ ZDO_START_NETWORK_11 = 0x505b,
+ ZDO_START_NETWORK_12 = 0x505c,
+ ZDO_START_NETWORK_13 = 0x505d,
+ ZDO_START_NETWORK_14 = 0x505e,
+ ZDO_START_NETWORK_15 = 0x505f,
+ ZDO_START_NETWORK_16 = 0x5060,
+ ZDO_START_NETWORK_17 = 0x5061,
+ ZDO_START_NETWORK_18 = 0x5062,
+ ZDO_START_NETWORK_19 = 0x5063,
+
+ ZDO_RESET_NETWORK_0 = 0x5070,
+ ZDO_RESET_NETWORK_1 = 0x5071,
+ ZDO_RESET_NETWORK_2 = 0x5072,
+ ZDO_RESET_NETWORK_3 = 0x5073,
+
+ ZDO_LEAVE_NETWORK_0 = 0x5090,
+ ZDO_LEAVE_NETWORK_1 = 0x5091,
+ ZDO_LEAVE_NETWORK_2 = 0x5092,
+ ZDO_LEAVE_NETWORK_3 = 0x5093,
+
+ ZDO_TC_SWAPOUT_0 = 0x50a0,
+ ZDO_TC_SWAPOUT_1 = 0x50a1,
+ ZDO_TC_SWAPOUT_2 = 0x50a2,
+ ZDO_TC_SWAPOUT_3 = 0x50a3,
+ ZDO_TC_SWAPOUT_4 = 0x50a4,
+ ZDO_TC_SWAPOUT_5 = 0x50a5,
+ ZDO_TC_SWAPOUT_6 = 0x50a6,
+ ZDO_TC_SWAPOUT_7 = 0x50a7,
+
+ ZDO_TC_KEEP_ALIVE_0 = 0x50b0,
+
+ ZDO_POWER_MANAGER_0 = 0x50c0,
+ ZDO_POWER_MANAGER_1 = 0x50c1,
+ ZDO_POWER_MANAGER_2 = 0x50c2,
+ ZDO_POWER_MANAGER_3 = 0x50c3,
+ ZDO_POWER_MANAGER_4 = 0x50c4,
+ ZDO_POWER_MANAGER_5 = 0x50c5,
+ ZDO_POWER_MANAGER_6 = 0x50c6,
+ ZDO_POWER_MANAGER_7 = 0x50c7,
+
+ ZDO_MEMORY_CORRUPTION_0 = 0x50d0,
+ ZDO_MEMORY_CORRUPTION_1 = 0x50d1,
+
+ ZDO_RESET_0 = 0x50e0,
+ ZDO_RESET_1 = 0x50e1,
+ ZDO_RESET_2 = 0x50e2,
+ ZDO_RESET_3 = 0x50e3,
+
+ ZDOENDDEVICEBINDING_ENDDEVICEBINDINGIND_0 = 0x50f0,
+ ZDOENDDEVICEBINDING_SAVESECONDENDDEVICEBINDINGREQ_0 = 0x50f1,
+ ZDOENDDEVICEBINDING_ENDDEVICEBINDINGRESPONSECREATE_0 = 0x50f2,
+ ZDOENDDEVICEBINDING_ENDDEVICEBINDINGRESPONSECREATE_1 = 0x50f3,
+ ZDOENDDEVICEBINDING_SENDNEXTBINDREQ_0 = 0x50f4,
+ ZDOENDDEVICEBINDING_ENDDEVICEBINDINGREQUESTCREATE_0 = 0x50f5,
+ ZDOENDDEVICEBINDING_ENDDEVICEBINDINGREQUESTCREATE_1 = 0x50f6,
+ ZDOENDDEVICEBINDING_PREPAREFIRSTUNBINDREQ_0 = 0x50f7,
+
+ ZDOBINDING_GENERATEUNBINDBINDREQ_0 = 0x5100,
+ ZDOBINDING_UNBINDBINDIND_0 = 0x5101,
+ ZDOBINDING_UNBINDBINDIND_1 = 0x5102,
+ ZDOBINDING_MGMTBINDIND_0 = 0x5103,
+ ZDOBINDING_INITDSTADDRESS_0 = 0x5104
+} ZdoDbgCode_t;
+
+#endif // _ZDODBG_H
+
+// eof zdoDbg.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoDiscoveryManager.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoDiscoveryManager.h
new file mode 100644
index 00000000..d06dd565
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoDiscoveryManager.h
@@ -0,0 +1,24 @@
+/************************************************************************//**
+ \file zdoDiscoveryManager.h
+
+ \brief The header file describes the constants and types of
+ ZDO discovery manager
+
+ \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:
+******************************************************************************/
+
+#ifndef ZDODISCOVERYMANAGER_H_
+#define ZDODISCOVERYMANAGER_H_
+
+void zdoZdpDiscoveryRequestCreate(void);
+void zdoZdpDiscoveryMessageInd(void);
+
+#endif /*ZDODISCOVERYMANAGER_H_*/
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoEndDeviceBinding.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoEndDeviceBinding.h
new file mode 100644
index 00000000..22380e81
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoEndDeviceBinding.h
@@ -0,0 +1,134 @@
+/**************************************************************************//**
+ \file zdoEndDeviceBinding.h
+
+ \brief Internal interface of ZDO End device Binding module.
+
+ \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:
+ 2011-03-11 Max Gekk - Created.
+ Last change:
+ $Id: zdoEndDeviceBinding.h 18225 2011-08-12 14:02:16Z mgekk $
+ ******************************************************************************/
+#if !defined _ZDO_END_DEVICE_BINDING_H
+#define _ZDO_END_DEVICE_BINDING_H
+
+/******************************************************************************
+ Includes section
+ ******************************************************************************/
+#include <appTimer.h>
+#include <zdo.h>
+
+/******************************************************************************
+ Definition section
+ ******************************************************************************/
+/** Pre-configured timeout duration awaiting a second End_Device_Bind_req.
+ * See ZigBee Smart Energy Profile Specification r15, Table 5.9 and ZigBee
+ * HA Profile Specification r26, 5.3.8, page 15. */
+#define ZDO_END_DEVICE_BIND_TIMEOUT 60000UL /* milliseconds */
+
+/** Minimum size of ZDP End Device Binding command:
+ * - 2 bytes - binding target,
+ * - 8 bytes - IEEE address of the device generating request,
+ * - 1 byte - source endpoint,
+ * - 2 bytes - profileId,
+ * - 2 bytes - numInClusters and numOutClusters.
+ */
+#define ZDO_MIN_END_DEVICE_BINDING_COMMAND_SIZE 15U
+
+/** Maximum number of stored input and output cluster ids. */
+#define ZDO_TOTAL_BIND_CLUSTERS_AMOUNT (2 * MAX_REQUESTED_CLUSTER_NUMBER)
+
+#if defined _END_DEVICE_BINDING_
+/******************************************************************************
+ Types section
+ ******************************************************************************/
+/* States of End Device Binding module. */
+typedef enum _ZdoEndDeviceBindingState_t
+{
+ ZDO_END_DEVICE_BINDING_NO_INIT_STATE = 0x00,
+ ZDO_WAIT_FIRST_END_DEVICE_BINDING_REQ_STATE = 0x45,
+ ZDO_WAIT_SECOND_END_DEVICE_BINDING_REQ_STATE = 0x46,
+ ZDO_SEND_FIRST_UNBIND_REQ_STATE = 0x47,
+ ZDO_SEND_END_DEVICE_BINDING_NO_MATCH_STATE = 0x48,
+ ZDO_SEND_END_DEVICE_BINDING_TIMEOUT_STATE = 0x49,
+ ZDO_SENDING_FIRST_UNBIND_REQ_STATE = 0x4A,
+ ZDO_SENDING_UNBIND_BIND_REQ_STATE = 0x4B,
+ ZDO_SENDING_FIRST_END_DEVICE_BINDING_RESP_STATE = 0x4C,
+ ZDO_SENDING_SECOND_END_DEVICE_BINDING_RESP_STATE = 0x4D,
+ ZDO_SENDING_END_DEVICE_BINDING_TIMEOUT_STATE = 0x4E
+} ZdoEndDeviceBindingState_t;
+
+/* Information about cluster that is received in ZDO End Device Binding request. */
+typedef struct _ZdoSavedClusterId_t
+{
+ ClusterId_t id; /* Identifier of stored cluster. */
+ bool busy : 1; /* Current entry is used (true) or not (false). */
+ /* If this field is 'true' then clusterId was received in the Input Cluster List
+ * of ZDP End Device Binding command frame. */
+ bool isInputCluster : 1;
+ /* if it's output cluster then this flag indicates bind state. */
+ bool bound : 1;
+} ZdoSavedClusterId_t;
+
+/* Information from received End Device Binding request. */
+typedef struct _ZdoBindDevice_t
+{
+ ExtAddr_t extAddress;
+ ShortAddr_t shortAddress;
+ ShortAddr_t bindingTarget;
+ Endpoint_t endpoint;
+ uint8_t seqNum; /*!< Sequence number of ZDP request. */
+} ZdoBindDevice_t;
+
+/* Internal state and variables of the End Device Binding module. */
+typedef struct _ZdoEndDeviceBinding_t
+{
+ ZdoEndDeviceBindingState_t state;
+ bool zdpReqBusy; /*!< Flag indicates using of zdpReq. */
+ ZDO_ZdpReq_t zdpReq;
+ HAL_AppTimer_t timer;
+ /* List of clusterIds (input and output) from first ZDP request. */
+ ZdoSavedClusterId_t cluster[ZDO_TOTAL_BIND_CLUSTERS_AMOUNT];
+ ProfileId_t profileId;
+ ClusterId_t bindClusterId;
+ ZDO_Status_t responseStatus; /*!< Status used in finish stage. */
+ ZdoBindDevice_t first; /*!< Information about a first binding device. */
+ ZdoBindDevice_t second; /*!< Information about a second binding device. */
+} ZdoEndDeviceBinding_t;
+
+/******************************************************************************
+ Prototypes section
+ ******************************************************************************/
+/**************************************************************************//**
+ \brief Prepare of APS_DataReq_t structure for end device binding request.
+ ******************************************************************************/
+void zdoEndDeviceBindingRequestCreate(void);
+
+#if defined _COORDINATOR_
+/**************************************************************************//**
+ \brief Process an incoming ZDP End Device Binding command.
+ ******************************************************************************/
+void zdoEndDeviceBindingInd(void);
+
+/**************************************************************************//**
+ \brief Prepare APS_DataReq_t structure for end device binding response.
+ ******************************************************************************/
+void zdoEndDeviceBindingResponseCreate(void);
+
+/**************************************************************************//**
+ \brief Reset internal state and variables of ZDO End Device Binding modile.
+ ******************************************************************************/
+void zdoResetEndDeviceBinding(void);
+
+#endif /* _COORDINATOR_ */
+#endif /* _END_DEVICE_BINDING_ */
+#endif /* _ZDO_END_DEVICE_BINDING_H */
+/** eof zdoEndDeviceBinding.h */
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoInit.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoInit.h
new file mode 100644
index 00000000..9490fcda
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoInit.h
@@ -0,0 +1,39 @@
+/**************************************************************************//**
+ \file zdoInit.h
+
+ \brief Interface for ZDO initialization routines
+
+ \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.10.09 A. Taradov - Created
+******************************************************************************/
+
+#ifndef _ZDOINIT_H
+#define _ZDOINIT_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zdoMem.h>
+#include <zdoStartNetwork.h>
+#include <zdoManager.h>
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/******************************************************************************
+ \brief ZDO initialization routine
+******************************************************************************/
+void zdoInitHandler(void);
+
+#endif // _ZDOINIT_H
+
+// eof zdoInit.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoLeaveNetwork.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoLeaveNetwork.h
new file mode 100644
index 00000000..1b16792c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoLeaveNetwork.h
@@ -0,0 +1,111 @@
+/**************************************************************************//**
+ \file zdoLeaveNetwork.h
+
+ \brief Interface for ZDO Leave Network routines
+
+ \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:
+ 29.10.09 A. Taradov - Created
+******************************************************************************/
+#ifndef _ZDOLEAVENETWORK_H
+#define _ZDOLEAVENETWORK_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zdo.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum _ZdoLeaveNetworkState_t
+{
+ ZDO_LEAVE_NETWORK_IDLE_STATE,
+ ZDO_LEAVE_NETWORK_NWK_LEAVE_STATE,
+ ZDO_LEAVE_NETWORK_APS_STOP_STATE
+} ZdoLeaveNetworkState_t;
+
+typedef void (ZdoLeaveNetworkConf_t)(ZDO_Status_t status);
+
+typedef struct _ZdoLeaveNetwork_t
+{
+ ZdoLeaveNetworkState_t state;
+ ZdoLeaveNetworkConf_t *confirm;
+ bool rejoin;
+} ZdoLeaveNetwork_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/******************************************************************************
+ Network leave indication
+ Parameters:
+ rejoin - true if rejoin is required
+ Return:
+ none
+******************************************************************************/
+void zdoLeaveNetworkInd(bool rejoin);
+
+/******************************************************************************
+ Leave device from network
+ Parameters:
+ removeChildren - remove or not children
+ rejoin - perform or not rejoin after leaving
+ Returns:
+ None
+******************************************************************************/
+void zdoLeaveNetworkReq(bool removeChildren, bool rejoin);
+
+/******************************************************************************
+ Leave device from network. Leave Network module must be allocated before
+ calling this function.
+ Parameters:
+ removeChildren - remove or not children
+ rejoin - perform or not rejoin after leaving
+ Returns:
+ None
+******************************************************************************/
+void zdoLeaveNetwork(bool removeChildren, bool rejoin);
+
+/******************************************************************************
+ Allocate Leave Network module
+ Parameters:
+ leaveNetworkConf - confirmation callback
+ Return:
+ true - if module was alocated, false otherwise
+******************************************************************************/
+bool zdoLeaveNetworkAlloc(ZdoLeaveNetworkConf_t *leaveNetworkConf);
+
+/******************************************************************************
+ Free Leave Network module
+ Parameters:
+ none
+ Return:
+ none
+******************************************************************************/
+void zdoLeaveNetworkFree(void);
+
+/******************************************************************************
+ Reset Leave Network component.
+ Parameters:
+ none
+ Return:
+ none
+******************************************************************************/
+void zdoLeaveNetworkReset(void);
+
+#endif // _ZDOLEAVENETWORK_H
+
+// eof zdoLeaveNetwork.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoManager.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoManager.h
new file mode 100644
index 00000000..e21a8db2
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoManager.h
@@ -0,0 +1,116 @@
+/**************************************************************************//**
+ \file zdoManager.h
+
+ \brief ZDO internal management functions interface
+
+ \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:
+ 28.10.09 A. Taradov - Created
+******************************************************************************/
+#ifndef _ZDOMANAGER_H
+#define _ZDOMANAGER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zdoMem.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum _ZdoModuleId_t
+{
+ ZDO_START_NETWORK_MODULE_ID = (1 << 0),
+ ZDO_RESET_NETWORK_MODULE_ID = (1 << 1),
+ ZDO_LEAVE_NETWORK_MODULE_ID = (1 << 2),
+ ZDO_BINDING_MANAGER_MODULE_ID = (1 << 3),
+ ZDO_DISCOVERY_MANAGER_MODULE_ID = (1 << 4),
+ ZDO_NODE_MANAGER_MODULE_ID = (1 << 5),
+ ZDO_NWK_MANAGER_MODULE_ID = (1 << 6),
+ ZDO_POWER_MANAGER_MODULE_ID = (1 << 7),
+ ZDO_SECURITY_MANAGER_MODULE_ID = (1 << 8),
+ ZDO_ZDP_FRAME_PROCESSOR_MODULE_ID = (1 << 9),
+ ZDO_ZDP_MANAGER_MODULE_ID = (1 << 10),
+ ZDO_NETWORK_STATUS_MODULE_ID = (1 << 11),
+ ZDO_TC_SWAPOUT_MODULE_ID = (1 << 12),
+} ZdoModuleId_t;
+
+typedef enum _ZdoModuleSet_t
+{
+ ZDO_INITIAL_MODULE_SET = 0,
+ ZDO_ALL_DISABLED_MODULE_SET = 0,
+ ZDO_READY_MODULE_SET = ZDO_START_NETWORK_MODULE_ID | ZDO_RESET_NETWORK_MODULE_ID |
+ ZDO_POWER_MANAGER_MODULE_ID | ZDO_TC_SWAPOUT_MODULE_ID,
+ ZDO_START_NETWORK_MODULE_SET = ZDO_ZDP_MANAGER_MODULE_ID,
+ ZDO_IN_NETWORK_MODULE_SET = ZDO_BINDING_MANAGER_MODULE_ID | ZDO_DISCOVERY_MANAGER_MODULE_ID |
+ ZDO_NODE_MANAGER_MODULE_ID | ZDO_NWK_MANAGER_MODULE_ID |
+ ZDO_POWER_MANAGER_MODULE_ID | ZDO_SECURITY_MANAGER_MODULE_ID |
+ ZDO_ZDP_FRAME_PROCESSOR_MODULE_ID | ZDO_ZDP_MANAGER_MODULE_ID |
+ ZDO_NETWORK_STATUS_MODULE_ID | ZDO_RESET_NETWORK_MODULE_ID |
+ ZDO_LEAVE_NETWORK_MODULE_ID | ZDO_TC_SWAPOUT_MODULE_ID,
+ ZDO_REJOIN_NETWORK_MODULE_SET = ZDO_ZDP_MANAGER_MODULE_ID,
+ ZDO_LEAVING_MODULE_SET = ZDO_LEAVE_NETWORK_MODULE_ID | ZDO_ZDP_MANAGER_MODULE_ID,
+ ZDO_TC_SWAPOUT_MODULE_SET = ZDO_ZDP_MANAGER_MODULE_ID,
+ ZDO_RESET_NETWORK_MODULE_SET = 0,
+} ZdoModuleSet_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+void zdoUpdateRandSeed(void);
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+
+/******************************************************************************
+ Enable certain modules
+ Parameters:
+ modules - modules to enable
+ Return:
+ none
+******************************************************************************/
+inline static void zdoEnable(uint16_t modules)
+{
+ zdoMem.enabledModules = modules;
+}
+
+/******************************************************************************
+ Check if certain module is enabled
+ Parameters:
+ module - module id to check
+ Return:
+ true - module is enabled
+ false - module is disabled
+******************************************************************************/
+inline static bool zdoEnabled(uint16_t module)
+{
+ return (zdoMem.enabledModules & module);
+}
+
+/******************************************************************************
+ Set 'Out of Network' flag for correct state restore after power failure.
+ Parameters:
+ none
+ Return:
+ none
+******************************************************************************/
+inline static void zdoSetOutOfNetworkFlag(void)
+{
+#if defined(_POWER_FAILURE_)
+ ExtPanId_t nwkExtPanId = NWK_NO_EXT_PANID;
+ NWK_SetExtPanId(&nwkExtPanId);
+
+ zdoMem.zdoStartNetwork.powerFailureControl.networkOperationsAccepted = 0U;
+#endif
+}
+
+#endif // _ZDOMANAGER_H
+
+// eof zdoManager.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoMem.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoMem.h
new file mode 100644
index 00000000..ce80a64d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoMem.h
@@ -0,0 +1,177 @@
+/************************************************************************//**
+ \file zdoMem.h
+
+ \brief The header file describes the internal ZDO memory
+
+ \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:
+******************************************************************************/
+
+#ifndef _ZDOMEM_H
+#define _ZDOMEM_H
+
+#include <zdo.h>
+#include <zdoNodeManager.h>
+#include <zdoNwkManager.h>
+#include <zdoPowerManager.h>
+#include <zdoStartNetwork.h>
+#include <zdoResetNetwork.h>
+#include <zdoLeaveNetwork.h>
+#include <zdoZdpManager.h>
+#include <zdoZdpFrameProcessor.h>
+#include <zdoSecurityManager.h>
+#include <zdoTcSwapOut.h>
+#include <zdoTcKeepAlive.h>
+#include <zdoReset.h>
+#include <zdoEndDeviceBinding.h>
+
+typedef union _ZdoStackReq_t
+{
+ // Requests from ZDO to NLME
+#if defined(_COORDINATOR_)
+ NWK_NetworkFormationReq_t nwkFormationReq;
+#endif
+
+#if defined(_ROUTER_) || defined(_ENDDEVICE_)
+ NWK_JoinReq_t nwkJoinReq;
+#endif
+
+#if defined(_COORDINATOR_) || defined(_ROUTER_)
+ NWK_PermitJoiningReq_t nwkPermitJoiningReq;
+#endif
+
+#if defined(_ROUTER_)
+ NWK_StartRouterReq_t nwkStartRouterReq;
+#endif
+
+ NWK_LeaveReq_t nwkLeaveReq;
+
+ // Requests from ZDO to APSME
+ APS_ResetReq_t apsResetReq;
+ APS_StartReq_t apsStartReq;
+ APS_StopReq_t apsStopReq;
+} ZdoStackReq_t;
+
+typedef struct _ZdoMem_t
+{
+ ZdoStackReq_t stackReq;
+ ZdoStartNetwork_t zdoStartNetwork;
+ ZdoLeaveNetwork_t zdoLeaveNetwork;
+ ZdoReset_t zdoReset;
+ ZdoResetNetwork_t zdoResetNetwork;
+ ZdoPowerManager_t powerManager;
+ ZdoNodeManager_t nodeManager;
+ ZdoNwkManager_t nwkManager;
+ ZdoZdpManager_t zdoZdpManager;
+ ZdoFrameProc_t zdpFrameProcessor;
+#ifdef _SECURITY_
+ ZdoSecurityManager_t zdoSecurityManager;
+#endif
+#ifdef _TC_SWAPOUT_
+ ZdoTcSwapOut_t zdoTcSwapOut;
+ ZdoTcKeepAlive_t zdoTcKeepAlive;
+#endif
+ uint16_t enabledModules;
+ RF_RandomReq_t randReq;
+ HAL_AppTimer_t timerReq;
+#ifdef _END_DEVICE_BINDING_
+ ZdoEndDeviceBinding_t endDevBinding;
+#endif
+} ZdoMem_t;
+
+extern ZdoMem_t zdoMem;
+
+static inline ZdoStackReq_t * zdoMemStackRequest(void)
+{
+ return &zdoMem.stackReq;
+}
+
+static inline HAL_AppTimer_t * zdoMemTimerRequest(void)
+{
+ return &zdoMem.timerReq;
+}
+
+static inline RF_RandomReq_t * zdoMemRandRequest(void)
+{
+ return &zdoMem.randReq;
+}
+
+static inline ZdoPowerManager_t * zdoMemPowerManager(void)
+{
+ return &zdoMem.powerManager;
+}
+
+static inline ZdoNodeManager_t * zdoMemNodeManager(void)
+{
+ return &zdoMem.nodeManager;
+}
+
+static inline ZdoNwkManager_t * zdoMemNwkManager(void)
+{
+ return &zdoMem.nwkManager;
+}
+
+static inline ZdoZdpManager_t * zdoMemZdpManager(void)
+{
+ return &zdoMem.zdoZdpManager;
+}
+
+static inline ZdoFrameProc_t * zdoMemZdpFrameProcessor(void)
+{
+ return &zdoMem.zdpFrameProcessor;
+}
+
+static inline ZdoStartNetwork_t * zdoMemStartNetwork(void)
+{
+ return &zdoMem.zdoStartNetwork;
+}
+
+static inline ZdoResetNetwork_t * zdoMemResetNetwork(void)
+{
+ return &zdoMem.zdoResetNetwork;
+}
+
+static inline ZdoReset_t * zdoMemReset(void)
+{
+ return &zdoMem.zdoReset;
+}
+
+static inline ZdoLeaveNetwork_t * zdoMemLeaveNetwork(void)
+{
+ return &zdoMem.zdoLeaveNetwork;
+}
+
+#ifdef _SECURITY_
+static inline ZdoSecurityManager_t * zdoMemSecurityManager(void)
+{
+ return &zdoMem.zdoSecurityManager;
+}
+#endif
+
+#ifdef _TC_SWAPOUT_
+static inline ZdoTcSwapOut_t * zdoMemTcSwapOut(void)
+{
+ return &zdoMem.zdoTcSwapOut;
+}
+
+static inline ZdoTcKeepAlive_t * zdoMemTcKeepAlive(void)
+{
+ return &zdoMem.zdoTcKeepAlive;
+}
+#endif
+
+#ifdef _END_DEVICE_BINDING_
+static inline ZdoEndDeviceBinding_t * zdoMemEndDeviceBinding(void)
+{
+ return &zdoMem.endDevBinding;
+}
+#endif
+#endif // _ZDOMEM_H
+
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoNodeManager.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoNodeManager.h
new file mode 100644
index 00000000..49cddb1a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoNodeManager.h
@@ -0,0 +1,68 @@
+/************************************************************************//**
+ \file zdoNodeManager.h
+
+ \brief The header file describes the constants, types and internal interface
+ of ZDO node manager
+
+ \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:
+******************************************************************************/
+
+#ifndef ZDONODEMANAGER_H_
+#define ZDONODEMANAGER_H_
+
+#include <zdoZdpManager.h>
+#include <zdoZdpFrameProcessor.h>
+#include <zdo.h>
+#include <aps.h>
+#include <appTimer.h>
+
+
+// ScanDuration field of Mgmt_NWK_Update_req
+#define MGMT_NWK_UPDATE_DUR_0 ((uint8_t)0x00)
+#define MGMT_NWK_UPDATE_DUR_1 ((uint8_t)0x01)
+#define MGMT_NWK_UPDATE_DUR_2 ((uint8_t)0x02)
+#define MGMT_NWK_UPDATE_DUR_3 ((uint8_t)0x03)
+#define MGMT_NWK_UPDATE_DUR_4 ((uint8_t)0x04)
+#define MGMT_NWK_UPDATE_DUR_5 ((uint8_t)0x05)
+#define MGMT_NWK_UPDATE_DUR_CHANNEL_CHANGE ((uint8_t)0xFE)
+#define MGMT_NWK_UPDATE_DUR_PARAMS_CHANGE ((uint8_t)0xFF)
+
+
+typedef struct zdoNodeManager_t_
+{
+ NWK_EDScanReq_t nwkEDScanReq;
+ MAC_SetReq_t macSetReq;
+ HAL_AppTimer_t channelChangeTimer;
+ uint8_t edScanCount;
+ uint8_t newChannel;
+ uint8_t nwkUpdateId;
+ NWK_EDScanConf_t *nwkEDScanConf;
+ ZDO_ZdpReq_t zdpNwkUpdateNotify;
+ ZDO_ZdpReq_t *storedZdpRequest;
+} ZdoNodeManager_t;
+
+void zdoZdpNodeManagerReset(void);
+void zdoExecuteEDScan(uint32_t scanChannels, uint8_t scanDuration);
+void zdoZdpNodeRequestCreate(void);
+void zdoZdpNodeMessageInd(void);
+void zdpNodeWaitTimerFired(void);
+
+/******************************************************************************
+ Set timer on interval BROADCAST_DELIVERY_TIME upon fires which node will
+ change the channel
+ Parameters:
+ scanChannels - channels to move to
+ Returns:
+ None.
+******************************************************************************/
+void zdoSetChannelChangeTimer(const uint32_t scanChannels);
+
+#endif /*ZDONODEMANAGER_H_*/
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoNwkManager.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoNwkManager.h
new file mode 100644
index 00000000..6c9d4ef8
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoNwkManager.h
@@ -0,0 +1,87 @@
+/************************************************************************//**
+ \file zdoNwkManager.h
+
+ \brief The header file describes the constants, types and internal interface
+ of ZDO network manager
+
+ \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:
+ 07/06/07 I. Kalganova - Modified
+******************************************************************************/
+
+#ifndef _ZDONWKMANAGER_H
+#define _ZDONWKMANAGER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <macAddr.h>
+#include <nwk.h>
+#include <zdo.h>
+#include <zdoTaskManager.h>
+#include <aps.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+/********************************************************************************//**
+\brief States of ZDO NWKUpdateState functionality
+***********************************************************************************/
+typedef enum
+{
+ ZDO_IDLE_NWK_UPDATE_STATE,
+ ZDO_INTERNAL_NWK_UPDATE_STATE,
+ ZDO_EXTERNAL_NWK_UPDATE_STATE,
+ ZDO_EXTERNAL_ERROR_NWK_UPDATE_STATE
+} ZdoNWKUpdateState_t;
+
+typedef struct _ZdoNwkManager_t
+{
+ uint8_t statusIndCounter: 4;
+ bool resendAnnce: 1;
+ bool zdpDataReqBusy: 1;
+ bool updateDeviceReqBusy: 1;
+ bool updateDeviceReqPending: 1;
+ ZDO_ZdpReq_t zdpDataReq;
+ void (*deviceAnnceConf)(ZDO_ZdpResp_t *zdpResp);
+ void (*resendAnnceConf)(ZDO_ZdpResp_t *zdpResp);
+ MAC_SetReq_t macSetReq;
+ ZDO_SetTxPowerReq_t *txPowerReq;
+#ifdef _SECURITY_
+ APS_UpdateDeviceReq_t apsUpdateDeviceReq;
+#endif //_SECURITY_
+ uint16_t totalTransactions;
+ uint16_t failTransactions;
+ bool badLink;
+ HAL_AppTimer_t updateNwkWaitTimer;
+ ZdoNWKUpdateState_t updateState;
+ uint8_t transSeqNum;
+} ZdoNwkManager_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+void zdoNwkManagerReset(void);
+void zdoSendDeviceAnnce(void (*deviceAnnceConf)(ZDO_ZdpResp_t *zdpResp));
+
+/******************************************************************************
+ Check if short address is available for given extended address and send
+ appropriate request if not.
+ Parameters:
+ addr - extended address to check
+ Return:
+ true - short address already available
+ false - short address currently is not available, request was sent
+******************************************************************************/
+bool zdoDiscoverNwkAddress(const ExtAddr_t *const addr);
+
+#endif // _ZDONWKMANAGER_H
+
+// eof zdoNwkManager.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoPowerManager.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoPowerManager.h
new file mode 100644
index 00000000..3e827aeb
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoPowerManager.h
@@ -0,0 +1,66 @@
+/*************************************************************************//**
+ \file zdoPowerManager.h
+
+ \brief The header file describes the constants, types and internal interface
+ of ZDO power manager
+
+ \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:
+******************************************************************************/
+
+#ifndef _ZDOPOWERMANAGER_H
+#define _ZDOPOWERMANAGER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <nwk.h>
+#include <zdo.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef struct _ZdoPowerManager_t
+{
+ ZDO_SleepReq_t *sleepReq;
+ ZDO_WakeUpReq_t *wakeUpReq;
+ bool sleeping;
+ MAC_RxEnableReq_t rxReq;
+ bool rxOnWhenIdle;
+ DeviceType_t deviceType;
+#ifdef _ENDDEVICE_
+ NWK_SyncReq_t syncReq;
+ HAL_AppTimer_t syncTimer;
+ uint8_t syncFailCounter;
+ bool waitingSyncConf;
+ bool polling;
+#endif // _ENDDEVICE_
+} ZdoPowerManager_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/**************************************************************************//**
+ \brief Reset power manager
+******************************************************************************/
+void zdoPowerManagerReset(void);
+
+/******************************************************************************
+ \brief Power Manager module task handler
+
+ Note: always post ZDO_POWER_MANAGER_TASK_ID after performing actions that
+ may result in device ability to sleep.
+******************************************************************************/
+void zdoPowerManagerHandler(void);
+
+#endif // _ZDOPOWERMANAGER_H_
+
+// eof zdoPowerManager.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoReset.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoReset.h
new file mode 100644
index 00000000..859ea7b4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoReset.h
@@ -0,0 +1,75 @@
+/**************************************************************************//**
+ \file zdoReset.h
+
+ \brief Interface for ZDO reset routine
+
+ \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:
+ 29.10.09 A. Taradov - Created
+******************************************************************************/
+
+#ifndef _ZDORESET_H
+#define _ZDORESET_H
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+typedef struct
+{
+ ZDO_Status_t status;
+} ZDO_SoftwareResetConf_t;
+
+typedef struct
+{
+ ZDO_SoftwareResetConf_t confirm;
+ void (*ZDO_SoftwareResetConf)(ZDO_Status_t status);
+} ZDO_SoftwareResetReq_t;
+
+typedef struct
+{
+ void (*stackResetCallback)(ZDO_Status_t status);
+} ZdoReset_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/**************************************************************************//**
+ \brief Stack software reset routine.
+
+ \param[in] req - pointer to request parameters.
+
+ \return None.
+ ******************************************************************************/
+void ZDO_SoftwareResetReq(ZDO_SoftwareResetReq_t *req);
+
+/******************************************************************************
+ \brief ZDO reset routine
+******************************************************************************/
+void zdoReset(void);
+
+/**************************************************************************//**
+ \brief Stack resetting start routine.
+
+ \param[in] powerFailureControl - stack restoring after power failure control bitfield;
+ affects on initialization procedure.
+ \param[out] callback - callback to stack reset finished handler.
+
+ \return None.
+ ******************************************************************************/
+void zdoStackReset(NWK_PowerFailureControl_t powerFailureControl, void (*callback)(ZDO_Status_t status));
+
+/**************************************************************************//**
+ \brief Reset component initialization routine.
+ ******************************************************************************/
+void zdoInitResetComponent(void);
+
+#endif // _ZDORESET_H
+
+// eof zdoReset.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoResetNetwork.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoResetNetwork.h
new file mode 100644
index 00000000..c71d7c17
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoResetNetwork.h
@@ -0,0 +1,61 @@
+/**************************************************************************//**
+ \file zdoResetNetwork.h
+
+ \brief Interface for ZDO Reset Network request routine
+
+ \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:
+ 17.09.09 A. Taradov - Created
+******************************************************************************/
+#ifndef _ZDORESETNETWORK_H
+#define _ZDORESETNETWORK_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zdo.h>
+#include <queue.h>
+#include <nwk.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum _ZdoResetNetworkState_t
+{
+ ZDO_RESET_NETWORK_IDLE_STATE,
+ ZDO_RESET_NETWORK_APS_RESET_STATE,
+} ZdoResetNetworkState_t;
+
+typedef struct _ZdoResetNetwork_t
+{
+ ZdoResetNetworkState_t state;
+ ZDO_ResetNetworkReq_t *req;
+} ZdoResetNetwork_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/******************************************************************************
+ Reset Reset Network component.
+ Parameters:
+ none
+ Return:
+ none
+******************************************************************************/
+void zdoResetNetworkReset(void);
+
+#endif // _ZDORESETNETWORK_H
+
+// eof zdoResetNetwork.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoStartNetwork.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoStartNetwork.h
new file mode 100644
index 00000000..57be2ed0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoStartNetwork.h
@@ -0,0 +1,127 @@
+/**************************************************************************//**
+ \file zdoStartNetwork.h
+
+ \brief Interface for ZDO Start Network request routines
+
+ \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:
+ 17.09.09 A. Taradov - Created
+******************************************************************************/
+#ifndef _ZDOSTARTNETWORK_H
+#define _ZDOSTARTNETWORK_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zdo.h>
+#include <queue.h>
+#include <nwk.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum _ZdoStartNetworkState_t
+{
+ ZDO_START_NETWORK_IDLE_STATE,
+ ZDO_START_NETWORK_BEGIN_STATE,
+ ZDO_START_NETWORK_APS_RESET_STATE,
+ ZDO_START_NETWORK_FORMATION_STATE,
+ ZDO_START_NETWORK_JOIN_STATE,
+ ZDO_START_NETWORK_REJOIN_STATE,
+ ZDO_START_NETWORK_JOINED_STATE,
+ ZDO_START_NETWORK_START_ROUTER_STATE,
+ ZDO_START_NETWORK_PERMIT_JOIN_STATE,
+ ZDO_START_NETWORK_APS_START_STATE,
+ ZDO_START_NETWORK_ANNCE_STATE,
+ ZDO_START_NETWORK_CONFIRM_STATE
+} ZdoStartNetworkState_t;
+
+typedef void (ZdoStartNetworkConf_t)(ZDO_Status_t status);
+
+typedef struct _ZdoStartNetwork_t
+{
+ QueueDescriptor_t queue;
+ ZdoStartNetworkState_t state;
+ NWK_RejoinNetwork_t startupType;
+ ZdoStartNetworkConf_t *confirm;
+ NWK_PowerFailureControl_t powerFailureControl;
+#if defined(_ROUTER_) || defined(_ENDDEVICE_)
+ uint8_t joinAttempts;
+ HAL_AppTimer_t joinTimer;
+#endif
+} ZdoStartNetwork_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/******************************************************************************
+ Reset Start Network component.
+ Parameters:
+ none
+ Return:
+ none
+******************************************************************************/
+void zdoStartNetworkReset(void);
+
+/******************************************************************************
+ Start network rejoin
+ Parameters:
+ none
+ Return:
+ none
+******************************************************************************/
+void zdoRejoinNetwork(void);
+
+/******************************************************************************
+ Start Network request task handler.
+ Parameters:
+ none
+ Return:
+ none
+******************************************************************************/
+void zdoStartNetworkTaskHandler(void);
+
+/******************************************************************************
+ Allocate Start Network module
+ Parameters:
+ startNetworkConf - confirmation callback
+ Return:
+ true - if module was alocated, false otherwise
+******************************************************************************/
+bool zdoStartNetworkAlloc(ZdoStartNetworkConf_t *startNetworkConf);
+
+/******************************************************************************
+ Free Start Network module
+ Parameters:
+ none
+ Return:
+ none
+******************************************************************************/
+void zdoStartNetworkFree(void);
+
+#ifdef _COORDINATOR_
+/******************************************************************************
+ NLME-NETWORK-FORMATION.request preparing and sending.
+ Parameters:
+ none
+ Return:
+ none
+******************************************************************************/
+void zdoNetworkFormationReq(void);
+#endif /* _COORDINATOR_ */
+
+#endif // _ZDOSTARTNETWORK_H
+
+// eof zdoStartNetwork.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTaskManager.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTaskManager.h
new file mode 100644
index 00000000..d7fbf779
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTaskManager.h
@@ -0,0 +1,66 @@
+/**************************************************************************//**
+ \file zdoTaskManager.h
+
+ \brief The header file describes the constants, types and internal interface
+ of ZDO task manager
+
+ \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:
+******************************************************************************/
+
+#ifndef _ZDOTASKMANAGER_H
+#define _ZDOTASKMANAGER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum _ZdoTaskId_t
+{
+ ZDO_SECURITYMANAGER_TASK_ID,
+ ZDO_ZDP_FRAME_PROCESSOR_TASK_ID,
+ ZDO_ZDP_MANAGER_TASK_ID,
+ ZDO_POWER_MANAGER_TASK_ID,
+ ZDO_START_NETWORK_TASK_ID,
+#ifdef _TC_SWAPOUT_
+ ZDO_TC_SWAPOUT_TASK_ID,
+#endif // _TC_SWAPOUT_
+ ZDO_INIT_TASK_ID,
+ ZDO_LAST_TASK_ID // Not a real task
+} ZdoTaskId_t;
+
+// Mask of posted ZDO tasks
+typedef uint16_t ZdoTaskBitMask_t;
+
+typedef void (*ZdoTaskHandler_t)(void);
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/******************************************************************************
+ \brief Post ZDO subtask
+******************************************************************************/
+void zdoPostTask(ZdoTaskId_t task);
+
+/******************************************************************************
+ \brief Remove ZDO subtask from list of posted tasks
+******************************************************************************/
+void zdoUnpostTask(ZdoTaskId_t task);
+
+#endif // _ZDOTASKMANAGER_H_
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTcKeepAlive.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTcKeepAlive.h
new file mode 100644
index 00000000..57e3f13d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTcKeepAlive.h
@@ -0,0 +1,72 @@
+/************************************************************************//**
+ \file zdoTcKeepAlive.h
+
+ \brief
+ The TC keep-alive mechanism interface.
+
+ \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:
+ 20.01.10 A. Taradov - Created.
+******************************************************************************/
+#ifndef _ZDO_TC_KEEP_ALIVE_H
+#define _ZDO_TC_KEEP_ALIVE_H
+
+#ifdef _TC_SWAPOUT_
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zdo.h>
+#include <zcl.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum _ZdoKeepAliveState_t
+{
+ ZDO_TC_KEEP_ALIVE_STARTED_STATE,
+ ZDO_TC_KEEP_ALIVE_STOPPED_STATE,
+} ZdoTcKeepAliveState_t;
+
+typedef enum _ZdoKeepAliveReqState_t
+{
+ ZDO_TC_KEEP_ALIVE_REQ_FREE_STATE,
+ ZDO_TC_KEEP_ALIVE_REQ_BUSY_STATE,
+} ZdoTcKeepAliveReqState_t;
+
+typedef struct _ZdoTcKeepAlive_t
+{
+ ZdoTcKeepAliveState_t state;
+ ZdoTcKeepAliveReqState_t reqState;
+ ZCL_Request_t req;
+ HAL_AppTimer_t timer;
+ uint8_t pingsFailed;
+ Endpoint_t localEndpoint;
+ Endpoint_t remoteEndpoint;
+} ZdoTcKeepAlive_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/******************************************************************************
+ Reset TC keep-alive module
+ Parameters:
+ none
+ Return:
+ none
+******************************************************************************/
+void zdoTcKeepAliveReset(void);
+
+#endif // _TC_SWAPOUT_
+
+#endif // _ZDO_TC_KEEP_ALIVE_H
+
+// eof zdoTcKeepAlive.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTcSwapOut.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTcSwapOut.h
new file mode 100644
index 00000000..f71712f4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoTcSwapOut.h
@@ -0,0 +1,92 @@
+/**************************************************************************//**
+ \file zdoTcSwapOut.h
+
+ \brief Interface to TC Swap-out implementation
+
+ \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:
+ 25.01.10 A. Taradov - Created
+******************************************************************************/
+
+#ifndef _ZDOTCSWAPOUT_H
+#define _ZDOTCSWAPOUT_H
+
+#ifdef _TC_SWAPOUT_
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zdo.h>
+#include <aps.h>
+#include <queue.h>
+#include <nwk.h>
+#include <zclSecurityManager.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum _ZdoTcSwapoutState_t
+{
+ ZDO_TC_SWAPOUT_IDLE_STATE,
+ ZDO_TC_SWAPOUT_BEGIN_STATE,
+ ZDO_TC_SWAPOUT_LEAVE_BEFORE_REJOIN_STATE,
+ ZDO_TC_SWAPOUT_REJOIN_STATE,
+ ZDO_TC_SWAPOUT_LEAVE_BEFORE_CONFIRM_STATE,
+ ZDO_TC_SWAPOUT_CONFIRM_STATE
+} ZdoTcSwapoutState_t;
+
+typedef struct _ZdoTcSwapOut_t
+{
+ QueueDescriptor_t queue;
+ ZdoTcSwapoutState_t state;
+ APS_Status_t keyWasSecuredWith;
+ ZCL_StartSecurityReq_t zclStartSecurityReq;
+} ZdoTcSwapOut_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/******************************************************************************
+ Indication of Transport Key command receipt
+ Parameters:
+ ind - indication parameters
+ Return:
+ none
+******************************************************************************/
+void zdoTcSwapOutTransportKeyInd(APS_TransportKeyInd_t *ind);
+
+/******************************************************************************
+ TC Swap-out request task handler.
+ Parameters:
+ none
+ Return:
+ none
+******************************************************************************/
+void zdoTcSwapOutTaskHandler(void);
+
+/******************************************************************************
+ Reset Trust Centre Swap-out component.
+ Parameters:
+ none
+ Return:
+ none
+******************************************************************************/
+void zdoTcSwapOutReset(void);
+
+#endif // _TC_SWAPOUT_
+
+#endif // _ZDOTCSWAPOUT_H
+
+// eof zdoTcSwapOut.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZdpFrameProcessor.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZdpFrameProcessor.h
new file mode 100644
index 00000000..da0d6678
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZdpFrameProcessor.h
@@ -0,0 +1,121 @@
+/************************************************************************//**
+ \file zdoZdpFrameProcessor.h
+
+ \brief The header file describes the constants, types and internal interface
+ of ZDP parser component. This component sends/receives ZDP commands.
+
+ \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:
+ 28/11/07 A. Zemlyanov - Created.
+******************************************************************************/
+
+#ifndef _ZDP_FRAME_PROCESSOR_H
+#define _ZDP_FRAME_PROCESSOR_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+#include <queue.h>
+#include <zdo.h>
+#include <zdoDbg.h>
+#include <aps.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef void (*ZdoAPSDataConf_t)(APS_DataConf_t *conf);
+
+typedef enum
+{
+ ZDO_ZDP_DATA_REQ_FREE_STATE,
+ ZDO_ZDP_DATA_REQ_BUSY_STATE,
+ ZDO_ZDP_DATA_REQ_SEND_STATE,
+ ZDO_ZDP_DATA_REQ_WAIT_CONF_STATE
+} ZDO_ZdpDataReqState_t;
+
+typedef enum
+{
+ ZDO_ZDP_IND_FREE_STATE,
+ ZDO_ZDP_IND_BUSY_STATE
+} ZDO_ZdpIndState_t;
+
+
+typedef struct zdoFrameProc_t_
+{
+ uint8_t requestSeqNum;
+ ZDO_ZdpReq_t *zdpRequest; // Currently processed zdpRequest
+
+ ZDO_ZdpDataReqState_t apsDataReqState;
+ APS_DataReq_t apsDataReq; // Common for all requests to APS
+
+ // Incoming data from APS
+ ZDO_ZdpIndState_t apsDataIndState;
+ APS_DataInd_t apsDataInd;
+ uint8_t apsAsduBuff[APS_MAX_ASDU_SIZE]; // Buffer for inconing APS ASDU
+} ZdoFrameProc_t;
+
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+ Reset the ZDP Frame Processor into initial state
+ Parameters:
+ None
+ Returns:
+ None.
+******************************************************************************/
+void zdoZdpFrameProcessorReset(void);
+
+/******************************************************************************
+ Send ZDP request
+ Parameters:
+ req - pointer to request object
+ Returns:
+ None.
+******************************************************************************/
+void zdoZdpSendRequest(ZDO_ZdpReq_t *req);
+
+/******************************************************************************
+ TODO
+******************************************************************************/
+void zdoSetZdpDataReqState(ZDO_ZdpDataReqState_t state);
+
+/******************************************************************************
+ TODO
+******************************************************************************/
+void zdoSetZdpIndState(ZDO_ZdpIndState_t state);
+
+/******************************************************************************
+ Process incoming ZDP frames data from APS layer
+ Parameters:
+ ind - Pointer to APS_DataInd_t type object
+ Returns:
+ None.
+******************************************************************************/
+void APS_ZdoDataInd(APS_DataInd_t *ind);
+
+/******************************************************************************
+ To be called when gets frame from APS
+ Parameters:
+ apsInd - Pointer to APS_DataInd_t type object
+ Returns:
+ None.
+******************************************************************************/
+void zdoZdpMessageInd(APS_DataInd_t *dataInd);
+
+void zdoZdpFrameProcessorHandler(void);
+
+#endif /* _ZDP_FRAME_PROCESSOR_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZdpManager.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZdpManager.h
new file mode 100644
index 00000000..641b47c3
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZdpManager.h
@@ -0,0 +1,65 @@
+/************************************************************************//**
+ \file zdoZdpManager.h
+
+ \brief The header file describes the constants, types and internal interface
+ of ZDP manager. This component manages ZDP requests and responses.
+
+ \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:
+******************************************************************************/
+
+#ifndef _ZDOZDPMANAGER_H
+#define _ZDOZDPMANAGER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <queue.h>
+#include <appTimer.h>
+#include <zdoZdpFrameProcessor.h>
+
+/******************************************************************************
+ Definitions section
+******************************************************************************/
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum _ZDO_ZdpRequestState_t
+{
+ ZDO_IDLE_ZDP_REQUEST_STATE,
+ ZDO_SEND_ZDP_REQUEST_STATE,
+ ZDO_WAIT_RESP_CONF_ZDP_REQUEST_STATE,
+ ZDO_WAIT_CONF_ZDP_REQUEST_STATE,
+ ZDO_WAIT_RESP_ZDP_REQUEST_STATE,
+ ZDO_CONFIRM_MDR_ZDP_REQUEST_STATE,
+ ZDO_CONFIRM_MDR1_ZDP_REQUEST_STATE,
+ ZDO_CONFIRM_ZDP_REQUEST_STATE,
+ ZDO_WAIT_CONFIRM_UPDATE_ZDP_REQUEST_STATE
+} ZDO_ZdpRequestState_t;
+
+typedef struct _ZdoZdpManager_t
+{
+ QueueDescriptor_t requestQueue;
+ HAL_AppTimer_t ttlUpdateTimer;
+ ZDO_ZdpFrame_t zdpFrame;
+} ZdoZdpManager_t;
+
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+void zdoZdpResetReq(void);
+
+void zdoZdpManagerHandler(void);
+
+void zdoInitZdpRequestTTL(ZDO_ZdpReq_t *const zdpReq, const uint32_t ttl);
+
+#endif // _ZDOZDPMANAGER_H_
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZib.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZib.h
new file mode 100644
index 00000000..baaa5eab
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/private/zdoZib.h
@@ -0,0 +1,99 @@
+/************************************************************************//**
+ \file zdoZib.h
+
+ \brief The header file describes the ZDO information base
+
+ \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:
+******************************************************************************/
+#ifndef _ZDOZIB_H
+#define _ZDOZIB_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <appFramework.h>
+#include <nwkCommon.h>
+
+/******************************************************************************
+ Definitions section.
+******************************************************************************/
+#define LUXOFT_MANUFACTURER_CODE 0x100c
+#define CT_EPID_MASK 0xFFFFFFFFFFFF0000 // ???
+#define COMMISSIONING_EPID 0x0050C27710000000 // ???
+#define NUM_ACTIVE_EP 1 //FIXME
+#define MAX_DISCOVERED_NETWORKS_NUMBER 3
+#define NETWORK_SELECT_CRITERIES (CHOOSENET_EXTPANID | CHOOSENET_STACKPROFILE | CHOOSENET_ZBVERSION)
+#define BEACON_ORDER 0x0f
+#define SUPER_FRAME_ORDER 0x0f
+#define BATTERY_LIFE_EXTENTION true
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef struct
+{
+ //scannig channel mask
+ uint32_t channelMask;
+ //extended PAN ID
+ ExtPanId_t extPanId;
+ //short address
+ ShortAddr_t shortAddr;
+ //current channel
+ uint8_t channel;
+ //parent extended address
+ ExtAddr_t parentExtAddress;
+ //parent short address
+ ShortAddr_t parentNetworkAddress;
+ //current PAN ID
+ PanId_t panID;
+ //node descriptor
+ NodeDescriptor_t nodeDescriptor;
+ //node power descriptor
+ PowerDescriptor_t powerDescriptor;
+ //simple descriptor
+ //SimpleDescriptor_t configSimpleDescriptors[NUM_ACTIVE_EP];
+ //scanning duration in seconds
+ uint8_t scanDuration;
+ //number of failure parent sync retries
+ uint8_t parentLinkRetryThreshold;
+ //
+ uint8_t permitJoinDuration;
+ //ZDP response wait timeout
+ uint16_t zdpResponseTimeout;
+} ZIB_t;
+
+extern ZIB_t csZIB;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/******************************************************************************
+ Reload ZIB from ConfigServer
+ Parameters:
+ none
+ Return:
+ none
+******************************************************************************/
+void zdoReloadZibFromConfigServer(void);
+
+/******************************************************************************
+ Set actual network parameters to ZIB
+ Parameters:
+ none
+ Return:
+ none
+******************************************************************************/
+void setNetworkParametersToZib(void);
+
+#endif // _ZDOZIB_H
+
+// eof zdoZib.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/zdo.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/zdo.h
new file mode 100644
index 00000000..50b71edb
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/zdo.h
@@ -0,0 +1,1676 @@
+/************************************************************************//**
+ \file zdo.h
+
+ \brief The header file describes the public ZDO interface and ZDO types
+
+ \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:
+******************************************************************************/
+
+#ifndef _ZDO_H
+#define _ZDO_H
+
+#include <macAddr.h>
+#include <appFramework.h>
+#include <aps.h>
+#include <configServer.h>
+#include <dbg.h>
+
+// \cond internal
+#define ZDP_REQUEST_MASK CCPU_TO_LE16(0x7FFF)
+#define ZDP_RESPONSE_MASK CCPU_TO_LE16(0x8000)
+
+#ifdef _SECURITY_
+#define PRECONFIGURED_NETWORK_KEY NWK_PRECONFIGURED_NETWORK_KEY
+#define PRECONFIGURED_TRUST_CENTER_LINK_KEY 1
+#define PRECONFIGURED_TRUST_CENTER_MASTER_KEY 2
+#define NOT_PRECONFIGURED NWK_NOT_PRECONFIGURED_NETWORK_KEY
+
+#ifndef ZDO_SECURITY_STATUS
+#define ZDO_SECURITY_STATUS NOT_PRECONFIGURED
+#endif //ZDO_SECURITY_STATUS
+
+
+#define ZDO_NONE_SECURITY_MODE 0
+#define ZDO_STANDARD_SECURITY_MODE 1
+#define ZDO_HIGH_SECURITY_MODE 2
+#endif//_SECURITY_
+
+#define MAX_REQUESTED_CLUSTER_NUMBER 9
+#define MAX_ACTIVE_EP_NUMBER 3
+
+#define ZDP_NEIGBOR_TABLE_LIST_OFFSET 3U
+#define ZDP_NEIGBOR_TABLE_LIST_SIZE (APS_MAX_ASDU_SIZE / (ZDP_NEIGBOR_TABLE_LIST_OFFSET + sizeof(NeighborTableList_t)))
+#define ZDP_ADDR_LIST_SIZE 10
+#define ZDP_BINDING_TABLE_LIST_SIZE 3
+// \endcond
+
+/*!
+\brief ZDO result status primitives.
+*/
+typedef enum
+{
+ //! The primitive has finished successfully
+ ZDO_SUCCESS_STATUS = 0x00,
+ //! Wrong parameters were put into the primitive
+ ZDO_INVALID_PARAMETERS_STATUS = 0x01,
+ ZDO_RESPONSE_WAIT_TIMEOUT_STATUS = 0x02,
+ //! ZDO layer is busy and cannot execute the primitive
+ ZDO_BUSY_STATUS = 0x04,
+ //! No network was found
+ ZDO_NO_NETWORKS_STATUS = 0x05,
+ //! There is a network with the same extended PANID
+ ZDO_EXTPANID_ALREADY_EXIST_STATUS = 0x06,
+ //! Unknown error
+ ZDO_FAIL_STATUS = 0x07,
+ ZDO_AUTHENTICATION_SUCCESS_STATUS = 0x08,
+ ZDO_AUTHENTICATION_FAIL_STATUS = 0x09,
+ ZDO_SECURITY_SUCCESS_STATUS = 0x0A,
+ ZDO_SECURITY_FAIL_STATUS = 0x0B,
+ ZDO_SECURITY_NOT_SUPPORTED_STATUS = 0x0C,
+ //! Indicates that command execution has finished. For a match descriptor
+ //request the confirmation with this status is issued if the timeout for
+ //ZDP response has exceeded and the stack has ceased waiting
+ ZDO_CMD_COMPLETED_STATUS = 0x0D,
+ ZDO_KEY_ESTABLISHMENT_NOT_SUPPORTED_STATUS = 0x0E,
+
+ //! Trust center could not find key pair descriptor to authenticate device
+ ZDO_NO_KEY_PAIR_DESCRIPTOR_STATUS = 0x50,
+
+ //! Link key for device was updated
+ ZDO_UPDATE_LINK_KEY_STATUS = 0x51,
+ //! Master key for device was updated
+ ZDO_UPDATE_MASTER_KEY_STATUS = 0x52,
+ //! Key pair descriptor was deleted
+ ZDO_DELETE_KEY_PAIR_STATUS = 0x53,
+ //! Link key for device was deleted
+ ZDO_DELETE_LINK_KEY_STATUS = 0x54,
+
+ //! TC is not responding to keep-alive requests
+ ZDO_TC_NOT_AVAILABLE_STATUS = 0x60,
+
+ //! ZDP request is invalid
+ ZDO_INVALID_REQUEST_STATUS = 0x80,
+ //! Requested device was not found
+ ZDO_DEVICE_NOT_FOUND_STATUS = 0x81,
+ //! Unsupported endpoint of 0x00 or between 0xF1 and 0xFF was requested
+ ZDO_INVALID_EP_STATUS = 0x82,
+ //! Requested endpoint has not been registered
+ ZDO_NOT_ACTIVE_STATUS = 0x83,
+ //! Requested optional feature is not supported
+ ZDO_NOT_SUPPORTED_STATUS = 0x84,
+ //! Timeout occured during the requested operation
+ ZDO_TIMEOUT_STATUS = 0x85,
+ //! End device bind request is unsuccessful due to a failure to match any suitable clusters
+ ZDO_NO_MATCH_STATUS = 0x86,
+ //! Unbind request is unsuccessful
+ ZDO_NO_ENTRY_STATUS = 0x88,
+ //! Child descriptor is not available
+ ZDO_NO_DESCRIPTOR_STATUS = 0x89,
+ //! Device does not have enough storage space
+ ZDO_INSUFFICIENT_SPACE_STATUS = 0x8A,
+ //! The device does not have storage space to support the requested operation.
+ ZDO_NOT_PERMITTED_STATUS = 0x8B,
+ //! Device does not have enough table space
+ ZDO_TABLE_FULL_STATUS = 0x8C,
+ //! Request is not authorized from this device
+ ZDO_NOT_AUTHORIZED_STATUS = 0x8D,
+ //! Network parameters have been updated (channel, PanId, shortAddr...)
+ ZDO_NWK_UPDATE_STATUS = 0x8E,
+ //! Device has joined/rejoined a network and data can be transmitted
+ ZDO_NETWORK_STARTED_STATUS = 0x8F,
+ //! Device has lost connection with a parent and the stack tries rejoin by itself. In this case transmission should be stopped.
+ ZDO_NETWORK_LOST_STATUS = 0x90,
+ //! Device has left a network. If autonetwork option is on, the stack will rejoin a network. Otherwise, an application should rejoin.
+ ZDO_NETWORK_LEFT_STATUS = 0x91,
+ //! New device has joined a network as a child of this device
+ ZDO_CHILD_JOINED_STATUS = 0x92,
+ //! Child has been removed from children list
+ ZDO_CHILD_REMOVED_STATUS = 0x93,
+ //! User descriptor is changed event
+ ZDO_USER_DESCRIPTOR_UPDATE_STATUS = 0x94,
+ //! On the device with static addressing the conflict of network addresses has been detected
+ ZDO_STATIC_ADDRESS_CONFLICT_STATUS = 0x95
+} ZDO_Status_t;
+
+/**************************************************************************//**
+\brief Types of response to address request
+******************************************************************************/
+enum
+{
+ SINGLE_RESPONSE_REQUESTTYPE = 0x00,
+ EXTENDED_RESPONSE_REQUESTTYPE = 0x01
+};
+
+/*!
+\brief The ZDP clusters ID list.
+
+<a name="zdp_clusters_list"></a>
+The ZDP cluster ID determines the type of ZDP request/confirm
+*/
+enum
+{
+// Device and Service Discovery commands
+ NWK_ADDR_CLID = CCPU_TO_LE16(0x0000),//!< Request for the 16-bit address of a remote device based on its known IEEE address.
+ IEEE_ADDR_CLID = CCPU_TO_LE16(0x0001),//!< Request for the 64-bit IEEE address of a remote device based on its known 16-bit address.
+ NODE_DESCRIPTOR_CLID = CCPU_TO_LE16(0x0002),//!< Request for the node descriptor of a remote device.
+ POWER_DESCRIPTOR_CLID = CCPU_TO_LE16(0x0003),//!< Request for the power descriptor of a remote device.
+ SIMPLE_DESCRIPTOR_CLID = CCPU_TO_LE16(0x0004),//!< Request for the simple descriptor of a remote device on the specified endpoint.
+ ACTIVE_ENDPOINTS_CLID = CCPU_TO_LE16(0x0005),//!< Request for the list of endpoints on a remote device with simple descriptors.
+ MATCH_DESCRIPTOR_CLID = CCPU_TO_LE16(0x0006),//!< Request for remote devices supporting a specific simple descriptor match criterion.
+ COMPLEX_DESCRIPTOR_CLID = CCPU_TO_LE16(0x0010),//!< Request for the complex descriptor of a remote device.
+ USER_DESCRIPTOR_CLID = CCPU_TO_LE16(0x0011),//!< Request for the user descriptor of a remote device.
+ DISCOVERY_CASH_CLID = CCPU_TO_LE16(0x0012),//!< Request to locate a Primary Discovery Cache device on the network.
+ DEVICE_ANNCE_CLID = CCPU_TO_LE16(0x0013),//!< Request to notify other ZigBee devices on the network that the device has joined or re-joined the network.
+ USER_DESC_CONF_CLID = CCPU_TO_LE16(0x0014),//!< Command to configure the user descriptor on a remote device.
+ SYSTEM_SERVER_DISCOVERY_CLID = CCPU_TO_LE16(0x0015),//!< Request for the location of a particular system server or servers.
+ DISCOVERY_STORE_CLID = CCPU_TO_LE16(0x0016),//!< Request for the storage of the device's discovery cache information on a Primary Discovery Cache device.
+ NODE_DESC_STORE_CLID = CCPU_TO_LE16(0x0017),//!< Request for the storage of the device's Node Descriptor on a Primary Discovery Cache device.
+ POWER_DESC_STORE_CLID = CCPU_TO_LE16(0x0018),//!< Request for the storage of the device's Descriptor on a Primary Discovery Cache device.
+ ACTIVE_EP_STORE_CLID = CCPU_TO_LE16(0x0019),//!< Request for the storage of the device's list of Active Endpoints on a Primary Discovery Cache device.
+ SIMPLE_DESC_STORE_CLID = CCPU_TO_LE16(0x001A),//!< Request for the storage of the device's list of Simple Descriptors on a Primary Discovery Cache device.
+ REMOVE_NODE_CACHE_CLID = CCPU_TO_LE16(0x001B),//!< Command for removal of discovery cache information for a specified ZigBee end device from a Primary Discovery Cache device.
+ FIND_NODE_CACHE_CLID = CCPU_TO_LE16(0x001C),//!< Request for a device on the network that holds discovery information for the device of interest.
+ EXTENDED_SIMPLE_DESC_CLID = CCPU_TO_LE16(0x001D),//!< Request for the simple descriptor of a remote device on the specified endpoint, to be used with devices which support more active endpoints than can be returned by a single ::SIMPLE_DESCRIPTOR_CLID request.
+ EXTENDED_ACTIVE_EP_CLID = CCPU_TO_LE16(0x001E),//!< Request for the list of endpoints on a remote device with simple descriptors, to be used with devices which support more active endpoints than can be returned by a single ::ACTIVE_ENDPOINTS_CLID request.
+// Bind client manager commands
+ END_DEVICE_BIND_CLID = CCPU_TO_LE16(0x0020),//!< Request generated from a Local Device wishing to perform End Device Bind with a Remote Device.
+ BIND_CLID = CCPU_TO_LE16(0x0021),//!< Request generated from a Local Device wishing to create a Binding Table entry for the source and destination addresses contained as parameters.
+ UNBIND_CLID = CCPU_TO_LE16(0x0022),//!< Request generated from a Local Device wishing to remove a Binding Table entry for the source and destination addresses contained as parameters.
+ BIND_REGISTER_CLID = CCPU_TO_LE16(0x0023),//!< Request generated from a Local Device and sent to a primary binding table cache device to register that the local device wishes to hold its own binding table entries.
+ REPLACE_DEVICE_CLID = CCPU_TO_LE16(0x0024),//!< Request sent to a primary binding table cache device to change all binding table entries which match OldAddress and OldEndpoint as specified.
+ STORE_BCKUP_BIND_ENTRY_CLID = CCPU_TO_LE16(0x0025),//!< Request generated from a local primary binding table cache and sent to a remote backup binding table cache device to request backup storage of the entry.
+ REMOVE_BCKUP_BIND_ENTRY_CLID = CCPU_TO_LE16(0x0026),//!< Request generated from a local primary binding table cache and sent to a remote backup binding table cache device to request removal of the entry from backup storage.
+ BACKUP_BIND_TABLE_CLID = CCPU_TO_LE16(0x0027),//!< Request generated from a local primary binding table cache and sent to the remote backup binding table cache device to request backup storage of its entire binding table.
+ RECOVER_BIND_TABLE_CLID = CCPU_TO_LE16(0x0028),//!< Request generated from a local primary binding table cache and sent to a remote backup binding table cache device when it wants a complete restore of the binding table.
+ BACKUP_SOURCE_BIND_CLID = CCPU_TO_LE16(0x0029),//!< Request generated from a local primary binding table cache and sent to a remote backup binding table cache device to request backup storage of its entire source table.
+ RECOVER_SOURCE_BIND_CLID = CCPU_TO_LE16(0x002A),//!< Request generated from a local primary binding table cache and sent to the remote backup binding table cache device when it wants a complete restore of the source binding table.
+// Network Management Client Services commands
+ MGMT_NWK_DISC_CLID = CCPU_TO_LE16(0x0030),//!< Request generated from a Local Device requesting that the Remote Device execute a Scan to report back networks in the vicinity of the Local Device.
+ MGMT_LQI_CLID = CCPU_TO_LE16(0x0031),//!< Request generated from a Local Device wishing to obtain a neighbor list for the Remote Device along with associated LQI values to each neighbor.
+ MGMT_RTG_CLID = CCPU_TO_LE16(0x0032),//!< Request generated from a Local Device wishing to retrieve the contents of the Routing Table from the Remote Device.
+ MGMT_BIND_CLID = CCPU_TO_LE16(0x0033),//!< Request generated from a Local Device wishing to retrieve the contents of the Binding Table from the Remote Device.
+ MGMT_LEAVE_CLID = CCPU_TO_LE16(0x0034),//!< Request generated from a Local Device requesting that a Remote Device leave the network or to request that another device leave the network.
+ MGMT_DIRECT_JOIN_CLID = CCPU_TO_LE16(0x0035),//!< Request generated from a Local Device requesting that a Remote Device permit a device designated by DeviceAddress to join the network directly.
+ MGMT_PERMIT_JOINING_CLID = CCPU_TO_LE16(0x0036),//!< Request generated from a Local Device requesting that a remote device or devices allow or disallow association.
+ MGMT_CACHE_CLID = CCPU_TO_LE16(0x0037),//!< Request The Mgmt_Cache_req is provided to enable ZigBee devices on the network to retrieve a list of ZigBee End Devices registered with a Primary Discovery Cache device.
+ MGMT_NWK_UPDATE_CLID = CCPU_TO_LE16(0x0038) //!< Command provided to allow updating of network configuration parameters or to request information from devices on network conditions in the local operating environment.
+};
+
+/**************************************************************************//**
+\brief Possible address modes
+******************************************************************************/
+typedef enum
+{
+ SHORT_ADDR_MODE, //!< Indicates that short address is used to point out a node
+ EXT_ADDR_MODE //!< Indicates that extended address is used to point out a node
+} AddrMode_t;
+
+#define ZDO_MGMT_ED_SCAN_DUR_0 0x00 //!< Used as a value for ZDO_MgmtNwkUpdateReq_t::scanDuration
+#define ZDO_MGMT_ED_SCAN_DUR_1 0x01 //!< Used as a value for ZDO_MgmtNwkUpdateReq_t::scanDuration
+#define ZDO_MGMT_ED_SCAN_DUR_2 0x02 //!< Used as a value for ZDO_MgmtNwkUpdateReq_t::scanDuration
+#define ZDO_MGMT_ED_SCAN_DUR_3 0x03 //!< Used as a value for ZDO_MgmtNwkUpdateReq_t::scanDuration
+#define ZDO_MGMT_ED_SCAN_DUR_4 0x04 //!< Used as a value for ZDO_MgmtNwkUpdateReq_t::scanDuration
+#define ZDO_MGMT_ED_SCAN_DUR_5 0x05 //!< Used as a value for ZDO_MgmtNwkUpdateReq_t::scanDuration
+#define ZDO_MGMT_CHANNEL_CHANGE 0xFE //!< Used as a special value for ZDO_MgmtNwkUpdateReq_t::scanDuration
+#define ZDO_MGMT_NWK_PARAMS_CHANGE 0xFF //!< Used as a special value for ZDO_MgmtNwkUpdateReq_t::scanDuration
+
+/**************************************************************************//**
+\brief Information about the addresses of a device.
+******************************************************************************/
+BEGIN_PACK
+typedef struct PACK
+{
+ ShortAddr_t shortAddr; //!< Short address
+ ExtAddr_t extAddr; //!< Extended address
+} NodeAddr_t;
+END_PACK
+
+BEGIN_PACK
+typedef struct PACK
+{
+ ShortAddr_t shortAddr; //!< Short address
+ ExtAddr_t extAddr; //!< Extended address
+ MAC_CapabilityInf_t capabilityInfo; //!< Device capability information
+} ChildInfo_t;
+END_PACK
+
+/**************************************************************************//**
+\brief Describes the parameters of the ZDO_StartNetworkConf() function
+******************************************************************************/
+typedef struct
+{
+ uint8_t activeChannel; //!< Current channel on which the device has connected.
+ ShortAddr_t shortAddr; //!< Assigned short address.
+ PanId_t PANId; //!< Received short network PANId.
+ uint64_t extPANId; //!< Received extended PANId if it was not determined during startup
+ ShortAddr_t parentAddr; //!< Parent short address
+ ZDO_Status_t status; //!< Resulting status of a network start operation
+} ZDO_StartNetworkConf_t;
+
+/**************************************************************************//**
+\brief Describes the parameters of the ZDO_StartNetworkReq() function
+******************************************************************************/
+typedef struct
+{
+ /** \cond SERVICE_FIELDS **/
+ struct
+ {
+ void *next;
+ } service; //!< Service field for internal use only, should not be touched by user
+ /** \endcond **/
+
+ ZDO_StartNetworkConf_t confirm; //!< Parameters of the confirm being returned in ZDO_StartNetworkConf()
+#ifdef _NWK_SILENT_JOIN_
+ NWK_RejoinNetwork_t startupType; //!< Startup type in case if Silent Join is enabled
+#endif
+#ifdef _LIGHT_LINK_PROFILE_
+ ShortAddr_t parent; //!< Known parent address (0xffff if unknown)
+#endif // _LIGHT_LINK_PROFILE_
+ void (*ZDO_StartNetworkConf)(ZDO_StartNetworkConf_t *conf); //!< The callback function to be called to confirm the request
+} ZDO_StartNetworkReq_t;
+
+/**************************************************************************//**
+\brief Desribes the parameters of the ZDO_ResetNetworkConf() function
+ *****************************************************************************/
+typedef struct
+{
+ ZDO_Status_t status; //!< Result of the reset request
+} ZDO_ResetNetworkConf_t;
+
+/**************************************************************************//**
+\brief Describes the parameters of the ZDO_ResetNetworkReq() function
+******************************************************************************/
+typedef struct
+{
+ ZDO_ResetNetworkConf_t confParams; //!< Parameters of the confirm being returned in ZDO_ResetNetworkConf()
+ void (*ZDO_ResetNetworkConf)(ZDO_ResetNetworkConf_t *conf); //!< The function called to confirm the request
+} ZDO_ResetNetworkReq_t;
+
+/**************************************************************************//**
+\brief This information is provided to enable ZigBee devices to report
+the condition on local channels to a network manager. The scanned channel list is
+the report of channels scanned and it is followed by a list of records, one for each
+channel scanned, each record including one byte of the energy level measured
+during the scan, or 0xff if there is too much interference on this channel.
+******************************************************************************/
+BEGIN_PACK
+typedef struct PACK
+{
+ uint32_t scannedChannels; //!< Bit mask of channels scanned by the request
+ uint16_t totalTransmissions; //!< Count of transmissions reported by the device
+ uint16_t transmissionsFailures; //!< Count of transmission failures reported by the device
+ uint8_t scannedChannelsListCount; //!< Number of records contained in the energyValues[] list
+ uint8_t energyValues[32]; /*! Results of energy measurements by channel.
+Each value is within the range from 0 to 84. Actually measured input power
+in dBm can be obtained by subtracting 91.*/
+} EDScan_t;
+END_PACK
+
+/**************************************************************************//**
+\brief This information is provided to inform an application about new network parameters
+if a device rejoined a network.
+******************************************************************************/
+BEGIN_PACK
+typedef struct PACK
+{
+ ShortAddr_t parentShortAddr; //!< Parent short address
+ PanId_t panId; //!< PAN ID of a network
+ uint8_t currentChannel; //!< Current channel
+ ShortAddr_t shortAddr; //!< New short address
+} NetworkInf_t;
+END_PACK
+/**************************************************************************//**
+\brief The type used to pack information about network updates in an argument of ZDO_MgmtNwkUpdateNotf() function
+
+The struct of this type comprises information about certain network updates. The type of the event is indicated by the ZDO_MgmtNwkUpdateNotf_t::status field.
+Additional event data is provided by the fields of the unnamed union.
+******************************************************************************/
+BEGIN_PACK
+typedef struct PACK
+{
+ /*! The parameter shows the notification status and can be:
+ ZDO_SUCCESS_STATUS,
+ ZDO_INVALID_PARAMETERS_STATUS,
+ ZDO_FAIL_STATUS,
+ ZDO_RESPONSE_WAIT_TIMEOUT_STATUS,
+ ZDO_NETWORK_STARTED_STATUS,
+ ZDO_NETWORK_LEFT_STATUS,
+ ZDO_NETWORK_LOST_STATUS,
+ ZDO_CHILD_JOINED_STATUS,
+ ZDO_CHILD_REMOVED_STATUS,
+ ZDO_USER_DESCRIPTOR_UPDATE_STATUS,
+ ZDO_STATIC_ADDRESS_CONFLICT_STATUS,
+ ZDO_NWK_UPDATE_STATUS
+ ZDO_NO_KEY_PAIR_DESCRIPTOR_STATUS*/
+ uint8_t status;
+ union PACK
+ {
+ //! Conflicting address
+ ShortAddr_t conflictAddress;
+ //! ED scan result
+ EDScan_t scanResult;
+ //! Network information updated
+ NetworkInf_t nwkUpdateInf;
+ //! Information about joined device or failed to authenticate child event
+ ChildInfo_t childInfo;
+ //! Addresses of removed device
+ NodeAddr_t childAddr;
+ //! Extended address of updated device
+ ExtAddr_t deviceExtAddr;
+ };
+} ZDO_MgmtNwkUpdateNotf_t;
+END_PACK
+
+/**************************************************************************//**
+\brief Desribes the parameters of the LQI response
+******************************************************************************/
+BEGIN_PACK
+typedef struct PACK _NeighborTableList_t
+{
+ ExtPanId_t extPanId;
+ ExtAddr_t extAddr;
+ ShortAddr_t networkAddr;
+ LITTLE_ENDIAN_OCTET(4, (
+ uint8_t deviceType : 2,
+ uint8_t rxOnWhenIdle : 2,
+ uint8_t relationship : 3,
+ uint8_t reserved1 : 1
+ ))
+ LITTLE_ENDIAN_OCTET(2, (
+ uint8_t permitJoining : 2,
+ uint8_t reserved2 : 6
+ ))
+ uint8_t depth;
+ uint8_t lqi;
+} NeighborTableList_t;
+
+typedef struct PACK _ZDO_MgmtLqiResp_t
+{
+ uint8_t neighborTableEntries;
+ uint8_t startIndex;
+ uint8_t neighborTableListCount;
+ NeighborTableList_t neighborTableList[ZDP_NEIGBOR_TABLE_LIST_SIZE];
+} ZDO_MgmtLqiResp_t;
+END_PACK
+
+/**************************************************************************//**
+\brief Desribes the parameters of the LQI request
+******************************************************************************/
+typedef struct
+{
+ uint8_t startIndex;
+} ZDO_MgmtLqiReq_t;
+
+/**************************************************************************//**
+\brief Desribes the parameters of the ZDO_SleepConf() function
+******************************************************************************/
+typedef struct
+{
+ /*! Stack is ready to sleep if status is ZDO_SUCCESS_STATUS,
+ stack is not ready to sleep if status is ZDO_BUSY_STATUS */
+ ZDO_Status_t status;
+} ZDO_SleepConf_t;
+
+/**************************************************************************//**
+\brief Describes the parameters of the ZDO_SleepReq() function
+******************************************************************************/
+typedef struct
+{
+ ZDO_SleepConf_t confirm; //!< Parameters of the confirm being returned in ZDO_SleepConf()
+ void (*ZDO_SleepConf)(ZDO_SleepConf_t *conf); //!< The function called to confirm the request
+} ZDO_SleepReq_t;
+
+/**************************************************************************//**
+\brief Describes the parameters of the ZDO_WakeUp() function
+******************************************************************************/
+typedef struct
+{
+ ZDO_Status_t status; //!< Result of the wakeup request
+} ZDO_WakeUpConf_t;
+
+/**************************************************************************//**
+\brief Describes the parameters of the ZDO_SleepReq() function
+******************************************************************************/
+typedef struct
+{
+ ZDO_WakeUpConf_t confirm; //!< Parameters of the confirm being returned in ZDO_WakeUpConf()
+ void (*ZDO_WakeUpConf)(ZDO_WakeUpConf_t *conf); //!< The function called to confirm the request
+} ZDO_WakeUpReq_t;
+
+/**************************************************************************//**
+\brief This request is generated from a Local Device wishing to inquire as to the
+16-bit address of the Remote Device based on its known IEEE address. The
+destination addressing on this command shall be unicast or broadcast to all
+devices for which macRxOnWhenIdle = TRUE.
+******************************************************************************/
+BEGIN_PACK
+typedef struct PACK
+{
+ /*! The IEEE address to be matched by the Remote Device */
+ ExtAddr_t ieeeAddrOfInterest;
+ /*! Request type for this command:
+ 0x00 Single device response
+ 0x01 Extended response
+ 0x02-0xFF reserved */
+ uint8_t reqType;
+ /*! If the Request type for this command is
+ Extended response, the StartIndex
+ provides the starting index for the
+ requested elements of the associated
+ devices list*/
+ uint8_t startIndex;
+} ZDO_NwkAddrReq_t;
+
+/**************************************************************************//**
+\brief This request is generated from a Local Device wishing to inquire as to the
+64-bit IEEE address of the Remote Device based on their known 16-bit address.
+The destination addressing on this command shall be unicast.
+******************************************************************************/
+typedef struct PACK
+{
+ /*! NWK address that is used for IEEE address mapping. */
+ ShortAddr_t nwkAddrOfInterest;
+ /*! Request type for this command:
+ 0x00 Single device response
+ 0x01 Extended response
+ 0x02-0xff reserved */
+ uint8_t reqType;
+ /*! If the Request type for this
+ command is Extended response, the
+ StartIndex provides the starting
+ index for the requested elements of
+ the associated devices list.*/
+ uint8_t startIndex;
+} ZDO_IeeeAddrReq_t;
+
+/**************************************************************************//**
+\brief This request is generated from a local device wishing to inquire
+as to the node descriptor of a remote device. This command shall be unicast either
+to the remote device itself or to an alternative device that contains the discovery
+information of the remote device.
+******************************************************************************/
+typedef struct PACK
+{
+ ShortAddr_t nwkAddrOfInterest; //!< NWK address for the node descriptor request
+} ZDO_NodeDescReq_t;
+
+/**************************************************************************//**
+\brief This request is generated from a local device wishing to
+inquire as to the power descriptor of a remote device. This command shall be
+unicast either to the remote device itself or to an alternative device that contains
+the discovery information of the remote device.
+******************************************************************************/
+typedef struct PACK
+{
+ ShortAddr_t nwkAddrOfInterest; //!< NWK address for the power descriptor request
+} ZDO_PowerDescReq_t;
+
+/**************************************************************************//**
+\brief This request is generated from a local device wishing to acquire
+the list of endpoints on a remote device with simple descriptors. This command
+shall be unicast either to the remote device itself or to an alternative device that
+contains the discovery information of the remote device.
+******************************************************************************/
+typedef struct PACK
+{
+ ShortAddr_t nwkAddrOfInterest; //!< NWK address for the active endpoints request
+} ZDO_ActiveEPReq_t;
+
+/**************************************************************************//**
+\brief This request is generated from a local device wishing to
+inquire as to the complex descriptor of a remote device. This command shall be
+unicast either to the remote device itself or to an alternative device that contains
+the discovery information of the remote device.
+******************************************************************************/
+typedef struct PACK
+{
+ ShortAddr_t nwkAddrOfInterest; //!< NWK address for the complex descriptor request
+} ZDO_ComplexDescReq_t;
+
+/**************************************************************************//**
+\brief This request is generated from a local device wishing to inquire
+as to the user descriptor of a remote device. This command shall be unicast either
+to the remote device itself or to an alternative device that contains the discovery
+information of the remote device.
+******************************************************************************/
+typedef struct PACK
+{
+ ShortAddr_t nwkAddrOfInterest; //!< NWK address for the user descriptor request
+} ZDO_UserDescReq_t;
+
+/**************************************************************************//**
+\brief This is generated from a local device wishing to
+configure the user descriptor on a remote device. This command shall be unicast
+either to the remote device itself or to an alternative device that contains the
+discovery information of the remote device.
+******************************************************************************/
+typedef struct PACK
+{
+ ShortAddr_t nwkAddrOfInterest; //!< NWK address for the user descriptor setting request
+ UserDescriptor_t userDescriptor; //!< The user descriptor of a device
+} ZDO_UserDescSetReq_t;
+
+/**************************************************************************//**
+\brief This request is generated from a local device wishing to
+inquire as to the simple descriptor of a remote device on a specified endpoint. This
+command shall be unicast either to the remote device itself or to an alternative
+device that contains the discovery information of the remote device.
+******************************************************************************/
+typedef struct PACK
+{
+ ShortAddr_t nwkAddrOfInterest; //!< NWK address for the simple descriptor request
+ Endpoint_t endpoint; //!< The endpoint on the destination
+} ZDO_SimpleDescReq_t;
+
+/**************************************************************************//**
+\brief This request is provided to enable ZigBee devices on the network to notify
+other ZigBee devices that the device has joined or re-joined the network,
+identifying the devices 64-bit IEEE address and new 16-bit NWK address, and
+informing the Remote Devices of the capability of the ZigBee device. This
+command shall be invoked for all ZigBee end devices upon join or rejoin. This
+command may also be invoked by ZigBee routers upon join or rejoin as part of
+NWK address conflict resolution. The destination addressing on this primitive is
+broadcast to all devices for which macRxOnWhenIdle = TRUE.
+******************************************************************************/
+typedef struct PACK
+{
+ ShortAddr_t nwkAddrLocal; //!< NWK address for the Local Device
+ ExtAddr_t ieeeAddrLocal; //!< IEEE address for the Local Device
+ MAC_CapabilityInf_t macCapability; //!< Capability of the local device
+} ZDO_DeviceAnnceReq_t;
+
+/**************************************************************************//**
+\brief This request is generated from a Local Device wishing to
+discover the location of a particular system server or servers as indicated by the
+ServerMask parameter. The destination addressing on this request is broadcast to
+all devices for which macRxOnWhenIdle = TRUE
+******************************************************************************/
+typedef struct PACK
+{
+ uint16_t serverMask; //!< Server mask field of the node descriptor
+} ZDO_SystemServerDiscoveryReq_t;
+
+#ifdef _BINDING_
+/**************************************************************************//**
+\brief ZDO Match Descriptor request primitive allows to find remote devices
+ supporting a specific simple descriptor match criterion.
+ ZigBee spec r17 Table 2.50 page 105.
+******************************************************************************/
+typedef struct PACK
+{
+ /*! NWK address for the request.*/
+ ShortAddr_t nwkAddrOfInterest;
+ /*! Profile ID to be matched at the destination.*/
+ ProfileId_t profileId;
+ /*! The number of Input Clusters provided for matching within the InClusterList.*/
+ uint8_t numInClusters;
+ /*! List of Input ClusterIDs to be used for matching; the InClusterList is the
+ desired list to be matched by the Remote Device (the elements of the InClusterList
+ are the supported output clusters of the Local Device).*/
+ ClusterId_t inClusterList[MAX_REQUESTED_CLUSTER_NUMBER];
+ /*! The number of Output Clusters provided for matching within OutClusterList.*/
+ uint8_t numOutClusters;
+ /*! List of Output ClusterIDs to be used for matching; the OutClusterList is the
+ desired list to be matched by the Remote Device (the elements of the OutClusterList
+ are the supported input clusters of the Local Device).*/
+ ClusterId_t outClusterList[MAX_REQUESTED_CLUSTER_NUMBER];
+} ZDO_MatchDescReq_t;
+
+/**************************************************************************//**
+\brief (ClusterID = 0x0020) This request is generated from a Local Device wishing
+to perform End Device with a Remote Device. The End Device Bind Request is generated,
+typically based on some user action like a button press. The destination addressing
+on this command shall be unicast, and the destination addressshall be that of the ZigBee
+Coordinator.
+******************************************************************************/
+typedef struct PACK
+{
+ /*! The address of the target for binding. This is a short address of the
+ local device.*/
+ ShortAddr_t bindingTarget;
+ /*! The IEEE address of the device generating the request.*/
+ ExtAddr_t srcExtAddr;
+ /*! The endpoint on the device generating the request.*/
+ Endpoint_t srcEndpoint;
+ /*! ProfileID wich is to be matched between two End_Device_Bind_Req received
+ at the ZigBee Coordinator within the timeout value pre-configured in the
+ ZigBee Coordinator.*/
+ ProfileId_t profileId;
+ /*! The Number of Input Clusters provided for end device binding within the
+ inClusterList.*/
+ uint8_t numInClusters;
+ /*! List of Input ClusterIDs to be used for matching. The inClusterList is the
+ desired list to be matched by the ZigBee Coordinator with the Remote Device's
+ output clusters (the elements of the inClusterList are supported input
+ clusters of the Local Device).*/
+ ClusterId_t inClusterList[MAX_REQUESTED_CLUSTER_NUMBER];
+ /*! The number of Output Clusters provided for matching within outClusterList.*/
+ uint8_t numOutClusters;
+ /*! List of Output ClusterIDs to be used for matching. The outClusterList is
+ the desired list to be matched by the ZigBee Coordinator with the Remote Device's
+ input clusters (the elements of the outClusterList are supported output clusters
+ of the Local Device).*/
+ ClusterId_t outClusterList[MAX_REQUESTED_CLUSTER_NUMBER];
+} ZDO_EndDeviceBindReq_t;
+
+/**************************************************************************//**
+\brief (ClusterID = 0x0021) This request is generated from a Local Device wishing
+to create a Binding Table entry for the source and destination addresses contained
+as parameters. The destination addressing on this command shall be unicast only,
+and the destination address shall be SrcAddress itself.
+******************************************************************************/
+typedef struct PACK
+{
+ /*! The IEEE address for the source.*/
+ ExtAddr_t srcAddr;
+ /*! The source endpoint for the binding entry.*/
+ Endpoint_t srcEndpoint;
+ /*! The identifier of the cluster on the source device that is bound to the
+ destination */
+ ClusterId_t clusterId;
+ /*! The addressing mode for the destination address used in this command. This
+ field can take one of the none-reserved values from the following list:
+ 0x00 = reserved
+ 0x01 = 16-bit group address for dstAddr and dstEndoint not present.
+ 0x02 = reserved
+ 0x03 = 64-bit extended address for dstAddr and dstEndpoint present
+ 0x04 - 0xff = reserved*/
+ uint8_t dstAddrMode;
+ /*! The destination address for the binding entry.*/
+ union PACK
+ {
+ struct PACK
+ {
+ ExtAddr_t dstExtAddr;
+ /*! This field shall be present only if the dstAddrMode field has a value of
+ 0x03 and, if present, shall be the destination endpoint for the binding entry.*/
+ Endpoint_t dstEndpoint;
+ };
+ ShortAddr_t dstGroupAddr;
+ };
+} ZDO_BindReq_t;
+
+/**************************************************************************//**
+\brief Declaration of ZDO Bind indication parameters structure. For details go
+to ZDO_BindReq declaration. ZB Specification extension!
+******************************************************************************/
+typedef ZDO_BindReq_t ZDO_BindInd_t;
+
+/**************************************************************************//**
+\brief (ClusterID = 0x0022) This request is generated from a Local Device wishing
+to remove a Binding Table entry for the source and destination addresses contained
+as parameters. The destination addressing on this command shall be unicast only,
+and the destination address shall be SrcAddress itself.
+******************************************************************************/
+typedef ZDO_BindReq_t ZDO_UnbindReq_t;
+
+/**************************************************************************//**
+\brief Declaration of ZDO Unbind indication parameters structure. For details go
+to ZDO_UnbindReq declaration. ZB Specification extension!
+******************************************************************************/
+typedef ZDO_UnbindReq_t ZDO_UnbindInd_t;
+
+/**************************************************************************//**
+\brief This request is generated from a Local Device wishing to retrieve the
+ contents of the Binding Table from the Remote Device.
+******************************************************************************/
+typedef struct PACK
+{
+ /*! Starting Index for the requested elements of the Binding Table. */
+ uint8_t startIndex;
+} ZDO_MgmtBindReq_t;
+
+#endif // _BINDING_
+
+/**************************************************************************//**
+\brief This request is generated from a Local Device requesting that a Remote
+Device leave the network or to request that another device leave the network.
+The Mgmt_Leave_req is generated by a management application which directs the
+request to a Remote Device where the NLME-LEAVE.request is to be executed
+using the parameter supplied by Mgmt_Leave_req.
+
+Besides the deviceAddr field, the structure also has two more bit fields embraced into
+a single octet and taking 1 or 0 as a value:
+ \li removeChildren - should be 1 to force the children of the affected node to
+ leave as well, otherwise, 0
+ \li rejoin - if it equals 1 the destination node will attempt ro rejoin the network
+ after it leaves
+******************************************************************************/
+typedef struct PACK
+{
+ ExtAddr_t deviceAddr; //!< IEEE address
+ LITTLE_ENDIAN_OCTET(3, (
+ uint8_t reserved : 6, //!< Reserved; can not be changed by user.
+ /*! This field shall have a value of 1 if the
+ device being asked to leave the
+ network is also asked to
+ remove all its child devices, if any.
+ Otherwise, it has a value of 0.*/
+ uint8_t removeChildren : 1,
+ /*! This field shall have a value of 1 if the
+ device being asked to leave from the
+ current parent is requested to rejoin
+ the network. Otherwise, it has a
+ value of 0.*/
+ uint8_t rejoin : 1
+ ))
+} ZDO_MgmtLeaveReq_t;
+
+/**************************************************************************//**
+\brief This request is generated from a Local Device requesting that
+a remote device or devices allow or disallow association.
+******************************************************************************/
+typedef struct PACK
+{
+ /*! Time span in seconds during
+ which the ZigBee coordinator or router
+ will allow associations. The value 0x00
+ or 0xff indicate that permission is, respectively,
+ disabled or enabled permanently.*/
+ uint8_t permitDuration;
+ /*! If this is set to 0x01 and the remote device is
+ the Trust Center, the command affects the
+ Trust Center authentication policy as
+ described in the sub-clauses below; If this is
+ set to 0x00, there is no effect on the Trust
+ Center.*/
+ uint8_t tcSignificance;
+} ZDO_MgmtPermitJoiningReq_t;
+
+/**************************************************************************//**
+\brief This command is provided to allow updating of network configuration parameters
+or to request information from devices on network conditions in the local
+operating environment. The destination addressing on this primitive shall be
+unicast or broadcast to all devices for which macRxOnWhenIdle = TRUE.
+******************************************************************************/
+typedef struct PACK
+{
+ /*! The five most significant bits (b27,... b31) are reserved. The 27 least
+ significant bits (b0, b1,... b26) indicate which channels are to be scanned
+ (1 = scan, 0 = do not scan) for each of the 27 valid channels*/
+ uint32_t scanChannels;
+ /*! Possible values are:\n
+::ZDO_MGMT_ED_SCAN_DUR_0 (0x00) to ::ZDO_MGMT_ED_SCAN_DUR_5 (0x05) - request
+to perform an ED scan with duration depending exponentially on the parameter value;\n
+::ZDO_MGMT_CHANNEL_CHANGE (0xFE) - request to change the working channel to
+the one specified by the ZDO_MgmtNwkUpdateReq_t::scanChannels bitmask;\n
+::ZDO_MGMT_NWK_PARAMS_CHANGE (0xFF) - request to change the device
+nwkUpdateId and nwkManagerAddr values to those contained in the request.\n
+Other values are invalid.*/
+ uint8_t scanDuration;
+ union PACK
+ {
+ /*! This field represents the number of
+ energy scans to be conducted and reported.
+ This field shall be present only if the
+ ZDO_MgmtNwkUpdateReq_t::scanDuration is within the range of
+ 0x00 to 0x05.*/
+ uint8_t scanCount;
+ /*! The value of the nwkUpdateId
+ contained in this request. This value
+ is set by the Network Channel
+ Manager prior to sending the message.
+ This field shall only be present if the
+ ZDO_MgmtNwkUpdateReq_t::scanDuration is 0xFE or 0xFF.*/
+ uint8_t nwkUpdateId;
+ };
+ /*! This field shall be present only if the ZDO_MgmtNwkUpdateReq_t::scanDuration
+ is set to 0xFF, and, if present, indicates the NWK address
+ for the device with the Network Manager bit set in its Node Descriptor.*/
+ ShortAddr_t nwkManagerAddr;
+} ZDO_MgmtNwkUpdateReq_t;
+
+/**************************************************************************//**
+\brief This command is generated by a Remote Device in response to a
+NWK_addr_req command inquiring as to the NWK address of the Remote Device
+or the NWK address of an address held in a local discovery cache.
+The destination addressing on this command is unicast.
+******************************************************************************/
+typedef struct PACK
+{
+ /*! 64-bit address for the Remote Device.*/
+ ExtAddr_t ieeeAddrRemote;
+ /*! 16-bit address for the Remote Device.*/
+ ShortAddr_t nwkAddrRemote;
+ /*! Count of the number of 16-bit short addresses to follow.
+ If the RequestType in the request is Extended Response
+ and there are no associated devices on the Remote
+ Device, this field shall be set to 0.
+ If an error occurs or the RequestType in the request is
+ for a Single Device Response, this field shall not
+ be included in the frame.*/
+ uint8_t numAssocDev;
+ /*! Starting index into the list of associated devices for this report.
+ If the RequestType in the request is Extended Response and there are no associated
+ devices on the Remote Device, this field shall not be included in the frame.
+ If an error occurs or the RequestType in the request is for a Single Device
+ Response, this field shall not be included in the frame.*/
+ uint8_t startIndex;
+ /*! A list of 16-bit addresses, one corresponding to each
+ associated device to Remote Device; The number of 16-bit
+ network addresses contained in this field is specified in the
+ NumAssocDev field.
+ If the RequestType in the request is Extended Response
+ and there are no associated devices on the Remote
+ Device, this field shall not be included in the frame.
+ If an error occurs or the RequestType in the request is
+ for a Single Device Response, this field shall not
+ be included in the frame.*/
+ ShortAddr_t nwkAddrAssocDevList[ZDP_ADDR_LIST_SIZE];
+} ZDO_NwkAddrResp_t;
+
+/**************************************************************************//**
+\brief This command is generated by a Remote Device in response to an
+IEEE_addr_req command inquiring as to the 64-bit IEEE address of the Remote
+Device or the 64-bit IEEE address of an address held in a local discovery cache.
+The destination addressing on this command shall be unicast.
+******************************************************************************/
+typedef struct PACK
+{
+ /*! 64-bit address for the Remote Device.*/
+ ExtAddr_t ieeeAddrRemote;
+ /*! 16-bit address for the Remote Device.*/
+ ShortAddr_t nwkAddrRemote;
+ /*! Count of the number of 16-bit short addresses to follow.
+ If the RequestType in the request is Extended
+ Response and there are no associated devices on the
+ Remote Device, this field shall be set to 0.
+ If an error occurs or the RequestType in the
+ request is for a Single Device Response, this
+ field shall not be included in the frame.*/
+ uint8_t numAssocDev;
+ /*! Starting index into the list of associated devices for this report.
+ If the RequestType in the request is Extended
+ Response and there are no associated devices on the
+ Remote Device, this field shall not be included in the frame.
+ If an error occurs or the RequestType in the request is for a Single
+ Device Response, this field shall not be included in the frame.*/
+ uint8_t startIndex;
+ /*! A list of 16-bit addresses, one corresponding to each
+ associated device to Remote Device; The number of 16-bit network
+ addresses contained in this field is specified in the NumAssocDev field.
+ If the RequestType in the request is Extended Response and there are no
+ associated devices on the Remote Device, this field
+ shall not be included in the frame.
+ If an error occurs or the RequestType in the request is for a Single
+ Device Response, this field shall not be included in the frame*/
+ ShortAddr_t nwkAddrAssocDevList[ZDP_ADDR_LIST_SIZE];
+} ZDO_IeeeAddrResp_t;
+
+/**************************************************************************//**
+\brief This command is generated by a remote device in response to a
+Node_Desc_req directed to the remote device. This command shall be unicast to
+the originator of the Node_Desc_req command.
+******************************************************************************/
+typedef struct PACK
+{
+ ShortAddr_t nwkAddrOfInterest; //!< NWK address of the node descriptor request
+ NodeDescriptor_t nodeDescriptor; //!< Node descriptor of the device
+} ZDO_NodeDescResp_t;
+
+/**************************************************************************//**
+\brief This command is generated by a remote device in response to a
+Power_Desc_req directed to the remote device. This command shall be unicast to
+the originator of the Power_Desc_req command.
+******************************************************************************/
+typedef struct PACK
+{
+ ShortAddr_t nwkAddrOfInterest; //!< NWK address of the power descriptor request
+ PowerDescriptor_t powerDescriptor; //!< Power descriptor of the device
+} ZDO_PowerDescResp_t;
+
+/**************************************************************************//**
+\brief This command is generated by a remote device in response to a
+Complex_Desc_req directed to the remote device. This command shall be unicast
+to the originator of the Complex_Desc_req command.
+******************************************************************************/
+typedef struct PACK
+{
+ ShortAddr_t nwkAddrOfInterest; //!< NWK address of the complex descriptor request
+ uint8_t length; //!< Length in bytes of the ComplexDescriptor field.
+} ZDO_ComplexDescResp_t;
+
+/**************************************************************************//**
+\brief The User_Desc_rsp is generated by a remote device in response to a
+User_Desc_req directed to the remote device. This command shall be unicast to
+the originator of the User_Desc_req command.
+******************************************************************************/
+typedef struct PACK
+{
+ ShortAddr_t nwkAddrOfInterest; //!< NWK address of the user descriptor request
+ UserDescriptor_t userDescriptor; //!< The user descriptor of a device
+} ZDO_UserDescResp_t;
+
+/**************************************************************************//**
+\brief This command is generated by a remote device in response to a
+User_Desc_set directed to the remote device. This command shall be unicast to
+the originator of the User_Desc_set command.
+******************************************************************************/
+typedef struct PACK
+{
+ ShortAddr_t nwkAddrOfInterest; //!< NWK address of the user descriptor setting request
+} ZDO_UserDescConfResp_t;
+
+/**************************************************************************//**
+\brief This command is generated by a remote device in response to an
+Active_EP_req directed to the remote device. This command shall be unicast to
+the originator of the Active_EP_req command.
+******************************************************************************/
+typedef struct PACK
+{
+ ShortAddr_t nwkAddrOfInterest; //!< NWK address of the active endpoints request
+ uint8_t activeEPCount; //!< Count of active endpoints on the remote device.
+ uint8_t activeEPList[MAX_ACTIVE_EP_NUMBER];//!< List of active endpoint Ids.
+} ZDO_ActiveEPResp_t;
+
+/**************************************************************************//**
+\brief The simple descriptor contains information specific to each endpoint contained in
+this node. The simple descriptor is mandatory for each endpoint present in the node.
+******************************************************************************/
+typedef struct PACK
+{
+ /*! The endpoint field of the simple descriptor is eight bits in length and specifies the
+ endpoint within the node to which this description refers. Applications shall only
+ use endpoints 1-240.*/
+ Endpoint_t endpoint;
+ /*! The application profile identifier field of the simple descriptor is sixteen bits in
+ length and specifies the profile that is supported on this endpoint. Profile
+ identifiers shall be obtained from the ZigBee Alliance.*/
+ ProfileId_t AppProfileId;
+ /*! The application device identifier field of the simple descriptor is sixteen bits in
+ length and specifies the device description supported on this endpoint. Device
+ description identifiers shall be obtained from the ZigBee Alliance.*/
+ uint16_t AppDeviceId;
+ LITTLE_ENDIAN_OCTET(2, (
+ /*! The application device version field of the simple descriptor is four bits in length
+ and specifies the version of the device description supported on this endpoint.*/
+ uint8_t AppDeviceVersion : 4,
+ uint8_t Reserved : 4
+ ))
+ /*! The application input cluster count field of the simple descriptor is eight bits in
+ length and specifies the number of input clusters, supported on this endpoint, that
+ will appear in the application input cluster list field. If the value of this field is
+ zero, the application input cluster list field shall not be included.*/
+ uint8_t AppInClustersCount;
+ /*! The application input cluster list of the simple descriptor is 16*i bits in length,
+ where i is the value of the application input cluster count field. This field specifies
+ the list of input clusters supported on this endpoint, for use during the service
+ discovery and binding procedures.
+ The application input cluster list field shall be included only if the value of the
+ application input cluster count field is greater than zero.*/
+ ClusterId_t AppInClustersList[MAX_REQUESTED_CLUSTER_NUMBER];
+ /*! The application output cluster count field of the simple descriptor is eight bits in
+ length and specifies the number of output clusters, supported on this endpoint, that
+ will appear in the application output cluster list field. If the value of this field is
+ zero, the application output cluster list field shall not be included.*/
+ uint8_t AppOutClustersCount;
+ /*! The application output cluster list of the simple descriptor is 16*o bits in length,
+ where o is the value of the application output cluster count field. This field
+ specifies the list of output clusters supported on this endpoint, for use during the
+ service discovery and binding procedures.
+ The application output cluster list field shall be included only if the value of the
+ application output cluster count field is greater than zero.*/
+ ClusterId_t AppOutClustersList[MAX_REQUESTED_CLUSTER_NUMBER];
+
+} ZdpSimpleDescriptor_t;
+
+/**************************************************************************//**
+\brief This command is generated by a remote device in response to a
+Simple_Desc_req directed to the remote device. This command shall be unicast to
+the originator of the Simple_Desc_req command.
+******************************************************************************/
+typedef struct PACK
+{
+ ShortAddr_t nwkAddrOfInterest; //!< NWK address of the simple descriptor request
+ uint8_t length; //!< Length in bytes of the Simple Descriptor to follow.
+ ZdpSimpleDescriptor_t simpleDescriptor; //!<The simple descriptor itself
+} ZDO_SimpleDescResp_t;
+
+/**************************************************************************//**
+\brief This command is generated from Remote Devices on receipt
+of a System_Server_Discovery_req primitive if the parameter matches the Server
+Mask field in its node descriptor. If there is no match, the
+System_Server_Discovery_req shall be ignored and no response given. Matching
+is performed by masking the ServerMask parameter of the
+System_Server_Discovery_req with the Server Mask field in the node descriptor.
+This command shall be unicast to the device which sent
+System_Server_Discovery_req with Acknowledge request set in TxOptions. The
+parameter ServerMask contains the bits in the parameter of the request which
+match the server mask in the node descriptor.
+******************************************************************************/
+typedef struct PACK
+{
+ uint16_t serverMask; //!< The server mask field of the node descriptor
+} ZDO_SystemServerDiscoveryResp_t;
+
+#ifdef _BINDING_
+typedef struct PACK
+{
+ ShortAddr_t nwkAddrOfInterest;
+ uint8_t matchLength;
+ uint8_t matchList[MAX_REQUESTED_CLUSTER_NUMBER];
+} ZDO_MatchDescResp_t;
+
+/**************************************************************************//**
+\brief (ClusterID = 0x8020) This response is generated by the ZigBee Coordinator
+in response to End Device Bind Request and contains the status of the request.
+This command shall be unicast to each device involved in the bind attempt, using
+acknowledged data sevice.
+******************************************************************************/
+typedef struct PACK
+{
+ /*! The status of the End Device Bind Request command.*/
+ uint8_t status;
+} ZDO_EndDeviceBindResp_t;
+
+/**************************************************************************//**
+\brief (ClusterID = 0x8021) This response is generated in response to
+Bind Request command and contains the status of the request.
+******************************************************************************/
+typedef struct PACK
+{
+ /*! The status of the End Device Bind Request command.*/
+ uint8_t status;
+} ZDO_BindResp_t;
+
+/**************************************************************************//**
+\brief (ClusterID = 0x8022) This response is generated in response to
+Unbind Request command and contains the status of the request.
+******************************************************************************/
+typedef struct PACK
+{
+ /*! The status of the End Device Bind Request command.*/
+ uint8_t status;
+} ZDO_UnbindResp_t;
+
+typedef struct PACK
+{
+ /*! Total number of Binding Table entries within the Remote Device. */
+ uint8_t bindingTableEntries;
+ /*! Starting index within the Binding Table to begin reporting for
+ * the BindingTableList. */
+ uint8_t startIndex;
+ /*! Number of Binding Table entries included within BindingTableList. */
+ uint8_t bindingTableListCount;
+ /*! A list of descriptors, beginning with the StartIndex element and
+ * continuing for BindingTableListCount, of the elements in the Remote
+ * Device's Binding Table. */
+ ZDO_BindReq_t bindingTableList[ZDP_BINDING_TABLE_LIST_SIZE];
+} ZDO_MgmtBindResp_t;
+
+#endif // _BINDING_
+
+/**************************************************************************//**
+\brief This struct contains response to one of the ZDP requests
+******************************************************************************/
+typedef struct PACK
+{
+ uint8_t seqNum; //!< Sequence number of a ZDP command
+ // user part
+ uint8_t status; //!< Result of a ZDP request. Is interpreted as ::ZDO_Status_t.
+ union PACK
+ {
+ ZDO_NwkAddrResp_t nwkAddrResp; //!< NWK address response
+ ZDO_IeeeAddrResp_t ieeeAddrResp; //!< IEEE address response
+ ZDO_NodeDescResp_t nodeDescResp; //!< Node descriptor response
+ ZDO_PowerDescResp_t powerDescResp; //!< Power descriptor response
+ ZDO_SimpleDescResp_t simpleDescResp; //!< Simple descriptor response
+ ZDO_ComplexDescResp_t complexDescResp; //!< Complex descriptor response
+ ZDO_UserDescResp_t userDescResp; //!< User descriptor response
+ ZDO_ActiveEPResp_t activeEPResp; //!< Active endpoint response
+ ZDO_UserDescConfResp_t userDescConfResp; //!< User descriptor setting confirmation
+ ZDO_SystemServerDiscoveryResp_t systemServerDiscoveryResp; //!< System server discovery response
+#ifdef _BINDING_
+ ZDO_MatchDescResp_t matchDescResp; //!< Match descriptor response
+ ZDO_BindResp_t bindResp; //!< Bind Response
+ ZDO_UnbindResp_t unbindResp; //!<Unbind Response
+#ifdef _CERTIFICATION_
+ ZDO_MgmtBindResp_t mgmtBindResp; //!< Management Bind response
+#endif // _CERTIFICATION_
+#endif // _BINDING_
+ ZDO_MgmtNwkUpdateNotf_t mgmtNwkUpdateNotf; //!< Network update notification
+ ZDO_MgmtLqiResp_t mgmtLqiResp; //!< LQI response
+ };
+} ZDO_ZdpRespFrame_t;
+
+/**************************************************************************//**
+\brief This struct contains one of the ZDP requests
+******************************************************************************/
+typedef struct PACK
+{
+ uint8_t seqNum; //!< Sequence number of a ZDP command
+ // user part
+ union PACK
+ {
+ ZDO_NwkAddrReq_t nwkAddrReq; //!< NWK address request
+ ZDO_IeeeAddrReq_t ieeeAddrReq; //!< IEEE address request
+ ZDO_NodeDescReq_t nodeDescReq; //!< Node descriptor request
+ ZDO_PowerDescReq_t powerDescReq; //!< Power descriptor request
+ ZDO_SimpleDescReq_t simpleDescReq; //!< Simple descriptor request
+ ZDO_DeviceAnnceReq_t deviceAnnce; //!< Device_annce request
+ ZDO_ActiveEPReq_t activeEPReq; //!< Active endpoint request
+ ZDO_ComplexDescReq_t complexDescReq; //!< Complex descriptor request (not supported yet)
+ ZDO_UserDescReq_t userDescReq; //!< User descriptor request (not supported yet)
+ ZDO_UserDescSetReq_t userDescSetReq; //!< User descriptor setting (not supported yet)
+ ZDO_SystemServerDiscoveryReq_t systemServerDiscoveryReq; //!< System server discovery request
+#ifdef _BINDING_
+ ZDO_MatchDescReq_t matchDescReq; //!< Match descriptor request
+ ZDO_EndDeviceBindReq_t endDeviceBindReq; //!< End Device Bind Request
+ ZDO_BindReq_t bindReq; //!< Bind Request
+ ZDO_UnbindReq_t unbindReq; //!< Unbind Request
+#ifdef _CERTIFICATION_
+ ZDO_MgmtBindReq_t mgmtBindReq; //!< Request elements from the binding table
+#endif // _CERTIFICATION_
+#endif // _BINDING_
+ ZDO_MgmtLeaveReq_t mgmtLeaveReq; //!< Leave request
+ ZDO_MgmtPermitJoiningReq_t mgmtPermitJoiningReq; //!< Permit joining request
+ ZDO_MgmtNwkUpdateReq_t mgmtNwkUpdateReq; //!< Network update request
+ ZDO_MgmtNwkUpdateNotf_t mgmtNwkUpdateNotf; //!< Network update notification
+ ZDO_MgmtLqiReq_t mgmtLqiReq; //!< LQI request
+ };
+} ZDO_ZdpReqFrame_t;
+
+/**************************************************************************//**
+\brief Frame for transmission one of the ZDP requests
+******************************************************************************/
+typedef struct PACK
+{
+ TOP_GUARD
+ uint8_t header[APS_ASDU_OFFSET];
+ union PACK
+ {
+ ZDO_ZdpRespFrame_t respPayload;
+ ZDO_ZdpReqFrame_t reqPayload;
+ };
+#if (APS_AFFIX_LENGTH - APS_ASDU_OFFSET)
+ uint8_t footer[APS_AFFIX_LENGTH - APS_ASDU_OFFSET];
+#endif
+ BOTTOM_GUARD
+} ZDO_ZdpFrame_t;
+END_PACK
+
+/**************************************************************************//**
+\brief ZDP response
+******************************************************************************/
+typedef struct
+{
+ AddrMode_t srcAddrMode; //!< Source address mode, either short or extended
+ union
+ {
+ ShortAddr_t srcNwkAddr; //!< Short source address
+ ExtAddr_t srcExtAddr; //!< Extended source address
+ };
+ ZDO_ZdpRespFrame_t respPayload; //!< Response frame
+} ZDO_ZdpResp_t;
+
+/**************************************************************************//**
+\brief ZDP request. Describes the parameters of the ZDO_ZdpReq() function.
+******************************************************************************/
+typedef struct
+{
+ //\cond internal
+ struct
+ {
+ void *next;
+ uint16_t ttl;
+ uint8_t state;
+ uint8_t seqNumCopy; //used to prevent seq number encription
+ } service;
+ //\endcond
+
+ // Address fields
+ uint16_t reqCluster; //!< Requested cluster
+ AddrMode_t dstAddrMode; //!< Destination address mode, either short (network) address more or extended address mode
+ union
+ {
+ ShortAddr_t dstNwkAddr; //!< Destination short address. Specify this field if short address mode is applied, i.e. dstAddrMode equals SHORT_ADDR_MODE
+ ExtAddr_t dstExtAddr;//!< Destination extended address. Specify this field if extended address mode is applied, i.e. dstAddrMode equals EXT_ADDR_MODE
+ };
+ // ZDP frame for sending out
+ ZDO_ZdpFrame_t req; //!< ZDP request parameters
+ //Callback and Response
+ void (*ZDO_ZdpResp)(ZDO_ZdpResp_t *zdpResp); //!< Response callback
+ ZDO_ZdpResp_t resp; //!< ZDP response parameters
+} ZDO_ZdpReq_t;
+
+/**************************************************************************//**
+\brief Describes the parameters of the ZDO_LqiRssiReq() function
+******************************************************************************/
+typedef struct
+{
+ ShortAddr_t nodeAddr; //!< Address of the requested node
+ uint8_t lqi; /*! Pointer to the memory allocated for LQI.
+ The range of the LQI value is from 0 to 255.*/
+ int8_t rssi; /*! Pointer to the memory allocated for RSSI.
+ The RSSI value range is different for various radio chips.
+ RF230A, RF230B, RF212: from -91 dBm to -7 dBm,
+ RF231: from -90 dBm to -7 dBm */
+} ZDO_GetLqiRssi_t;
+
+/**************************************************************************//**
+\brief Describes the parameters of the ZDO_ChildrenAddrReq() function
+******************************************************************************/
+typedef struct
+{
+ uint8_t childrenCount; //!< Number of children
+ NodeAddr_t *childrenTable; //!< Pointer to the memory allocated for children information
+} ZDO_GetChildrenAddr_t;
+
+/**************************************************************************//**
+\brief Describes the parameters of the ZDO_SetTxPowerConf() function
+******************************************************************************/
+typedef struct
+{
+ ZDO_Status_t status; //!< Result of transmitter power setting
+} ZDO_SetTxPowerConf_t;
+
+/**************************************************************************//**
+\brief Describes the parameters of the ZDO_SetTxPowerReq() function
+******************************************************************************/
+typedef struct
+{
+ uint8_t txPower; /*! Transmitter power to be set (dBm).
+Valid range is hardware-dependent: for AT86RF230 RF part, it is from 0xEF to 0x03 (-17 to 3).
+For AT86RF212 RF part, it is from 0xF5 to 0x0B (-11 to 11). */
+ void (* ZDO_SetTxPowerConf)(ZDO_SetTxPowerConf_t *conf); //!< The function called to confirm the request
+ ZDO_SetTxPowerConf_t confirm; //!< Parameters of the confirm being returned in ZDO_SetTxPowerConf()
+} ZDO_SetTxPowerReq_t;
+
+/**************************************************************************//**
+\brief List of network status
+******************************************************************************/
+typedef enum
+{
+ ZDO_IN_NETWORK_STATUS, //!< device is in the network
+ ZDO_OUT_NETWORK_STATUS //!< device is out of the network
+} ZDO_NwkStatus_t;
+
+/**************************************************************************//**
+\brief Describes the parameters of the ZDO_GetNeibAmount() function
+******************************************************************************/
+typedef struct
+{
+ uint8_t routersAmount; //!< Amount of routers in the neighbor table
+ uint8_t childrenAmount; //!< Amount of children in the neighbor table
+} ZDO_GetNeibAmount_t;
+
+/**************************************************************************//**
+\brief Describes neighbor table entry
+
+Neighbor table is an essential object involved in many network-related stack operations. It is also used by a
+number of synchronous functions performing network control. The neighbor table is filled on the network start
+procedure. The stack maintains the table updating it upon receiving various network requests such as Link status
+frames, leave requests, child joining and loss, etc.
+******************************************************************************/
+typedef struct
+{
+ ShortAddr_t shortAddr; //!< Short address of the node
+ ExtAddr_t extAddr; //!< Extended address of the node
+ DeviceType_t deviceType; //!< Device type of the node
+ uint8_t lqi; //!< LQI value for the node
+ int8_t rssi; //!< RSSI value for the node
+ bool rxOnWhenIdle; //!< Idle portions of the node
+ Relationship_t relationship; //!< Type of relationship between the current node and the neighbor node
+ ExtPanId_t extPanId; //!< Extended PAN identifier of the node
+ uint8_t logicalChannel; //!< Logical channel of the node
+ uint8_t depth; //!< Network depth on the node, i.e. the number of parent links from the node to the coordinator
+ bool permitJoining; //!< Indicates whether the node permits joining devices not present in the network before
+ bool potentialParent; //!< Indicates whether the node can serve as a parent for the current node
+} ZDO_Neib_t;
+
+#ifdef _SECURITY_
+#ifdef _LINK_SECURITY_
+typedef struct
+{
+ ZDO_Status_t status;
+} ZDO_EndToEndAppKeyConf_t;
+
+typedef struct
+{
+ ExtAddr_t deviceAddr;
+ void (*ZDO_EndToEndAppKeyConf)(ZDO_EndToEndAppKeyConf_t *conf);
+ ZDO_EndToEndAppKeyConf_t confirm;
+} ZDO_EndToEndAppKeyReq_t;
+#endif // _LINK_SECURITY_
+#endif // _SECURITY_
+
+#ifdef _TC_SWAPOUT_
+/**************************************************************************//**
+\brief Describes the parameters of the ZDO_TcSwapOutConf() function
+******************************************************************************/
+typedef struct
+{
+ ZDO_Status_t status; //!< Result of operation
+} ZDO_TcSwapOutConf_t;
+
+/**************************************************************************//**
+\brief Describes the parameters of the ZDO_StartNetworkReq() function
+******************************************************************************/
+typedef struct
+{
+ struct
+ {
+ void *next;
+ } service; //!< Service field, should not be touched by user
+ ZDO_TcSwapOutConf_t confirm; //!< Parameters of the confirm being returned in ZDO_TcSwpaOutConf()
+ void (*ZDO_TcSwapOutConf)(ZDO_TcSwapOutConf_t *conf); //!< The function called to confirm the request
+} ZDO_TcSwapOutReq_t;
+#endif // _TC_SWAPOUT_
+
+/******************************************************************************
+ Primitives declarations.
+******************************************************************************/
+
+/**************************************************************************//**
+\brief Performs network formation for coordinator and network join for router or
+end device.
+
+This function makes a request for starting a network. Before calling this function
+a device cannot participate in network interactions with other nodes. If node type
+is the coordinator, a new network is created, while nodes of the router or the
+end device type search for and join an existing network.
+
+Before calling the function make sure that certain node and network parameters
+affecting the result of a network start are set correctly. Node parameters include
+extended address (#CS_UID), short address (#CS_NWK_ADDR) if static addressing scheme
+is used, and device type (#CS_DEVICE_TYPE). Network parameters are comprised of channel
+mask (#CS_CHANNEL_MASK), channel page (#CS_CHANNEL_PAGE), extended PANID (#CS_EXT_PANID),
+and maximum network depth(#CS_MAX_NETWORK_DEPTH). Special attention should be given
+to security options. Note that for a coordinator extended PANID must be always set to
+a notzero value. In the case of a router or an end device it may equal 0, which will
+cause joining to the first suitable network, while a nonzero value makes it possible
+to join only a network which PANID equal the specified value.
+
+The argument's ZDO_StartNetworkConf field must contain a pointer to a callback function,
+typically named ZDO_StartNetworkConf(). Upon successful request completion
+ZDO_SUCCESS_STATUS is returned. Successful netwrok join will also cause a notification
+of obtained parent node via ZDO_MgmtNwkUpdateNotf() function reporting ZDO_CHILD_JOINED_STATUS.
+
+\param[in] req - Determines the network parameters for join and formation
+******************************************************************************/
+void ZDO_StartNetworkReq(ZDO_StartNetworkReq_t *req);
+
+/**************************************************************************//**
+\brief Resets the stack without sending any commands to the network
+
+The function resets the stack to the default state. All internal values and buffers
+including the neighbor table are reset to iniatl state. No data is send to the network,
+so the ex-parent of the node does not receive any notifications and is not able to
+find out child node's reset immediately.
+
+\param[in] req - Determines the parameters of the request
+******************************************************************************/
+void ZDO_ResetNetworkReq(ZDO_ResetNetworkReq_t *req);
+
+/**************************************************************************//**
+\brief Indicates network parameters update.
+
+The function shall be implemented by the application. It is called by the stack to signal
+certain network-related updates. The argument's fields contain indication of the event which
+caused the update (see possible values of ZDO_MgmtNwkUpdateNotf_t::status field) as well as
+additional information concerned with the update. Example cases when the function is called
+include changing of network parameters, resolving address/PANID conflict, rejoining the network,
+attaching new child and child loss.
+
+\note Child loss notification is issued only in the case of the end device child. A router
+is not considered a child after its parent receives the first Link status frame from the
+router. From that moment no notification is issued on the router's parent in case the router
+leaves the network. But if the parent has not yet received any Link status frames from its
+router child and the router leaves, the notification is raised on the parent as usual.
+
+\param[out] nwkParams - Describes the reason of network update and new parameters' values.
+******************************************************************************/
+void ZDO_MgmtNwkUpdateNotf(ZDO_MgmtNwkUpdateNotf_t * nwkParams);
+
+/**************************************************************************//**
+\brief Sends a ZDP request
+
+This function is used by an application to send a ZDP request.
+
+\param[in] zdpReq - Determines the parameters of the ZDP request
+******************************************************************************/
+void ZDO_ZdpReq(ZDO_ZdpReq_t *zdpReq);
+
+/**************************************************************************//**
+\brief Requests for LQI and RSSI
+
+This function requests LQI and RSSI for a remote node whose address is
+contained in ZDO_GetLqiRssi_t::nodeAddr.
+If called for an unknown node (i.e. with no link established to it), will return zeros.
+
+\param[in] lqiRssi - Determines the parameters of the request.
+******************************************************************************/
+void ZDO_GetLqiRssi(ZDO_GetLqiRssi_t *lqiRssi);
+
+/**************************************************************************//**
+\brief Retrieves parent's short and extended addresses
+
+The function gets the short address and the extended address of the current node's
+parent. Addresses' values are written to the corresponding fields of the argument.
+The information is retrieved from the neighbor table.
+
+\param[out] parentAddr - Determines the parameters of the request.
+******************************************************************************/
+void ZDO_GetParentAddr(NodeAddr_t *parentAddr);
+
+/**************************************************************************//**
+\brief Retrieves children's short and extended addresses
+
+The function gets the address information of all node's children including
+unauthenticated children. The information is retrieved from the neighbor table
+and is written to the dedicated static variable given in the argument. The
+following code example demonstrates a typical usage of the function:
+
+\code
+static NodeAddr_t childAddrTable[CS_MAX_CHILDREN_AMOUNT - CS_MAX_CHILDREN_ROUTER_AMOUNT];
+static ZDO_GetChildrenAddr_t children =
+{
+ .childrenCount = CS_MAX_CHILDREN_AMOUNT - CS_MAX_CHILDREN_ROUTER_AMOUNT,
+ .childrenTable = childAddrTable,
+};
+...
+ZDO_GetChildrenAddr(&children);
+int actualNumberOfChildren = children.childrenCount;
+\endcode
+
+While initializing the structure for storing information about children, set
+the \c childrenCount field to the maximum number of entries in the table. After
+the ZDO_GetChildrenAddr() function is executed, the value of this field will
+equal the actual number of children.
+
+\param[in] childrenAddr - Determines the parameters of the request.
+******************************************************************************/
+void ZDO_GetChildrenAddr(ZDO_GetChildrenAddr_t *childrenAddr);
+
+/**************************************************************************//**
+\brief Sets tx power
+
+This function sets tx power.
+
+\param[in] req - Determines the parameters of the request.
+******************************************************************************/
+void ZDO_SetTxPowerReq(ZDO_SetTxPowerReq_t *req);
+
+/**************************************************************************//**
+\brief Returns the network status
+
+The function returns the network status.
+
+\return one of the following:
+ \li ZDO_IN_NETWORK_STATUS - device is in the network
+ \li ZDO_OUT_NETWORK_STATUS - device is out of the network
+******************************************************************************/
+ZDO_NwkStatus_t ZDO_GetNwkStatus(void);
+
+/**************************************************************************//**
+\brief Gets neighbor routers and children amount
+
+\param[out] amount - routers and children amount information
+******************************************************************************/
+void ZDO_GetNeibAmount(ZDO_GetNeibAmount_t *amount);
+
+/**************************************************************************//**
+\brief Retrieves the neighbor table
+
+The function writes the contents of the neighbor table to the buffer specified by a
+pointer to it. Note that not all entries of the neighbor table are included, namely
+only neighbors with RELATIONSHIP_PARENT, RELATIONSHIP_CHILD, and RELATIONSHIP_NONE_OF_ABOVE
+relationships are included (in addtition, this implies that unauthenticated children's
+information is not retrieved). The space for the buffer shall be allocated at compile
+time, i.e. a variable for the buffer shall be static. The following code example
+demonstrates a typical way to call the function:
+
+\code
+static ZDO_Neib_t neighborTable[CS_NEIB_TABLE_SIZE]; // Buffer for the neighbor table
+...
+ZDO_GetNeibTable(neighborTable);
+\endcode
+
+\param[out] table - neighbor table
+******************************************************************************/
+void ZDO_GetNeibTable(ZDO_Neib_t *table);
+
+/**************************************************************************//**
+ \brief Puts the device into the sleep mode
+
+ The duration of the sleep period is determined by the ::CS_END_DEVICE_SLEEP_PERIOD
+ parameter. If CS_END_DEVICE_SLEEP_PERIOD is 0 then the device
+ will sleep infinitely and could be waken up by a hardware interrupt only. Note that
+ CS_END_DEVICE_SLEEP_PERIOD is also used by the parent to track the state of
+ the child.
+
+ \param[in] req - sleep request parameters
+******************************************************************************/
+void ZDO_SleepReq(ZDO_SleepReq_t *req);
+
+/**************************************************************************//**
+ \brief Sleep timer wake up indication
+
+ This function is called after wake up due to a sleep timer. When the function is entered
+ the stack is already fully operational.
+******************************************************************************/
+void ZDO_WakeUpInd(void);
+
+/**************************************************************************//**
+ \brief Forces the stack to wake up from the sleep mode
+
+ This function should be used by the application to wake up the stack in case
+ the wake up occured not due to the sleep timer, but rather due to an external interrupt.
+ In this case when the callback for the interrupt is being executed, the stck is not yet ready
+ to operate and the application shall issue an asynchronous wake up request via this function.
+
+ \param[in] req - wakeup request parameters
+******************************************************************************/
+void ZDO_WakeUpReq(ZDO_WakeUpReq_t *req);
+
+#ifdef _ENDDEVICE_
+/**************************************************************************//**
+ \brief Starts sending sync requests (polling the parent)
+
+ The function turns on auto polling mechanism if it was turned off by ZDO_StopSyncReq()
+ before. The stack starts sending polling requests to the parent automatically. So if the
+ parent node receives some data frames for the node when the node is sleeping,
+ the node will automatically request for those data frames stored by its parent when it wakes up.
+
+ The function should be used only on end devices which are able to sleep and with
+ ::CS_RX_ON_WHEN_IDLE set to false. The latter implies that radio is being switched on only
+ for a certain period of time when the stack sends data and waits for a reply.
+
+ \return - one of the following:
+ \li ZDO_SUCCESS_STATUS - operation completed successfully
+ \li ZDO_INVALID_REQUEST_STATUS - sync requests were already started
+******************************************************************************/
+ZDO_Status_t ZDO_StartSyncReq(void);
+
+/**************************************************************************//**
+ \brief Stops sending sync requests (polling the parent)
+
+ The function turns off auto polling mechanism. The stack stops sending polling
+ requests to the parent automatically. So if the parent node receives data frames
+ for the node when the node is sleeping, the node will not automatically request
+ for those data frames stored by its parent. In this case synchronization with the
+ parent can be done manually by sending NWK_SyncReq(). This can be useful if the
+ application does dot want a node to perform any actions after it wakes up and wants
+ to control fully data flow to end devices.
+
+ The function should be used only on end devices which are able to sleep and with
+ ::CS_RX_ON_WHEN_IDLE set to false. The latter implies that radio is being switched on
+ only for a certain period of time when the stack sends data and waits for a reply.
+
+ \return - one of the following:
+ \li ZDO_SUCCESS_STATUS - operation completed successfully
+ \li ZDO_INVALID_REQUEST_STATUS - sync requests were already stopped
+******************************************************************************/
+ZDO_Status_t ZDO_StopSyncReq(void);
+#endif // _ENDDEVICE_
+
+#ifdef _BINDING_
+/**************************************************************************//**
+\brief ZDO Binding indication function.
+
+\param[out] bindInd - ZDO bind indication parameters structure pointer. For details go to
+ ZDO_BindInd_t declaration.
+\return none
+******************************************************************************/
+void ZDO_BindIndication(ZDO_BindInd_t *bindInd);
+
+/**************************************************************************//**
+\brief ZDO Unbinding indication function.
+
+\param[out] unbindInd - ZDO Unbind indication parameters structure pointer. For details go to
+ ZDO_UnbindInd_t declaration.
+\return none
+******************************************************************************/
+void ZDO_UnbindIndication(ZDO_UnbindInd_t *unbindInd);
+#endif // _BINDING_
+
+#ifdef _TC_SWAPOUT_
+/**************************************************************************//**
+\brief Initiate search for the new Trust Centre
+
+This function initiates search for the new Trust Centre
+
+\param[in] req - Determines the parameters of the request.
+\return none
+******************************************************************************/
+void ZDO_TcSwapOutReq(ZDO_TcSwapOutReq_t *req);
+
+/******************************************************************************
+ Start sending TC keep-alive requests
+ Parameters:
+ none
+ Return:
+ status of operation
+******************************************************************************/
+ZDO_Status_t ZDO_TcKeepAliveStart(void);
+
+/******************************************************************************
+ Stop sending TC keep-alive requests
+ Parameters:
+ none
+ Return:
+ status of operation
+******************************************************************************/
+ZDO_Status_t ZDO_TcKeepAliveStop(void);
+
+/******************************************************************************
+ Stop sending TC keep-alive requests
+ Parameters:
+ endpoint - endpoint to set
+ Return:
+ none
+******************************************************************************/
+void ZDO_TcKeepAliveSetEndpoint(Endpoint_t localEndpoint, Endpoint_t remoteEndpoint);
+#endif // _TC_SWAPOUT_
+
+#endif // _ZDO_H
+
+// eof zdo.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/zdoNotify.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/zdoNotify.h
new file mode 100644
index 00000000..4ba798bc
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/zdoNotify.h
@@ -0,0 +1,108 @@
+/**************************************************************************//**
+ \file zdoNotify.h
+
+ \brief Functions for raising ZDO notifications
+
+ \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:
+ 13.11.09 A. Taradov - Created
+******************************************************************************/
+#ifndef _ZDONOTIFY_H
+#define _ZDONOTIFY_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <zdo.h>
+#include <aps.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+
+/******************************************************************************
+ Call ZDO_MgmtNwkUpdateNotf() only with status information.
+ Parameters:
+ status - update status
+ Return:
+ none
+******************************************************************************/
+void ZDO_NotifySimple(ZDO_Status_t status);
+
+/******************************************************************************
+ Call ZDO_MgmtNwkUpdateNotf() with prepared notification information
+ Parameters:
+ notf - notification information
+ Return:
+ none
+******************************************************************************/
+void ZDO_NotifyGeneral(ZDO_MgmtNwkUpdateNotf_t *notf);
+
+/******************************************************************************
+ Call ZDO_MgmtNwkUpdateNotf() with child update information.
+ Parameters:
+ status - update status
+ childInfo - updated device information
+ Return:
+ none
+******************************************************************************/
+void ZDO_NotifyChildUpdate(ZDO_Status_t status, ChildInfo_t *childInfo);
+
+/******************************************************************************
+ Call ZDO_MgmtNwkUpdateNotf() with new network parameters.
+ Parameters:
+ status - update status
+ Return:
+ none
+******************************************************************************/
+void ZDO_NotifyNwkUpdate(ZDO_Status_t status);
+
+/******************************************************************************
+ Call ZDO_MgmtNwkUpdateNotf() with conflict address.
+ Parameters:
+ status - update status
+ shortAddr - conflicting address
+ Return:
+ none
+******************************************************************************/
+void ZDO_NotifyAddressConflict(ZDO_Status_t status, ShortAddr_t *shortAddr);
+
+#if defined(_SECURITY_) && defined _LINK_SECURITY_
+/******************************************************************************
+ Call ZDO_MgmtNwkUpdateNotf() with information about security keys updates.
+ Parameters:
+ status - update status
+ extAddr - extended address of updated device
+ Return:
+ none
+******************************************************************************/
+void ZDO_NotifySecurityUpdate(ZDO_Status_t status, ExtAddr_t *extAddr);
+
+#ifdef _TC_PROMISCUOUS_MODE_
+/**************************************************************************//**
+\brief Notification about remote device bind have been staled
+
+ The function should be defined by an application.
+ It is called when the device was notificated about bounded device lost
+
+\param[in] extAddr - pointer to extended address of lost bounded device
+******************************************************************************/
+void ZDO_NotifyBindLost(ExtAddr_t* extAddr);
+#endif /* _TC_PROMISCUOUS_MODE_ */
+
+#endif // defined(_SECURITY_) && defined _LINK_SECURITY_
+
+#endif // _ZDONOTIFY_H
+
+// eof zdoNotify.h
diff --git a/digital/zigbit/bitcloud/stack/Components/ZDO/include/zdoSecurityManager.h b/digital/zigbit/bitcloud/stack/Components/ZDO/include/zdoSecurityManager.h
new file mode 100644
index 00000000..fb093ec9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/ZDO/include/zdoSecurityManager.h
@@ -0,0 +1,85 @@
+/************************************************************************//**
+ \file zdoSecurityManager.h
+
+ \brief The header file describes the constants, types and internal interface
+ of ZDO security manager
+
+ \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:
+******************************************************************************/
+
+#ifndef _ZDOSECURITYMANAGER_H
+#define _ZDOSECURITYMANAGER_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <appTimer.h>
+#include <zdo.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+typedef enum
+{
+ ZDO_IDLE_SECURITY_STATE,
+ ZDO_NORMAL_OPERATING_SECURITY_STATE,
+ ZDO_WAITING_ESTABLISH_KEY_SECURITY_STATE,
+ ZDO_WAITING_TRANSPORT_KEY_SECURITY_STATE,
+ ZDO_WAITING_PARENT_AUTHENTICATION_SECURITY_STATE,
+ ZDO_WAITING_CHILD_AUTHENTICATION_SECURITY_STATE,
+ ZDO_APP_KEY_ESTABLISH_RESPONDER_SECURITY_STATE,
+ ZDO_APP_KEY_ESTABLISH_INITIATOR_SECURITY_STATE,
+ ZDO_STARTING_NORMAL_OPERATING_SECURITY_STATE,
+ ZDO_FAIL_CONFIRM_SECURITY_STATE,
+ ZDO_CONFIRM_APP_KEY_SECURITY_STATE,
+ ZDO_WAITING_APP_KEY_SECURITY_STATE,
+ ZDO_WAITING_TC_LINK_KEY_SECURITY_STATE,
+} ZdoSecurityManagerState_t;
+
+typedef struct
+{
+ ZdoSecurityManagerState_t state;
+#ifdef _SECURITY_
+ HAL_AppTimer_t waitTimer;
+ HAL_AppTimer_t delayTimer;
+ uint8_t newKeySeqNum;
+#ifdef _LINK_SECURITY_
+ union
+ {
+ APS_AuthenticateReq_t apsAuthenticateReq;
+#ifdef _HI_SECURITY_
+ APS_EstablishKeyReq_t apsEstablishKeyReq;
+#endif // _HI_SECURITY_
+#ifdef _CUSTOM_4_SECURITY_MODE_
+ APS_RequestKeyReq_t apsRequestKeyReq;
+#endif // _CUSTOM_4_SECURITY_MODE_
+ };
+#ifdef _HI_SECURITY_
+ APS_EstablishKeyResp_t apsEstablishKeyResp;
+#endif // _HI_SECURITY_
+ ZDO_EndToEndAppKeyReq_t *appKeyReq;
+#endif // _LINK_SECURITY_
+#endif // _SECURITY_
+} ZdoSecurityManager_t;
+
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+void zdoResetSecurityManager(void);
+void zdoAuthenticationStart(void);
+void zdoAuthenticationConf(ZDO_Status_t status);
+uint8_t ZDO_GetPreconfiguredStatus(void);
+void zdoAuthenticateChild(const ExtAddr_t *childAddr);
+void zdoSecurityManagerHandler(void);
+
+#endif // _ZDOSECURITYMANAGER_H
+
+// eof zdoSecurityManager.h
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf212_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf212_Gcc
new file mode 100644
index 00000000..6d303c84
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf212_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF212 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_COORDINATOR_ -D_ROUTER_ -D_ENDDEVICE_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf212_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf212_Gcc.h
new file mode 100644
index 00000000..48106c43
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf212_Gcc.h
@@ -0,0 +1,91 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf230B_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf230B_Gcc
new file mode 100644
index 00000000..33d2106e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf230B_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230B -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_COORDINATOR_ -D_ROUTER_ -D_ENDDEVICE_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf230B_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf230B_Gcc.h
new file mode 100644
index 00000000..48106c43
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf230B_Gcc.h
@@ -0,0 +1,91 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf230_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf230_Gcc
new file mode 100644
index 00000000..eef6b708
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf230_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_COORDINATOR_ -D_ROUTER_ -D_ENDDEVICE_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf230_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf230_Gcc.h
new file mode 100644
index 00000000..48106c43
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf230_Gcc.h
@@ -0,0 +1,91 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf231_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf231_Gcc
new file mode 100644
index 00000000..d6482c0e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf231_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF231 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_COORDINATOR_ -D_ROUTER_ -D_ENDDEVICE_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf231_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf231_Gcc.h
new file mode 100644
index 00000000..48106c43
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Atmega1281_Rf231_Gcc.h
@@ -0,0 +1,91 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf212_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf212_Gcc
new file mode 100644
index 00000000..fc001929
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf212_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF212 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_MAC_HW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_COORDINATOR_ -D_ROUTER_ -D_ENDDEVICE_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf212_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf212_Gcc.h
new file mode 100644
index 00000000..3f0c44f6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf212_Gcc.h
@@ -0,0 +1,112 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _MAC_HW_AES_
+#define _MAC_HW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf230B_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf230B_Gcc
new file mode 100644
index 00000000..45e004b5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf230B_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230B -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_COORDINATOR_ -D_ROUTER_ -D_ENDDEVICE_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf230B_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf230B_Gcc.h
new file mode 100644
index 00000000..96deb136
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf230B_Gcc.h
@@ -0,0 +1,112 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf230_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf230_Gcc
new file mode 100644
index 00000000..c7de2ea9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf230_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_COORDINATOR_ -D_ROUTER_ -D_ENDDEVICE_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf230_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf230_Gcc.h
new file mode 100644
index 00000000..96deb136
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf230_Gcc.h
@@ -0,0 +1,112 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf231_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf231_Gcc
new file mode 100644
index 00000000..9af06bb5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf231_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF231 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_MAC_HW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_COORDINATOR_ -D_ROUTER_ -D_ENDDEVICE_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf231_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf231_Gcc.h
new file mode 100644
index 00000000..3f0c44f6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_All_Sec_Atmega1281_Rf231_Gcc.h
@@ -0,0 +1,112 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _MAC_HW_AES_
+#define _MAC_HW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf212_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf212_Gcc
new file mode 100644
index 00000000..99e80542
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf212_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF212 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_COORDINATOR_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf212_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf212_Gcc.h
new file mode 100644
index 00000000..f09ecd7a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf212_Gcc.h
@@ -0,0 +1,85 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf230B_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf230B_Gcc
new file mode 100644
index 00000000..9f6e034b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf230B_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230B -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_COORDINATOR_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf230B_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf230B_Gcc.h
new file mode 100644
index 00000000..f09ecd7a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf230B_Gcc.h
@@ -0,0 +1,85 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf230_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf230_Gcc
new file mode 100644
index 00000000..feaa6ace
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf230_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_COORDINATOR_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf230_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf230_Gcc.h
new file mode 100644
index 00000000..f09ecd7a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf230_Gcc.h
@@ -0,0 +1,85 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf231_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf231_Gcc
new file mode 100644
index 00000000..4cab1a17
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf231_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF231 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_COORDINATOR_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf231_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf231_Gcc.h
new file mode 100644
index 00000000..f09ecd7a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Atmega1281_Rf231_Gcc.h
@@ -0,0 +1,85 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf212_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf212_Gcc
new file mode 100644
index 00000000..7ca8e92d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf212_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF212 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_MAC_HW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_COORDINATOR_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf212_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf212_Gcc.h
new file mode 100644
index 00000000..deae20d0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf212_Gcc.h
@@ -0,0 +1,106 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _MAC_HW_AES_
+#define _MAC_HW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf230B_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf230B_Gcc
new file mode 100644
index 00000000..4b9037ca
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf230B_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230B -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_COORDINATOR_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf230B_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf230B_Gcc.h
new file mode 100644
index 00000000..f886c3e6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf230B_Gcc.h
@@ -0,0 +1,106 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf230_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf230_Gcc
new file mode 100644
index 00000000..5d3e83e5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf230_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_COORDINATOR_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf230_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf230_Gcc.h
new file mode 100644
index 00000000..f886c3e6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf230_Gcc.h
@@ -0,0 +1,106 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf231_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf231_Gcc
new file mode 100644
index 00000000..0bc7fcf9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf231_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF231 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_MAC_HW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_COORDINATOR_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf231_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf231_Gcc.h
new file mode 100644
index 00000000..deae20d0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_Sec_Atmega1281_Rf231_Gcc.h
@@ -0,0 +1,106 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _MAC_HW_AES_
+#define _MAC_HW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf212_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf212_Gcc
new file mode 100644
index 00000000..3fc08e53
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf212_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF212 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_LINK_SECURITY_ -D_UNIVERSAL_EXTENDED_ADDRESS_ -D_COORDINATOR_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf212_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf212_Gcc.h
new file mode 100644
index 00000000..c22ea2a1
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf212_Gcc.h
@@ -0,0 +1,112 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _LINK_SECURITY_
+#define _LINK_SECURITY_
+#endif
+#ifndef _UNIVERSAL_EXTENDED_ADDRESS_
+#define _UNIVERSAL_EXTENDED_ADDRESS_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf230B_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf230B_Gcc
new file mode 100644
index 00000000..d8e5fe47
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf230B_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230B -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_LINK_SECURITY_ -D_UNIVERSAL_EXTENDED_ADDRESS_ -D_COORDINATOR_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf230B_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf230B_Gcc.h
new file mode 100644
index 00000000..c22ea2a1
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf230B_Gcc.h
@@ -0,0 +1,112 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _LINK_SECURITY_
+#define _LINK_SECURITY_
+#endif
+#ifndef _UNIVERSAL_EXTENDED_ADDRESS_
+#define _UNIVERSAL_EXTENDED_ADDRESS_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf230_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf230_Gcc
new file mode 100644
index 00000000..d9c4caaa
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf230_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_LINK_SECURITY_ -D_UNIVERSAL_EXTENDED_ADDRESS_ -D_COORDINATOR_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf230_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf230_Gcc.h
new file mode 100644
index 00000000..c22ea2a1
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf230_Gcc.h
@@ -0,0 +1,112 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _LINK_SECURITY_
+#define _LINK_SECURITY_
+#endif
+#ifndef _UNIVERSAL_EXTENDED_ADDRESS_
+#define _UNIVERSAL_EXTENDED_ADDRESS_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf231_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf231_Gcc
new file mode 100644
index 00000000..f87cdedf
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf231_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF231 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_MAC_HW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_LINK_SECURITY_ -D_UNIVERSAL_EXTENDED_ADDRESS_ -D_COORDINATOR_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf231_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf231_Gcc.h
new file mode 100644
index 00000000..8c543001
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Coordinator_StdlinkSec_Atmega1281_Rf231_Gcc.h
@@ -0,0 +1,112 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _MAC_HW_AES_
+#define _MAC_HW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _LINK_SECURITY_
+#define _LINK_SECURITY_
+#endif
+#ifndef _UNIVERSAL_EXTENDED_ADDRESS_
+#define _UNIVERSAL_EXTENDED_ADDRESS_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf212_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf212_Gcc
new file mode 100644
index 00000000..0c231eb9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf212_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF212 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_ENDDEVICE_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf212_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf212_Gcc.h
new file mode 100644
index 00000000..27a8f1c0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf212_Gcc.h
@@ -0,0 +1,82 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf230B_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf230B_Gcc
new file mode 100644
index 00000000..b46b58de
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf230B_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230B -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_ENDDEVICE_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf230B_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf230B_Gcc.h
new file mode 100644
index 00000000..27a8f1c0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf230B_Gcc.h
@@ -0,0 +1,82 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf230_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf230_Gcc
new file mode 100644
index 00000000..d1b0c2b5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf230_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_ENDDEVICE_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf230_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf230_Gcc.h
new file mode 100644
index 00000000..27a8f1c0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf230_Gcc.h
@@ -0,0 +1,82 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf231_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf231_Gcc
new file mode 100644
index 00000000..42ff1a3c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf231_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF231 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_ENDDEVICE_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf231_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf231_Gcc.h
new file mode 100644
index 00000000..27a8f1c0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Atmega1281_Rf231_Gcc.h
@@ -0,0 +1,82 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf212_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf212_Gcc
new file mode 100644
index 00000000..efbe8b62
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf212_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF212 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_MAC_HW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_ENDDEVICE_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf212_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf212_Gcc.h
new file mode 100644
index 00000000..d58d4d7a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf212_Gcc.h
@@ -0,0 +1,103 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _MAC_HW_AES_
+#define _MAC_HW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf230B_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf230B_Gcc
new file mode 100644
index 00000000..844dc27c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf230B_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230B -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_ENDDEVICE_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf230B_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf230B_Gcc.h
new file mode 100644
index 00000000..c5af77e1
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf230B_Gcc.h
@@ -0,0 +1,103 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf230_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf230_Gcc
new file mode 100644
index 00000000..9374b46c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf230_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_ENDDEVICE_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf230_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf230_Gcc.h
new file mode 100644
index 00000000..c5af77e1
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf230_Gcc.h
@@ -0,0 +1,103 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf231_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf231_Gcc
new file mode 100644
index 00000000..6f5d0b00
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf231_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF231 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_MAC_HW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_ENDDEVICE_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf231_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf231_Gcc.h
new file mode 100644
index 00000000..d58d4d7a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_Sec_Atmega1281_Rf231_Gcc.h
@@ -0,0 +1,103 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _MAC_HW_AES_
+#define _MAC_HW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf212_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf212_Gcc
new file mode 100644
index 00000000..e5cbe615
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf212_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF212 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_LINK_SECURITY_ -D_UNIVERSAL_EXTENDED_ADDRESS_ -D_ENDDEVICE_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf212_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf212_Gcc.h
new file mode 100644
index 00000000..0f94932d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf212_Gcc.h
@@ -0,0 +1,109 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _LINK_SECURITY_
+#define _LINK_SECURITY_
+#endif
+#ifndef _UNIVERSAL_EXTENDED_ADDRESS_
+#define _UNIVERSAL_EXTENDED_ADDRESS_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf230B_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf230B_Gcc
new file mode 100644
index 00000000..354744aa
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf230B_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230B -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_LINK_SECURITY_ -D_UNIVERSAL_EXTENDED_ADDRESS_ -D_ENDDEVICE_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf230B_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf230B_Gcc.h
new file mode 100644
index 00000000..0f94932d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf230B_Gcc.h
@@ -0,0 +1,109 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _LINK_SECURITY_
+#define _LINK_SECURITY_
+#endif
+#ifndef _UNIVERSAL_EXTENDED_ADDRESS_
+#define _UNIVERSAL_EXTENDED_ADDRESS_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf230_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf230_Gcc
new file mode 100644
index 00000000..89c241c3
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf230_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_LINK_SECURITY_ -D_UNIVERSAL_EXTENDED_ADDRESS_ -D_ENDDEVICE_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf230_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf230_Gcc.h
new file mode 100644
index 00000000..0f94932d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf230_Gcc.h
@@ -0,0 +1,109 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _LINK_SECURITY_
+#define _LINK_SECURITY_
+#endif
+#ifndef _UNIVERSAL_EXTENDED_ADDRESS_
+#define _UNIVERSAL_EXTENDED_ADDRESS_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf231_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf231_Gcc
new file mode 100644
index 00000000..fc34c14f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf231_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF231 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_MAC_HW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_LINK_SECURITY_ -D_UNIVERSAL_EXTENDED_ADDRESS_ -D_ENDDEVICE_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf231_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf231_Gcc.h
new file mode 100644
index 00000000..3738a91d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_EndDevice_StdlinkSec_Atmega1281_Rf231_Gcc.h
@@ -0,0 +1,109 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _MAC_HW_AES_
+#define _MAC_HW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _LINK_SECURITY_
+#define _LINK_SECURITY_
+#endif
+#ifndef _UNIVERSAL_EXTENDED_ADDRESS_
+#define _UNIVERSAL_EXTENDED_ADDRESS_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf212_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf212_Gcc
new file mode 100644
index 00000000..efe14175
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf212_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF212 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_ROUTER_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf212_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf212_Gcc.h
new file mode 100644
index 00000000..1ec69985
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf212_Gcc.h
@@ -0,0 +1,85 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf230B_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf230B_Gcc
new file mode 100644
index 00000000..bc0bd40b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf230B_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230B -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_ROUTER_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf230B_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf230B_Gcc.h
new file mode 100644
index 00000000..1ec69985
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf230B_Gcc.h
@@ -0,0 +1,85 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf230_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf230_Gcc
new file mode 100644
index 00000000..5cfffc47
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf230_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_ROUTER_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf230_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf230_Gcc.h
new file mode 100644
index 00000000..1ec69985
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf230_Gcc.h
@@ -0,0 +1,85 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf231_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf231_Gcc
new file mode 100644
index 00000000..fd9521d5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf231_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF231 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_ROUTER_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf231_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf231_Gcc.h
new file mode 100644
index 00000000..1ec69985
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Atmega1281_Rf231_Gcc.h
@@ -0,0 +1,85 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf212_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf212_Gcc
new file mode 100644
index 00000000..c92798dd
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf212_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF212 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_MAC_HW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_ROUTER_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf212_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf212_Gcc.h
new file mode 100644
index 00000000..2f46e331
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf212_Gcc.h
@@ -0,0 +1,106 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _MAC_HW_AES_
+#define _MAC_HW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf230B_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf230B_Gcc
new file mode 100644
index 00000000..b219d325
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf230B_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230B -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_ROUTER_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf230B_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf230B_Gcc.h
new file mode 100644
index 00000000..0efc99f0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf230B_Gcc.h
@@ -0,0 +1,106 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf230_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf230_Gcc
new file mode 100644
index 00000000..0655089a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf230_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_ROUTER_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf230_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf230_Gcc.h
new file mode 100644
index 00000000..0efc99f0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf230_Gcc.h
@@ -0,0 +1,106 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf231_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf231_Gcc
new file mode 100644
index 00000000..20e2c1e8
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf231_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF231 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_MAC_HW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_ROUTER_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf231_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf231_Gcc.h
new file mode 100644
index 00000000..2f46e331
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_Sec_Atmega1281_Rf231_Gcc.h
@@ -0,0 +1,106 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _MAC_HW_AES_
+#define _MAC_HW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf212_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf212_Gcc
new file mode 100644
index 00000000..86bab858
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf212_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF212 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_LINK_SECURITY_ -D_UNIVERSAL_EXTENDED_ADDRESS_ -D_ROUTER_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf212_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf212_Gcc.h
new file mode 100644
index 00000000..b8ce9865
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf212_Gcc.h
@@ -0,0 +1,112 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _LINK_SECURITY_
+#define _LINK_SECURITY_
+#endif
+#ifndef _UNIVERSAL_EXTENDED_ADDRESS_
+#define _UNIVERSAL_EXTENDED_ADDRESS_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf230B_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf230B_Gcc
new file mode 100644
index 00000000..ec7af0bc
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf230B_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230B -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_LINK_SECURITY_ -D_UNIVERSAL_EXTENDED_ADDRESS_ -D_ROUTER_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf230B_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf230B_Gcc.h
new file mode 100644
index 00000000..b8ce9865
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf230B_Gcc.h
@@ -0,0 +1,112 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _LINK_SECURITY_
+#define _LINK_SECURITY_
+#endif
+#ifndef _UNIVERSAL_EXTENDED_ADDRESS_
+#define _UNIVERSAL_EXTENDED_ADDRESS_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf230_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf230_Gcc
new file mode 100644
index 00000000..61deb3f3
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf230_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_LINK_SECURITY_ -D_UNIVERSAL_EXTENDED_ADDRESS_ -D_ROUTER_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf230_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf230_Gcc.h
new file mode 100644
index 00000000..b8ce9865
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf230_Gcc.h
@@ -0,0 +1,112 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _LINK_SECURITY_
+#define _LINK_SECURITY_
+#endif
+#ifndef _UNIVERSAL_EXTENDED_ADDRESS_
+#define _UNIVERSAL_EXTENDED_ADDRESS_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf231_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf231_Gcc
new file mode 100644
index 00000000..cb621ddc
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf231_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF231 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_MAC_HW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_LINK_SECURITY_ -D_UNIVERSAL_EXTENDED_ADDRESS_ -D_ROUTER_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_GROUP_ -D_GROUP_TABLE_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_APS_FRAGMENTATION_ -D_APS_MULTICAST_ -D_GROUP_TABLE_ -D_BINDING_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf231_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf231_Gcc.h
new file mode 100644
index 00000000..28e21103
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesBc_Router_StdlinkSec_Atmega1281_Rf231_Gcc.h
@@ -0,0 +1,112 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _MAC_HW_AES_
+#define _MAC_HW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _LINK_SECURITY_
+#define _LINK_SECURITY_
+#endif
+#ifndef _UNIVERSAL_EXTENDED_ADDRESS_
+#define _UNIVERSAL_EXTENDED_ADDRESS_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_GROUP_
+#define _NWK_GROUP_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _APS_FRAGMENTATION_
+#define _APS_FRAGMENTATION_
+#endif
+#ifndef _APS_MULTICAST_
+#define _APS_MULTICAST_
+#endif
+#ifndef _GROUP_TABLE_
+#define _GROUP_TABLE_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesHalSe_x86_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesHalSe_x86_Gcc
new file mode 100644
index 00000000..97fd4be7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesHalSe_x86_Gcc
@@ -0,0 +1,32 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_x86_Gcc
+
+#-Compiler flags-------------------------------
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+#STACK_LIB = Zse_All_SESec_Sam7xEkRf2xx_At91sam7x256_Rf231_Iar
+#HAL_LIB = HAL_Sam7xEkRf2xx_At91sam7x256_Iar
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+#VCP_LIB = VCP
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/pc
+#HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/arm7tdmi/at91sam7x256/atmlEvalKit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+ZCL_PATH = $(COMPONENTS_PATH)/./ZCL
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesSelector b/digital/zigbit/bitcloud/stack/lib/MakerulesSelector
new file mode 100644
index 00000000..69fd72a0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesSelector
@@ -0,0 +1,380 @@
+#-------------------------------------------------------------------------------
+# Check user's configuration.
+#-------------------------------------------------------------------------------
+ifeq ($(BOARD), BOARD_MESHBEAN) ######### MeshBean board #####
+ # Checking parameters which have been set by user.
+ ifeq (, $(findstring $(RFCHIP), AT86RF230 AT86RF230B AT86RF231 AT86RF212))
+ $(error ERROR Wrong configuration: Unknown type of RF chip for $(BOARD) board: '$(RFCHIP)')
+ endif
+
+ ifeq (, $(findstring $(HAL_FREQUENCY), HAL_8MHz HAL_4MHz))
+ $(error ERROR Wrong configuration: Unknown type of HAL frequency for $(BOARD) board: '$(HAL_FREQUENCY)')
+ endif
+
+ ifeq (, $(findstring $(HAL), ATMEGA1281 ATMEGA2561))
+ $(error ERROR Wrong configuration: Unknown type of HAL for $(BOARD) board: '$(HAL)')
+ endif
+
+else ifeq ($(BOARD), BOARD_STK600) ######### STK600 board #####
+ ifeq ($(HAL), ATMEGA128RFA1)
+ RFCHIP = ATMEGA128RFA1
+ endif
+
+ # Checking parameters which have been set by user.
+ ifeq (, $(findstring $(RFCHIP), AT86RF230 AT86RF230B AT86RF231 AT86RF212 ATMEGA128RFA1))
+ $(error ERROR Wrong configuration: Unknown type of RF chip for $(BOARD) board: '$(RFCHIP)')
+ endif
+
+ ifeq (, $(findstring $(HAL_FREQUENCY), HAL_16MHz HAL_32MHz HAL_12MHz HAL_8MHz HAL_4MHz))
+ $(error ERROR Wrong configuration: Unknown type of HAL frequency for $(BOARD) board: '$(HAL_FREQUENCY)')
+ endif
+
+ ifeq (, $(findstring $(HAL), ATXMEGA128A1 ATXMEGA256A3 ATXMEGA256D3 ATMEGA128RFA1))
+ $(error ERROR Wrong configuration: Unknown type of HAL for $(BOARD) board: '$(HAL)')
+ endif
+
+else ifeq ($(BOARD), BOARD_USB_DONGLE) ######### Usb Dongle board #####
+ HAL = AT90USB1287
+ HAL_FREQUENCY = HAL_8MHz
+ RFCHIP = AT86RF230B
+
+else ifeq ($(BOARD), BOARD_SAM7X_EK) ##### ATML_SAM7X_EK board ####
+ HAL = AT91SAM7X256
+ HAL_CLOCK_SOURCE = CRYSTAL
+ HAL_FREQUENCY = HAL_18d432MHz
+
+ # Checking parameters which have been set by user.
+ ifeq (, $(findstring $(RFCHIP), AT86RF230 AT86RF230B AT86RF231 AT86RF212))
+ $(error ERROR Wrong configuration: Unknown type of RF chip for $(BOARD) board: '$(RFCHIP)')
+ endif
+
+else ifeq ($(BOARD), BOARD_MESHBEAN_LAN) #### BOARD_MESHBEAN_LAN board ####
+ # Setting board parameters which can not be changed by user.
+ HAL = AT91SAM7X256
+ RFCHIP = AT86RF231
+
+else ifeq ($(BOARD), BOARD_CUSTOM_1) ########### CUSTOM_1 board ####
+ HAL = AT91SAM7X256
+ HAL_CLOCK_SOURCE = CRYSTAL
+ RFCHIP = AT86RF230B
+ HAL_FREQUENCY = HAL_8MHz
+
+else ifeq ($(BOARD), BOARD_CUSTOM_2) ########### CUSTOM_2 board ####
+ HAL = AT91SAM7X256
+ HAL_CLOCK_SOURCE = CRYSTAL
+ RFCHIP = AT86RF230B
+ HAL_FREQUENCY = HAL_8MHz
+
+else ifeq ($(BOARD), BOARD_SAM3S_EK) ##### ATML_SAMAS_EK board ####
+ HAL = AT91SAM3S4C
+
+ # Checking parameters which were set by user.
+ ifeq (, $(findstring $(HAL_FREQUENCY), HAL_4MHz HAL_8MHz HAL_12MHz HAL_64MHz))
+ $(error ERROR Wrong configuration: Unknown type of HAL frequency for $(BOARD) board: '$(HAL_FREQUENCY)')
+ endif
+
+ # Checking parameters which have been set by user.
+ ifeq (, $(findstring $(RFCHIP), AT86RF230 AT86RF230B AT86RF231 AT86RF212))
+ $(error ERROR Wrong configuration: Unknown type of RF chip for $(BOARD) board: '$(RFCHIP)')
+ endif
+
+else ifeq ($(BOARD), BOARD_SAM3S_PIRRD) ##### SAMAS_PIRRD board ####
+ HAL = AT91SAM3S4C
+
+ # Checking parameters which were set by user.
+ ifeq (, $(findstring $(HAL_FREQUENCY), HAL_4MHz HAL_8MHz HAL_12MHz HAL_64MHz))
+ $(error ERROR Wrong configuration: Unknown type of HAL frequency for $(BOARD) board: '$(HAL_FREQUENCY)')
+ endif
+
+ # Checking parameters which have been set by user.
+ ifeq (, $(findstring $(RFCHIP), AT86RF230 AT86RF230B AT86RF231 AT86RF212))
+ $(error ERROR Wrong configuration: Unknown type of RF chip for $(BOARD) board: '$(RFCHIP)')
+ endif
+
+else ifeq ($(BOARD), BOARD_CUSTOM_3) ##### CUSTOM_3 board ####
+ HAL = AT91SAM3S4C
+ HAL_FREQUENCY = HAL_64MHz
+ RFCHIP = CUSTOMRF3
+
+else ifeq ($(BOARD), BOARD_RAVEN) ########### BOARD_RAVEN board ####
+ HAL = ATMEGA1284
+ RFCHIP = AT86RF230B
+
+ # Checking parameters which were set by user.
+ ifeq (, $(findstring $(HAL_FREQUENCY), HAL_8MHz HAL_4MHz))
+ $(error ERROR Wrong configuration: Unknown type of HAL frequency for $(BOARD) board: '$(HAL_FREQUENCY)')
+ endif
+
+else ifeq ($(BOARD), BOARD_RCB) ########### RCB board ####
+ ifeq (, $(findstring $(BOARD_REV), RCB_ATMEGA128RFA1 RCB230_V31 RCB230_V32 RCB230_V331 RCB231_V402 RCB231_V411 RCB212_V532))
+ $(error ERROR in file Makerules: $(PLATFORM_REV) Unknown board revision for rcb board)
+ endif
+
+ ifeq ($(BOARD_REV), RCB_ATMEGA128RFA1)
+ HAL = ATMEGA128RFA1
+ RFCHIP = ATMEGA128RFA1
+ else
+ ifeq ($(USE_KF_MAC), TRUE)
+ HAL = ATMEGA2561
+ else
+ HAL = ATMEGA1281
+ endif
+ ifneq (, $(findstring $(BOARD_REV), RCB230_V31 RCB230_V32 RCB230_V331))
+ RFCHIP = AT86RF230
+ endif
+ ifneq (, $(findstring $(BOARD_REV), RCB231_V402 RCB231_V411))
+ RFCHIP = AT86RF231
+ endif
+ ifneq (, $(findstring $(BOARD_REV), RCB212_V532))
+ RFCHIP = AT86RF212
+ endif
+ endif # BOARD_REV
+
+ # Checking parameters which were set by user.
+ ifeq (, $(findstring $(HAL_FREQUENCY), HAL_8MHz HAL_4MHz))
+ $(error ERROR Wrong configuration: Unknown type of HAL frequency for $(BOARD) board: '$(HAL_FREQUENCY)')
+ endif
+
+else ifeq ($(BOARD), BOARD_STK500) ######### STK500 board #####
+ # Checking parameters which have been set by user.
+ ifeq (, $(findstring $(RFCHIP), AT86RF230 AT86RF230B AT86RF231 AT86RF212))
+ $(error ERROR Wrong configuration: Unknown type of RF chip for $(BOARD) board: '$(RFCHIP)')
+ endif
+
+ ifeq (, $(findstring $(HAL_FREQUENCY), HAL_8MHz HAL_4MHz))
+ $(error ERROR Wrong configuration: Unknown type of HAL frequency for $(BOARD) board: '$(HAL_FREQUENCY)')
+ endif
+
+ ifeq (, $(findstring $(HAL), ATMEGA1281 ATMEGA2561))
+ $(error ERROR Wrong configuration: Unknown type of HAL for $(BOARD) board: '$(HAL)')
+ endif
+
+else ifeq ($(BOARD), BOARD_PC) ##### PC board ####
+ HAL = X86
+ # HAL_CLOCK_SOURCE = CRYSTAL
+ # HAL_FREQUENCY = HAL_18d432MHz
+
+else ifeq ($(BOARD), BOARD_AVR32_EVK1105)
+ # Checking parameters which have been set by user.
+ ifeq (, $(findstring $(RFCHIP), AT86RF230 AT86RF230B AT86RF231 AT86RF212))
+ $(error ERROR Wrong configuration: Unknown type of RF chip for $(BOARD) board: '$(RFCHIP)')
+ endif
+
+ HAL = AT32UC3A0512
+
+else ifeq ($(BOARD), BOARD_XPLAIN) ######### Xplain board #####
+ # Checking parameters which have been set by user.
+ ifeq (, $(findstring $(RFCHIP), AT86RF230B AT86RF231 AT86RF212))
+ $(error ERROR Wrong configuration: Unknown type of RF chip for $(BOARD) board: '$(RFCHIP)')
+ endif
+
+ ifeq (, $(findstring $(HAL_FREQUENCY), HAL_16MHz HAL_32MHz HAL_12MHz HAL_8MHz HAL_4MHz))
+ $(error ERROR Wrong configuration: Unknown type of HAL frequency for $(BOARD) board: '$(HAL_FREQUENCY)')
+ endif
+
+ HAL = ATXMEGA128A1
+
+else ifeq ($(BOARD), BOARD_REB_CBB) ######### REB CBB board #####
+ # Checking parameters which have been set by user.
+ ifeq (, $(findstring $(RFCHIP), AT86RF230B AT86RF231 AT86RF212))
+ $(error ERROR Wrong configuration: Unknown type of RF chip for $(BOARD) board: '$(RFCHIP)')
+ endif
+
+ ifeq (, $(findstring $(HAL_FREQUENCY), HAL_16MHz HAL_32MHz HAL_12MHz HAL_8MHz HAL_4MHz))
+ $(error ERROR Wrong configuration: Unknown type of HAL frequency for $(BOARD) board: '$(HAL_FREQUENCY)')
+ endif
+
+ HAL = ATXMEGA256A3
+
+else ifeq ($(BOARD), BOARD_SIMULATOR) ######### Simulator board #####
+ HAL = SIMULATOR
+ RFCHIP = AT86RF231
+ HAL_FREQUENCY = HAL_0MHz
+
+else
+ $(error unknown BOARD)
+endif
+
+
+
+#-------------------------------------------------------------------------------
+# Automatic selection of Makerules and related parameters
+#-------------------------------------------------------------------------------
+ifndef LIB_TYPE
+ LIB_TYPE = Bc
+endif
+
+ifndef SECURITY_MODE
+ SECURITY_MODE = NO_SECURITY_MODE
+endif
+
+ifeq ($(COMPILER_TYPE), IAR)
+ LIB_NAME_COMPILER = _Iar
+else ifeq ($(COMPILER_TYPE), GCC)
+ LIB_NAME_COMPILER = _Gcc
+else
+ $(error unknown COMPILER_TYPE)
+endif
+
+ifneq ($(LIB_TYPE), HalSe)
+ ifeq ($(STACK_TYPE), ALL_DEVICES_TYPES)
+ LIB_NAME_DEV_TYPE = _All
+ else ifeq ($(STACK_TYPE), COORDINATOR)
+ LIB_NAME_DEV_TYPE = _Coordinator
+ else ifeq ($(STACK_TYPE), ROUTER)
+ LIB_NAME_DEV_TYPE = _Router
+ else ifeq ($(STACK_TYPE), ENDDEVICE)
+ LIB_NAME_DEV_TYPE = _EndDevice
+ else
+ $(error unknown STACK_TYPE)
+ endif
+
+ ifeq ($(SECURITY_MODE), NO_SECURITY_MODE)
+ LIB_NAME_SECURITY_MODE =
+ else ifeq ($(SECURITY_MODE), STANDARD_SECURITY_MODE)
+ LIB_NAME_SECURITY_MODE = _Sec
+ else ifeq ($(SECURITY_MODE), STDLINK_SECURITY_MODE)
+ LIB_NAME_SECURITY_MODE = _StdlinkSec
+ else ifeq ($(SECURITY_MODE), CERTICOM_SECURITY_MODE)
+ LIB_NAME_SECURITY_MODE = _SeSec
+ else ifeq ($(SECURITY_MODE), HIGH_SECURITY_MODE)
+ LIB_NAME_SECURITY_MODE = _HighSec
+ else ifeq ($(SECURITY_MODE), CUSTOM_4_SECURITY_MODE)
+ LIB_NAME_SECURITY_MODE = _Custom4Sec
+ else
+ $(error unknown SECURITY_MODE)
+ endif
+
+ ifeq ($(RFCHIP), AT86RF230)
+ LIB_NAME_RFCHIP = _Rf230
+ else ifeq ($(RFCHIP), AT86RF230B)
+ LIB_NAME_RFCHIP = _Rf230B
+ else ifeq ($(RFCHIP), AT86RF231)
+ LIB_NAME_RFCHIP = _Rf231
+ else ifeq ($(RFCHIP), AT86RF212)
+ LIB_NAME_RFCHIP = _Rf212
+ else ifeq ($(RFCHIP), ATMEGA128RFA1)
+ LIB_NAME_RFCHIP = _Atmega128rfa1
+ else ifeq ($(RFCHIP), CUSTOMRF3)
+ LIB_NAME_RFCHIP = _CustomRf3
+ else
+ $(error unknown LIB_TYPE)
+ endif
+endif
+
+
+ifeq ( , $(findstring $(HAL), AT91SAM7X256 X86 AT32UC3A0512))
+ ifeq ($(HAL_FREQUENCY), HAL_0MHz)
+ LIB_NAME_HAL_FREQ = _0Mhz
+ else ifeq ($(HAL_FREQUENCY), HAL_4MHz)
+ LIB_NAME_HAL_FREQ = _4Mhz
+ else ifeq ($(HAL_FREQUENCY), HAL_8MHz)
+ LIB_NAME_HAL_FREQ = _8Mhz
+ else ifeq ($(HAL_FREQUENCY), HAL_12MHz)
+ LIB_NAME_HAL_FREQ = _12Mhz
+ else ifeq ($(HAL_FREQUENCY), HAL_16MHz)
+ LIB_NAME_HAL_FREQ = _16Mhz
+ else ifeq ($(HAL_FREQUENCY), HAL_32MHz)
+ LIB_NAME_HAL_FREQ = _32Mhz
+ else ifeq ($(HAL_FREQUENCY), HAL_64MHz)
+ LIB_NAME_HAL_FREQ = _64Mhz
+ else
+ $(error unknown HAL_FREQUENCY)
+ endif
+endif
+
+ifeq ($(BOARD), BOARD_MESHBEAN)
+ HAL_LIB_NAME_PLATFORM = _ZigBit
+else ifeq ($(BOARD), BOARD_USB_DONGLE)
+ HAL_LIB_NAME_PLATFORM = _AtmlUsbDongle
+else ifeq ($(BOARD), BOARD_STK600)
+ HAL_LIB_NAME_PLATFORM = _AtmlStk600
+else ifeq ($(BOARD), BOARD_STK500)
+ HAL_LIB_NAME_PLATFORM = _AtmlStk500Rf2xx
+else ifeq ($(BOARD), BOARD_SAM7X_EK)
+ HAL_LIB_NAME_PLATFORM = _Sam7xEkRf2xx
+else ifeq ($(BOARD), BOARD_SAM3S_EK)
+ HAL_LIB_NAME_PLATFORM = _Sam3sEkRf2xx
+else ifeq ($(BOARD), BOARD_SAM3S_PIRRD)
+ HAL_LIB_NAME_PLATFORM = _Sam3sPirrd
+else ifeq ($(BOARD), BOARD_MESHBEAN_LAN)
+ HAL_LIB_NAME_PLATFORM = _ZigBitLan
+else ifeq ($(BOARD), BOARD_CUSTOM_1)
+ HAL_LIB_NAME_PLATFORM = _Custom1
+else ifeq ($(BOARD), BOARD_CUSTOM_2)
+ HAL_LIB_NAME_PLATFORM = _Custom2
+else ifeq ($(BOARD), BOARD_CUSTOM_3)
+ HAL_LIB_NAME_PLATFORM = _Custom3
+else ifeq ($(BOARD), BOARD_RAVEN)
+ HAL_LIB_NAME_PLATFORM = _Raven
+else ifeq ($(BOARD), BOARD_RCB)
+ ifeq ($(BOARD_REV), RCB_ATMEGA128RFA1)
+ HAL_LIB_NAME_PLATFORM = _RcbAtm128rfa1
+ else
+ ifneq (, $(findstring $(BOARD_REV), RCB230_V31 RCB230_V32 RCB230_V331))
+ HAL_LIB_NAME_PLATFORM = _Rcb230
+ endif
+ ifneq (, $(findstring $(BOARD_REV), RCB231_V402 RCB231_V411 RCB212_V532))
+ HAL_LIB_NAME_PLATFORM = _Rcb231_212
+ endif
+ endif # BOARD_REV
+else ifeq ($(BOARD), BOARD_PC)
+ HAL_LIB_NAME_PLATFORM = _PC
+else ifeq ($(BOARD), BOARD_AVR32_EVK1105)
+ HAL_LIB_NAME_PLATFORM = _Avr32Evk1105
+else ifeq ($(BOARD), BOARD_XPLAIN)
+ HAL_LIB_NAME_PLATFORM = _Xplain
+else ifeq ($(BOARD), BOARD_REB_CBB)
+ ifneq (, $(findstring $(RFCHIP), AT86RF230B))
+ HAL_LIB_NAME_PLATFORM = _RebCbb230
+ endif
+ ifneq (, $(findstring $(RFCHIP), AT86RF231 AT86RF212))
+ HAL_LIB_NAME_PLATFORM = _RebCbb231_212
+ endif
+else ifeq ($(BOARD), BOARD_SIMULATOR)
+ HAL_LIB_NAME_PLATFORM = _Sim
+else
+ $(error unknown HAL_LIB_NAME_PLATFORM for board $(BOARD))
+endif
+
+ifeq ($(HAL), ATMEGA1281)
+ LIB_NAME_MICRO = _Atmega1281
+else ifeq ($(HAL), ATMEGA2561)
+ LIB_NAME_MICRO = _Atmega2561
+else ifeq ($(HAL), AT90USB1287)
+ LIB_NAME_MICRO = _At90usb1287
+else ifeq ($(HAL), ATMEGA1284)
+ LIB_NAME_MICRO = _Atmega1284
+else ifeq ($(HAL), ATXMEGA128A1)
+ LIB_NAME_MICRO = _Atxmega128a1
+else ifeq ($(HAL), ATXMEGA256A3)
+ LIB_NAME_MICRO = _Atxmega256a3
+else ifeq ($(HAL), ATXMEGA256D3)
+ LIB_NAME_MICRO = _Atxmega256d3
+else ifeq ($(HAL), ATMEGA128RFA1)
+ LIB_NAME_MICRO = _Atmega128rfa1
+else ifeq ($(HAL), AT91SAM7X256)
+ LIB_NAME_MICRO = _At91sam7x256
+else ifeq ($(HAL), AT91SAM3S4C)
+ LIB_NAME_MICRO = _At91sam3s4c
+else ifeq ($(HAL), X86)
+ LIB_NAME_MICRO = _x86
+else ifeq ($(HAL), AT32UC3A0512)
+ LIB_NAME_MICRO = _At32uc3a0512
+else ifeq ($(HAL), SIMULATOR)
+ LIB_NAME_MICRO = _Sim
+else
+ $(error unknown HAL)
+endif
+
+ifeq ($(HAL_USE_AMPLIFIER), TRUE)
+ LIB_NAME_AMP = _Amp
+endif
+
+ifeq ($(USE_KF_MAC), TRUE)
+ LIB_NAME_KF = _Kf
+endif
+
+LIB_MAKERULES = Makerules$(LIB_TYPE)$(LIB_NAME_KF)$(LIB_NAME_DEV_TYPE)$(LIB_NAME_SECURITY_MODE)$(LIB_NAME_MICRO)$(LIB_NAME_RFCHIP)$(LIB_NAME_COMPILER)
+STACK_LIB = $(LIB_TYPE)$(LIB_NAME_KF)$(LIB_NAME_DEV_TYPE)$(LIB_NAME_SECURITY_MODE)$(LIB_NAME_MICRO)$(LIB_NAME_RFCHIP)$(LIB_NAME_COMPILER)
+HAL_LIB = HAL$(HAL_LIB_NAME_PLATFORM)$(LIB_NAME_MICRO)$(LIB_NAME_HAL_FREQ)$(LIB_NAME_COMPILER)$(LIB_NAME_AMP)$(LIB_NAME_KF)
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesSelector.h b/digital/zigbit/bitcloud/stack/lib/MakerulesSelector.h
new file mode 100644
index 00000000..6f68db52
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesSelector.h
@@ -0,0 +1,15813 @@
+// This is automatically generated file, do not edit
+
+#if !defined(BOARD_SAM3S_EK) && !defined(BOARD_SIMULATOR) && !defined(BOARD_REB_CBB) && !defined(BOARD_RAVEN) && !defined(BOARD_AVR32_EVK1105) && !defined(BOARD_STK600) && !defined(BOARD_PC) && !defined(BOARD_USB_DONGLE) && !defined(BOARD_SAM7X_EK) && !defined(BOARD_CUSTOM_3) && !defined(BOARD_RCB) && !defined(BOARD_XPLAIN) && !defined(BOARD_MESHBEAN)
+# error invalid BOARD
+#endif
+#ifdef BOARD_SAM3S_EK
+# if !defined(AT91SAM3S4C)
+# error invalid HAL
+# endif
+#endif
+#ifdef BOARD_SIMULATOR
+# if !defined(SIMULATOR)
+# error invalid HAL
+# endif
+#endif
+#ifdef BOARD_REB_CBB
+# if !defined(ATXMEGA256A3)
+# error invalid HAL
+# endif
+#endif
+#ifdef BOARD_RAVEN
+# if !defined(ATMEGA1284)
+# error invalid HAL
+# endif
+#endif
+#ifdef BOARD_AVR32_EVK1105
+# if !defined(AT32UC3A0512)
+# error invalid HAL
+# endif
+#endif
+#ifdef BOARD_STK600
+# if !defined(ATXMEGA256A3) && !defined(ATXMEGA128A1) && !defined(ATXMEGA256D3) && !defined(ATMEGA128RFA1)
+# error invalid HAL
+# endif
+#endif
+#ifdef BOARD_PC
+# if !defined(X86)
+# error invalid HAL
+# endif
+#endif
+#ifdef BOARD_USB_DONGLE
+# if !defined(AT90USB1287)
+# error invalid HAL
+# endif
+#endif
+#ifdef BOARD_SAM7X_EK
+# if !defined(AT91SAM7X256)
+# error invalid HAL
+# endif
+#endif
+#ifdef BOARD_CUSTOM_3
+# if !defined(AT91SAM3S4C)
+# error invalid HAL
+# endif
+#endif
+#ifdef BOARD_RCB
+# if !defined(ATMEGA128RFA1) && !defined(ATMEGA1281)
+# error invalid HAL
+# endif
+#endif
+#ifdef BOARD_XPLAIN
+# if !defined(ATXMEGA128A1)
+# error invalid HAL
+# endif
+#endif
+#ifdef BOARD_MESHBEAN
+# if !defined(ATMEGA1281) && !defined(ATMEGA2561)
+# error invalid HAL
+# endif
+#endif
+#if !defined(LIB_TYPE_HALSE)
+# if !defined(STACK_TYPE_ALL) && !defined(STACK_TYPE_COORDINATOR) && !defined(STACK_TYPE_ROUTER) && !defined(STACK_TYPE_ENDDEVICE)
+# error invalid STACK_TYPE
+# endif
+# if !defined(STANDARD_SECURITY_MODE) && !defined(DUMMY_ECC_SECURITY_MODE) && !defined(HIGH_SECURITY_MODE) && !defined(NO_SECURITY_MODE) && !defined(CERTICOM_SECURITY_MODE)
+# error invalid SECURITY_MODE
+# endif
+# ifdef BOARD_SAM3S_EK
+# if !defined(AT86RF230) && !defined(AT86RF230B) && !defined(AT86RF231) && !defined(AT86RF212)
+# error invalid RFCHIP
+# endif
+# if !defined(HAL_4MHz) && !defined(HAL_8MHz) && !defined(HAL_16MHz) && !defined(HAL_64MHz)
+# error invalid HAL_FREQUENCY
+# endif
+# endif
+# ifdef BOARD_SIMULATOR
+# if !defined(AT86RF231)
+# error invalid RFCHIP
+# endif
+# if !defined(HAL_0MHz)
+# error invalid HAL_FREQUENCY
+# endif
+# endif
+# ifdef BOARD_REB_CBB
+# if !defined(AT86RF230B) && !defined(AT86RF231) && !defined(AT86RF212)
+# error invalid RFCHIP
+# endif
+# if !defined(HAL_4MHz) && !defined(HAL_8MHz) && !defined(HAL_12MHz) && !defined(HAL_16MHz) && !defined(HAL_32MHz)
+# error invalid HAL_FREQUENCY
+# endif
+# endif
+# ifdef BOARD_RAVEN
+# if !defined(AT86RF230B)
+# error invalid RFCHIP
+# endif
+# if !defined(HAL_4MHz) && !defined(HAL_8MHz)
+# error invalid HAL_FREQUENCY
+# endif
+# endif
+# ifdef BOARD_AVR32_EVK1105
+# if !defined(AT86RF230) && !defined(AT86RF230B) && !defined(AT86RF231) && !defined(AT86RF212)
+# error invalid RFCHIP
+# endif
+# if !defined(HAL_48MHz)
+# error invalid HAL_FREQUENCY
+# endif
+# endif
+# ifdef BOARD_STK600
+# if !defined(AT86RF230) && !defined(AT86RF230B) && !defined(AT86RF231) && !defined(AT86RF212) && !defined(ATMEGA128RFA1)
+# error invalid RFCHIP
+# endif
+# if !defined(HAL_4MHz) && !defined(HAL_8MHz) && !defined(HAL_12MHz) && !defined(HAL_16MHz) && !defined(HAL_32MHz)
+# error invalid HAL_FREQUENCY
+# endif
+# endif
+# ifdef BOARD_PC
+# endif
+# ifdef BOARD_USB_DONGLE
+# if !defined(AT86RF230B)
+# error invalid RFCHIP
+# endif
+# if !defined(HAL_8MHz)
+# error invalid HAL_FREQUENCY
+# endif
+# endif
+# ifdef BOARD_SAM7X_EK
+# if !defined(AT86RF230) && !defined(AT86RF230B) && !defined(AT86RF231) && !defined(AT86RF212)
+# error invalid RFCHIP
+# endif
+# if !defined(HAL_48MHz)
+# error invalid HAL_FREQUENCY
+# endif
+# endif
+# ifdef BOARD_CUSTOM_3
+# if !defined(CUSTOMRF3)
+# error invalid RFCHIP
+# endif
+# if !defined(HAL_4MHz) && !defined(HAL_8MHz) && !defined(HAL_16MHz) && !defined(HAL_64MHz)
+# error invalid HAL_FREQUENCY
+# endif
+# endif
+# ifdef BOARD_RCB
+# if !defined(ATMEGA128RFA1) && !defined(AT86RF230) && !defined(AT86RF230B) && !defined(AT86RF231) && !defined(AT86RF212)
+# error invalid RFCHIP
+# endif
+# if !defined(HAL_4MHz) && !defined(HAL_8MHz)
+# error invalid HAL_FREQUENCY
+# endif
+# endif
+# ifdef BOARD_XPLAIN
+# if !defined(AT86RF230B) && !defined(AT86RF231) && !defined(AT86RF212)
+# error invalid RFCHIP
+# endif
+# if !defined(HAL_4MHz) && !defined(HAL_8MHz) && !defined(HAL_12MHz) && !defined(HAL_16MHz) && !defined(HAL_32MHz)
+# error invalid HAL_FREQUENCY
+# endif
+# endif
+# ifdef BOARD_MESHBEAN
+# if !defined(AT86RF230) && !defined(AT86RF230B) && !defined(AT86RF231) && !defined(AT86RF212)
+# error invalid RFCHIP
+# endif
+# if !defined(HAL_4MHz) && !defined(HAL_8MHz)
+# error invalid HAL_FREQUENCY
+# endif
+# endif
+#endif
+
+#if defined(__GNUC__)
+# if defined(LIB_TYPE_ZCL)
+# ifdef STACK_TYPE_ALL
+# ifdef STANDARD_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_All_Sec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // STANDARD_SECURITY_MODE
+# ifdef DUMMY_ECC_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_All_SESec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // DUMMY_ECC_SECURITY_MODE
+# ifdef HIGH_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_All_HighSec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // HIGH_SECURITY_MODE
+# ifdef NO_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_All_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_All_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_All_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_All_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_All_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // NO_SECURITY_MODE
+# ifdef CERTICOM_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_All_SESec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // CERTICOM_SECURITY_MODE
+# endif // STACK_TYPE_ALL
+# ifdef STACK_TYPE_COORDINATOR
+# ifdef STANDARD_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Coordinator_Sec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // STANDARD_SECURITY_MODE
+# ifdef DUMMY_ECC_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Coordinator_SESec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // DUMMY_ECC_SECURITY_MODE
+# ifdef HIGH_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Coordinator_HighSec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // HIGH_SECURITY_MODE
+# ifdef NO_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Coordinator_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // NO_SECURITY_MODE
+# ifdef CERTICOM_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Coordinator_SESec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // CERTICOM_SECURITY_MODE
+# endif // STACK_TYPE_COORDINATOR
+# ifdef STACK_TYPE_ROUTER
+# ifdef STANDARD_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Router_Sec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // STANDARD_SECURITY_MODE
+# ifdef DUMMY_ECC_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Router_SESec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // DUMMY_ECC_SECURITY_MODE
+# ifdef HIGH_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Router_HighSec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // HIGH_SECURITY_MODE
+# ifdef NO_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Router_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // NO_SECURITY_MODE
+# ifdef CERTICOM_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Router_SESec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // CERTICOM_SECURITY_MODE
+# endif // STACK_TYPE_ROUTER
+# ifdef STACK_TYPE_ENDDEVICE
+# ifdef STANDARD_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_EndDevice_Sec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // STANDARD_SECURITY_MODE
+# ifdef DUMMY_ECC_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_EndDevice_SESec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // DUMMY_ECC_SECURITY_MODE
+# ifdef HIGH_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_EndDevice_HighSec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // HIGH_SECURITY_MODE
+# ifdef NO_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_EndDevice_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // NO_SECURITY_MODE
+# ifdef CERTICOM_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_EndDevice_SESec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // CERTICOM_SECURITY_MODE
+# endif // STACK_TYPE_ENDDEVICE
+# elif defined(LIB_TYPE_HALSE)
+# ifdef ATXMEGA256A3
+# include <MakerulesHalSe_Atxmega256a3_Gcc.h>
+# endif
+# ifdef ATMEGA128RFA1
+# include <MakerulesHalSe_Atmega128rfa1_Gcc.h>
+# endif
+# ifdef AT32UC3A0512
+# include <MakerulesHalSe_At32uc3a0512_Gcc.h>
+# endif
+# ifdef AT91SAM7X256
+# include <MakerulesHalSe_At91sam7x256_Gcc.h>
+# endif
+# ifdef ATXMEGA256D3
+# include <MakerulesHalSe_Atxmega256d3_Gcc.h>
+# endif
+# ifdef ATXMEGA128A1
+# include <MakerulesHalSe_Atxmega128a1_Gcc.h>
+# endif
+# ifdef ATMEGA2561
+# include <MakerulesHalSe_Atmega2561_Gcc.h>
+# endif
+# ifdef SIMULATOR
+# include <MakerulesHalSe_Sim_Gcc.h>
+# endif
+# ifdef AT91SAM3S4C
+# include <MakerulesHalSe_At91sam3s4c_Gcc.h>
+# endif
+# ifdef ATMEGA1284
+# include <MakerulesHalSe_Atmega1284_Gcc.h>
+# endif
+# ifdef AT90USB1287
+# include <MakerulesHalSe_At90usb1287_Gcc.h>
+# endif
+# ifdef ATMEGA1281
+# include <MakerulesHalSe_Atmega1281_Gcc.h>
+# endif
+# else // LIB_TYPE_BITCLOUD
+# ifdef STACK_TYPE_ALL
+# ifdef STANDARD_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_All_Sec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // STANDARD_SECURITY_MODE
+# ifdef DUMMY_ECC_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_All_SESec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // DUMMY_ECC_SECURITY_MODE
+# ifdef HIGH_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_All_HighSec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // HIGH_SECURITY_MODE
+# ifdef NO_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_All_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_All_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_All_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_All_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_All_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_All_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_All_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_All_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_All_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_All_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_All_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // NO_SECURITY_MODE
+# ifdef CERTICOM_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_All_SESec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // CERTICOM_SECURITY_MODE
+# endif // STACK_TYPE_ALL
+# ifdef STACK_TYPE_COORDINATOR
+# ifdef STANDARD_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Coordinator_Sec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // STANDARD_SECURITY_MODE
+# ifdef DUMMY_ECC_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Coordinator_SESec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // DUMMY_ECC_SECURITY_MODE
+# ifdef HIGH_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Coordinator_HighSec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // HIGH_SECURITY_MODE
+# ifdef NO_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Coordinator_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // NO_SECURITY_MODE
+# ifdef CERTICOM_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Coordinator_SESec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // CERTICOM_SECURITY_MODE
+# endif // STACK_TYPE_COORDINATOR
+# ifdef STACK_TYPE_ROUTER
+# ifdef STANDARD_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Router_Sec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // STANDARD_SECURITY_MODE
+# ifdef DUMMY_ECC_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Router_SESec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // DUMMY_ECC_SECURITY_MODE
+# ifdef HIGH_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Router_HighSec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // HIGH_SECURITY_MODE
+# ifdef NO_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Router_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Router_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Router_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Router_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Router_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // NO_SECURITY_MODE
+# ifdef CERTICOM_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Router_SESec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // CERTICOM_SECURITY_MODE
+# endif // STACK_TYPE_ROUTER
+# ifdef STACK_TYPE_ENDDEVICE
+# ifdef STANDARD_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_EndDevice_Sec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // STANDARD_SECURITY_MODE
+# ifdef DUMMY_ECC_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_EndDevice_SESec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // DUMMY_ECC_SECURITY_MODE
+# ifdef HIGH_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_EndDevice_HighSec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // HIGH_SECURITY_MODE
+# ifdef NO_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_EndDevice_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // NO_SECURITY_MODE
+# ifdef CERTICOM_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_EndDevice_SESec_Atmega128rfa1_Atmega128rfa1_Gcc.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_Rf212_Gcc.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_Rf212_Gcc.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Sim_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Sim_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Sim_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Sim_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Sim_Rf212_Gcc.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_Rf212_Gcc.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_Rf212_Gcc.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_Rf231_Gcc.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_Rf230_Gcc.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_Rf230B_Gcc.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_CustomRf3_Gcc.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_Rf212_Gcc.h>
+# endif
+# endif // ATMEGA1281
+# endif // CERTICOM_SECURITY_MODE
+# endif // STACK_TYPE_ENDDEVICE
+# endif
+#endif // GCC
+#if defined(__ICCAVR__) || defined(__ICCARM__) || defined(__ICCAVR32__)
+# if defined(LIB_TYPE_ZCL)
+# ifdef STACK_TYPE_ALL
+# ifdef STANDARD_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_All_Sec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // STANDARD_SECURITY_MODE
+# ifdef DUMMY_ECC_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_All_SESec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // DUMMY_ECC_SECURITY_MODE
+# ifdef HIGH_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_All_HighSec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_All_HighSec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_HighSec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_HighSec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_HighSec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_HighSec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // HIGH_SECURITY_MODE
+# ifdef NO_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_All_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_All_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_All_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_All_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_All_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_All_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // NO_SECURITY_MODE
+# ifdef CERTICOM_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_All_SESec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_All_SESec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_All_SESec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_All_SESec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_All_SESec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_All_SESec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // CERTICOM_SECURITY_MODE
+# endif // STACK_TYPE_ALL
+# ifdef STACK_TYPE_COORDINATOR
+# ifdef STANDARD_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Coordinator_Sec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // STANDARD_SECURITY_MODE
+# ifdef DUMMY_ECC_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Coordinator_SESec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // DUMMY_ECC_SECURITY_MODE
+# ifdef HIGH_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Coordinator_HighSec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_HighSec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // HIGH_SECURITY_MODE
+# ifdef NO_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Coordinator_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // NO_SECURITY_MODE
+# ifdef CERTICOM_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Coordinator_SESec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Coordinator_SESec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // CERTICOM_SECURITY_MODE
+# endif // STACK_TYPE_COORDINATOR
+# ifdef STACK_TYPE_ROUTER
+# ifdef STANDARD_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Router_Sec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // STANDARD_SECURITY_MODE
+# ifdef DUMMY_ECC_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Router_SESec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // DUMMY_ECC_SECURITY_MODE
+# ifdef HIGH_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Router_HighSec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_HighSec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_HighSec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_HighSec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_HighSec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_HighSec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // HIGH_SECURITY_MODE
+# ifdef NO_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Router_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // NO_SECURITY_MODE
+# ifdef CERTICOM_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_Router_SESec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_Router_SESec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_Router_SESec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_Router_SESec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_Router_SESec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_Router_SESec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // CERTICOM_SECURITY_MODE
+# endif // STACK_TYPE_ROUTER
+# ifdef STACK_TYPE_ENDDEVICE
+# ifdef STANDARD_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_EndDevice_Sec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // STANDARD_SECURITY_MODE
+# ifdef DUMMY_ECC_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_EndDevice_SESec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // DUMMY_ECC_SECURITY_MODE
+# ifdef HIGH_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_EndDevice_HighSec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_HighSec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // HIGH_SECURITY_MODE
+# ifdef NO_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_EndDevice_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // NO_SECURITY_MODE
+# ifdef CERTICOM_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesZcl_EndDevice_SESec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesZcl_EndDevice_SESec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // CERTICOM_SECURITY_MODE
+# endif // STACK_TYPE_ENDDEVICE
+# elif defined(LIB_TYPE_HALSE)
+# ifdef ATXMEGA256A3
+# include <MakerulesHalSe_Atxmega256a3_Iar.h>
+# endif
+# ifdef ATMEGA128RFA1
+# include <MakerulesHalSe_Atmega128rfa1_Iar.h>
+# endif
+# ifdef AT32UC3A0512
+# include <MakerulesHalSe_At32uc3a0512_Iar.h>
+# endif
+# ifdef AT91SAM7X256
+# include <MakerulesHalSe_At91sam7x256_Iar.h>
+# endif
+# ifdef ATXMEGA256D3
+# include <MakerulesHalSe_Atxmega256d3_Iar.h>
+# endif
+# ifdef ATXMEGA128A1
+# include <MakerulesHalSe_Atxmega128a1_Iar.h>
+# endif
+# ifdef ATMEGA2561
+# include <MakerulesHalSe_Atmega2561_Iar.h>
+# endif
+# ifdef SIMULATOR
+# include <MakerulesHalSe_Sim_Iar.h>
+# endif
+# ifdef AT91SAM3S4C
+# include <MakerulesHalSe_At91sam3s4c_Iar.h>
+# endif
+# ifdef ATMEGA1284
+# include <MakerulesHalSe_Atmega1284_Iar.h>
+# endif
+# ifdef AT90USB1287
+# include <MakerulesHalSe_At90usb1287_Iar.h>
+# endif
+# ifdef ATMEGA1281
+# include <MakerulesHalSe_Atmega1281_Iar.h>
+# endif
+# else // LIB_TYPE_BITCLOUD
+# ifdef STACK_TYPE_ALL
+# ifdef STANDARD_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_All_Sec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // STANDARD_SECURITY_MODE
+# ifdef DUMMY_ECC_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_All_SESec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // DUMMY_ECC_SECURITY_MODE
+# ifdef HIGH_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_All_HighSec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_All_HighSec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_HighSec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_HighSec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_HighSec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_HighSec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // HIGH_SECURITY_MODE
+# ifdef NO_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_All_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_All_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_All_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_All_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_All_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_All_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_All_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_All_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_All_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_All_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_All_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_All_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // NO_SECURITY_MODE
+# ifdef CERTICOM_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_All_SESec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_All_SESec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_All_SESec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_All_SESec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_All_SESec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_All_SESec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // CERTICOM_SECURITY_MODE
+# endif // STACK_TYPE_ALL
+# ifdef STACK_TYPE_COORDINATOR
+# ifdef STANDARD_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Coordinator_Sec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // STANDARD_SECURITY_MODE
+# ifdef DUMMY_ECC_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Coordinator_SESec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // DUMMY_ECC_SECURITY_MODE
+# ifdef HIGH_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Coordinator_HighSec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_HighSec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_HighSec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_HighSec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_HighSec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_HighSec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // HIGH_SECURITY_MODE
+# ifdef NO_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Coordinator_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // NO_SECURITY_MODE
+# ifdef CERTICOM_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Coordinator_SESec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Coordinator_SESec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // CERTICOM_SECURITY_MODE
+# endif // STACK_TYPE_COORDINATOR
+# ifdef STACK_TYPE_ROUTER
+# ifdef STANDARD_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Router_Sec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // STANDARD_SECURITY_MODE
+# ifdef DUMMY_ECC_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Router_SESec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // DUMMY_ECC_SECURITY_MODE
+# ifdef HIGH_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Router_HighSec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Router_HighSec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_HighSec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_HighSec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_HighSec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_HighSec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // HIGH_SECURITY_MODE
+# ifdef NO_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Router_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Router_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Router_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Router_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Router_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Router_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // NO_SECURITY_MODE
+# ifdef CERTICOM_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_Router_SESec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_Router_SESec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_Router_SESec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_Router_SESec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_Router_SESec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_Router_SESec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // CERTICOM_SECURITY_MODE
+# endif // STACK_TYPE_ROUTER
+# ifdef STACK_TYPE_ENDDEVICE
+# ifdef STANDARD_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_EndDevice_Sec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // STANDARD_SECURITY_MODE
+# ifdef DUMMY_ECC_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_EndDevice_SESec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // DUMMY_ECC_SECURITY_MODE
+# ifdef HIGH_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_EndDevice_HighSec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_HighSec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_HighSec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_HighSec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_HighSec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_HighSec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // HIGH_SECURITY_MODE
+# ifdef NO_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_EndDevice_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // NO_SECURITY_MODE
+# ifdef CERTICOM_SECURITY_MODE
+# ifdef ATXMEGA256A3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atxmega256a3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256A3
+# ifdef ATMEGA128RFA1
+# ifdef ATMEGA128RFA1
+# include <MakerulesBc_EndDevice_SESec_Atmega128rfa1_Atmega128rfa1_Iar.h>
+# endif
+# endif // ATMEGA128RFA1
+# ifdef AT32UC3A0512
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_At32uc3a0512_Rf212_Iar.h>
+# endif
+# endif // AT32UC3A0512
+# ifdef AT91SAM7X256
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_At91sam7x256_Rf212_Iar.h>
+# endif
+# endif // AT91SAM7X256
+# ifdef ATXMEGA256D3
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atxmega256d3_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA256D3
+# ifdef ATXMEGA128A1
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atxmega128a1_Rf212_Iar.h>
+# endif
+# endif // ATXMEGA128A1
+# ifdef ATMEGA2561
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atmega2561_Rf212_Iar.h>
+# endif
+# endif // ATMEGA2561
+# ifdef SIMULATOR
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Sim_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Sim_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Sim_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Sim_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Sim_Rf212_Iar.h>
+# endif
+# endif // SIMULATOR
+# ifdef AT91SAM3S4C
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_At91sam3s4c_Rf212_Iar.h>
+# endif
+# endif // AT91SAM3S4C
+# ifdef ATMEGA1284
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atmega1284_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1284
+# ifdef AT90USB1287
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_At90usb1287_Rf212_Iar.h>
+# endif
+# endif // AT90USB1287
+# ifdef ATMEGA1281
+# ifdef AT86RF231
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_Rf231_Iar.h>
+# endif
+# ifdef AT86RF230
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_Rf230_Iar.h>
+# endif
+# ifdef AT86RF230B
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_Rf230B_Iar.h>
+# endif
+# ifdef CUSTOMRF3
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_CustomRf3_Iar.h>
+# endif
+# ifdef AT86RF212
+# include <MakerulesBc_EndDevice_SESec_Atmega1281_Rf212_Iar.h>
+# endif
+# endif // ATMEGA1281
+# endif // CERTICOM_SECURITY_MODE
+# endif // STACK_TYPE_ENDDEVICE
+# endif
+#endif // IAR
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Atmega1281_Rf212_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Atmega1281_Rf212_Gcc
new file mode 100644
index 00000000..c3c4c53b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Atmega1281_Rf212_Gcc
@@ -0,0 +1,34 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF212 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_SYS_ZCL_TASK_ -D_COORDINATOR_ -D_ROUTER_ -D_ENDDEVICE_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_BINDING_ -D_ZCL_ -D_OTAU_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+OFD_LIB = OFD
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+ZCL_PATH = $(COMPONENTS_PATH)/./ZCL
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Atmega1281_Rf212_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Atmega1281_Rf212_Gcc.h
new file mode 100644
index 00000000..bec5fe8e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Atmega1281_Rf212_Gcc.h
@@ -0,0 +1,85 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SYS_ZCL_TASK_
+#define _SYS_ZCL_TASK_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _ZCL_
+#define _ZCL_
+#endif
+#ifndef _OTAU_
+#define _OTAU_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Atmega1281_Rf230_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Atmega1281_Rf230_Gcc
new file mode 100644
index 00000000..efe56067
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Atmega1281_Rf230_Gcc
@@ -0,0 +1,34 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_SYS_ZCL_TASK_ -D_COORDINATOR_ -D_ROUTER_ -D_ENDDEVICE_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_BINDING_ -D_ZCL_ -D_OTAU_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+OFD_LIB = OFD
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+ZCL_PATH = $(COMPONENTS_PATH)/./ZCL
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Atmega1281_Rf230_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Atmega1281_Rf230_Gcc.h
new file mode 100644
index 00000000..bec5fe8e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Atmega1281_Rf230_Gcc.h
@@ -0,0 +1,85 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SYS_ZCL_TASK_
+#define _SYS_ZCL_TASK_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _ZCL_
+#define _ZCL_
+#endif
+#ifndef _OTAU_
+#define _OTAU_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Sec_Atmega1281_Rf212_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Sec_Atmega1281_Rf212_Gcc
new file mode 100644
index 00000000..2be50fe8
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Sec_Atmega1281_Rf212_Gcc
@@ -0,0 +1,34 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF212 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SYS_ZCL_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_MAC_HW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_COORDINATOR_ -D_ROUTER_ -D_ENDDEVICE_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_BINDING_ -D_ZCL_ -D_OTAU_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+OFD_LIB = OFD
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+ZCL_PATH = $(COMPONENTS_PATH)/./ZCL
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Sec_Atmega1281_Rf212_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Sec_Atmega1281_Rf212_Gcc.h
new file mode 100644
index 00000000..aa6621fd
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Sec_Atmega1281_Rf212_Gcc.h
@@ -0,0 +1,106 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SYS_ZCL_TASK_
+#define _SYS_ZCL_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _MAC_HW_AES_
+#define _MAC_HW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _ZCL_
+#define _ZCL_
+#endif
+#ifndef _OTAU_
+#define _OTAU_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Sec_Atmega1281_Rf230_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Sec_Atmega1281_Rf230_Gcc
new file mode 100644
index 00000000..f1d814fb
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Sec_Atmega1281_Rf230_Gcc
@@ -0,0 +1,34 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SYS_ZCL_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_COORDINATOR_ -D_ROUTER_ -D_ENDDEVICE_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_BINDING_ -D_ZCL_ -D_OTAU_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+OFD_LIB = OFD
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+ZCL_PATH = $(COMPONENTS_PATH)/./ZCL
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Sec_Atmega1281_Rf230_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Sec_Atmega1281_Rf230_Gcc.h
new file mode 100644
index 00000000..408be86a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_All_Sec_Atmega1281_Rf230_Gcc.h
@@ -0,0 +1,106 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SYS_ZCL_TASK_
+#define _SYS_ZCL_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _ZCL_
+#define _ZCL_
+#endif
+#ifndef _OTAU_
+#define _OTAU_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Atmega1281_Rf212_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Atmega1281_Rf212_Gcc
new file mode 100644
index 00000000..3e8d7642
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Atmega1281_Rf212_Gcc
@@ -0,0 +1,34 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF212 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_SYS_ZCL_TASK_ -D_COORDINATOR_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_BINDING_ -D_ZCL_ -D_OTAU_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+OFD_LIB = OFD
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+ZCL_PATH = $(COMPONENTS_PATH)/./ZCL
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Atmega1281_Rf212_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Atmega1281_Rf212_Gcc.h
new file mode 100644
index 00000000..93cf43e1
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Atmega1281_Rf212_Gcc.h
@@ -0,0 +1,79 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SYS_ZCL_TASK_
+#define _SYS_ZCL_TASK_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _ZCL_
+#define _ZCL_
+#endif
+#ifndef _OTAU_
+#define _OTAU_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Atmega1281_Rf230_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Atmega1281_Rf230_Gcc
new file mode 100644
index 00000000..48907abc
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Atmega1281_Rf230_Gcc
@@ -0,0 +1,34 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_SYS_ZCL_TASK_ -D_COORDINATOR_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_BINDING_ -D_ZCL_ -D_OTAU_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+OFD_LIB = OFD
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+ZCL_PATH = $(COMPONENTS_PATH)/./ZCL
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Atmega1281_Rf230_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Atmega1281_Rf230_Gcc.h
new file mode 100644
index 00000000..93cf43e1
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Atmega1281_Rf230_Gcc.h
@@ -0,0 +1,79 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SYS_ZCL_TASK_
+#define _SYS_ZCL_TASK_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _ZCL_
+#define _ZCL_
+#endif
+#ifndef _OTAU_
+#define _OTAU_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Sec_Atmega1281_Rf212_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Sec_Atmega1281_Rf212_Gcc
new file mode 100644
index 00000000..034a2e5f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Sec_Atmega1281_Rf212_Gcc
@@ -0,0 +1,34 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF212 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SYS_ZCL_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_MAC_HW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_COORDINATOR_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_BINDING_ -D_ZCL_ -D_OTAU_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+OFD_LIB = OFD
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+ZCL_PATH = $(COMPONENTS_PATH)/./ZCL
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Sec_Atmega1281_Rf212_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Sec_Atmega1281_Rf212_Gcc.h
new file mode 100644
index 00000000..2285ba4f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Sec_Atmega1281_Rf212_Gcc.h
@@ -0,0 +1,100 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SYS_ZCL_TASK_
+#define _SYS_ZCL_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _MAC_HW_AES_
+#define _MAC_HW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _ZCL_
+#define _ZCL_
+#endif
+#ifndef _OTAU_
+#define _OTAU_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Sec_Atmega1281_Rf230_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Sec_Atmega1281_Rf230_Gcc
new file mode 100644
index 00000000..2d3ec743
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Sec_Atmega1281_Rf230_Gcc
@@ -0,0 +1,34 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SYS_ZCL_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_COORDINATOR_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_BINDING_ -D_ZCL_ -D_OTAU_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+OFD_LIB = OFD
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+ZCL_PATH = $(COMPONENTS_PATH)/./ZCL
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Sec_Atmega1281_Rf230_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Sec_Atmega1281_Rf230_Gcc.h
new file mode 100644
index 00000000..bb51aa7e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Coordinator_Sec_Atmega1281_Rf230_Gcc.h
@@ -0,0 +1,100 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SYS_ZCL_TASK_
+#define _SYS_ZCL_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _COORDINATOR_
+#define _COORDINATOR_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _ZCL_
+#define _ZCL_
+#endif
+#ifndef _OTAU_
+#define _OTAU_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Atmega1281_Rf212_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Atmega1281_Rf212_Gcc
new file mode 100644
index 00000000..5022f9ff
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Atmega1281_Rf212_Gcc
@@ -0,0 +1,34 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF212 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_SYS_ZCL_TASK_ -D_ENDDEVICE_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_BINDING_ -D_ZCL_ -D_OTAU_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+OFD_LIB = OFD
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+ZCL_PATH = $(COMPONENTS_PATH)/./ZCL
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Atmega1281_Rf212_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Atmega1281_Rf212_Gcc.h
new file mode 100644
index 00000000..c0973589
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Atmega1281_Rf212_Gcc.h
@@ -0,0 +1,76 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SYS_ZCL_TASK_
+#define _SYS_ZCL_TASK_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _ZCL_
+#define _ZCL_
+#endif
+#ifndef _OTAU_
+#define _OTAU_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Atmega1281_Rf230_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Atmega1281_Rf230_Gcc
new file mode 100644
index 00000000..010a1f55
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Atmega1281_Rf230_Gcc
@@ -0,0 +1,34 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_SYS_ZCL_TASK_ -D_ENDDEVICE_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_BINDING_ -D_ZCL_ -D_OTAU_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+OFD_LIB = OFD
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+ZCL_PATH = $(COMPONENTS_PATH)/./ZCL
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Atmega1281_Rf230_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Atmega1281_Rf230_Gcc.h
new file mode 100644
index 00000000..c0973589
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Atmega1281_Rf230_Gcc.h
@@ -0,0 +1,76 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SYS_ZCL_TASK_
+#define _SYS_ZCL_TASK_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _ZCL_
+#define _ZCL_
+#endif
+#ifndef _OTAU_
+#define _OTAU_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Sec_Atmega1281_Rf212_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Sec_Atmega1281_Rf212_Gcc
new file mode 100644
index 00000000..def32b62
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Sec_Atmega1281_Rf212_Gcc
@@ -0,0 +1,34 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF212 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SYS_ZCL_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_MAC_HW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_ENDDEVICE_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_BINDING_ -D_ZCL_ -D_OTAU_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+OFD_LIB = OFD
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+ZCL_PATH = $(COMPONENTS_PATH)/./ZCL
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Sec_Atmega1281_Rf212_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Sec_Atmega1281_Rf212_Gcc.h
new file mode 100644
index 00000000..92ff78fd
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Sec_Atmega1281_Rf212_Gcc.h
@@ -0,0 +1,97 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SYS_ZCL_TASK_
+#define _SYS_ZCL_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _MAC_HW_AES_
+#define _MAC_HW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _ZCL_
+#define _ZCL_
+#endif
+#ifndef _OTAU_
+#define _OTAU_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Sec_Atmega1281_Rf230_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Sec_Atmega1281_Rf230_Gcc
new file mode 100644
index 00000000..a30a459e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Sec_Atmega1281_Rf230_Gcc
@@ -0,0 +1,34 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SYS_ZCL_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_ENDDEVICE_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_BINDING_ -D_ZCL_ -D_OTAU_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+OFD_LIB = OFD
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+ZCL_PATH = $(COMPONENTS_PATH)/./ZCL
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Sec_Atmega1281_Rf230_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Sec_Atmega1281_Rf230_Gcc.h
new file mode 100644
index 00000000..fcd54a3b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_EndDevice_Sec_Atmega1281_Rf230_Gcc.h
@@ -0,0 +1,97 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SYS_ZCL_TASK_
+#define _SYS_ZCL_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _ENDDEVICE_
+#define _ENDDEVICE_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _ZCL_
+#define _ZCL_
+#endif
+#ifndef _OTAU_
+#define _OTAU_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Atmega1281_Rf212_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Atmega1281_Rf212_Gcc
new file mode 100644
index 00000000..4ec1c0bf
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Atmega1281_Rf212_Gcc
@@ -0,0 +1,34 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF212 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_SYS_ZCL_TASK_ -D_ROUTER_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_BINDING_ -D_ZCL_ -D_OTAU_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+OFD_LIB = OFD
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+ZCL_PATH = $(COMPONENTS_PATH)/./ZCL
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Atmega1281_Rf212_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Atmega1281_Rf212_Gcc.h
new file mode 100644
index 00000000..b9ba1364
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Atmega1281_Rf212_Gcc.h
@@ -0,0 +1,79 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SYS_ZCL_TASK_
+#define _SYS_ZCL_TASK_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _ZCL_
+#define _ZCL_
+#endif
+#ifndef _OTAU_
+#define _OTAU_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Atmega1281_Rf230_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Atmega1281_Rf230_Gcc
new file mode 100644
index 00000000..24ab001c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Atmega1281_Rf230_Gcc
@@ -0,0 +1,34 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_ZDO_TASK_ -D_SYS_ZCL_TASK_ -D_ROUTER_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_BINDING_ -D_ZCL_ -D_OTAU_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+OFD_LIB = OFD
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+ZCL_PATH = $(COMPONENTS_PATH)/./ZCL
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Atmega1281_Rf230_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Atmega1281_Rf230_Gcc.h
new file mode 100644
index 00000000..b9ba1364
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Atmega1281_Rf230_Gcc.h
@@ -0,0 +1,79 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SYS_ZCL_TASK_
+#define _SYS_ZCL_TASK_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _ZCL_
+#define _ZCL_
+#endif
+#ifndef _OTAU_
+#define _OTAU_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Sec_Atmega1281_Rf212_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Sec_Atmega1281_Rf212_Gcc
new file mode 100644
index 00000000..423d8e7c
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Sec_Atmega1281_Rf212_Gcc
@@ -0,0 +1,34 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF212 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SYS_ZCL_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_MAC_HW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_ROUTER_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_BINDING_ -D_ZCL_ -D_OTAU_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+OFD_LIB = OFD
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+ZCL_PATH = $(COMPONENTS_PATH)/./ZCL
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Sec_Atmega1281_Rf212_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Sec_Atmega1281_Rf212_Gcc.h
new file mode 100644
index 00000000..4b2a890f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Sec_Atmega1281_Rf212_Gcc.h
@@ -0,0 +1,100 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SYS_ZCL_TASK_
+#define _SYS_ZCL_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _MAC_HW_AES_
+#define _MAC_HW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _ZCL_
+#define _ZCL_
+#endif
+#ifndef _OTAU_
+#define _OTAU_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Sec_Atmega1281_Rf230_Gcc b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Sec_Atmega1281_Rf230_Gcc
new file mode 100644
index 00000000..d75532a8
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Sec_Atmega1281_Rf230_Gcc
@@ -0,0 +1,34 @@
+#----------------------------------------------
+#User application makerules - should be included into user application Makefile
+#----------------------------------------------
+
+include $(COMPONENTS_PATH)/../lib/Makerules_Atmega1281_Gcc
+
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2 -DATMEGA1281 -DAT86RF230 -DNONE_OS -D_IEEE_ZIGBEE_COMPLIANCE_ -D_SYS_MAC_PHY_HWD_TASK_ -D_SYS_HAL_TASK_ -D_SYS_MAC_HWI_TASK_ -D_SYS_BSP_TASK_ -D_SYS_APL_TASK_ -D_SYS_NWK_TASK_ -D_SYS_APS_TASK_ -D_SYS_SSP_TASK_ -D_SYS_TC_TASK_ -D_SYS_ZDO_TASK_ -D_SYS_ZCL_TASK_ -D_SECURITY_ -D_NWK_ALLOCATOR_ -D_SSP_SW_AES_ -D_TRUST_CENTRE_ -D_UNIVERSAL_TC_EXT_ADDR_ -D_ROUTER_ -D_FFD_ -D_NWK_FAST_ROUTE_DISCOVERY_ -D_NWK_NONSTANDARD_BEACON_FILTER_ -D_NWK_CHECK_OUT_BROADCAST_ -D_NWK_ROUTING_OPTIMIZATION_=3 -D_NWK_STOCHASTIC_ADDRESSING_ -D_RESOLVE_ADDR_CONFLICT_ -D_NWK_MESH_ROUTING_ -D_BINDING_ -D_ZCL_ -D_OTAU_ -D_COMMISSIONING_ -D_POWER_FAILURE_ -D_NWK_PASSIVE_ACK_
+CFLAGS += $(BOARDCFLAGS)
+#-Libraries names------------------------------
+CS_LIB = ConfigServer
+PDS_LIB = PersistDataServer
+OFD_LIB = OFD
+
+#-Stack components paths-----------------------
+HAL_HWD_COMMON_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/common
+HAL_MAC_API_PATH = $(COMPONENTS_PATH)/./HAL/avr/atmega1281/zigBit
+HAL_PATH = $(COMPONENTS_PATH)/./HAL
+MAC_PHY_PATH = $(COMPONENTS_PATH)/./MAC_PHY
+MAC_ENV_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_ENV
+MAC_HWD_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWD_PHY
+MAC_HWI_PATH = $(COMPONENTS_PATH)/./MAC_PHY/MAC_HWI
+NWK_PATH = $(COMPONENTS_PATH)/./NWK
+APS_PATH = $(COMPONENTS_PATH)/./APS
+ZDO_PATH = $(COMPONENTS_PATH)/./ZDO
+ZCL_PATH = $(COMPONENTS_PATH)/./ZCL
+SSP_PATH = $(COMPONENTS_PATH)/./Security/ServiceProvider
+TC_PATH = $(COMPONENTS_PATH)/./Security/TrustCentre
+CS_PATH = $(COMPONENTS_PATH)/./ConfigServer
+PDS_PATH = $(COMPONENTS_PATH)/./PersistDataServer
+BSP_PATH = $(COMPONENTS_PATH)/./BSP
+DRIVERS_PATH = $(COMPONENTS_PATH)/./HAL/drivers
+
diff --git a/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Sec_Atmega1281_Rf230_Gcc.h b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Sec_Atmega1281_Rf230_Gcc.h
new file mode 100644
index 00000000..2832adb5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/MakerulesZcl_Router_Sec_Atmega1281_Rf230_Gcc.h
@@ -0,0 +1,100 @@
+#ifndef NONE_OS
+#define NONE_OS
+#endif
+#ifndef _IEEE_ZIGBEE_COMPLIANCE_
+#define _IEEE_ZIGBEE_COMPLIANCE_
+#endif
+#ifndef _SYS_MAC_PHY_HWD_TASK_
+#define _SYS_MAC_PHY_HWD_TASK_
+#endif
+#ifndef _SYS_HAL_TASK_
+#define _SYS_HAL_TASK_
+#endif
+#ifndef _SYS_MAC_HWI_TASK_
+#define _SYS_MAC_HWI_TASK_
+#endif
+#ifndef _SYS_BSP_TASK_
+#define _SYS_BSP_TASK_
+#endif
+#ifndef _SYS_APL_TASK_
+#define _SYS_APL_TASK_
+#endif
+#ifndef _SYS_NWK_TASK_
+#define _SYS_NWK_TASK_
+#endif
+#ifndef _SYS_APS_TASK_
+#define _SYS_APS_TASK_
+#endif
+#ifndef _SYS_SSP_TASK_
+#define _SYS_SSP_TASK_
+#endif
+#ifndef _SYS_TC_TASK_
+#define _SYS_TC_TASK_
+#endif
+#ifndef _SYS_ZDO_TASK_
+#define _SYS_ZDO_TASK_
+#endif
+#ifndef _SYS_ZCL_TASK_
+#define _SYS_ZCL_TASK_
+#endif
+#ifndef _SECURITY_
+#define _SECURITY_
+#endif
+#ifndef _NWK_ALLOCATOR_
+#define _NWK_ALLOCATOR_
+#endif
+#ifndef _SSP_SW_AES_
+#define _SSP_SW_AES_
+#endif
+#ifndef _TRUST_CENTRE_
+#define _TRUST_CENTRE_
+#endif
+#ifndef _UNIVERSAL_TC_EXT_ADDR_
+#define _UNIVERSAL_TC_EXT_ADDR_
+#endif
+#ifndef _ROUTER_
+#define _ROUTER_
+#endif
+#ifndef _FFD_
+#define _FFD_
+#endif
+#ifndef _NWK_FAST_ROUTE_DISCOVERY_
+#define _NWK_FAST_ROUTE_DISCOVERY_
+#endif
+#ifndef _NWK_NONSTANDARD_BEACON_FILTER_
+#define _NWK_NONSTANDARD_BEACON_FILTER_
+#endif
+#ifndef _NWK_CHECK_OUT_BROADCAST_
+#define _NWK_CHECK_OUT_BROADCAST_
+#endif
+#ifndef _NWK_ROUTING_OPTIMIZATION_
+#define _NWK_ROUTING_OPTIMIZATION_ 3
+#endif
+#ifndef _NWK_STOCHASTIC_ADDRESSING_
+#define _NWK_STOCHASTIC_ADDRESSING_
+#endif
+#ifndef _RESOLVE_ADDR_CONFLICT_
+#define _RESOLVE_ADDR_CONFLICT_
+#endif
+#ifndef _NWK_MESH_ROUTING_
+#define _NWK_MESH_ROUTING_
+#endif
+#ifndef _BINDING_
+#define _BINDING_
+#endif
+#ifndef _ZCL_
+#define _ZCL_
+#endif
+#ifndef _OTAU_
+#define _OTAU_
+#endif
+#ifndef _COMMISSIONING_
+#define _COMMISSIONING_
+#endif
+#ifndef _POWER_FAILURE_
+#define _POWER_FAILURE_
+#endif
+#ifndef _NWK_PASSIVE_ACK_
+#define _NWK_PASSIVE_ACK_
+#endif
+#include <configuration.h>
diff --git a/digital/zigbit/bitcloud/stack/lib/Makerules_Atmega1281_Gcc b/digital/zigbit/bitcloud/stack/lib/Makerules_Atmega1281_Gcc
new file mode 100644
index 00000000..714352d4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/Makerules_Atmega1281_Gcc
@@ -0,0 +1,28 @@
+#----------------------------------------------
+#HAL makerules - should be included into components Makerules
+#----------------------------------------------
+
+#-Compiler type definition---------------------
+COMPILER_TYPE = GCC
+COMPILER_AND_MICRO_TYPE = GCC_AVR
+#-Tools definitions----------------------------
+AS = avr-as
+LD = avr-ld
+CC = avr-gcc
+CPP = avr-g++
+AR = avr-ar
+NM = avr-nm
+STRIP = avr-strip
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -pipe -c -W -Wall -ffunction-sections -mmcu=atmega1281 -mcall-prologues -fshort-enums --param inline-call-cost=2
+AR_KEYS = cr
+
+
+#-Objects to be linked with app----------------
+PLATFORM_SPECIFIC_OBJECTS = WdtInitatmega1281_Gcc.o
+
+SE_PATH = $(COMPONENTS_PATH)/./SystemEnvironment
diff --git a/digital/zigbit/bitcloud/stack/lib/Makerules_x86_Gcc b/digital/zigbit/bitcloud/stack/lib/Makerules_x86_Gcc
new file mode 100644
index 00000000..7b856435
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/Makerules_x86_Gcc
@@ -0,0 +1,35 @@
+#----------------------------------------------
+#HAL makerules - should be included into components Makerules
+#----------------------------------------------
+
+#-Compiler type definition---------------------
+COMPILER_TYPE = GCC
+COMPILER_AND_MICRO_TYPE = GCC_X86
+#-Tools definitions----------------------------
+AS = as
+LD = ld
+CC = gcc
+CPP = g++
+AR = ar
+NM = nm
+STRIP = strip
+OBJCOPY = objcopy
+OBJDUMP = objdump
+SIZE = size
+
+#-Compiler flags-------------------------------
+CFLAGS = -Os -std=gnu99 -c -g -Wall -W -fshort-enums -DX86 -DPLATFORM_PC -DNONE_OS -D_RF_TX_RX_INDICATOR_ -D_UART_0_HW_CONTROL_ -D_SYS_LOG_ON_ -D_HAL_LOG_ON_ -D_MAC_LOG_ON_ -D_NWK_LOG_ON_ -D_APS_LOG_ON_ -D_ZDO_LOG_ON_ -D_SSP_TC_LOG_ON_ -D_ZSE_LOG_ON_ -D_APL_LOG_ON_ -D_HAL_LOG_INTERFACE_UART0_ -D_SYS_ASSERT_ON_ -D_HAL_ASSERT_INTERFACE_DBG_PORT_
+AR_KEYS = cr
+
+#-Thumb mode flags-----------------------------
+#ARM_MODE_THUMBS_CFLAGS = -mthumb
+#ARM_MODE_ARM_CFLAGS = -marm
+
+#-Platform definitions-------------------------
+HAL = X86
+PLATFORM = PLATFORM_PC
+
+#-Objects to be linked with app----------------
+#PLATFORM_SPECIFIC_OBJECTS = /FirmwareBootGcc.o
+
+SE_PATH = $(COMPONENTS_PATH)/./SystemEnvironment
diff --git a/digital/zigbit/bitcloud/stack/lib/WdtInitatmega1281_Gcc.o b/digital/zigbit/bitcloud/stack/lib/WdtInitatmega1281_Gcc.o
new file mode 100644
index 00000000..b11de440
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/WdtInitatmega1281_Gcc.o
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_All_Atmega1281_Rf212_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_All_Atmega1281_Rf212_Gcc.a
new file mode 100644
index 00000000..5560659e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_All_Atmega1281_Rf212_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_All_Atmega1281_Rf230B_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_All_Atmega1281_Rf230B_Gcc.a
new file mode 100644
index 00000000..97d6971a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_All_Atmega1281_Rf230B_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_All_Atmega1281_Rf230_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_All_Atmega1281_Rf230_Gcc.a
new file mode 100644
index 00000000..a3dd2d7a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_All_Atmega1281_Rf230_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_All_Atmega1281_Rf231_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_All_Atmega1281_Rf231_Gcc.a
new file mode 100644
index 00000000..9e63e2dd
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_All_Atmega1281_Rf231_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_All_Sec_Atmega1281_Rf212_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_All_Sec_Atmega1281_Rf212_Gcc.a
new file mode 100644
index 00000000..45b0e1f3
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_All_Sec_Atmega1281_Rf212_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_All_Sec_Atmega1281_Rf230B_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_All_Sec_Atmega1281_Rf230B_Gcc.a
new file mode 100644
index 00000000..0b4c8d6b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_All_Sec_Atmega1281_Rf230B_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_All_Sec_Atmega1281_Rf230_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_All_Sec_Atmega1281_Rf230_Gcc.a
new file mode 100644
index 00000000..34fb73ae
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_All_Sec_Atmega1281_Rf230_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_All_Sec_Atmega1281_Rf231_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_All_Sec_Atmega1281_Rf231_Gcc.a
new file mode 100644
index 00000000..4dadfb77
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_All_Sec_Atmega1281_Rf231_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Atmega1281_Rf212_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Atmega1281_Rf212_Gcc.a
new file mode 100644
index 00000000..7acc947e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Atmega1281_Rf212_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Atmega1281_Rf230B_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Atmega1281_Rf230B_Gcc.a
new file mode 100644
index 00000000..12719dd9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Atmega1281_Rf230B_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Atmega1281_Rf230_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Atmega1281_Rf230_Gcc.a
new file mode 100644
index 00000000..6fdeb74e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Atmega1281_Rf230_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Atmega1281_Rf231_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Atmega1281_Rf231_Gcc.a
new file mode 100644
index 00000000..ebaf5b69
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Atmega1281_Rf231_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Sec_Atmega1281_Rf212_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Sec_Atmega1281_Rf212_Gcc.a
new file mode 100644
index 00000000..ec78be99
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Sec_Atmega1281_Rf212_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Sec_Atmega1281_Rf230B_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Sec_Atmega1281_Rf230B_Gcc.a
new file mode 100644
index 00000000..57c00f54
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Sec_Atmega1281_Rf230B_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Sec_Atmega1281_Rf230_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Sec_Atmega1281_Rf230_Gcc.a
new file mode 100644
index 00000000..54000eb3
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Sec_Atmega1281_Rf230_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Sec_Atmega1281_Rf231_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Sec_Atmega1281_Rf231_Gcc.a
new file mode 100644
index 00000000..84797350
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_Sec_Atmega1281_Rf231_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_StdlinkSec_Atmega1281_Rf212_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_StdlinkSec_Atmega1281_Rf212_Gcc.a
new file mode 100644
index 00000000..a97538c9
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_StdlinkSec_Atmega1281_Rf212_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_StdlinkSec_Atmega1281_Rf230B_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_StdlinkSec_Atmega1281_Rf230B_Gcc.a
new file mode 100644
index 00000000..612cc480
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_StdlinkSec_Atmega1281_Rf230B_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_StdlinkSec_Atmega1281_Rf230_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_StdlinkSec_Atmega1281_Rf230_Gcc.a
new file mode 100644
index 00000000..a0e75f31
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_StdlinkSec_Atmega1281_Rf230_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_StdlinkSec_Atmega1281_Rf231_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_StdlinkSec_Atmega1281_Rf231_Gcc.a
new file mode 100644
index 00000000..7bb51067
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Coordinator_StdlinkSec_Atmega1281_Rf231_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Atmega1281_Rf212_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Atmega1281_Rf212_Gcc.a
new file mode 100644
index 00000000..4aef1595
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Atmega1281_Rf212_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Atmega1281_Rf230B_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Atmega1281_Rf230B_Gcc.a
new file mode 100644
index 00000000..d9241538
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Atmega1281_Rf230B_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Atmega1281_Rf230_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Atmega1281_Rf230_Gcc.a
new file mode 100644
index 00000000..2bb1e64d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Atmega1281_Rf230_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Atmega1281_Rf231_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Atmega1281_Rf231_Gcc.a
new file mode 100644
index 00000000..76d393aa
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Atmega1281_Rf231_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Sec_Atmega1281_Rf212_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Sec_Atmega1281_Rf212_Gcc.a
new file mode 100644
index 00000000..ca2f253d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Sec_Atmega1281_Rf212_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Sec_Atmega1281_Rf230B_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Sec_Atmega1281_Rf230B_Gcc.a
new file mode 100644
index 00000000..2a39567d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Sec_Atmega1281_Rf230B_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Sec_Atmega1281_Rf230_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Sec_Atmega1281_Rf230_Gcc.a
new file mode 100644
index 00000000..14c52b14
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Sec_Atmega1281_Rf230_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Sec_Atmega1281_Rf231_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Sec_Atmega1281_Rf231_Gcc.a
new file mode 100644
index 00000000..e6062878
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_Sec_Atmega1281_Rf231_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_StdlinkSec_Atmega1281_Rf212_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_StdlinkSec_Atmega1281_Rf212_Gcc.a
new file mode 100644
index 00000000..992ed4ee
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_StdlinkSec_Atmega1281_Rf212_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_StdlinkSec_Atmega1281_Rf230B_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_StdlinkSec_Atmega1281_Rf230B_Gcc.a
new file mode 100644
index 00000000..325376db
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_StdlinkSec_Atmega1281_Rf230B_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_StdlinkSec_Atmega1281_Rf230_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_StdlinkSec_Atmega1281_Rf230_Gcc.a
new file mode 100644
index 00000000..4342fa89
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_StdlinkSec_Atmega1281_Rf230_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_StdlinkSec_Atmega1281_Rf231_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_StdlinkSec_Atmega1281_Rf231_Gcc.a
new file mode 100644
index 00000000..320e6751
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_EndDevice_StdlinkSec_Atmega1281_Rf231_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Router_Atmega1281_Rf212_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Router_Atmega1281_Rf212_Gcc.a
new file mode 100644
index 00000000..b50ab9b8
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Router_Atmega1281_Rf212_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Router_Atmega1281_Rf230B_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Router_Atmega1281_Rf230B_Gcc.a
new file mode 100644
index 00000000..532b73eb
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Router_Atmega1281_Rf230B_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Router_Atmega1281_Rf230_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Router_Atmega1281_Rf230_Gcc.a
new file mode 100644
index 00000000..b141f15e
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Router_Atmega1281_Rf230_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Router_Atmega1281_Rf231_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Router_Atmega1281_Rf231_Gcc.a
new file mode 100644
index 00000000..6f2ce419
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Router_Atmega1281_Rf231_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Router_Sec_Atmega1281_Rf212_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Router_Sec_Atmega1281_Rf212_Gcc.a
new file mode 100644
index 00000000..31ef94da
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Router_Sec_Atmega1281_Rf212_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Router_Sec_Atmega1281_Rf230B_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Router_Sec_Atmega1281_Rf230B_Gcc.a
new file mode 100644
index 00000000..1c014f8a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Router_Sec_Atmega1281_Rf230B_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Router_Sec_Atmega1281_Rf230_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Router_Sec_Atmega1281_Rf230_Gcc.a
new file mode 100644
index 00000000..5d4858a0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Router_Sec_Atmega1281_Rf230_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Router_Sec_Atmega1281_Rf231_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Router_Sec_Atmega1281_Rf231_Gcc.a
new file mode 100644
index 00000000..19810dfc
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Router_Sec_Atmega1281_Rf231_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Router_StdlinkSec_Atmega1281_Rf212_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Router_StdlinkSec_Atmega1281_Rf212_Gcc.a
new file mode 100644
index 00000000..4e7376d5
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Router_StdlinkSec_Atmega1281_Rf212_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Router_StdlinkSec_Atmega1281_Rf230B_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Router_StdlinkSec_Atmega1281_Rf230B_Gcc.a
new file mode 100644
index 00000000..9556f92d
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Router_StdlinkSec_Atmega1281_Rf230B_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Router_StdlinkSec_Atmega1281_Rf230_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Router_StdlinkSec_Atmega1281_Rf230_Gcc.a
new file mode 100644
index 00000000..a9af6748
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Router_StdlinkSec_Atmega1281_Rf230_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libBc_Router_StdlinkSec_Atmega1281_Rf231_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libBc_Router_StdlinkSec_Atmega1281_Rf231_Gcc.a
new file mode 100644
index 00000000..b8e4f066
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libBc_Router_StdlinkSec_Atmega1281_Rf231_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libHAL_Rcb230_Atmega1281_8Mhz_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libHAL_Rcb230_Atmega1281_8Mhz_Gcc.a
new file mode 100644
index 00000000..9154619b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libHAL_Rcb230_Atmega1281_8Mhz_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libHAL_Rcb231_212_Atmega1281_8Mhz_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libHAL_Rcb231_212_Atmega1281_8Mhz_Gcc.a
new file mode 100644
index 00000000..05402552
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libHAL_Rcb231_212_Atmega1281_8Mhz_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc.a
new file mode 100644
index 00000000..1985112a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc_Amp.a b/digital/zigbit/bitcloud/stack/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc_Amp.a
new file mode 100644
index 00000000..0cb0b0c0
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libHAL_ZigBit_Atmega1281_8Mhz_Gcc_Amp.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libZcl_All_Atmega1281_Rf212_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libZcl_All_Atmega1281_Rf212_Gcc.a
new file mode 100644
index 00000000..5f38567b
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libZcl_All_Atmega1281_Rf212_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libZcl_All_Atmega1281_Rf230_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libZcl_All_Atmega1281_Rf230_Gcc.a
new file mode 100644
index 00000000..252b1138
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libZcl_All_Atmega1281_Rf230_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libZcl_All_Sec_Atmega1281_Rf212_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libZcl_All_Sec_Atmega1281_Rf212_Gcc.a
new file mode 100644
index 00000000..579d16e4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libZcl_All_Sec_Atmega1281_Rf212_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libZcl_All_Sec_Atmega1281_Rf230_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libZcl_All_Sec_Atmega1281_Rf230_Gcc.a
new file mode 100644
index 00000000..f40fec22
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libZcl_All_Sec_Atmega1281_Rf230_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libZcl_Coordinator_Atmega1281_Rf212_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libZcl_Coordinator_Atmega1281_Rf212_Gcc.a
new file mode 100644
index 00000000..55365b57
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libZcl_Coordinator_Atmega1281_Rf212_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libZcl_Coordinator_Atmega1281_Rf230_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libZcl_Coordinator_Atmega1281_Rf230_Gcc.a
new file mode 100644
index 00000000..f5ca98ce
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libZcl_Coordinator_Atmega1281_Rf230_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libZcl_Coordinator_Sec_Atmega1281_Rf212_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libZcl_Coordinator_Sec_Atmega1281_Rf212_Gcc.a
new file mode 100644
index 00000000..4be60e8f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libZcl_Coordinator_Sec_Atmega1281_Rf212_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libZcl_Coordinator_Sec_Atmega1281_Rf230_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libZcl_Coordinator_Sec_Atmega1281_Rf230_Gcc.a
new file mode 100644
index 00000000..cb31b4b6
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libZcl_Coordinator_Sec_Atmega1281_Rf230_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libZcl_EndDevice_Atmega1281_Rf212_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libZcl_EndDevice_Atmega1281_Rf212_Gcc.a
new file mode 100644
index 00000000..175fc780
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libZcl_EndDevice_Atmega1281_Rf212_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libZcl_EndDevice_Atmega1281_Rf230_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libZcl_EndDevice_Atmega1281_Rf230_Gcc.a
new file mode 100644
index 00000000..1ef4953a
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libZcl_EndDevice_Atmega1281_Rf230_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libZcl_EndDevice_Sec_Atmega1281_Rf212_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libZcl_EndDevice_Sec_Atmega1281_Rf212_Gcc.a
new file mode 100644
index 00000000..06d470ce
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libZcl_EndDevice_Sec_Atmega1281_Rf212_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libZcl_EndDevice_Sec_Atmega1281_Rf230_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libZcl_EndDevice_Sec_Atmega1281_Rf230_Gcc.a
new file mode 100644
index 00000000..8eaa50a7
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libZcl_EndDevice_Sec_Atmega1281_Rf230_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libZcl_Router_Atmega1281_Rf212_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libZcl_Router_Atmega1281_Rf212_Gcc.a
new file mode 100644
index 00000000..3c52e9f4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libZcl_Router_Atmega1281_Rf212_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libZcl_Router_Atmega1281_Rf230_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libZcl_Router_Atmega1281_Rf230_Gcc.a
new file mode 100644
index 00000000..41e819a8
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libZcl_Router_Atmega1281_Rf230_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libZcl_Router_Sec_Atmega1281_Rf212_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libZcl_Router_Sec_Atmega1281_Rf212_Gcc.a
new file mode 100644
index 00000000..c86a4aac
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libZcl_Router_Sec_Atmega1281_Rf212_Gcc.a
Binary files differ
diff --git a/digital/zigbit/bitcloud/stack/lib/libZcl_Router_Sec_Atmega1281_Rf230_Gcc.a b/digital/zigbit/bitcloud/stack/lib/libZcl_Router_Sec_Atmega1281_Rf230_Gcc.a
new file mode 100644
index 00000000..513f3669
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/lib/libZcl_Router_Sec_Atmega1281_Rf230_Gcc.a
Binary files differ