LOCAL void ICACHE_FLASH_ATTR resolve_cb(const char *name, ip_addr_t *ip, void *arg) {
	if (ip == NULL) {
		dhdebug("Resolve %s failed. Trying again...", name);
		mConnectionState = CS_DISCONNECT;
		arm_repeat_timer(RETRY_CONNECTION_INTERVAL_MS);
		dhstatistic_inc_network_errors_count();
		return;
	}
	unsigned char *bip = (unsigned char *) ip;
	dhdebug("Host %s ip: %d.%d.%d.%d, using port %d", name, bip[0], bip[1], bip[2], bip[3], mDHConnector.proto.tcp->remote_port);

	dhsender_init(ip, mDHConnector.proto.tcp->remote_port);
	dhconnector_init_connection(ip);
	if(mPollRequest.len)
		set_state(CS_POLL);
	else
		set_state(CS_GETINFO);
}
LOCAL void ICACHE_FLASH_ATTR senderErrorCb(void *arg, sint8 err) {
	dhesperrors_espconn_result("Sender error occurred:", err);
	decrementSenderTook();
	dhsender_arm_timer(RETRY_CONNECTION_INTERVAL_MS);
	dhstatistic_inc_network_errors_count();
}
LOCAL void network_error_cb(void *arg, sint8 err) {
	dhesperrors_espconn_result("Connector error occurred:", err);
	mConnectionState = CS_DISCONNECT;
	arm_repeat_timer(RETRY_CONNECTION_INTERVAL_MS);
	dhstatistic_inc_network_errors_count();
}