0

Hello I'm trying to start the SRP(Service Registration Protocol) Client in my main.c. I've found following description in 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)

My 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();
....
}

Can Someone explain me how i can define the parameters for the function?

uyl
  • 1

1 Answers1

0

This is my Code and I can Flash the Firmware but the Thread Device doesn't connect to the Thread Network anymore.

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
uyl
  • 1