diff --git a/avr/apps/network/main.asm b/avr/apps/network/main.asm index a52aa97..04e8527 100644 --- a/avr/apps/network/main.asm +++ b/avr/apps/network/main.asm @@ -111,6 +111,8 @@ AppNetwork_HandleMsg: sbiw xh:xl, NETMSG_OFFS_CMD cpi r16, NETMSG_CMD_REBOOT_REQUEST breq AppNetwork_HandleMsg_handleRebootMsg + cpi r16, NETMSG_CMD_PING + breq AppNetwork_HandleMsg_handlePingMsg cpi r16, NETMSG_CMD_NEED_ADDRESS brcs AppNetwork_HandleMsg_clcRet ; lower than "HAVE_NEED" cpi r16, NETMSG_CMD_ADDRESS_RANGE @@ -138,6 +140,13 @@ AppNetwork_HandleMsg_handleRebootMsg: pop xh pop xl ret +AppNetwork_HandleMsg_handlePingMsg: + push xl + push xh + rcall appNetworkHandlePingRequest + pop xh + pop xl + ret AppNetwork_HandleMsg_clcRet: clc ret @@ -162,6 +171,27 @@ appNetworkHandleRebootRequest_end: +appNetworkHandlePingRequest: + adiw xh:xl, NETMSG_OFFS_SRCADDR + ld r17, X + push r17 + rcall NET_Buffer_Alloc ; (R16, R17, X) + pop r17 + brcc appNetworkHandlePingRequest_end ; jmp on error + push r16 ; buffer num + mov r16, r17 ; DEST addr + ldi r18, NETMSG_CMD_PONG ; msg type + adiw xh:xl, 1 + ldi yl, LOW(netInterfaceData) + ldi yh, HIGH(netInterfaceData) + rcall NETMSG_SimpleMsgWrite ; (R16, R17, R18, R19, R20, X) + sbiw xh:xl, 1 + pop r16 ; buffer num + rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) +appNetworkHandlePingRequest_end: + ret + + appNetworkTimerTable: rjmp appNetworkHandleStateInitialWait @@ -233,7 +263,6 @@ appNetworkHandleStateUp: ret - ; --------------------------------------------------------------------------- ; @routine appNetworkSendMsgNextState ; diff --git a/avr/devices/all/includes.asm b/avr/devices/all/includes.asm index eea0d35..3d96891 100644 --- a/avr/devices/all/includes.asm +++ b/avr/devices/all/includes.asm @@ -196,6 +196,7 @@ .include "apps/network/main.asm" .include "modules/network/msg/reboot-d.asm" .include "modules/network/msg/reboot-r.asm" +.include "modules/network/msg/simplemsg-w.asm" #endif