MQTT sample cpde for MC60

Hi,

I am using MC60_OpenCPU_GS3_SDK_V1.6 SDK to develop MQTT client, but there is no example code for using MQTT protocol (inside cloud\protocol\mqtt APIs). Can anyone please help with MQTT sample example for MC60?

Thanks!

Hi @trakbond
kindly use this below example

/*****************************************************************************

  • Copyright Statement:

  • This software is protected by Copyright and the information contained
  • herein is confidential. The software may not be copied and the information
  • contained herein may not be used or disclosed except with the written
  • permission of Quectel Co., Ltd. 2013

/
/

*

  • Filename:

  • example_tcpssl.c
  • Project:

  • OpenCPU
  • Description:

  • This example demonstrates how to use tcp ssl function with APIs in OpenCPU.
  • Usage:

  • Compile & Run:
  • Set "C_PREDEF=-D __EXAMPLE_TCPSSL__" in gcc_makefile file. And compile the 
    
  • app using "make clean/new".
    
  • Download image bin to module to run.
    
  • Operation:
  • Author:


*============================================================================

  •         HISTORY
    

*----------------------------------------------------------------------------
*
****************************************************************************/

#ifdef EXAMPLE_MQTT
#include “ql_stdlib.h”
#include “ql_common.h”
#include “ql_type.h”
#include “ql_trace.h”
#include “ql_error.h”
#include “ql_uart.h”
#include “ql_gprs.h”
#include “ql_timer.h”
#include “ril_network.h”
#include “ril.h”
#include “ril_util.h”
#include “ril_system.h”

#define DEBUG_ENABLE 1
#if DEBUG_ENABLE > 0
#define DEBUG_PORT UART_PORT1
#define DBG_BUF_LEN 512
static char DBG_BUFFER[DBG_BUF_LEN];
#define APP_DEBUG(FORMAT,…) {
Ql_memset(DBG_BUFFER, 0, DBG_BUF_LEN);
Ql_sprintf(DBG_BUFFER,FORMAT,##VA_ARGS);
if (UART_PORT2 == (DEBUG_PORT))
{
Ql_Debug_Trace(DBG_BUFFER);
} else {
Ql_UART_Write((Enum_SerialPort)(DEBUG_PORT), (u8*)(DBG_BUFFER), Ql_strlen((const char *)(DBG_BUFFER)));
}
}
#else
#define APP_DEBUG(FORMAT,…)
#endif

typedef struct{
u8 index;
u8* prefix;
s32 data;
u32 length;

}MQTT_Param;

/*****************************************************************

  • timer param
    ******************************************************************/
    #define MQTT_TIMER_ID TIMER_ID_USER_START
    #define TIMEOUT_90S_TIMER_ID TIMER_ID_USER_START + 1 //timeout
    #define MQTT_TIMER_PERIOD 100
    #define TIMEOUT_90S_PERIOD 90000

static s32 timeout_90S_monitor = FALSE;

/*****************************************************************

  • APN Param
    ******************************************************************/
    static u8 m_apn[MAX_GPRS_APN_LEN] = “cmnet”;
    static u8 m_userid[MAX_GPRS_USER_NAME_LEN] = “”;
    static u8 m_passwd[MAX_GPRS_PASSWORD_LEN] = “”;

/**********************************************************************************/

#define MAX_MQTT_PARAM_LENGTH 100
// #define HOST_NAME “iot-as-mqtt.cn-shanghai.aliyuncs.com
#define HOST_NAME “test.mosquitto.org
#define HOST_PORT 1883
#define CONTEXT 0

static u8 product_key[MAX_MQTT_PARAM_LENGTH] = “142”;
static u8 device_name[MAX_MQTT_PARAM_LENGTH] = “TEST1”;
static u8 device_secret[MAX_MQTT_PARAM_LENGTH] = “lN9l09QesoiL4HXw7W9Z1XVJ0JzTJxhs”;

static u8 topic_update[MAX_MQTT_PARAM_LENGTH] = “adpp”;
// static u8 topic_update[MAX_MQTT_PARAM_LENGTH] = “/hDTjzV2bVeR/TEST1/update”;
static u8 topic_error[MAX_MQTT_PARAM_LENGTH] = “/hDTjzV2bVeR/TEST1/update/error”;
static u8 topic_get[MAX_MQTT_PARAM_LENGTH] = “/hDTjzV2bVeR/TEST1/get”;

