Skip to content

Commit 5b4ffed

Browse files
jtguggedaljukkar
authored andcommitted
samples: net: azure_iot_hub: Fix bug in response to direct method
The response payload size was not set correctly resulting in an invalid json response. The size set was the size of the pointer (4) and not the string content. Signed-off-by: Jan Tore Guggedal <[email protected]>
1 parent 0da8ac9 commit 5b4ffed

File tree

1 file changed

+2
-2
lines changed
  • samples/net/azure_iot_hub/src

1 file changed

+2
-2
lines changed

samples/net/azure_iot_hub/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ static void send_event(struct k_work *work)
313313
static void direct_method_handler(struct k_work *work)
314314
{
315315
int err;
316-
static char *response = "{\"it\":\"worked\"}";
316+
static const char response[] = "{\"it\":\"worked\"}";
317317

318318
/* Status code 200 indicates successful execution of direct method. */
319319
struct azure_iot_hub_result result = {
@@ -322,7 +322,7 @@ static void direct_method_handler(struct k_work *work)
322322
.size = strlen(method_data.request_id),
323323
},
324324
.status = 200,
325-
.payload.ptr = response,
325+
.payload.ptr = (char *)response,
326326
.payload.size = sizeof(response) - 1,
327327
};
328328
bool led_state = strncmp(method_data.payload, "0", 1) ? 1 : 0;

0 commit comments

Comments
 (0)