Esempio n. 1
0
/*!
 * @brief Thread handling the RTC
 */
void ToggleThread(void *data)
{
	LEDs_Off(LED_BLUE);
	LEDs_Off(LED_GREEN);
	LEDs_Off(LED_YELLOW);
	LEDs_Off(LED_ORANGE);
	Touch_EnableScan(bTRUE);
	uint8_t values = 0;
	for (;;)
	{
		//At least 5s, so 501 * 10ms > 5s
		if (Touch_Wait(501, &values) == OS_TIMEOUT)
		{
			break;
		}
		SetLeds(values);
	}
	LEDs_Off(LED_BLUE);
	LEDs_Off(LED_GREEN);
	LEDs_Off(LED_YELLOW);
	LEDs_Off(LED_ORANGE);
	Touch_EnableScan(bFALSE);
	(*Callback)((void *)0);
	OS_ERROR error = OS_ThreadDelete(OS_PRIORITY_SELF);
}
Esempio n. 2
0
static void atcmd_task(void *arg)
{
	ATCMD_DBG("%s() start...\n", __func__);

	while (1) {
		at_cmd_exec();
	}

	ATCMD_DBG("%s() exit\n", __func__);
	OS_ThreadDelete(&g_atcmd_thread);
}
Esempio n. 3
0
static enum cmd_status cmd_mqtt_disconnect_exec(char *cmd)
{
	int32_t cnt;
	uint32_t tcponly;
	int rc;
	uint32_t i;

	/* get param */
	cnt = cmd_sscanf(cmd, "tcponly=%u",
			 &tcponly);

	/* check param */
	if (cnt != 1) {
		CMD_ERR("invalid param number %d\n", cnt);
		return CMD_STATUS_INVALID_ARG;
	}

	if (tcponly > 1) {
		CMD_ERR("invalid tcponly %d\n", tcponly);
		return CMD_STATUS_INVALID_ARG;
	}


	OS_ThreadDelete(&mqtt_bg_thread);

	i = 0;
	while (i < MAX_SUB_TOPICS) {
		if (sub_topic[i] != NULL) {
			cmd_free(sub_topic[i]);
			sub_topic[i] = NULL;
		}
		i++;
	}

	if (tcponly == 0) {
		if ((rc = MQTTDisconnect(&client)) != 0){
			CMD_ERR("Return code from MQTT disconnect is %d\n", rc);
			network.disconnect(&network);
			return CMD_STATUS_FAIL;
		}
	} else {
		network.disconnect(&network);
	}

	return CMD_STATUS_OK;
}