Beispiel #1
0
void MQTT_InitClient(MQTT_Client *mqttClient, uint8_t* client_id, uint8_t* client_user, uint8_t* client_pass, uint32_t keepAliveTime)
{
//spam	INFO("MQTT_InitClient\r\n");

	os_memset(&mqttClient->connect_info, 0, sizeof(mqtt_connect_info_t));
	mqttClient->connect_info.client_id = client_id;
	mqttClient->connect_info.username = client_user;
	mqttClient->connect_info.password = client_pass;

	mqttClient->connect_info.keepalive = keepAliveTime;
	mqttClient->connect_info.clean_session = 1;
	//mqttClient->mqtt_state = (mqtt_state_t *)os_zalloc(sizeof(mqtt_state_t));

	mqttClient->mqtt_state.in_buffer = (uint8_t *)os_zalloc(MQTT_BUF_SIZE);
	mqttClient->mqtt_state.in_buffer_length = MQTT_BUF_SIZE;
	mqttClient->mqtt_state.out_buffer =  (uint8_t *)os_zalloc(MQTT_BUF_SIZE);
	mqttClient->mqtt_state.out_buffer_length = MQTT_BUF_SIZE;
	mqttClient->mqtt_state.connect_info = &mqttClient->connect_info;
	mqttClient->keepAliveTick = 0;
	mqttClient->reconnectTick = 0;

	os_timer_disarm(&mqttClient->mqttTimer);
	os_timer_setfn(&mqttClient->mqttTimer, (os_timer_func_t *)mqtt_timer, mqttClient);
	os_timer_arm(&mqttClient->mqttTimer, 1000, 1);

	QUEUE_Init(&mqttClient->msgQueue, QUEUE_BUFFER_SIZE);

	system_os_task(MQTT_Task, MQTT_TASK_PRIO, mqtt_procTaskQueue, MQTT_TASK_QUEUE_SIZE);
	system_os_post(MQTT_TASK_PRIO, 0, (os_param_t)mqttClient);
}
Beispiel #2
0
void APP_Run(void) {
  appState = APP_STATE_INIT;
  MOT_Init();
  SHELL_Init();
#if PL_HAS_LINE_SENSOR
  REF_Init();
  LF_Init();
  TURN_Init();
#endif
#if PL_HAS_ULTRASONIC
  US_Init();
#endif
#if PL_HAS_BUZZER
  BUZ_Init();
#endif
#if PL_HAS_EVENTS
  EVNT_Init();
#endif
#if PL_HAS_RADIO
  RADIO_Init();
#endif
#if PL_HAS_REMOTE
  REMOTE_Init();
#endif
#if PL_HAS_QUEUE
  QUEUE_Init();
#endif
  if (FRTOS1_xTaskCreate(MainTask, (signed portCHAR *)"Main", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) {
    for(;;){} /* error */
  }
  FRTOS1_vTaskStartScheduler();
}
Beispiel #3
0
/**
 * Creates MidpSession for the specified XRPC client id. Invoked on the XRPC
 * thread under synchronization.
 */
STATIC MidpSession* GWENG_MidpCreateSession(EcmtGateway* gw, int xrpcSid)
{
    MidpSession* ses = MEM_New(MidpSession);
    if (ses) {
        LUID luid;
        /* Just in case if AllocateLocallyUniqueId fails... */
        luid.LowPart = (DWORD)ses;
        AllocateLocallyUniqueId(&luid);
        memset(ses, 0, sizeof(*ses));
        ses->key.xrpcSid = xrpcSid;
        ses->key.xrpcSession = XRPC_GetCurrentSession(gw->xrpc);
        ses->sid = luid.LowPart;
        ASSERT(!HASH_Contains(&gw->ecmtSessionMap,(HashKey)ses->sid));
        ASSERT(!HASH_Contains(&gw->midpSessionMap,&ses->key));
        if (HASH_Init(&ses->connMap, 1, NULL, NULL, hashFreeValueProc)) {
            /* Create context for the control connection (number zero) */
            MidpConnection* conn = MEM_New(MidpConnection);
            if (conn) {
                memset(conn, 0, sizeof(*conn));
                if (HASH_Put(&ses->connMap, (HashKey)0, conn)) {
                    if (HASH_Put(&gw->ecmtSessionMap,(HashKey)ses->sid,ses)) {
                        if (HASH_Put(&gw->midpSessionMap, &ses->key, ses)) {
                            if (MUTEX_Init(&ses->xrpcMutex)) {
                                ses->xrpcWorkThread = WKQ_Create();
                                if (ses->xrpcWorkThread) {
                                    ses->xrpcWorkItem = WKI_Create(
                                        ses->xrpcWorkThread, GWENG_AsyncXRpc,
                                        ses);
                                    if (ses->xrpcWorkItem) {
                                        QUEUE_Init(&ses->xrpcQueue);
                                        TRACE3("GW: new session %08x for "
                                            "%08x.%08x\n", ses->sid,
                                            ses->key.xrpcSession,
                                            ses->key.xrpcSid);
                                        return ses;
                                    }
                                    WKQ_Delete(ses->xrpcWorkThread);
                                }
                                MUTEX_Destroy(&ses->xrpcMutex);
                            }
                            HASH_Remove(&gw->midpSessionMap, &ses->key);
                        }
                        HASH_Remove(&gw->ecmtSessionMap, (HashKey)ses->sid);
                    }
                } else {
                    MEM_Free(conn);
                }
            }
            HASH_Destroy(&ses->connMap);
        }
        MEM_Free(ses);
    }
    return NULL;
}
Beispiel #4
0
/**
 * Initialize the lock.
 */
Bool RWLOCK_Init(RWLock * lock) 
{
    LOCK_InitCheck();
    memset(lock, 0, sizeof(*lock));
    if (MUTEX_Init(&lock->mutex)) {
        if (EVENT_Init(&lock->shareEvent)) {
            if (EVENT_Init(&lock->exclusiveEvent)) {
                QUEUE_Init(&lock->shareWaiters);
                QUEUE_Init(&lock->exclusiveWaiters);
                QUEUE_Init(&lock->waiterCache);
                lock->numEntries = COUNT(lock->staticEntries);
                lock->lock.type = &LockType_RWLock;
                return True;
            }
            EVENT_Destroy(&lock->shareEvent);
        }
        MUTEX_Destroy(&lock->mutex);
    }
    return False;
}
Beispiel #5
0
void WKQ_InitModule()
{
    if ((WKQ.initcount++) == 0) {
        THREAD_InitModule();
        QUEUE_Init(&WKQ.itempool);
        if (MUTEX_Init(&WKQ.mutex)) {
            WKQ.maxwait = DEFAULT_MAX_WAIT_POOL;
            WKQ.maxitems = DEFAULT_MAX_ITEM_POOL;
            return;
        }
        SLIB_Abort(TEXT("WKQ"));
    }
}
Beispiel #6
0
/**
  * @brief  MQTT initialization mqtt client function
  * @param  client: 	MQTT_Client reference
  * @param  clientid: 	MQTT client id
  * @param  client_user:MQTT client user
  * @param  client_pass:MQTT client password
  * @param  client_pass:MQTT keep alive timer, in second
  * @retval None
  */
void ICACHE_FLASH_ATTR
MQTT_InitClient(MQTT_Client *mqttClient, uint8_t* client_id, uint8_t* client_user, uint8_t* client_pass, uint32_t keepAliveTime, uint8_t cleanSession)
{
	uint32_t temp;
	INFO("MQTT_InitClient\r\n");

	memset(&mqttClient->connect_info, 0, sizeof(mqtt_connect_info_t));

	temp = strlen(client_id);
	mqttClient->connect_info.client_id = (uint8_t*)calloc(1, temp + 1);
	strcpy(mqttClient->connect_info.client_id, client_id);
	mqttClient->connect_info.client_id[temp] = 0;

	if (client_user)
	{
		temp = strlen(client_user);
		mqttClient->connect_info.username = (uint8_t*)calloc(1, temp + 1);
		strcpy(mqttClient->connect_info.username, client_user);
		mqttClient->connect_info.username[temp] = 0;
	}

	if (client_pass)
	{
		temp = strlen(client_pass);
		mqttClient->connect_info.password = (uint8_t*)calloc(1, temp + 1);
		strcpy(mqttClient->connect_info.password, client_pass);
		mqttClient->connect_info.password[temp] = 0;
	}


	mqttClient->connect_info.keepalive = keepAliveTime;
	mqttClient->connect_info.clean_session = cleanSession;

	mqttClient->mqtt_state.in_buffer = (uint8_t *) calloc(1, MQTT_BUF_SIZE);
	mqttClient->mqtt_state.in_buffer_length = MQTT_BUF_SIZE;
	mqttClient->mqtt_state.out_buffer =  (uint8_t *) calloc(1, MQTT_BUF_SIZE);
	mqttClient->mqtt_state.out_buffer_length = MQTT_BUF_SIZE;
	mqttClient->mqtt_state.connect_info = &mqttClient->connect_info;

	mqtt_msg_init(&mqttClient->mqtt_state.mqtt_connection, mqttClient->mqtt_state.out_buffer, mqttClient->mqtt_state.out_buffer_length);

	QUEUE_Init(&mqttClient->msgQueue, QUEUE_BUFFER_SIZE);

	vSemaphoreCreateBinary(mqttClient->mqttTaskSem);
	vSemaphoreCreateBinary(mqttClient->mqttExitSem);

	mqttClient->mqttTimer = xTimerCreate(NULL, configTICK_RATE_HZ, 1, (void *) mqttClient, mqtt_timer);
	mqttClient->mqttTask = xTaskCreate(MQTT_Task, NULL, configMINIMAL_STACK_SIZE, mqttClient->mqttTaskSem, MQTT_TASK_PRIO, NULL);

	xSemaphoreGive(mqttClient->mqttTaskSem);
}
Beispiel #7
0
/**
  * @brief  MQTT initialization mqtt client function
  * @param  client:     MQTT_Client reference
  * @param  clientid:     MQTT client id
  * @param  client_user:MQTT client user
  * @param  client_pass:MQTT client password
  * @param  client_pass:MQTT keep alive timer, in second
  * @retval None
  */
void ICACHE_FLASH_ATTR
MQTT_InitClient(MQTT_Client *mqttClient, uint8_t* client_id, uint8_t* client_user, uint8_t* client_pass, uint32_t keepAliveTime, uint8_t cleanSession)
{
    uint32_t temp;
    INFO("MQTT_InitClient\r\n");

    os_memset(&mqttClient->connect_info, 0, sizeof(mqtt_connect_info_t));

    temp = os_strlen(client_id);
    mqttClient->connect_info.client_id = (uint8_t*)os_zalloc(temp + 1);
    os_strcpy(mqttClient->connect_info.client_id, client_id);
    mqttClient->connect_info.client_id[temp] = 0;

    if (client_user)
    {
        temp = os_strlen(client_user);
        mqttClient->connect_info.username = (uint8_t*)os_zalloc(temp + 1);
        os_strcpy(mqttClient->connect_info.username, client_user);
        mqttClient->connect_info.username[temp] = 0;
    }

    if (client_pass)
    {
        temp = os_strlen(client_pass);
        mqttClient->connect_info.password = (uint8_t*)os_zalloc(temp + 1);
        os_strcpy(mqttClient->connect_info.password, client_pass);
        mqttClient->connect_info.password[temp] = 0;
    }


    mqttClient->connect_info.keepalive = keepAliveTime;
    mqttClient->connect_info.clean_session = cleanSession;

    mqttClient->mqtt_state.in_buffer = (uint8_t *)os_zalloc(MQTT_BUF_SIZE);
    mqttClient->mqtt_state.in_buffer_length = MQTT_BUF_SIZE;
    mqttClient->mqtt_state.out_buffer =  (uint8_t *)os_zalloc(MQTT_BUF_SIZE);
    mqttClient->mqtt_state.out_buffer_length = MQTT_BUF_SIZE;
    mqttClient->mqtt_state.connect_info = &mqttClient->connect_info;

    mqtt_msg_init(&mqttClient->mqtt_state.mqtt_connection, mqttClient->mqtt_state.out_buffer, mqttClient->mqtt_state.out_buffer_length);

    QUEUE_Init(&mqttClient->msgQueue, QUEUE_BUFFER_SIZE);

    system_os_task(MQTT_Task, MQTT_TASK_PRIO, mqtt_procTaskQueue, MQTT_TASK_QUEUE_SIZE);
    system_os_post(MQTT_TASK_PRIO, 0, (os_param_t)mqttClient);
}
Beispiel #8
0
static int init_queue()
{
	if(g_queue != NULL)
		return 0;

	g_queue = QUEUE_Init();
	if(g_queue == NULL)
	{
		fprintf(stderr, "%s\n", "error creating queue");
		return -1;
	}
	if(signal_wrap(SIGALRM, alarm_handler) == -1)
	{
		fprintf(stderr, "%s\n", "error create timer");
		return -1;
	}
	return 0;
}
/**
  * @brief  MQTT initialization mqtt client function
  * @param  client: 	MQTT_Client reference
  * @param  clientid: 	MQTT client id
  * @param  client_user:MQTT client user
  * @param  client_pass:MQTT client password
  * @param  client_pass:MQTT keep alive timer, in second
  * @retval None
  */
void FUNCTION_ATTRIBUTE
MQTT_InitClient(MQTT_Client *mqttClient, uint8_t* client_id, uint8_t* client_user, uint8_t* client_pass, uint32_t keepAliveTime, uint8_t cleanSession)
{
	uint32_t temp;
	INFO("MQTT_InitClient\r\n");
	pd_memset(&mqttClient->connect_info, 0, sizeof(mqtt_connect_info_t));

	temp = pd_strlen(client_id);
	mqttClient->connect_info.client_id = (uint8_t*)pd_malloc(temp + 1);
    pd_memset(mqttClient->connect_info.client_id, 0, temp + 1);
	pd_strcpy(mqttClient->connect_info.client_id, client_id);
	mqttClient->connect_info.client_id[temp] = 0;

	temp = pd_strlen(client_user);
	mqttClient->connect_info.username = (uint8_t*)pd_malloc(temp + 1);
	pd_memset(mqttClient->connect_info.username, 0, temp + 1);
	pd_strcpy(mqttClient->connect_info.username, client_user);
	mqttClient->connect_info.username[temp] = 0;

	temp = pd_strlen(client_pass);
	mqttClient->connect_info.password = (uint8_t*)pd_malloc(temp + 1);
	pd_memset(mqttClient->connect_info.password, 0, temp + 1);
	pd_strcpy(mqttClient->connect_info.password, client_pass);
	mqttClient->connect_info.password[temp] = 0;

	mqttClient->connect_info.keepalive = keepAliveTime;
	mqttClient->connect_info.clean_session = cleanSession;

	mqttClient->mqtt_state.in_buffer = (uint8_t *)pd_malloc(MQTT_BUF_SIZE);
    pd_memset(mqttClient->mqtt_state.in_buffer, 0, MQTT_BUF_SIZE);
	mqttClient->mqtt_state.in_buffer_length = MQTT_BUF_SIZE;
	mqttClient->mqtt_state.out_buffer =  (uint8_t *)pd_malloc(MQTT_BUF_SIZE);
    pd_memset(mqttClient->mqtt_state.out_buffer, 0, MQTT_BUF_SIZE);
    mqttClient->mqtt_state.out_buffer_length = MQTT_BUF_SIZE;
	mqttClient->mqtt_state.connect_info = &mqttClient->connect_info;
	mqttClient->mqtt_state.message_length_read = 0;

	mqtt_msg_init(&mqttClient->mqtt_state.mqtt_connection, mqttClient->mqtt_state.out_buffer, mqttClient->mqtt_state.out_buffer_length);
	QUEUE_Init(&mqttClient->msgQueue, QUEUE_BUFFER_SIZE);
    //MQTT_Task(mqttClient);
}
Beispiel #10
0
int main() {
    uint8_t tmpCurrentMode, tmpPreviousMode;
    //init ddr
    SetHigh(DBP_GSCLK_DDR, DBP_GSCLK_PIN);
    SetHigh(DBP_BLANK_DDR, DBP_BLANK_PIN);
    SetHigh(DBP_XLAT_DDR, DBP_XLAT_PIN);
    SetHigh(DBP_VPRG_DDR, DBP_VPRG_PIN);
    SetHigh(DBP_DCPRG_DDR, DBP_DCPRG_PIN);
    SetHigh(DBP_SIN_DDR, DBP_SIN_PIN);
    SetHigh(DBP_SCLK_DDR, DBP_SCLK_PIN);
    //set initial values
    SetHigh(DBP_BLANK_PORT, DBP_BLANK_PIN);
    SetHigh(DBP_VPRG_PORT, DBP_VPRG_PIN);
    SetHigh(DBP_DCPRG_PORT, DBP_DCPRG_PIN);
    SetLow(DBP_GSCLK_PORT, DBP_GSCLK_PIN);
    SetLow(DBP_XLAT_PORT, DBP_XLAT_PIN);
    SetLow(DBP_SIN_PORT, DBP_SIN_PIN);
    SetLow(DBP_SCLK_PORT, DBP_SCLK_PIN);
    //init adc converter
    /*
    SetHigh(IRP_TRANSMITTER_DDR, IRP_TRANSMITTER_PIN);
    SetLow(IRP_RECEIVER_DDR, IRP_RECEIVER_PIN);
    ADMUX = (1 << REFS0); //voltage reference = AVCC, input channel = ADC0
    ADCSRA = (1 << ADATE) | (1 << ADIE) | (1 << ADEN) | (1 << ADPS1); //f.osc / 4
    ADCSRB = (1 << ADTS1) | (1 << ADTS0); //auto trigger source = timer0 compare match A
    */
    //init GSCLK timer
    TCCR0A |= (1 << WGM01);
    TCCR0B |= (1 << CS02) | (1 << CS00);
    OCR0A = 0x03; //f.osc / 4096
    TIMSK0 |= (1 << OCIE0A);
    //init spi
    SetHigh(SPI_SS_DDR, SPI_SS_PIN);
    SPCR = (1 << SPE) | (1 << MSTR) | (1 << SPR1); //F_CPU / 16 ~ 365kHz
    //init i2c
    TWAR = (SLAVE_Address << 1);
    TWCR = (1 << TWEA) | (1 << TWEN) | (1 << TWIE);
    //init queue
    QUEUE_Init(&TWI_InputBuffer);
    //send dc data to driver through spi
    for(i = 0; i < 36; ++i) {
        SPDR = 0xff;
        while(!(SPSR & (1 << SPIF)));
    }
    SetHigh(DBP_XLAT_PORT, DBP_XLAT_PIN);
    SetLow(DBP_XLAT_PORT, DBP_XLAT_PIN);
    tmpPreviousMode = CMD_SetDC;
    SetLow(DBP_VPRG_PORT, DBP_VPRG_PIN);
    //send gs data to driver through spi
    for(i = 0; i < 72; ++i) {
        SPDR = 0xff;
        while(!(SPSR & (1 << SPIF)));
    }
    SPCR &= ~(1 << SPE);
    SetHigh(DBP_XLAT_PORT, DBP_XLAT_PIN);
    SetLow(DBP_XLAT_PORT, DBP_XLAT_PIN);
    SetLow(DBP_BLANK_PORT, DBP_BLANK_PIN);
    tmpPreviousMode = CMD_SetGS;
    //enable interrupts
    sei();
    while(1) {
        if(!GLB_NeedXLAT && !QUEUE_Empty(&TWI_InputBuffer)) {
            tmpCurrentMode = QUEUE_Remove(&TWI_InputBuffer);
            switch(tmpCurrentMode) {
            case CMD_SetDC: {
                SetHigh(DBP_VPRG_PORT, DBP_VPRG_PIN);
                SendDataToTLC5940(&TWI_InputBuffer, 36);
                GLB_NeedXLAT = 1;
                tmpPreviousMode = tmpCurrentMode;
                break;
            }
            case CMD_SetGS: {
                if(tmpPreviousMode == CMD_SetGS) {
                    SetHigh(DBP_SCLK_PORT, DBP_SCLK_PIN);
                    SetLow(DBP_SCLK_PORT, DBP_SCLK_PIN);
                }
                SetLow(DBP_VPRG_PORT, DBP_VPRG_PIN);
                SendDataToTLC5940(&TWI_InputBuffer, 72);
                GLB_NeedXLAT = 1;
                tmpPreviousMode = tmpCurrentMode;
                break;
            }
            case CMD_ClearGS: {
                if(tmpPreviousMode == CMD_SetGS) {
                    SetHigh(DBP_SCLK_PORT, DBP_SCLK_PIN);
                    SetLow(DBP_SCLK_PORT, DBP_SCLK_PIN);
                }
                SetLow(DBP_VPRG_PORT, DBP_VPRG_PIN);
                SPCR |= (1 << SPE);
                cli();
                for(i = 0; i < 72; ++i) {
                    SPDR = 0x00;
                    while(!(SPSR & (1 << SPIF)));
                }
                sei();
                SPCR &= ~(1 << SPE);
                GLB_NeedXLAT = 1;
                tmpPreviousMode = CMD_SetGS;
                break;
            }
            }
        }
    }
}
Beispiel #11
0
int Main (void)
    {
    static char szAppName[] = MAIN_NAME ;
    char        *cFilePart ;


    // get installed path
    if (! SearchPath (NULL, MAIN_EXE, NULL, MSG_SIZE, InstallDir, &cFilePart))
        {
        GetCurrentDirectory (MSG_SIZE, InstallDir) ;
        }
    
    // initialize system
    SYS_Init () ;

    // initialize coordinate
    TOOLBOX_InitCoord () ;

    // initialize font
    FONT_Init () ;

    // initialize telnet variables
    TELNET_Init () ;

    // initialize timeseal
    TIMESEAL_Init () ;

    // initialize history
    HISTORY_Init () ;

    // initialize script
    SCRIPT_Init () ;

    // initialize state
    STATE_Init () ;

    // initialize command
    COMMAND_Init () ;

    // initialize player
    PLAYER_Init () ;

    // initialize group
    GROUP_Init () ;

    // initialize arb
    ARB_Init () ;

    // initialize ini
    INI_Init () ;

    // initialize queue
    QUEUE_Init () ;

    // read from SETUP.TXT
    INI_ReadSys () ;

    // setup server address
    TIMESEAL_SetServerAddress () ;

    // create font
    FONT_Create () ;

    // connect
    TIMESEAL_Load () ;

    // load window coordinate
    TOOLBOX_LoadWindowCoord () ;

    // setup window title
    TOOLBOX_SetupWinTitle () ;


    // get message
    while (1)
        {
		  IDLE_Proc () ;
	  }

    // destroy font
    FONT_Destroy () ;

    // write into SETUP.TXT
    INI_WriteSys () ;

    // quit
    return 0;
    }
Beispiel #12
0
/**
  * @brief  MQTT initialization mqtt client function
  * @param  client:   MQTT_Client reference
  * @param  clientid:   MQTT client id
  * @param  client_user:MQTT client user
  * @param  client_pass:MQTT client password
  * @param  client_pass:MQTT keep alive timer, in second
  * @retval None
  */
BOOL ICACHE_FLASH_ATTR
MQTT_InitClient(MQTT_Client *mqttClient, uint8_t* client_id, uint8_t* client_user, uint8_t* client_pass, uint32_t keepAliveTime, uint8_t cleanSession)
{
  uint32_t temp;
  MQTT_INFO("MQTT:InitClient\r\n");

  os_memset(&mqttClient->connect_info, 0, sizeof(mqtt_connect_info_t));

  if ( !client_id )
  {
    /* Should be allowed by broker, but clean session flag must be set. */
  #ifdef PROTOCOL_NAMEv311
    if (cleanSession)
    {
      mqttClient->connect_info.client_id = zero_len_id;
    } else {
      MQTT_INFO("cleanSession must be set to use 0 length client_id\r\n");
      return false;
    }
    /* Not supported. Return. */
  #else
    MQTT_INFO("Client ID required for MQTT < 3.1.1!\r\n");
    return false;
  #endif
 }

  /* If connect_info's client_id is still NULL and we get here, we can        *
   * assume the passed client_id is non-NULL.                                 */
  if ( !(mqttClient->connect_info.client_id) )
  {
    temp = os_strlen(client_id);
    mqttClient->connect_info.client_id = (uint8_t*)os_zalloc(temp + 1);
    os_strcpy(mqttClient->connect_info.client_id, client_id);
    mqttClient->connect_info.client_id[temp] = 0;
  }

  if (client_user)
  {
    temp = os_strlen(client_user);
    mqttClient->connect_info.username = (uint8_t*)os_zalloc(temp + 1);
    os_strcpy(mqttClient->connect_info.username, client_user);
    mqttClient->connect_info.username[temp] = 0;
  }

  if (client_pass)
  {
    temp = os_strlen(client_pass);
    mqttClient->connect_info.password = (uint8_t*)os_zalloc(temp + 1);
    os_strcpy(mqttClient->connect_info.password, client_pass);
    mqttClient->connect_info.password[temp] = 0;
  }


  mqttClient->connect_info.keepalive = keepAliveTime;
  mqttClient->connect_info.clean_session = cleanSession;

  mqttClient->mqtt_state.in_buffer = (uint8_t *)os_zalloc(MQTT_BUF_SIZE);
  mqttClient->mqtt_state.in_buffer_length = MQTT_BUF_SIZE;
  mqttClient->mqtt_state.out_buffer =  (uint8_t *)os_zalloc(MQTT_BUF_SIZE);
  mqttClient->mqtt_state.out_buffer_length = MQTT_BUF_SIZE;
  mqttClient->mqtt_state.connect_info = &mqttClient->connect_info;

  mqtt_msg_init(&mqttClient->mqtt_state.mqtt_connection, mqttClient->mqtt_state.out_buffer, mqttClient->mqtt_state.out_buffer_length);

  QUEUE_Init(&mqttClient->msgQueue, QUEUE_BUFFER_SIZE);

  system_os_task(MQTT_Task, MQTT_TASK_PRIO, mqtt_procTaskQueue, MQTT_TASK_QUEUE_SIZE);
  system_os_post(MQTT_TASK_PRIO, 0, (os_param_t)mqttClient);
  return true;
}