Other Parts Discussed in Thread: CC3135
主题中讨论的其他器件:CC3135
大家好、
我使用 CC3135模块连接到 WiFi 网络。 我的设备使用由特定于设备的 ID 和通用服务名称组成的服务名称在网络上进行广播:
int simplelink_configure_mdns(int mode, char *name, char* txt, int port)
{
static char mds_service[64];
int retval;
retval = simplelink_start_stop_mdns(1); // Start mdns service <-- Registration of a new service should be performed only if the mDNS service is enabled
ASSERT_ON_ERROR(retval, NETAPP_ERROR);
// unregister mdns services
retval = sl_NetAppMDNSUnRegisterService(0, 0, 0);
ASSERT_ON_ERROR(retval, NETAPP_ERROR);
if (!mode)
{
return retval;
}
//name = device ID
//MDNS_STRING = "_smartcam._tcp.local"
sprintf(mds_service, "%s.%s", name, MDNS_STRING);
/* Stop continuous query */
retval = sl_NetAppSet(SL_NETAPP_MDNS_ID, SL_NETAPP_MDNS_CONT_QUERY_OPT,0 , 0);
/* Register mDNS services */
// Advertise (Mdns host) broadcasts its own IP address, port number and message to 224.0.0.251 + 5353
uint32_t opt = /*SL_NETAPP_MDNS_OPTIONS_IS_UNIQUE_BIT |*/ SL_NETAPP_MDNS_IPV4_ONLY_SERVICE | SL_NETAPP_MDNS_OPTIONS_IS_NOT_PERSISTENT;
retval = sl_NetAppMDNSRegisterService((const signed char*)mds_service, strlen(mds_service),
(const signed char*)txt, strlen(txt), port, TTL_VALUE, opt);
ASSERT_ON_ERROR(retval, NETAPP_ERROR);
LOG_SERIAL_INFO("[mDNS advertise] : service name %s registered successfully", mds_service);
/* The below parameters are used to configure the advertise times and interval
For example:
If:
Period is set to T
Repetitions are set to P
Telescopic factor is K=2
The transmission shall be:
advertise P times
wait T
advertise P times
wait 4 * T
advertise P time
wait 16 * T ... (till max time reached / configuration changed / query issued)
*/
SlNetAppServiceAdvertiseTimingParameters_t Timing;
Timing.t = 100; // 1 seconds Default is 100 ticks for 1 second
Timing.p = 2; // 2 repetitions
Timing.k = 2; // Telescopic factor 1
Timing.RetransInterval = 500;
Timing.Maxinterval = 1000;
Timing.max_time = 0xFF; // in seconds FOREVER
retval = sl_NetAppSet(SL_NETAPP_MDNS_ID, SL_NETAPP_MDNS_TIMING_PARAMS_OPT, sizeof(Timing), (const unsigned char*)&Timing);
if (retval < 0)
{
LOG_SERIAL_ERROR("[mDNS advertise] : mDNS set timing params %d", retval);
}
return retval;
}
当我 只有一个器件广播时、我会在查找器件的软件中的"标准查询"后看到"标准查询响应": 
而当我有2个器件时、我也会看到两个器件发送查询作为对软件查询的答复(请参阅突出显示的消息) 
设备似乎正在向 PC 发送查询而不是查询响应。
有人能解释一下原因吗? 我可以通过某种方式避免它吗? 这种行为似乎正在减慢 PC 对器件的检测速度。
谢谢你
此致
Arianna
