ZHCU938C May 2018 – January 2021 CC3100 , CC3100MOD , CC3200 , CC3200MOD
sl_NetAppStart – 启用或启动不同的网络服务。可以是以下一项,也可以是多项的组合:
sl_NetAppStop – 禁用或停止网络服务。与 sl_NetAppStart 中的选项类似。
sl_NetAppSet 设置各种网络应用参数
示例:
unsigned char str[32] = "domainname.net";
unsigned char len = strlen((const char *)str);
retVal = sl_NetAppSet(SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME,
len, (unsigned char*)str);
sl_NetAppGet – 检索各种网络应用参数。
sl_NetAppDnsGetHostByName – 根据机器名称获取网络上某台机器的 IP 地址。
示例:
unsigned long DestinationIP;
sl_NetAppDnsGetHostByName("www.ti.com", strlen("www.ti.com"), &DestinationIP, SL_AF_INET);
Addr.sin_family = SL_AF_INET; Addr.sin_port = sl_Htons(80);
Addr.sin_addr.s_addr = sl_Htonl(DestinationIP);
AddrSize = sizeof(SlSockAddrIn_t);
SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
sl_NetAppDnsGetHostByService – 根据服务名称返回服务属性,如 IP 地址、端口和文本。用户设置完整或部分服务名称(请参阅以下示例),并且应获得:
这类似于 GET host by name(按名称获取主机)方法,实际是对服务名称进行 PTR 类型的一次性查询。完整服务名称的示例如下:
部分服务名称的示例如下:
sl_NetAppGetServiceList – 获取对等服务的列表。该列表采用服务结构的形式。用户选择服务结构的类型。支持的结构:
不同类型的结构可以节省主机中的内存。
sl_NetAppMDNSRegisterService – 向 mDNS 包和数据库注册新的 mDNS 服务。该注册服务由应用提供。根据 DNS-SD RFC,服务名称应该是完整服务名称,即 SRV 应答中名称字段中的值。
服务名称示例:
如果设置了 is_unique 选项,mDNS 会探测服务名称,以确保它是唯一的,然后在网络上公布该服务。
sl_NetAppMDNSUnRegisterService – 从 mDNS 包和数据库中删除 mDNS 服务。
sl_NetAppPingStart – 向网络主机发送 ICMP ECHO_REQUEST(或 Ping)。以下是发送 20 个 Ping 请求并在发送所有请求后将结果报告给回调例程的示例:
// callback routine
void pingRes(SlPingReport_t* pReport)
{
// handle ping results
}
// ping activation
void PingTest()
{
SlPingReport_t report;
SlPingStartCommand_t pingCommand;
pingCommand.Ip = SL_IPV4_VAL(10,1,1,200); // destination IP address is 10.1.1.200
pingCommand.PingSize = 150; // size of ping, in bytes
pingCommand.PingIntervalTime = 100; // delay between pings, in milliseconds
pingCommand.PingRequestTimeout = 1000; // timeout for every ping in milliseconds
pingCommand.TotalNumberOfAttempts = 20; // max number of ping requests.0 - forever
pingCommand.Flags = 0; // report only when finished
sl_NetAppPingStart( &pingCommand, SL_AF_INET, &report, pingRes ) ;
}