Skip to content

Commit

Permalink
STM32 firmware update to avoid crashe in worst cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi688 committed Mar 16, 2024
1 parent a42a340 commit 3e43d93
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions firmware/STM32F401CCU6/SKMOIP/Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ static void MX_SPI1_Init(void);

static wiz_NetInfo netInfo =
{
.mac = { 0x0c, 0x29, 0xab, 0x7c, 0x00, 0x01 },
.ip = { 192, 168, 1, 113 },
.mac = { 0xec, 0xec, 0xec, 0xec, 0xec, 0xec },
.ip = { 192, 168, 1, 117 },
.sn = { 255, 255, 255, 0 },
.gw = { 192, 168, 1, 1 },
.dns = { 0, 0, 0, 0 },
Expand Down Expand Up @@ -416,6 +416,7 @@ int main(void)
MX_SPI1_Init();
MX_USB_DEVICE_Init();
/* USER CODE BEGIN 2 */
CREATE_SOCKET:
W5500_Init();
SetupNetworkDevice();
SOCKET mySocket = socket(0, Sn_MR_TCP, 2000, 0);
Expand All @@ -439,7 +440,10 @@ int main(void)
while (1)
{
LISTEN_AGAIN:
if(listen(mySocket) != SOCK_OK);
if(listen(mySocket) != SOCK_OK)
{
goto CREATE_SOCKET;
}

while(getSn_SR(mySocket) != SOCK_ESTABLISHED);

Expand All @@ -451,11 +455,11 @@ int main(void)
if(size == SOCKERR_SOCKSTATUS)
{
if(close(mySocket) != SOCK_OK)
Error("failed to close socket\n");
goto LISTEN_AGAIN;
HAL_Delay(100);
if(socket(mySocket, Sn_MR_TCP, 2000, 0) != mySocket)
{
Error("failed to create socket again\n");
goto LISTEN_AGAIN;
}
break;
}
Expand Down Expand Up @@ -524,11 +528,11 @@ int main(void)
if(result == SOCKERR_SOCKSTATUS)
{
if(close(mySocket) != SOCK_OK)
Error("failed to close socket\n");
goto LISTEN_AGAIN;
HAL_Delay(100);
if(socket(mySocket, Sn_MR_TCP, 2000, 0) != mySocket)
{
Error("failed to create socket again\n");
goto LISTEN_AGAIN;
}
}
goto LISTEN_AGAIN;
Expand Down

0 comments on commit 3e43d93

Please sign in to comment.