📄 task_command.c
字号:
#endif
RF_ClrCommand(CommandClrCount); // notice here !!!
return LISTEN_PACKAGE; // something done, return 1; otherwise return 0.
}
}
//////////////////////////////////////////////////////////////////////////////////
// ((Line_Num==PowerLine_ID) && (RouteAddress == ModuleAddress)
// ((DestinationAddr==ModuleAddress) || (DestinationAddr==RF_BROAD_CAST_ADDR))
//////////////////////////////////////////////////////////////////////////////////
uint8 RF_FunExecute(uint8 ActionType,uint8 *buff_pt)
{
uint8 result;
uint16 i;
Trace_FunAddr((void*)RF_FunExecute);
#ifndef EN_RF_COMMAND_CHANNEL
ExecutedPkgID--; //for next test
#endif
result=NOTHING_TO_DO;
switch(ActionType)
{ //Line_ID,DestinationAddress and RouteAddress matched
/////////////////////////////////////////////////////////////////////////
///////////////////// do notsupport Broadcast address ///////////////////
///////////////////////////
case SETUP_LINE_ID: //caution: can not be inquire
if(DestinationAddr==ModuleAddress){
PowerLine_ID=ActionValue; //lamp control, IO drive here.
SaveLineID();
Uart0SendString("SETUP_LINE_ID");
DelayMS_(1);
#ifdef ENABLE_RESPONSE_HOST
MakeRelayPackage(REVS_ROUTE_DIR); //relay the massage(data package) to host.
Uart0SendString("Response to host");
#else
RF_SendingOver();
MakeRFstopRoutePkg();
RF_SendAddCrc(RFSendByteCounter); //sending data in buffer
Uart0SendString("sending RFstopRoutingPkg");
#endif
}
else if(DestinationAddr==RF_BROAD_CAST_ADDR){
Uart0SendString("don't support broad cast address.");
}
result=SETUP_LINE_ID;
break;
///////////////////////////
case SETUP_MODULE_ADDR: //caution: can not be inquire
if(DestinationAddr==ModuleAddress){
ModuleAddress=ActionValue; //lamp control, IO drive here.
SaveModuleAddr();
Uart0SendString("SETUP_MODULE_ADDR");
DelayMS_(1);
#ifdef ENABLE_RESPONSE_HOST
MakeRelayPackage(REVS_ROUTE_DIR); //relay the massage(data package) to host.
Uart0SendString("Response to host");
#else
RF_SendingOver();
MakeRFstopRoutePkg();
RF_SendAddCrc(RFSendByteCounter); //sending data in buffer
Uart0SendString("sending RFstopRoutingPkg");
#endif
}
else if(DestinationAddr==RF_BROAD_CAST_ADDR){
Uart0SendString("don't support broad cast address.");
}
result=SETUP_MODULE_ADDR;
break;
///////////////////////////
case SET_LAMP_NUM: //caution: can not be inquire
if(DestinationAddr==ModuleAddress){
TubeNumber=ActionValue; //lamp control, IO drive here.
SaveLampNumber();
Uart0SendString("SET_LAMP_NUM");
DelayMS_(1);
#ifdef ENABLE_RESPONSE_HOST
MakeRelayPackage(REVS_ROUTE_DIR); //relay the massage(data package) to host.
Uart0SendString("Response to host");
#else
RF_SendingOver();
MakeRFstopRoutePkg();
RF_SendAddCrc(RFSendByteCounter); //sending data in buffer
Uart0SendString("sending RFstopRoutingPkg");
#endif
}
else if(DestinationAddr==RF_BROAD_CAST_ADDR){
Uart0SendString("don't support broad_cast address.");
}
result = SET_LAMP_NUM;
break;
///////////////////////////
case SET_TRANSFER_KKK: //caution: can not be inquire
TransferKKK=ActionValue; //lamp control, IO drive here.
if((TransferKKK<AUTO_VOLTAGE_MIN_STEP_LEVEL)||(TransferKKK>AUTO_VOLTAGE_MAX_STEP_LEVEL)){
TransferKKK=AUTO_VOLTAGE_STEP_LEVEL;
}
SaveTransferKKK();
Uart0SendString("SET_TRANSFER_KKK");
DelayMS_(1);
if(DestinationAddr==RF_BROAD_CAST_ADDR){ //support broadcast address
MakeRelayPackage(KEEP_ROUTE_DIR); //relay the massage(data package) to other.
Uart0SendString("RelayPackage to others");
}
else if(DestinationAddr==ModuleAddress){
#ifdef ENABLE_RESPONSE_HOST
MakeRelayPackage(REVS_ROUTE_DIR); //relay the massage(data package) to host.
Uart0SendString("Response to host");
#else
RF_SendingOver();
MakeRFstopRoutePkg();
RF_SendAddCrc(RFSendByteCounter); //sending data in buffer
Uart0SendString("sending RFstopRoutingPkg");
#endif
}
result = SET_TRANSFER_KKK;
break;
///////////////////////////
case SET_II_LIMIT: //caution: can not be inquire
#ifdef EN_LOAD_LIMIT_PROTECT
MaxInputLimitII=ActionValue; //lamp control, IO drive here.
Save_II_Limit();
Uart0SendString("SET_I_LIMIT_VALUE");
DelayMS_(1);
if(DestinationAddr==RF_BROAD_CAST_ADDR){ //support broadcast address
MakeRelayPackage(KEEP_ROUTE_DIR); //relay the massage(data package) to other.
Uart0SendString("RelayPackage to others");
}
else if(DestinationAddr==ModuleAddress){
#ifdef ENABLE_RESPONSE_HOST
MakeRelayPackage(REVS_ROUTE_DIR); //relay the massage(data package) to host.
Uart0SendString("Response to host");
#else
RF_SendingOver();
MakeRFstopRoutePkg();
RF_SendAddCrc(RFSendByteCounter); //sending data in buffer
Uart0SendString("sending RFstopRoutingPkg");
#endif
}
#endif
result = SET_II_LIMIT;
break;
///////////////////////////
case SET_CONTROL_TIME: //caution: can not be inquire
ControlTime=ActionValue; //lamp control, IO drive here.
if(ControlTime<AUTO_VOLTAGE_DEFAULT_TIME){
ControlTime=AUTO_VOLTAGE_DEFAULT_TIME;
}
SaveControlTime();
Uart0SendString("SET_CONTROL_TIME");
DelayMS_(1);
if(DestinationAddr==RF_BROAD_CAST_ADDR){ //support broadcast address
MakeRelayPackage(KEEP_ROUTE_DIR); //relay the massage(data package) to other.
Uart0SendString("RelayPackage to others");
}
else if(DestinationAddr==ModuleAddress){
#ifdef ENABLE_RESPONSE_HOST
MakeRelayPackage(REVS_ROUTE_DIR); //relay the massage(data package) to host.
Uart0SendString("Response to host");
#else
RF_SendingOver();
MakeRFstopRoutePkg();
RF_SendAddCrc(RFSendByteCounter); //sending data in buffer
Uart0SendString("sending RFstopRoutingPkg");
#endif
}
result = SET_CONTROL_TIME;
break;
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// support Broadcast address ///////////////////
/////////////////////////////////
case SETUP_TIMER_CONTROL: //setup default control table.
GetControlTable(buff_pt+11+RouteTableLen+RF_DATA_ADDR_BIAS);
SaveControlTable();
Uart0SendString("SETUP_TIMER_CONTROL");
if(DestinationAddr==RF_BROAD_CAST_ADDR){ //support broadcast address
MakeRelayPackage(KEEP_ROUTE_DIR); //relay the massage(data package) to other.
Uart0SendString("RelayPackage to others");
}
else if(DestinationAddr==ModuleAddress){
#ifdef ENABLE_RESPONSE_HOST
MakeRelayPackage(REVS_ROUTE_DIR); //relay the massage(data package) to host.
Uart0SendString("Response to host");
#else
RF_SendingOver();
MakeRFstopRoutePkg();
RF_SendAddCrc(RFSendByteCounter); //sending data in buffer
Uart0SendString("sending RFstopRoutingPkg");
#endif
}
result=SETUP_TIMER_CONTROL;
break;
///////////////////////////////////
case DISABLE_TIMER_CONTROL: //disable default control table.
DisableControlTable();
Uart0SendString("DISABLE_TIMER_CONTROL");
DelayMS_(1);
if(DestinationAddr==RF_BROAD_CAST_ADDR){ //support broadcast address
MakeRelayPackage(KEEP_ROUTE_DIR); // relay the massage(data package) to other
Uart0SendString("RelayPackage to others");
}
else if(DestinationAddr==ModuleAddress){
#ifdef ENABLE_RESPONSE_HOST
MakeRelayPackage(REVS_ROUTE_DIR); //relay the massage(data package) to host.
Uart0SendString("Response to host");
#else
RF_SendingOver();
MakeRFstopRoutePkg();
RF_SendAddCrc(RFSendByteCounter); // sending data in buffer
Uart0SendString("sending RFstopRoutingPkg");
#endif
}
result=DISABLE_TIMER_CONTROL;
break;
//////////////////////////////////
case ENABLE_TIMER_CONTROL: // enable default control table.
EnableControlTable();
Uart0SendString("ENABLE_TIMER_CONTROL");
DelayMS_(1);
if(DestinationAddr==RF_BROAD_CAST_ADDR){ // support the broadcast address
MakeRelayPackage(KEEP_ROUTE_DIR); // relay the massage(data package) to other
Uart0SendString("RelayPackage to others");
}
else if(DestinationAddr==ModuleAddress){
#ifdef ENABLE_RESPONSE_HOST
MakeRelayPackage(REVS_ROUTE_DIR); //relay the massage(data package) to host.
Uart0SendString("Response to host");
#else
RF_SendingOver();
MakeRFstopRoutePkg();
RF_SendAddCrc(RFSendByteCounter); //sending data in buffer
Uart0SendString("sending RFstopRoutingPkg");
#endif
}
result=ENABLE_TIMER_CONTROL;
break;
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// do not support Broadcast address ////////////////////
//////////////////////////////////
case SETUP_ROUTE_TABLE_DN: //setup down_direction route table.
if(DestinationAddr==ModuleAddress){
GetDnRouteTable(buff_pt+12+RouteTableLen+RF_DATA_ADDR_BIAS);
SaveRouteTableDN();
Uart0SendString("SETUP_DN_ROUTE_TABLE");
#ifdef ENABLE_RESPONSE_HOST
MakeRelayPackage(REVS_ROUTE_DIR); //relay the massage(data package) to host.
Uart0SendString("Response to host");
#else
RF_SendingOver();
MakeRFstopRoutePkg();
RF_SendAddCrc(RFSendByteCounter); //sending data in buffer
Uart0SendString("sending RFstopRoutingPkg");
#endif
}
else if(DestinationAddr==RF_BROAD_CAST_ADDR){
Uart0SendString("don't support broad cast address.");
}
result=SETUP_ROUTE_TABLE_DN;
break;
//////////////////////////////////
case SETUP_ROUTE_TABLE_UP: //setup up_direction route table.
if(DestinationAddr==ModuleAddress){
GetUpRouteTable(buff_pt+12+RouteTableLen+RF_DATA_ADDR_BIAS);
SaveRouteTableUP();
Uart0SendString("SETUP_UP_ROUTE_TABLE");
#ifdef ENABLE_RESPONSE_HOST
MakeRelayPackage(REVS_ROUTE_DIR); //relay the massage(data package) to host.
Uart0SendString("Response to host");
#else
RF_SendingOver();
MakeRFstopRoutePkg();
RF_SendAddCrc(RFSendByteCounter); //sending data in buffer
Uart0SendString("sending RFstopRoutingPkg");
#endif
}
else if(DestinationAddr==RF_BROAD_CAST_ADDR){
Uart0SendString("don't support broad cast address.");
}
result=SETUP_ROUTE_TABLE_UP;
break;
////////////////////////////////////////////////////////////////////////
//////////////////////// support Broadcast address /////////////////////
////////////////////////////
case SETUP_CALENDAR:
GetCalendar(buff_pt+12+RouteTableLen+RF_DATA_ADDR_BIAS);
SettingRTC(SettingTime);
Uart0SendString("SETUP_CALENDAR");
DelayMS_(1);
if(DestinationAddr==RF_BROAD_CAST_ADDR){ //support broadcast address
MakeRelayPackage(KEEP_ROUTE_DIR); //relay the massage(data package) to other
Uart0SendString("RelayPackage to others");
}
else if(DestinationAddr==ModuleAddress){
#ifdef ENABLE_RESPONSE_HOST
MakeRelayPackage(REVS_ROUTE_DIR); //relay the massage(data package) to host.
Uart0SendString("Response to host");
#else
RF_SendingOver();
MakeRFstopRoutePkg();
RF_SendAddCrc(RFSendByteCounter); //sending data in buffer
Uart0SendString("sending RFstopRoutingPkg");
#endif
}
result=SETUP_CALENDAR;
break;
//////////////////////// the same way as timer action. ///////////////
//#define Light_toON (0x20-1) //0x1f
//#define Light_toOFF (Light_toON-1) //0x1e
////////////////////////////support broadcast address/////////////////
/////////////////////////////
case VOLTAGE_CONTROL:
#ifdef PACKAGE_RELAY_PRIORITY // process the route information
DelayMS_(1);
if(DestinationAddr==RF_BROAD_CAST_ADDR){
MakeRelayPackage(KEEP_ROUTE_DIR); // relay the massage(data package) to other
Uart0SendString("Relay the Package");
WatchDogClear(); // relay the first package to other in priority
RF_RelayPkgSending(); // for RF channel
RF_SendingOver();
}
else if(DestinationAddr==ModuleAddress){
#ifdef ENABLE_RESPONSE_HOST
MakeRelayPackage(REVS_ROUTE_DIR); //relay the massage(data package) to host.
Uart0SendString("Response to host");
#else //ENABLE_RESPONSE_HOST
RF_SendingOver();
MakeRFstopRoutePkg();
RF_SendAddCrc(RFSendByteCounter); //sending data in buffer
Uart0SendString("sending RFstopRoutingPkg");
#endif //ENABLE_RESPONSE_HOST
}
#endif //PACKAGE_RELAY_PRIORITY
#ifdef EN_ON_OFF_PRIORITY //modified by Travis Feb.9,2006
if(PriorityPkgID == Pkg_SerialNum){
Uart0SendString("kill the priority executed package.");
}else{
CommandLightControl(ActionValue); // execute light control function
}
#else //EN_ON_OFF_PRIORITY
CommandLightControl(ActionValue); // execute light control function
#endif //EN_ON_OFF_PRIORITY
#ifndef PACKAGE_RELAY_PRIORITY // process the route information
DelayMS_(1);
if(DestinationAddr==RF_BROAD_CAST_ADDR){ //support broadcast address
MakeRelayPackage(KEEP_ROUTE_DIR); // relay the data package to other
Uart0SendString("RelayPackage to others");
}
else if(DestinationAddr==ModuleAddress){
#ifdef ENABLE_RESPONSE_HOST
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -