I'm trying to work with native C on the ESP8266-01 module I have but I am getting what I think is an invalid parameter code coming back from an API call and to me everything looks OK.
I have a pointer to a connection object which I initialise as follows:
struct espconn *_ptrUDPServer;
//
// Allocate an "espconn" for the UDP connection.
//
_ptrUDPServer = (struct espconn *) os_zalloc(sizeof(struct espconn));
_ptrUDPServer->type = ESPCONN_UDP;
_ptrUDPServer->state = ESPCONN_NONE;
_ptrUDPServer->proto.udp = (esp_udp *) os_zalloc(sizeof(esp_udp));
_ptrUDPServer->proto.udp->local_port = 1000;
sint8 result = espconn_create(_ptrUDPServer);
I have a timer running every second which is trying to send a message to the server:
void TimerCallback(void *arg)
{
struct ip_info info;
wifi_get_ip_info(STATION_IF, &info);
if (wifi_station_get_connect_status() != STATION_GOT_IP || info.ip.addr == 0)
{
BitBang(0x01);
}
else
{
BitBang(0x02);
sint8 result = espconn_sent(_ptrUDPServer, (uint8 *) USER_DATA, (uint16) strlen(USER_DATA));
BitBang(result);
}
}
Where USER_DATA is a simple string for the minute. The BitBang method just dumps data out on GPIO0 and GPIO2 for debugging.
I have tried setting the remote port, the destination IP address (direct and the broadcast address for the subnet) and various combinations of each.
Has anyone managed to get this sort of scenario working as I' appreciate some pointers.
Regards,
Mark