Skip to content

Commit

Permalink
send error msgs as events to c8y
Browse files Browse the repository at this point in the history
  • Loading branch information
ck-c8y committed Jul 28, 2020
1 parent 8b11121 commit 82a046f
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions source/MQTTOperation.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ static void MQTTOperation_ClientReceive(MQTT_SubscribeCBParam_TZ param) {
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));
Expand Down Expand Up @@ -894,12 +900,14 @@ static void MQTTOperation_AssetUpdate(xTimerHandle xTimer) {

LOG_AT_TRACE(("MQTTOperation: current time: %s\r\n", timezoneISO8601format));

assetStreamBuffer.length +=
snprintf(assetStreamBuffer.data + assetStreamBuffer.length,
sizeof(assetStreamBuffer.data)
- assetStreamBuffer.length,
"400,xdk_ErrorCountEvent,\"Errors: Collision Semaphore/Error Publish:%i/%i!\"\r\n",
errorCountSemaphore, errorCountPublish);
// only send event when some error occurs
if (errorCountSemaphore != 0 || errorCountPublish != 0 )
assetStreamBuffer.length +=
snprintf(assetStreamBuffer.data + assetStreamBuffer.length,
sizeof(assetStreamBuffer.data)
- assetStreamBuffer.length,
"400,xdk_ErrorCountEvent,\"Errors: Collision Semaphore/Error Publish:%i/%i!\"\r\n",
errorCountSemaphore, errorCountPublish);

#if INCLUDE_uxTaskGetStackHighWaterMark
uint32_t everFreeHeap = xPortGetMinimumEverFreeHeapSize();
Expand Down

0 comments on commit 82a046f

Please sign in to comment.