/*************************************************************************************/

u8 test_message[50] = “allan\0”;

typedef enum{
STATE_NW_GET_SIMSTATE,
STATE_NW_QUERY_STATE,
STATE_GPRS_CONTEXT,
STATE_GPRS_ACTIVATE,
STATE_MQTT_CFG,
STATE_MQTT_OPEN,
STATE_MQTT_CONN,
STATE_MQTT_SUB_1,
STATE_MQTT_SUB_2,
STATE_MQTT_PUB,
STATE_MQTT_CLOSE,
STATE_GPRS_DEACTIVATE,
STATE_TOTAL_NUM,
NULL_STATE
}Enum_TCPSTATE;

static u8 m_tcp_state = STATE_NW_GET_SIMSTATE;

static MQTT_Param mqtt_param;
/*****************************************************************

  • uart callback function
    ****************************************************************/
    static void CallBack_UART_Hdlr(Enum_SerialPort port, Enum_UARTEventType msg, bool level, void
    customizedPara);
    static void Callback_Timer(u32 timerId, void
    param);

static s32 ATResponse_mqtt_handler(char* line, u32 len, void* userdata);
static s32 ATResponse_mqtt_handler_pub(char* line, u32 len, void* userdata);
static s32 ATResponse_mqtt_handler_close(char* line, u32 len, void* userdata);
static void Hdlr_Mqtt_Recv_Data(u8* packet);
static void Hdlr_Mqtt_Recv_State(u8* packet);

s32 RIL_MQTT_QMTCFG_Ali( u8 connectID,u8* product_key,u8* device_name,u8* device_secret);
s32 RIL_MQTT_QMTOPEN( u8 connectID,u8* hostName, u32 port );
s32 RIL_MQTT_QMTCONN(u8 connectID, u8* clientID,u8* username,u8* password);
s32 RIL_MQTT_QMTSUB(u8 connectID, u8 msgId,u8* topic, u8 qos,u8* others);
s32 RIL_MQTT_QMTPUB(u8 connectID, u8 msgId,u8 qos,u8 retain, u8* topic,u8* data,u8 length);
s32 RIL_MQTT_QMTDISC(u8 connectID);
s32 RIL_MQTT_QMTCLOSE(u8 connectID);
s32 RIL_MQTT_QMTUNS(u8 connectID, u8 msgId,u8* topic,u8* others);

void proc_main_task(s32 taskId)
{
s32 ret;
ST_MSG msg;

// Register & open UART port
Ql_UART_Register(UART_PORT1, CallBack_UART_Hdlr, NULL);
Ql_UART_Open(UART_PORT1, 115200, FC_NONE);

APP_DEBUG("<--OpenCPU: mqtt test.-->\r\n");

Ql_Timer_Register(MQTT_TIMER_ID, Callback_Timer, NULL);
Ql_Timer_Start(MQTT_TIMER_ID, MQTT_TIMER_PERIOD, TRUE);

Ql_Timer_Register(TIMEOUT_90S_TIMER_ID, Callback_Timer, NULL);
timeout_90S_monitor = FALSE;

while(TRUE)
{
    Ql_OS_GetMessage(&msg);
    switch(msg.message)
   {
    case MSG_ID_RIL_READY:
        APP_DEBUG("<-- RIL is ready -->\r\n");
        Ql_RIL_Initialize();
        break;
    case MSG_ID_URC_INDICATION:
        switch (msg.param1)
        {
 	       case URC_MQTT_RECV_IND:
 	         APP_DEBUG("<-- RECV DATA:%s -->\r\n", msg.param2);
 			 Hdlr_Mqtt_Recv_Data(msg.param2);
 		    break;
 	       case URC_MQTT_STAT_IND:
 	         APP_DEBUG("<-- RECV STAT:%s-->\r\n", msg.param2);
 			 Hdlr_Mqtt_Recv_State(msg.param2);
 		   break;
        }
	    break;
     default:
        break;
    }

}
}

