BC660K-GL_QuecOpen_NB5_SDK_V1.0 example_fs.c correction

The current file system example example_fs.c code in the V1.0 SDK does not work out of the box. This is due to the code trying to use the maintask_queue before it had the chance to be created.

Since we don’t know exactly when the MSG_ID_URC_INDICATION message will be sent by the driver we have to ensure that we have our queue setup before trying to use. The default code returned osStatus_t osErrorParameter (-4) indicating that the parameter passed to the osMessageQueuePut(maintask_queue, &msg, 0,0) on the line marked /* here */ was invalid.

The code below shows that the maintask_queue = osMessageQueueNew(8, sizeof(msg), NULL) MUST be done much earlier in time, even before registering the pscallback call back.

static s32 pscallback(ENUMurcID eventId, void *param, u32 paramLen)
{
	CmiSimImsiStr *pCmiSimImsiInd = NULL;
	ST_MSG msg;
	
	switch (eventId)
	{
		case URC_ID_SIM_READY:
			pCmiSimImsiInd = (CmiSimImsiStr *)param;
			APP_DEBUG("SIM_READY:[%s]\r\n",pCmiSimImsiInd->contents);
			msg.message = MSG_ID_URC_INDICATION;	
			msg.param1 = URC_SIM_CARD_STATE_IND;
			osMessageQueuePut(maintask_queue, &msg, 0,0); /* here */
			break;
		// other code remove for brevity 
		default:
			break;
	}
	return 0;
}

void proc_main_task(void)  
{
	s32 ret = -1;
	ST_MSG msg;
	u8 nw_state = 0;
	Ql_SleepDisable();

	Ql_RIL_Initialize();
 	Ql_UART_Open(UART_PORT0,115200,MainUartRecvCallback);

 	maintask_queue = osMessageQueueNew(8, sizeof(msg), NULL);   
	
	APP_DEBUG("<-- QuecOpen: File Example -->\r\n");
	ret = Ql_PSCallback_Register(GROUP_ALL_MASK,pscallback);
	osDelay(1000);

    while (1)
    {
        APP_DEBUG("11 ");  
		if(osOK == osMessageQueueGet(maintask_queue,(void*)&msg, NULL, osWaitForever))
        APP_DEBUG("12 ");  
		switch(msg.message)
        {
        	case MSG_ID_URC_INDICATION:
				{
		            //APP_DEBUG("<-- Received URC: type: %d, -->\r\n", msg.param1);
		            switch (msg.param1)
		            {	
		            	case URC_SIM_CARD_STATE_IND:
							{
			                	msg.message = MSG_ID_APP_START;	
								msg.param1 = STATE_GET_SPACE1;
								osMessageQueuePut(maintask_queue, &msg, 0,0);
			                    APP_DEBUG("<-- Module has registered to network, status:%d -->\r\n",nw_state);						
							}
		                	break; 
						
				
		            	default:
		                	APP_DEBUG("<-- Other URC: type = %d\r\n", msg.param1);
		                	break;
		            }
				}
            	break;
			// other code remove for brevity 
        	default:
            	break;
        }
       
	}
}

Please refer to the documentation carefully, thank you