diff --git a/server/src/ngsi.c b/server/src/ngsi.c index 06eb187c1..a08293c43 100644 --- a/server/src/ngsi.c +++ b/server/src/ngsi.c @@ -1,3 +1,4 @@ + /** Node type: OMA Next Generation Services Interface 10 (NGSI) (FIWARE context broker) * * This file implements the NGSI context interface. NGSI is RESTful HTTP is specified by @@ -326,10 +327,13 @@ int ngsi_read(struct node *n, struct msg *pool, int poolsize, int first, int cnt int ngsi_write(struct node *n, struct msg *pool, int poolsize, int first, int cnt) { struct ngsi *i = n->ngsi; - struct msg *m = &pool[first]; - + struct msg *m = &pool[first % poolsize]; + + if (cnt > 1) + error("NGSI nodes only can send a single message at once"); + /* Update context */ - for (int j = 0; j < i->context_len; j++) { + for (int j = 0; j < MIN(i->context_len, m->length); j++) { json_t *attribute = i->context_map[j]; json_t *value = json_object_get(attribute, "value"); json_t *metadatas = json_object_get(attribute, "metadatas"); @@ -366,4 +370,4 @@ int ngsi_write(struct node *n, struct msg *pool, int poolsize, int first, int cn return 1; } -REGISTER_NODE_TYPE(NGSI, "ngsi", ngsi) \ No newline at end of file +REGISTER_NODE_TYPE(NGSI, "ngsi", ngsi)