本文整理汇总了C++中EthernetClient::GetIpAddress方法的典型用法代码示例。如果您正苦于以下问题:C++ EthernetClient::GetIpAddress方法的具体用法?C++ EthernetClient::GetIpAddress怎么用?C++ EthernetClient::GetIpAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EthernetClient
的用法示例。
在下文中一共展示了EthernetClient::GetIpAddress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetVals
Weather::ReturnVals Weather::GetVals(const char * key, uint32_t zip, const char * pws, bool usePws) const
{
ReturnVals vals = {0};
EthernetClient client;
if (client.connect(m_wundergroundAPIHost, 80))
{
char getstring[255];
trace(F("Connected\n"));
if (usePws)
snprintf(getstring, sizeof(getstring), "GET http://%s/api/%s/yesterday/conditions/q/pws:%s.json HTTP/1.1\r\n",m_wundergroundAPIHost, key, pws);
else
snprintf(getstring, sizeof(getstring), "GET http://%s/api/%s/yesterday/conditions/q/%ld.json HTTP/1.1\r\n",m_wundergroundAPIHost, key, (long) zip);
//trace("GetString:%s\n",getstring);
client.write((uint8_t*) getstring, strlen(getstring));
//send host header
snprintf(getstring, sizeof(getstring), "Host: %s\r\nConnection: close\r\n\r\n",m_wundergroundAPIHost);
//trace("GetString:%s\n",getstring);
client.write((uint8_t*) getstring, strlen(getstring));
ParseResponse(client, &vals);
vals.resolvedIP=client.GetIpAddress();
client.stop();
if (!vals.valid)
{
if (vals.keynotfound)
trace("Invalid WUnderground Key\n");
else
trace("Bad WUnderground Response\n");
}
}
else
{
trace(F("connection failed\n"));
client.stop();
}
return vals;
}