apps/network: implemented ping request.

This commit is contained in:
Martin Preuss
2025-05-29 15:47:21 +02:00
parent b4e747c3db
commit 581eeff996
2 changed files with 31 additions and 1 deletions

View File

@@ -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
;