Cannot run FTP as a Task

I have been attempting to use the message service to launch an FTP task within a FXT009 modem. The bearer is successfully opened during initialization of the main task which has the highest priority. The following lists the task declaration table.

const adl_InitTasks_t adl_InitTasks [] = {
    { main_task,  3072, "main", 5 },
    { uart_task,  3072, "uart", 4 },
    { timer_task,  3072, "timer", 3 },
    { FTP_task,  3072, "FTP", 2 },
    { FLASH_task,  3072, "FLASH", 1 },
    { 0, 0, 0, 0 } }

The FTP_task initializes the message service as follows:

S32 FTP_task (void)
{ s32 s32Return;
  static adl_msgFilter_t msgFilter = { 0, 0, ADL_MSG_ID_COMP_EQUAL, ADL_CTX_ALL };
  s32Return = adl_msgSubscribe (&msgFilter, FTP_handler);
}

Then a message is sent by another task to send a file via FTP by issuing the following:

void FTP_handler  (u32 MsgIdentifier, adl_ctxID_e ctxSource, u32 Length, void * incomingData)
{
dst_ftp_cx = wip_FTPCreateOpts (FTP_Server,
	FTP_Session_Handler, NULL,
	WIP_COPT_USER, FTP_User,
	WIP_COPT_PASSWORD,FTP_Password
	WIP_COPT_PASSIVE, DST_ISPASSIVE,
	WIP_COPT_PEER_PORT, (u16)atoi(FTP_Port),
	WIP_COPT_END );
}

There are no messaging errors detected and the wip_FTPCreateOpts is executed. Then depending on the server address, the wip_FTPCreateOpts either returns a channel or a null (error). In the case when channel address is returned, there is no further FTP activity, i.e. no WIP_CIV events occur and the FTP seems dead.

When I rewrite the code to not use messaging and call the FTP_handler function directly, everything works fine. Any suggestion as to how to launch an FTP as a task rather than a function call would be most appreciated.

Hi,

Please note as per the doc “WIP_Open_AT_IP_Connectivity_Development_Guide.pdf”, “wip_netinit”
API has to be called from each task to reserve the associated execution context for each WIPlib Plug-
In operation. Please confirm the same. Also check if the FTP creation was done only after the WIP_BEV_IP_CONNECTED event was received in the bearer handler.

Try this in your FTP start function (as Rex_Alex said, only after you are sure your GPRS bearer has started correctly):

const ascii * FTP_STR_HOSTNAME = "www.yourftpaddress.com";

static void pfk_FTPStart (void)
{
    const ascii * FTP_STR_USERNAME = "test123";
    const ascii * FTP_STR_PASSWORD = "test123";

    TRACE((FTP_TRACE_LEVEL1, FTP_STR_USERNAME));
    TRACE((FTP_TRACE_LEVEL1, FTP_STR_PASSWORD));

    if (wip_netInit() == 0)
    {
        FtpCnxCh = wip_FTPCreateOpts((ascii *) FTP_STR_HOSTNAME, pfk_ftpCnxHandler, NULL, WIP_COPT_USER, FTP_STR_USERNAME,
                WIP_COPT_PASSWORD, FTP_STR_PASSWORD, WIP_COPT_PASSIVE, TRUE, WIP_COPT_TYPE, (ascii) FTP_TYPE,
                WIP_COPT_PEER_PORT, 21, WIP_COPT_END);

        if (FtpCnxCh != NULL)
        {
            TRACE((FTP_TRACE_LEVEL1,"[pfk_FTPStart] FTP control channel created: %d", FtpCnxCh));
        }
        else
        {
            TRACE((FTP_TRACE_LEVEL1,"[pfk_FTPStart] FTP channel cannot be created: %d", FtpCnxCh));
            pfk_ftpError();
        }
    }
    else
    {
        TRACE((FTP_TRACE_LEVEL1, "[pfk_FTPStart] Could not re-init WIP"));
    }
}