Hi, I am usnig ESP8266 WiFi module. My APP is communicating with ESP8266 by sending UDP packets. ESP8266 is working as AP. When I send UDP packet, ESP 8266 respond back with message "Success"or "Fail" based on data sent from APP.
When APP receives "Success" packet, I change boolean value (connectionSuccess) to true and when APP receives "Fail"packet, I change boolean value (connectionSuccess) to false.
Now, the problem is, when "Success" packet is received by APP, ït changes boolean value however when APP receives "Fail" packet, my APP automatically gets closed. As APP is connected to ESP8266 AP, I am unable to find the reason.
Code when UDP packet is received
Sub UDP_PacketArrived (Pkt As UDPPacket)
UDPRcvMsg = BytesToString(Pkt.Data, Pkt.Offset, Pkt.Length,"UTF8")
If UDPRcvMsg.SubString2(0,7)="Success" Then
Label3.Text=""
connectionSuccess=True
Else 'If UDPRcvMsg.subString2(0,6)="Failed" Then
Label3.Text="Connection to device is failed. Retry...."
connectionSuccess=False
End If
End Sub
When APP receives "Success" packet, I change boolean value (connectionSuccess) to true and when APP receives "Fail"packet, I change boolean value (connectionSuccess) to false.
Now, the problem is, when "Success" packet is received by APP, ït changes boolean value however when APP receives "Fail" packet, my APP automatically gets closed. As APP is connected to ESP8266 AP, I am unable to find the reason.
Code when UDP packet is received
Sub UDP_PacketArrived (Pkt As UDPPacket)
UDPRcvMsg = BytesToString(Pkt.Data, Pkt.Offset, Pkt.Length,"UTF8")
If UDPRcvMsg.SubString2(0,7)="Success" Then
Label3.Text=""
connectionSuccess=True
Else 'If UDPRcvMsg.subString2(0,6)="Failed" Then
Label3.Text="Connection to device is failed. Retry...."
connectionSuccess=False
End If
End Sub