//src_string=“GPRMC,235945.799,V,0.00,0.00,050180,N” index =1 ·µ»ØTRUE ,dest_string=“235945.799”; index =3£¬·µ»ØFALSE
char QSDK_Get_Str(char *src_string, char *dest_string, unsigned char index)
{
char SentenceCnt = 0;
char ItemSum = 0;
char ItemLen = 0, Idx = 0;
char len = 0;
unsigned int i = 0;

if (src_string ==NULL)
{
    return FALSE;
}
len = Ql_strlen(src_string);
for ( i = 0;  i < len; i++)
{
	if (*(src_string + i) == ',')
	{
		ItemLen = i - ItemSum - SentenceCnt;
		ItemSum  += ItemLen;
        if (index == SentenceCnt )
        {
            if (ItemLen == 0)
            {
                return FALSE;
            }
	        else
            {
                Ql_memcpy(dest_string, src_string + Idx, ItemLen);
                *(dest_string + ItemLen) = '\0';
                return TRUE;
            }
        }
		SentenceCnt++; 	 
		Idx = i + 1;
	}		
}
if (index == SentenceCnt && (len - Idx) != 0)
{
    Ql_memcpy(dest_string, src_string + Idx, len - Idx);
    *(dest_string + len) = '\0';
    return TRUE;
}
else 
{
    return FALSE;
}

}

static void Hdlr_Mqtt_Recv_Data(u8* packet)
{
u8 mqtt_message[1024]={0};
QSDK_Get_Str(packet,mqtt_message,3);
APP_DEBUG("<-- RECV message:%s–>\r\n",mqtt_message);

}
static void Hdlr_Mqtt_Recv_State(u8* packet)
{
char strTmp[10];

Ql_memset(strTmp, 0x0, sizeof(strTmp));
QSDK_Get_Str(packet,strTmp,3);
APP_DEBUG("<-- mqtt state = %d-->\r\n",Ql_atoi(strTmp));

}

static void CallBack_UART_Hdlr(Enum_SerialPort port, Enum_UARTEventType msg, bool level, void* customizedPara)
{

}

