Facing problem while sending AT commands using le_atclient api service

Hi all,

I am trying to send AT commands and using AT command I want to connect to gprs.
I am getting some error as below and application get stop:
le_atClient_client.c GetCurrentSessionRef() 320 | le_atClient_ConnectService() not called for current thread

my source code is as below:

void fSendandReceiveAtCommand()
    {
        char fd[200];
        strcpy(fd,"WP8548");
        char cmd[100];
        strcpy(cmd,"AT+CSQ");
        char interResp[100];
        char finalResp[100];

        le_result_t res;

        le_atClient_DeviceRef_t ref_device = le_atClient_Start(fd);

        le_atClient_ConnectService();

         le_atClient_CmdRef_t ref_client = le_atClient_Create();

        res = le_atClient_SetCommandAndSend(&ref_client,ref_device,cmd,NULL,"+CPIN:READY",1000);

        if(res == LE_OK)
        {
            LE_INFO("send cmd success inter resp %s   Final resp %s" , interResp, finalResp);
        }
        else if(res == LE_FAULT)
        {
            LE_INFO("fault in send");
        }
        else if(res == LE_TIMEOUT)
        {
            LE_INFO("time out occured");
        }
        else
        {
            LE_INFO("not found ");
        }

    }

In " le_atClient_Start" api, the device path is to be given as argument, which path ideally to be added.?

Can any one please give me solution?
Thank you in advance

I believe you want to call open() on /dev/ttyAT and then pass the resulting file descriptor as the parameter to le_atClient_Start()

Hello dfrey

I have added “open()” before le_atClient_Start() but it is giving same error.

source code:

void fSendandReceiveAtCommand()
    {
        char fd[50];
        strcpy(fd,"/dev/ttyAT");
        char cmd[100];
        strcpy(cmd,"AT+CSQ?");
        char interResp[100];
        char finalResp[100];

        le_result_t res;

        int open_res = 0;

        open_res = open(fd,O_RDWR);

        //sprintf(fd,"%d",open_res);

        le_atClient_DeviceRef_t ref_device = le_atClient_Start(open_res);

        le_atClient_ConnectService();

         le_atClient_CmdRef_t ref_client = le_atClient_Create();

        res = le_atClient_SetCommandAndSend(&ref_client,ref_device,cmd,NULL,"+CPIN:READY",1000);

        if(res == LE_OK)
        {
            LE_INFO("send cmd success inter resp %s   Final resp %s" , interResp, finalResp);
        }
        else if(res == LE_FAULT)
        {
            LE_INFO("fault in send");
        }
        else if(res == LE_TIMEOUT)
        {
            LE_INFO("time out occured");
        }
        else
        {
            LE_INFO("not found ");
        }

    }

COMPONENT_INIT
{
    LE_INFO("Hello, world.");

    fSendandReceiveAtCommand();

}

I haven’t used the ATClient service myself. Maybe this test code can be used as a reference to get you started:

Hi,

I am using same sample code as given in the above link but it is giving me same error at le_atClient_ConnectService().
Error : le_atClient_client.c GetCurrentSessionRef() 320 | le_atClient_ConnectService() not called for current thread

when I tried to use api : le_atClient_TryConnectService
it gives me error : LE_NOT_PERMITTED = -5, ///< Current user does not have permission to perform requested action.

Due to this error, application get stop at starting only and does not execute rest of code.

As I have taken sample code as it is, then also facing this issue.
please give me solution for this issue.

Thank you!

I would think it is because you have not connected your atClient API client to the atClient API server.

Cf Application Definition .adef - Legato Docs for the doc.

It should look like:

bindings:
{
    myApp.myComp.le_atClient -> atService.le_atClient
}