source/MQTTOperation.c
/**
 * @brief callback function for subriptions
 *        toggles LEDS or sets read data flag
 *
 * @param[in] md - received message from the MQTT Broker
 *
 * @return NONE
 */
@brief callback function for subriptions
toggles LEDS or sets read data flag

@param[in] md - received message from the MQTT Broker

@return NONE
@brief callback function for subriptions toggles LEDS or sets read data flag @param [ in ] md - received message from the MQTT Broker @return NONE
static void MQTTOperation_ClientReceive(MQTT_SubscribeCBParam_TZ param) {
	static char appIncomingMsgTopicBuffer[SIZE_SMALL_BUF];
	static char appIncomingMsgPayloadBuffer[SIZE_LARGE_BUF];
	memset(appIncomingMsgTopicBuffer, 0, sizeof(appIncomingMsgTopicBuffer));
	memset(appIncomingMsgPayloadBuffer, 0, sizeof(appIncomingMsgPayloadBuffer));
	strncpy(appIncomingMsgTopicBuffer, (const char *) param.Topic,
			fmin(param.TopicLength, (sizeof(appIncomingMsgTopicBuffer) - 1U)));
	strncpy(appIncomingMsgPayloadBuffer, (const char *) param.Payload,
			fmin(param.PayloadLength,
					(sizeof(appIncomingMsgPayloadBuffer) - 1U)));
	if (strncmp(appIncomingMsgTopicBuffer, TOPIC_DOWNSTREAM_ERROR,
			strlen(TOPIC_DOWNSTREAM_ERROR)) == 0) {
		LOG_AT_ERROR(
				("MQTTOperation: Error from upstream: %.*s, Error Msg : %.*s\r\n", (int) param.TopicLength, appIncomingMsgTopicBuffer, (int) param.PayloadLength, appIncomingMsgPayloadBuffer));
		assetStreamBuffer.length +=
				snprintf(assetStreamBuffer.data + assetStreamBuffer.length,
						sizeof(assetStreamBuffer.data)
								- assetStreamBuffer.length,
						"400,xdk_ErrorCountEvent,\"Error Msg : %.*s\"\r\n",
						(int) param.PayloadLength, appIncomingMsgPayloadBuffer);
	} else {
		LOG_AT_INFO(
				("MQTTOperation: Upstream msg: Topic: %.*s, Msg Received: %.*s\r\n", (int) param.TopicLength, appIncomingMsgTopicBuffer, (int) param.PayloadLength, appIncomingMsgPayloadBuffer));
		AppController_SetCmdStatus(APP_STATUS_COMMAND_RECEIVED);
		char *token = strtok(appIncomingMsgPayloadBuffer, "\n");
		while (token != NULL) {
			LOG_AT_ERROR(
					("MQTTOperation: Try to place command [%s] in queue!\r\n", token));
			if (xQueueSend(commandQueue,token, 0) != pdTRUE) {
				LOG_AT_ERROR(
						("MQTTOperation_ClientReceive: Could not buffer command!\r\n"));
				break;
			}
			token = strtok(NULL, "\n");
		}
	}
}
static void MQTTOperation_ClientReceive ( MQTT_SubscribeCBParam_TZ param ) { static char appIncomingMsgTopicBuffer [ SIZE_SMALL_BUF ] ; static char appIncomingMsgPayloadBuffer [ SIZE_LARGE_BUF ] ; memset ( appIncomingMsgTopicBuffer , 0 , sizeof ( appIncomingMsgTopicBuffer ) ) ; memset ( appIncomingMsgPayloadBuffer , 0 , sizeof ( appIncomingMsgPayloadBuffer ) ) ; strncpy ( appIncomingMsgTopicBuffer , ( const char * ) param . Topic , fmin ( param . TopicLength , ( sizeof ( appIncomingMsgTopicBuffer ) - 1U ) ) ) ; strncpy ( appIncomingMsgPayloadBuffer , ( const char * ) param . Payload , fmin ( param . PayloadLength , ( sizeof ( appIncomingMsgPayloadBuffer ) - 1U ) ) ) ; if ( strncmp ( appIncomingMsgTopicBuffer , TOPIC_DOWNSTREAM_ERROR , strlen ( TOPIC_DOWNSTREAM_ERROR ) ) == 0 ) { LOG_AT_ERROR ( ( " \r \n " , ( int ) param . TopicLength , appIncomingMsgTopicBuffer , ( int ) param . PayloadLength , appIncomingMsgPayloadBuffer ) ) ; assetStreamBuffer . length += snprintf ( assetStreamBuffer . data + assetStreamBuffer . length , sizeof ( assetStreamBuffer . data ) - assetStreamBuffer . length , " \" \" \r \n " , ( int ) param . PayloadLength , appIncomingMsgPayloadBuffer ) ; } else { LOG_AT_INFO ( ( " \r \n " , ( int ) param . TopicLength , appIncomingMsgTopicBuffer , ( int ) param . PayloadLength , appIncomingMsgPayloadBuffer ) ) ; AppController_SetCmdStatus ( APP_STATUS_COMMAND_RECEIVED ) ; char * token = strtok ( appIncomingMsgPayloadBuffer , " \n " ) ; while ( token != NULL ) { LOG_AT_ERROR ( ( " \r \n " , token ) ) ; if ( xQueueSend ( commandQueue , token , 0 ) != pdTRUE ) { LOG_AT_ERROR ( ( " \r \n " ) ) ; break ; } token = strtok ( NULL , " \n " ) ; } } }
@brief callback function for subriptions
        toggles LEDS or sets read data flag
@brief callback function for subriptions toggles LEDS or sets read data flag
/* Initialize Variables */ /**< Incoming message topic buffer */ /**< Incoming message payload buffer */ // split batch of commands in single commands