static void Callback_Timer(u32 timerId, void* param)
{
s32 ret ;

if (MQTT_TIMER_ID == timerId)
{
switch(m_tcp_state)
{
case NULL_STATE:
{

	}
	break;
  case STATE_NW_GET_SIMSTATE:
  {
	  s32 simStat = 0;
	  RIL_SIM_GetSimState(&simStat);
	  if (simStat == SIM_STAT_READY)
	  {
		  m_tcp_state = STATE_NW_QUERY_STATE;
		  APP_DEBUG("<--SIM card status is normal!-->\r\n");
	  }else
	  {
		  APP_DEBUG("<--SIM card status is unnormal!-->\r\n");
	  }
	  break;
  } 	   
  case STATE_NW_QUERY_STATE:
  {
	  s32 creg = 0;
	  s32 cgreg = 0;
	  ret = RIL_NW_GetGSMState(&creg);
	  ret = RIL_NW_GetGPRSState(&cgreg);
	  APP_DEBUG("<--Network State:creg=%d,cgreg=%d-->\r\n",creg,cgreg);
	  if((cgreg == NW_STAT_REGISTERED)||(cgreg == NW_STAT_REGISTERED_ROAMING))
	  {
		  m_tcp_state = STATE_GPRS_CONTEXT;
	  }
	  break;
  }
  case STATE_GPRS_CONTEXT:
  {
    ret = RIL_NW_SetGPRSContext(CONTEXT);
    APP_DEBUG("<-- Set GPRS context, ret=%d -->\r\n", ret);

	if(ret ==0)
	{
      m_tcp_state = STATE_GPRS_ACTIVATE;
    }
	break;
  }
   
  case STATE_GPRS_ACTIVATE:
  {
    ret = RIL_NW_SetAPN(1, m_apn, m_userid, m_passwd);
    APP_DEBUG("<-- Set GPRS APN, ret=%d -->\r\n", ret);

    ret = RIL_NW_OpenPDPContext();
    APP_DEBUG("<-- Open PDP context, ret=%d -->\r\n", ret);
	if(ret ==0)
	{
      // m_tcp_state = STATE_MQTT_OPEN;
      m_tcp_state = STATE_MQTT_CFG;
    }
	break;
  }
  case STATE_MQTT_CFG:
  {
    ret =  RIL_MQTT_QMTCFG_Ali( 0,product_key,device_name, device_secret);
    APP_DEBUG("<-- mqtt config, ret=%d -->\r\n", ret);
	if(ret ==0)
	{
      m_tcp_state = STATE_MQTT_OPEN;
    }
	break;
  }

  case STATE_MQTT_OPEN:
  {
   ret = RIL_MQTT_QMTOPEN( 0,HOST_NAME, HOST_PORT) ;
    APP_DEBUG("<-- mqtt open, ret=%d -->\r\n",ret);
	if(ret ==0)
	{
      m_tcp_state = STATE_MQTT_CONN;
    }
	else 
	{
      m_tcp_state = STATE_GPRS_DEACTIVATE;
	}
	break;
  }
  case STATE_MQTT_CONN:
  {
    char strImei[30];
    Ql_memset(strImei, 0x0, sizeof(strImei));
	
    ret = RIL_GetIMEI(strImei);
    APP_DEBUG("<-- IMEI:%s,ret=%d -->\r\n", strImei,ret);
	
    ret = RIL_MQTT_QMTCONN(0,strImei,NULL,NULL);
    APP_DEBUG("<-- mqtt connect,ret=%d -->\r\n", ret);
	if(ret ==0)
	{
      m_tcp_state = STATE_MQTT_SUB_1;
    }
    else 
    {
	  m_tcp_state = STATE_GPRS_DEACTIVATE;
    }
   break;
  }
  case STATE_MQTT_SUB_1:
  {
    ret = RIL_MQTT_QMTSUB(0, 1,topic_update, 1,NULL);
    APP_DEBUG("<-- mqtt subscribe, ret=%d -->\r\n",ret);
	if(ret ==0)
	{
      m_tcp_state = STATE_MQTT_SUB_2;
    }
	else 
    {
	   m_tcp_state = STATE_MQTT_CLOSE;
    }
	break;
  }	
  case STATE_MQTT_SUB_2:
  {
    ret = RIL_MQTT_QMTSUB(0, 1,"adpp/#", 1,NULL);
    APP_DEBUG("<-- mqtt subscribe, ret=%d -->\r\n",ret);
	if(ret ==0)
	{
      m_tcp_state = STATE_MQTT_PUB;
    }
	else 
    {
	   m_tcp_state = STATE_MQTT_CLOSE;
    }
	break;
  }	
  case STATE_MQTT_PUB:
  {
  	u32 length =0;
	
	length = Ql_strlen(test_message);
    ret = RIL_MQTT_QMTPUB(0, 1,1,0, topic_update,test_message,length);
    APP_DEBUG("<-- mqtt publish, ret=%d -->\r\n", ret);
	if(ret ==0)
	{
		m_tcp_state = NULL_STATE;
		// m_tcp_state = STATE_MQTT_SUB;
      //m_tcp_state = STATE_MQTT_CLOSE;
    }
	else 
    {
	   m_tcp_state = STATE_MQTT_CLOSE;
    }
	break;
  }	
   case STATE_MQTT_CLOSE:
  {
    ret =RIL_MQTT_QMTCLOSE(0);
    APP_DEBUG("<--mqtt CLOSE, ret=%d -->\r\n", ret);
	if(ret ==0)
	{
      m_tcp_state = STATE_GPRS_DEACTIVATE;
    }
	break;
  }	
  case STATE_GPRS_DEACTIVATE:
  {
    ret = RIL_NW_ClosePDPContext();
    APP_DEBUG("<-- Set GPRS DEACTIVATE, ret=%d -->\r\n", ret);
	if(ret ==0)
	{
      m_tcp_state = STATE_TOTAL_NUM;
    }
	break;
  }
}

}

}

s32 RIL_MQTT_QMTCFG_Ali( u8 connectID,u8* product_key,u8* device_name,u8* device_secret)
{
s32 ret = RIL_AT_SUCCESS;
char strAT[200];

Ql_memset(strAT, 0, sizeof(strAT));
Ql_sprintf(strAT, "AT+QMTCFG=\"KEEPALIVE\",%d\n",connectID);
// Ql_sprintf(strAT, "AT+QMTCFG=\"ALIAUTH\",%d,\"%s\",\"%s\",\"%s\"\n",connectID,product_key,device_name,device_secret);

ret = Ql_RIL_SendATCmd(strAT,Ql_strlen(strAT),NULL,NULL,0);
APP_DEBUG("<-- Send AT:%s, ret = %d -->\r\n",strAT, ret);
if (RIL_AT_SUCCESS != ret)
{
    return ret;
}
return ret;

}

