📄 common.h
字号:
#ifndef COMMON_H
#define COMMON_H
#include PLATFORM_HEADER //compiler/micro specifics, types
#include "stack/include/ember.h"
#include "stack/include/error.h"
#include "hal/hal.h"
#include "app/util/serial/serial.h"
#include "stack/include/packet-buffer.h"
#include "app/util/scan/scan-utils.h"
//#include "app/util/network/network-utils.h" // network utilities
#ifdef USE_BOOTLOADER_LIB
#include "app/util/bootload/bootload-utils.h"
#endif
// *******************************************************************
// Ember endpoint and interface configuration
// The application profile ID we use. This profile ID is assigned to
// Ember Corp. and can only be used during development.
// 2006-12-15 lvyong change to 0x484C
//#define PROFILE_ID 0xC00F
#define PROFILE_ID 0x484C
// Numeric index for the first endpoint. Applications can use any
// endpoints between 1 and 238.
// 0 = ZDO, 239 = SPDO, 240 = EDO, 241-255 reserved
// This application uses only one endpoint. This constant makes the code
// easier to read.
#define ENDPOINT 1
// End Ember endpoint and interface configuration
// *******************************************************************
// *******************************************************************
// Application specific constants and globals
// The constants below deal with the binding table. All nodes
// running the sensor or sink application will belong to the
// same MULTICAST group and will use the same location in the
// binding table for the multicast binding. The sink nodes will
// use the remaining positions in the binding table for bindings
// to sensor nodes. All sensor nodes will use the same position
// in the binding table for their sink
#define MULTICAST_BINDING_INDEX (EMBER_BINDING_TABLE_SIZE - 1)
#define SINK_BINDING_INDEX (0)
// This is the unique identifier for the multicast group that
// this application uses.
#define MULTICAST_ID 0x1111
#define HELLO_MSG_SIZE 5
// application timers are based on ticks, each tick is APP_TICK_INTERVAL
// milliseconds. This value corresponds with halSleepForQuarterSeconds.
#define APP_TICK_INTERVAL 256
//时间间隔宏
#define TIME_BEFORE_SET_CHANNEL 240
// **********************************
// define the message types
#define MSG_NONE 0
// lvyong changed 2006-12-5
// protocol for hooking up a sensor to a sink
#define MSG_SINK_ADVERTISE 0xF1 //1 // sink: advertise service
#define MSG_SENSOR_SELECT_SINK 0xF2 // sensor: selects one sink
#define MSG_SINK_READY 0xF3 // sink: tells sensor it is ready to rx data
//#define MSG_SINK_ADVERTISE 1 //1 // sink: advertise service
//#define MSG_SENSOR_SELECT_SINK 2 // sensor: selects one sink
//#define MSG_SINK_READY 3 // sink: tells sensor it is ready to rx data
// data transmission from [sensor to sink]
#define MSG_DATA 10 // sensor: tx data
// multicast hello
#define MSG_MULTICAST_HELLO 100
//#define MSG_TRANSFER_DATA 7 // lvyong commented
//#define MSG_READING_DATA 6
//#define MSG_PARA_READING 1
//#define MSG_PARA_WRITE 2
//#define MSG_PARA_CONFIG 3
//Header
#define APP_HEADER_LENGTH 5
// serial ports
//#define APP_SERIAL 1 /* for debug */
#define APP_SERIAL 0
#define HOLLEY_SERIAL 1
#define DEBUG_SERIAL 0
// the time a sink waits before advertising.
// This is in application ticks. (see APP_TICK_INTERVAL define)
#define TIME_BEFORE_SINK_ADVERTISE 240 // ~60 seconds
// the next two defines determine how fast to send data and
// how much data to send. SEND_DATA_SIZE must be multiple of 2
// (since we're sending two-byte integers). The maximum value for
// SEND_DATA_SIZE is determined by the maximum transport payload
// size, which varies if security is on or off. The sendData
// function in sensor.c checks this value and changes it if necessary
#define SEND_DATA_SIZE 40 // default 40 bytes
#define SEND_DATA_RATE 1 //80 // ~20 seconds (min 2)
// num of pkts to miss before deciding that other node is gone
#define MISS_PACKET_TOLERANCE 5
// End application specific constants and globals
// *******************************************************************
// common utility functions
void setSecurityKey(void);
void printBindingTable(int8u tableSize);
void printEUI64(int8u port, EmberEUI64* eui);
void printNodeInfo(void);
void printTokens(void);
void printChildTable(void);
// it is not recommended to ever hard code the network settings
// applications should always scan to determine the channel and panid
// to use. However, in some instances, this can aid in debugging
#define USE_HARDCODED_NETWORK_SETTINGS
//#ifdef USE_HARDCODED_NETWORK_SETTINGS
// #define APP_CHANNEL 26
// #define APP_PANID 0x01ff
//// #define APP_POWER (-1)
// #define APP_POWER (+3)
//#endif //USE_HARDCODED_NETWORK_SETTINGS
// ****************************************************************
// The following variables are to support JIT (just-in-time) messaging
// to sleepy end devices
// adds a JIT message of type msgType for all current children.
void appAddJitForAllChildren(int8u msgType,
int8u* data,
int8u dataLength);
// construct and send an APS message based on a stored JIT message
// this is called from emberPollHandler when transmitExpected is TRUE
void appSendJitToChild(EmberNodeId childId);
// print the variables that keep track of the JIT messages.
// (primarily used for debugging)
void jitMessageStatus(void);
#ifdef USE_BOOTLOADER_LIB
// ****************************************************************
// the following functions are defined to support the em250 standalone
// bootloader in the sensor sample application.
//
// The sensor application only makes use of passthru bootloading and does not
// use clone or recovery bootload modes. The solution presented is not a
// complete solution as the command line interface on the applications only
// supports bootloading the first child in the child table or first entry in
// the binding table. (This could be solved with either an extension to the
// command line interface, or a different model for determining the EUI to
// be bootloaded). This is meant as a reference to show what is needed
// to support bootloading in an existing application. All code related to
// bootloading is defined under USE_BOOTLOADER_LIB.
//
// Please see the standalone-bootloader-demo sample application for a
// complete example of using the bootloader.
// called by a parent when a child should be bootloaded. The Bootload does
// not start until the next time the child wakes up.
void bootloadMySleepyChild(EmberEUI64 targetEui);
// called by a non-sleepy to bootload a neighbor. The bootload will attempt
// to start immediately.
void bootloadMyNeighborRouter(EmberEUI64 targetEui);
// utility to determine if a device(based on EUI) is a child or not.
boolean isMyChild(EmberEUI64 candidateEui, int8u* childIndex);
// utility to determine if a device(based on EUI) is a neighbor or not
boolean isMyNeighbor(EmberEUI64 eui);
// read an EUI from the binding table. returns false if the binding
// could not be read, was not set, or is not a unicast binding.
// the eui passed in is set by the function.
boolean getEuiFromUnicastBinding(int8u bindingIndex, EmberEUI64* eui);
#endif //USE_BOOTLOADER_LIB
#endif // #ifndef COMMON_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -