ENC28J60 и Domoticz
- Войдите на сайт для отправки комментариев
Вс, 20/05/2018 - 08:49
Здравствуйте.
Помогите пожалуйста написать скетч для отправки вот такого GET запроса
http://192.168.1.38:8080/json.htm?type=command¶m=udevice&idx=4&nvalu...
с помощью ардуино и модуля ENC28J60
Перепробовал все, что только нашел и библиотеку ethercard и UIPEthernet - один хрен ничего не работает.
Сейчас код такой:
#include <EtherCard.h>
#define REQUEST_RATE 5000 // milliseconds
// ethernet interface mac address
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
// ethernet interface ip address
static byte myip[] = { 192,168,1,203 };
// gateway ip address
static byte gwip[] = { 192,168,1,1 };
// remote website ip address and port
static byte hisip[] = { 192,168,1,38 };
static byte hisport[] = { 8080 };
// remote website name
const char website[] PROGMEM = "192.168.1.38";
byte Ethernet::buffer[1000]; // a very small tcp/ip buffer is enough here
static long timer;
// called when the client request is complete
static void my_result_cb (byte status, word off, word len) {
Serial.print("<<< reply ");
Serial.print(millis() - timer);
Serial.println(" ms");
Serial.println((const char*) Ethernet::buffer + off);
}
void setup () {
Serial.begin(57600);
Serial.println("\n[getStaticIP]");
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println( "Failed to access Ethernet controller");
ether.staticSetup(myip, gwip);
ether.copyIp(ether.hisip, hisip);
ether.printIp("Server: ", ether.hisip);
while (ether.clientWaitingGw())
ether.packetLoop(ether.packetReceive());
Serial.println("Gateway found");
timer = - REQUEST_RATE; // start timing out right away
}
void loop () {
ether.packetLoop(ether.packetReceive());
if (millis() > timer + REQUEST_RATE) {
timer = millis();
Serial.println("\n>>> REQ");
ether.browseUrl(PSTR("/json.htm?"), "type=command¶m=udevice&idx=4&nvalue=0&svalue=25", website, my_result_cb);
//ether.browseUrl(PSTR(""), "/json.htm?type=command¶m=udevice&idx=4&nvalue=0&svalue=25", website, my_result_cb);
}
}
Шлюз видит, запрос вроде бы отправляет - но сервер не реагирует никак.
Спасибо.