本文整理汇总了C++中NetConnection::readCallback方法的典型用法代码示例。如果您正苦于以下问题:C++ NetConnection::readCallback方法的具体用法?C++ NetConnection::readCallback怎么用?C++ NetConnection::readCallback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetConnection
的用法示例。
在下文中一共展示了NetConnection::readCallback方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strlen
void ICACHE_FLASH_ATTR esp8266_resolveCallback(const char* name, ip_addr_t* ip, void* arg)
{
struct espconn* conn = (struct espconn*)arg;
NetConnection* netConn = (NetConnection*)conn->reverse;
uart0_tx_buffer("get conn\r\n", 10);
HTTPESP8266ConnectionData* driver = esp8266_getConnection(netConn);
uart0_tx_buffer("check ip\r\n", 10);
if(!ip)
{ // failed to lookup the hostname
uart0_tx_buffer("bad ip\r\n", 8);
esp8266_destroyConnection(netConn);
netConn->readCallback(netConn->userData, NULL, 0, net_error);
return;
}
char pageBuffer[20];
ets_sprintf(pageBuffer, "r: %d.%d.%d.%d\r\n", IP2STR(ip));
uart0_tx_buffer(pageBuffer, strlen(pageBuffer));
uart0_tx_buffer("set tcp callbacks\r\n", 19);
espconn_regist_connectcb(conn, esp8266_connectCallback);
espconn_regist_disconcb(conn, esp8266_disconnectCallback);
espconn_regist_reconcb(conn, esp8266_reconnectCallback);
uart0_tx_buffer("set callbacks\r\n", 15);
espconn_regist_recvcb(conn, esp8266_recvCallback);
espconn_regist_sentcb(conn, esp8266_sendCallback);
uart0_tx_buffer("set ip\r\n", 8);
ets_memcpy(&conn->proto.tcp->remote_ip, ip, 4);
if(driver->secure)
{
uart0_tx_buffer("async sconnect\r\n", 16);
conn->proto.tcp->remote_port = 443;
ets_sprintf(pageBuffer, "port: %d\r\n", conn->proto.tcp->remote_port);
uart0_tx_buffer(pageBuffer, strlen(pageBuffer));
sint8 r = espconn_secure_connect(conn);
ets_sprintf(pageBuffer, "c_conn: %d\r\n", r);
uart0_tx_buffer(pageBuffer, strlen(pageBuffer));
}
else
{
uart0_tx_buffer("async connect\r\n", 15);
conn->proto.tcp->remote_port = 80;
ets_sprintf(pageBuffer, "port: %d\r\n", conn->proto.tcp->remote_port);
uart0_tx_buffer(pageBuffer, strlen(pageBuffer));
sint8 r = espconn_connect(conn);
ets_sprintf(pageBuffer, "c_conn: %d\r\n", r);
uart0_tx_buffer(pageBuffer, strlen(pageBuffer));
}
}