0

I start from example found at ibm-watson-iot.github.io

  1. I define my device on Watson IOT

  2. I create my C-device snippet using deviceSample.c and it send an event {"d": {"SensorID":"Test","Reading": 99}}

  3. I see the event in Watson IoT platform correctly

But when I try to manage the event from my C application I catch the following error

iotp_async.c iotp_client_messageArrived 1320: ERROR: Callback not found for topic. topic: iot-2/type/semaforo/id/1002/evt/status/fmt/json

from my client log I take the following msg

iotp_client_setHandler 1176: INFO: Handler (type=AppEvent) is added. Topic=iot-2/type/+/id/+/evt/+/fmt/+

Does this msg means that my code is subscribed to the event ? In my C code I define a CallBack event func using

IoTPApplication_setEventHandler
               (application, applicationEventCallback, 
                        devType, devId, eventName, format
               );

where my applicationEventCallback is

void  applicationEventCallback (char* type, char* id, 
           char* eventName, char *format, void* payload, size_t payloadSize);

Why my client does not mange correctly the incoming event ?

LucaAmato
  • 1
  • 2
  • From what I can see, you have provided the prototype of your callback not the actual callback function. It seems that you need to define your function callback as it was done in the example. Function declaration / Prototype is different than Function declaration. – oneshepherdssheep Nov 26 '20 at 14:46
  • On top of that it make sense with the error "Callback not found". For your function definition, try something basic like: void applicationEventCallback (char* type, char* id, char* eventName, char *format, void* payload, size_t payloadSize) { printf("My callback has been ... called\n"); } – oneshepherdssheep Nov 26 '20 at 14:50
  • thanks sasha. Obviously the function is defined. I put only prototype to do not oversize the post. The function i defined you cas see it below void applicationEventCallback (char* type, char* id, char* eventName, char *format, void* payload, size_t payloadSize) { fprintf(stdout, "Received application event:\n"); fprintf(stdout, "Type=%s ID=%s eventName=%s Format=%s Len=%d\n", type, id, eventName, format, (int)payloadSize); fprintf(stdout, "Payload: %s\n", (char *)payload); } – LucaAmato Nov 26 '20 at 17:15

1 Answers1

0

A fix for the issue is delivered in the GigHub project:

https://github.com/ibm-watson-iot/iot-c

For details, refer to:

https://github.com/ibm-watson-iot/iot-c/pull/10

thanks to Ranjan for collaboration and fixing

LucaAmato
  • 1
  • 2