22-02-2022, 13:52
Hej wszystkim.
Mam problem w uzyskaniu odpowiedzi z PHP.
Kod mam taki:
Na ten skrypt w przeglądarce odpowiedź jest 1.
Ale po wysłaniu go przez HTTP z arduino nie mogę usyskać client.avalieble() true więc nie mam zarejestrowanej odpowiedzi.
Może ktoś pomóć?
W logu wygląda to tak:
12:51:28.252 -> IP Address : 192.168.28.222
12:51:28.299 -> Subnet Mask : 255.255.255.0
12:51:28.299 -> Default Gateway IP: 192.168.28.250
12:51:28.346 -> DNS Server IP : 8.8.8.8
12:51:29.424 -> Data sent
12:51:29.424 -> ARDUINO: Client connected : 1
12:51:29.470 -> ARDUINO: Client avaliable : 0
12:51:29.517 -> ARDUINO: no response received / no response received in time
12:51:29.565 -> Disconected
12:51:34.985 -> Conected
12:51:34.985 -> Data sent
12:51:34.985 -> ARDUINO: Client connected : 1
12:51:34.985 -> ARDUINO: Client avaliable : 0
12:51:35.032 -> ARDUINO: no response received / no response received in time
12:51:35.078 -> Disconected
Mam problem w uzyskaniu odpowiedzi z PHP.
Kod mam taki:
Kod:
#include <UIPEthernet.h>
//----ETHERNET----/
EthernetClient client;
char server[] = "192.168.2.11"; //<-Localhost
static byte mac[] = { 0x74, 0x69, 0x69, 0x2D, 0x30, 0x31 };
void setup() {
Serial.begin(9600);
//----ETHERNET----/
Ethernet.begin(mac);
Serial.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
Serial.print("IP Address : ");
Serial.println(Ethernet.localIP());
Serial.print("Subnet Mask : ");
Serial.println(Ethernet.subnetMask());
Serial.print("Default Gateway IP: ");
Serial.println(Ethernet.gatewayIP());
Serial.print("DNS Server IP : ");
Serial.println(Ethernet.dnsServerIP());
}
void loop() {
sender();
delay(5000);
}
void sender(){
if(client.connect(server, 80)){
Serial.println("Conected");
}
client.print( "GET /FoF_AC_CzyOtworzycDrzwi_2.php?Karta=5911250");
// client.print(5911250);
client.println(" HTTP/1.1");
client.print("HOST: ");
client.println(server);
client.println();
client.println();
Serial.println("Data sent");
delay(100);
Serial.print("ARDUINO: Client connected : ");
Serial.println(client.connected());
Serial.print("ARDUINO: Client avaliable : ");
Serial.println(client.available());
if(client.available())
{
Serial.println("ARDUINO: HTTP message received");
Serial.println("ARDUINO: printing received headers and script response...\n");
while(client.available())
{
char c = client.read();
Serial.print(c);
}
//Code to display info through the serial monitor and the LCD
}
else
{
Serial.println("ARDUINO: no response received / no response received in time");
}
client.stop();
Serial.println("Disconected");
}
Na ten skrypt w przeglądarce odpowiedź jest 1.
Ale po wysłaniu go przez HTTP z arduino nie mogę usyskać client.avalieble() true więc nie mam zarejestrowanej odpowiedzi.
Może ktoś pomóć?
W logu wygląda to tak:
12:51:28.252 -> IP Address : 192.168.28.222
12:51:28.299 -> Subnet Mask : 255.255.255.0
12:51:28.299 -> Default Gateway IP: 192.168.28.250
12:51:28.346 -> DNS Server IP : 8.8.8.8
12:51:29.424 -> Data sent
12:51:29.424 -> ARDUINO: Client connected : 1
12:51:29.470 -> ARDUINO: Client avaliable : 0
12:51:29.517 -> ARDUINO: no response received / no response received in time
12:51:29.565 -> Disconected
12:51:34.985 -> Conected
12:51:34.985 -> Data sent
12:51:34.985 -> ARDUINO: Client connected : 1
12:51:34.985 -> ARDUINO: Client avaliable : 0
12:51:35.032 -> ARDUINO: no response received / no response received in time
12:51:35.078 -> Disconected