static s32 ATResponse_mqtt_handler(char* line, u32 len, void* userdata)
{
MQTT_Param *mqtt_param = (MQTT_Param )userdata;
char head = Ql_RIL_FindString(line, len, mqtt_param->prefix); //continue wait
if(head)
{
char strTmp[10];
char
p1 = NULL;
char
p2 = NULL;
Ql_memset(strTmp, 0x0, sizeof(strTmp));
p1 = Ql_strstr(head, “:”);
if (p1)
{
QSDK_Get_Str((p1+1),strTmp, mqtt_param->index);
mqtt_param->data= Ql_atoi(strTmp);
}
return RIL_ATRSP_SUCCESS;
}
head = Ql_RIL_FindString(line, len, “OK”);
if(head)
{
return RIL_ATRSP_CONTINUE;
}
head = Ql_RIL_FindString(line, len, “ERROR”);
if(head)
{
return RIL_ATRSP_FAILED;
}
head = Ql_RIL_FindString(line, len, “+CME ERROR:”);//fail
if(head)
{
return RIL_ATRSP_FAILED;
}
head = Ql_RIL_FindString(line, len, “+CMS ERROR:”);//fail
if(head)
{
return RIL_ATRSP_FAILED;
}
return RIL_ATRSP_CONTINUE; //continue wait
}

static s32 ATResponse_mqtt_handler_pub(char* line, u32 len, void* userdata)
{
u8 *head = NULL;
u8 uCtrlZ = 0x1A;

MQTT_Param *mqtt_param = (MQTT_Param *)userdata;

head = Ql_RIL_FindString(line, len, "\r\n>");
if(head)
{
	Ql_RIL_WriteDataToCore (mqtt_param->prefix,mqtt_param->length);
    Ql_RIL_WriteDataToCore(&uCtrlZ,1);
	
	return RIL_ATRSP_CONTINUE;
}
head = Ql_RIL_FindString(line, len, "ERROR");
if(head)
{
    return  RIL_ATRSP_FAILED;
}
head = Ql_RIL_FindString(line, len, "OK");
if(head)
{
    return  RIL_ATRSP_SUCCESS;
}
head = Ql_RIL_FindString(line, len, "+CMS ERROR:");//fail
if(head)
{
    return  RIL_ATRSP_FAILED;
}
return RIL_ATRSP_CONTINUE; //continue wait

}

s32 RIL_MQTT_QMTOPEN( u8 connectID,u8* hostName, u32 port)
{
s32 ret = RIL_AT_SUCCESS;
char strAT[200];

Ql_memset(strAT, 0, sizeof(strAT));
mqtt_param.prefix="+QMTOPEN:";
mqtt_param.index = 1;
mqtt_param.data = 255;

Ql_sprintf(strAT, "AT+QMTOPEN=%d,\"%s\",%d\n", connectID,hostName,port);
ret = Ql_RIL_SendATCmd(strAT,Ql_strlen(strAT),ATResponse_mqtt_handler,(void* )&mqtt_param,0);
APP_DEBUG("<-- Send AT:%s, ret = %d -->\r\n",strAT, ret);
if(RIL_AT_SUCCESS != ret)
{
    APP_DEBUG("\r\n<-- send AT command failure -->\r\n");
    return ret;
}
else if(0 != mqtt_param.data) 
{
    APP_DEBUG("\r\n<--MQTT OPEN failure, =%d -->\r\n", mqtt_param.data);
    return QL_RET_ERR_RIL_MQTT_FAIL;
}

return ret;

}

s32 RIL_MQTT_QMTCONN(u8 connectID, u8* clientID,u8* username,u8* password)
{
s32 ret = RIL_AT_SUCCESS;
char strAT[200];

Ql_memset(strAT, 0, sizeof(strAT));
mqtt_param.prefix="+QMTCONN:";
mqtt_param.index = 1;
mqtt_param.data = 255;

if(NULL != username && NULL !=password)
{
  Ql_sprintf(strAT, "AT+QMTCONN=%d,\"%s\",\"%s\",\"%s\"\n", connectID,clientID,username,password);
}
else
{
	Ql_sprintf(strAT, "AT+QMTCONN=%d,\"%s\"\n", connectID,clientID);
}
ret = Ql_RIL_SendATCmd(strAT,Ql_strlen(strAT),ATResponse_mqtt_handler,(void* )&mqtt_param,0);
APP_DEBUG("<-- Send AT:%s, ret = %d -->\r\n",strAT, ret);
if(RIL_AT_SUCCESS != ret)
{
    APP_DEBUG("\r\n<-- send AT command failure -->\r\n");
    return ret;
}
else if(0 != mqtt_param.data) 
{
    APP_DEBUG("\r\n<--MQTT connect failure, =%d -->\r\n", mqtt_param.data);
    return QL_RET_ERR_RIL_MQTT_FAIL;
}

return ret;

}

