如何解决main.c 中的 Openthread SRP 客户端
您好,我正在尝试在 main.c 中启动 SRP(服务注册协议)客户端。我在 openthread/srp_client.h 中找到了以下描述"
* This function starts the SRP client operation.
SRP client will prepare and send "SRP Update" message to the SRP server once all the following
conditions are met:
- The SRP client is started - `otSrpClientStart()` is called.
- Host name is set - `otSrpClientSetHostName()` is called.
- At least one host IPv6 address is set - `otSrpClientSetHostName()` is called.
- At least one service is added - `otSrpClientAddService()` is called.
It does not matter in which order these functions are called. When all conditions are met,the
SRP client will wait for a short delay before preparing an "SRP Update" message and sending to
server.
* @param[in] aInstance A pointer to the OpenThread instance.
* @param[in] aServerSockAddr The socket address (IPv6 address and port number) of the SRP
* server.
*
* @retval OT_ERROR_NONE SRP client operation started successfully or it is already
running with same server
* socket address and callback.
* @retval OT_ERROR_BUSY SRP client is busy running with a different socket address.
* @retval OT_ERROR_Failed Failed to open/connect the client's UDP socket.
*/
otError otSrpClientStart(otInstance *aInstance,const otSockAddr *aServerSockAddr);
srp_client.h
otError otSrpClientStart(otInstance *aInstance,const otSockAddr *aServerSockAddr)
otError otSrpClientSetHostName(otInstance *aInstance,const char *aName)
otError otSrpClientAddService(otInstance *aInstance,otSrpClientService *aService)
我的 Main.c
#include <openthread/srp_client.h>
static void SrpClientinit(void){
otSrpClientStart(**What comes in here?**,**How can i Use the EUI64 as IP?**)
otSrpClientSetHostName(**What comes in here?**,'SrpTest')
otSrpClientAddService(**What comes in here?**,**What comes in here?**)
}
int main(int argc,char *argv[]){
....
SrpClientinit();
....
}
谁能解释我如何定义函数的参数?
解决方法
这是我的代码,我可以刷入固件,但 Thread 设备不再连接到 Thread 网络。
void SrpClientInit(void)
{
otSockAddr SRP_1;
SRP_1.mAddress.mFields.mComponents.mIid.mFields.m8[0] = 0xff;
SRP_1.mPort = 0xff;
otSockAddr *SRP_1_pointer = &SRP_1;
otIp6Address SRPaddr;
SRPaddr.mFields.m16[0] = 0xfff;
otIp6Address *SRPaddr_pointer = &SRPaddr;
otSrpClientService SRPclient;
SRPclient.mName = "_knx._udp";
SRPclient.mInstanceName = "fancy-service";
//SRPclient.mTxtEntries->mKey = NULL;
SRPclient.mPort = 12356;
SRPclient.mPriority = 1;
SRPclient.mWeight = 1;
SRPclient.mNumTxtEntries = 1;
otSrpClientService *SRPclient_pointer = &SRPclient;
otSrpClientSetHostName(sInstance,"SRPtest");
otSrpClientSetHostAddresses(sInstance,SRPaddr_pointer,0x0f);
otSrpClientAddService(sInstance,SRPclient_pointer);
otSrpClientStart(sInstance,SRP_1_pointer);
}
srp_client.h
#define OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_DEFAULT_MODE 1
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。