#ifndef _CONFIGURATION_H_ #define _CONFIGURATION_H_ #include "apsCommon.h" //----------------------------------------------- // Disables board-specific peripherals support //----------------------------------------------- //#define APP_DISABLE_BSP 1 #define APP_DISABLE_BSP 1 //----------------------------------------------- // Includes board-specific peripherals support in application. //----------------------------------------------- #include #define APP_INTERFACE_USART 0x01 #define APP_INTERFACE_VCP 0x02 #define APP_INTERFACE_SPI 0x03 #define APP_INTERFACE_UART 0x04 #define APP_INTERFACE_USBFIFO 0x05 // Receive buffer size for USART. #define APP_USART_RX_BUFFER_SIZE 100 // Transmit buffer size for USART. #define APP_USART_TX_BUFFER_SIZE 100 #define AT25F2048 0x01 #define AT45DB041 0x02 #define AT25DF041A 0x03 // Enables or disables APS Fragmentation support. #define APP_FRAGMENTATION 0 //#define APP_FRAGMENTATION 1 // Link failure detection functionality #define APP_DETECT_LINK_FAILURE 1 //#define APP_DETECT_LINK_FAILURE 0 // Enable this option if target board belongs to MNZB-EVBx family #define BSP_MNZB_EVB_SUPPORT 1 //#define BSP_MNZB_EVB_SUPPORT 0 // Defines primary serial interface type to be used by application. #define APP_INTERFACE APP_INTERFACE_USART // Defines USART interface name to be used by application. #define APP_USART_CHANNEL USART_CHANNEL_1 #define APP_JOINING_INDICATION_PERIOD 500L // Period of blinking during starting network #define APP_ENDPOINT 1 // Endpoint will be useed #define APP_PROFILE_ID 1 // Profile Id will be used #define APP_CLUSTER_ID 1 // Cluster Id will be used // 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. // Valid channel numbers for 2.4 GHz band are 0x0b - 0x1a // Valid channel numbers for 900 MHz band are 0x00 - 0x0a // // Notes: // 1. for small amount of enabled channels it is more convinient to specify list // of channels in the form of '(1ul << 0x0b)' // 2. For 900 MHz band you also need to specify channel page // // Value range: 32-bit values: // Valid channel numbers for 2.4 GHz band are 0x0b - 0x1a // Valid channel numbers for 900 MHz band are 0x00 - 0x0a // // C-type: uint32_t // Can be set: at any time before network start #define CS_CHANNEL_MASK (1L<<0x0f) // 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. #define CS_EXT_PANID 0xAAAAAAAAAAAAAAAALL // 64-bit Unique Identifier (UID) determining the device extended address. 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. // Specifies short (network) 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. #ifdef LOL_NUMBER_0 #define CS_UID 0x1LL #define CS_NWK_ADDR 0x0000 #define TYPE_COOR #elif LOL_NUMBER_1 #define CS_UID 0x1LL #define CS_NWK_ADDR 0x0001 #define TYPE_END #elif LOL_NUMBER_2 #define CS_UID 0x2LL #define CS_NWK_ADDR 0x0002 #define TYPE_END #elif LOL_NUMBER_3 #define CS_UID 0x3LL #define CS_NWK_ADDR 0x0003 #define TYPE_END #else #error NO_ADDR_DEFINED #endif // 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. #define CS_MAX_CHILDREN_AMOUNT 8 // 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. #define CS_MAX_CHILDREN_ROUTER_AMOUNT 2 // Network depht limits amount of hops that packet may travel in the network. // Actual maximum number of hops is network depth multiplied by 2. // // 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. #define CS_MAX_NETWORK_DEPTH 6 //----------------------------------------------- //STANDARD_SECURITY_MODE //----------------------------------------------- #ifdef STANDARD_SECURITY_MODE // The parameter is used to determine the security type. // // Value range: 0,3 - for standard security; 1,2 - for high security. // 0 - network key is preconfigured ; // 1 - network join without master key, but with a trust center link key, which // must be set via APS_SetLinkKey(); // 2 - network join employs a master key, which must be set APS_SetMasterKey(); // 3 - network key is no preconfigured, but rather received from the trust center // in an unencrypted frame. (CS_APS_MAX_BLOCKS_AMOUNT * APS_MAX_ASDU_SIZE) #error APP_MAX_PACKET_SIZE must be less or equal to (CS_APS_MAX_BLOCKS_AMOUNT * APS_MAX_ASDU_SIZE) #endif #else #if APP_APS_PAYLOAD_SIZE > APS_MAX_ASDU_SIZE #error APP_APS_PAYLOAD_SIZE must be less or equal to APS_MAX_ASDU_SIZE #endif #endif // Common application state definition typedef enum { APP_INITIAL_STATE, // Initial state APP_NETWORK_JOINING_STATE, // Attempting join the network APP_NETWORK_JOINED_STATE, // Successfully joined APP_NETWORK_LEAVING_STATE, // Leaving from the network APP_ERROR_STATE // Error state (runtime error occured) } AppState_t; // Network data transmission state typedef enum { APP_DATA_TRANSMISSION_SENDING_STATE, // APS Data Request was not sent yet APP_DATA_TRANSMISSION_BUSY_STATE, // APS Data Request was sent (confirm waiting) APP_DATA_TRANSMISSION_WAIT_STATE, // Waiting a data block from USART APP_DATA_TRANSMISSION_READY_STATE, // Ready to send new APS Data Request APP_DATA_TRANSMISSION_STOP_STATE // Inter-frame delay } AppDataTransmissionState_t; #endif // _CONFIGURATION_H_