s32 RIL_MQTT_QMTSUB(u8 connectID, u8 msgId,u8* topic, u8 qos,u8* others)
{
s32 ret = RIL_AT_SUCCESS;
char strAT[200];

Ql_memset(strAT, 0, sizeof(strAT));
mqtt_param.prefix="+QMTSUB:";
mqtt_param.index = 2;
mqtt_param.data = 255;

if(NULL == others)
{
  Ql_sprintf(strAT, "AT+QMTSUB=%d,%d,\"%s\",%d\n", connectID,msgId,topic,qos);
}
else
{
	
}
ret = Ql_RIL_SendATCmd(strAT,Ql_strlen(strAT),ATResponse_mqtt_handler,(void* )&mqtt_param,0);
APP_DEBUG("<-- Send AT:%s, ret = %d -->\r\n",strAT, ret);
if(RIL_AT_SUCCESS != ret)
{
    APP_DEBUG("\r\n<-- send AT command failure -->\r\n");
    return ret;
}
else if(0 != mqtt_param.data) 
{
    APP_DEBUG("\r\n<--MQTT subscribe failure, =%d -->\r\n", mqtt_param.data);
    return QL_RET_ERR_RIL_MQTT_FAIL;
}

return ret;

}

s32 RIL_MQTT_QMTPUB(u8 connectID, u8 msgId,u8 qos,u8 retain, u8* topic,u8* data,u8 length)
{
s32 ret = RIL_AT_SUCCESS;
char strAT[200];

Ql_memset(strAT, 0, sizeof(strAT));
mqtt_param.prefix=data;
mqtt_param.length= length;
Ql_sprintf(strAT, "AT+QMTPUB=%d,%d,%d,%d,\"%s\"\n", connectID,msgId,qos,retain,topic);
ret = Ql_RIL_SendATCmd(strAT,Ql_strlen(strAT),ATResponse_mqtt_handler_pub,(void* )&mqtt_param,0);
APP_DEBUG("<-- Send AT:%s, ret = %d -->\r\n",strAT, ret);
if(RIL_AT_SUCCESS != ret)
{
    APP_DEBUG("\r\n<-- send AT command failure -->\r\n");
    return ret;
}
return ret;

}

s32 RIL_MQTT_QMTCLOSE(u8 connectID)
{
s32 ret = RIL_AT_SUCCESS;
char strAT[200];

Ql_memset(strAT, 0, sizeof(strAT));
Ql_sprintf(strAT, "AT+QMTCLOSE=%d\n",connectID);

ret = Ql_RIL_SendATCmd(strAT,Ql_strlen(strAT),NULL,NULL,0);
APP_DEBUG("<-- Send AT:%s, ret = %d -->\r\n",strAT, ret);
if (RIL_AT_SUCCESS != ret)
{
    return ret;
}
return ret;

}

s32 RIL_MQTT_QMTUNS(u8 connectID, u8 msgId,u8* topic,u8* others)
{
s32 ret = RIL_AT_SUCCESS;
char strAT[200];

Ql_memset(strAT, 0, sizeof(strAT));
mqtt_param.prefix="+QMTUNS:";
mqtt_param.index = 2;
mqtt_param.data = 255;

if(NULL == others)
{
  Ql_sprintf(strAT, "AT+QMTUNS=%d,%d,\"%s\"\n", connectID,msgId,topic);
}
else
{
	
}
ret = Ql_RIL_SendATCmd(strAT,Ql_strlen(strAT),ATResponse_mqtt_handler,(void* )&mqtt_param,0);
APP_DEBUG("<-- Send AT:%s, ret = %d -->\r\n",strAT, ret);
if(RIL_AT_SUCCESS != ret)
{
    APP_DEBUG("\r\n<-- send AT command failure -->\r\n");
    return ret;
}
else if(0 != mqtt_param.data) 
{
    APP_DEBUG("\r\n<--MQTT subscribe failure, =%d -->\r\n", mqtt_param.data);
    return QL_RET_ERR_RIL_MQTT_FAIL;
}

return ret;

}

#endif // EXAMPLE_TCPSSL

regards
kannannatesh