Community
cancel
Showing results for 
Search instead for 
Did you mean: 
idata
Community Manager
1,419 Views

Error sending to Analytics from Eclipse

Hello

I recently configured Eclipse to work with the iotkit-comm library following these: and http://iotkit-comm-c.s3-website-us-west-2.amazonaws.com/api/md_tutorials_cloud.html Tutorials: cloud

And was able to successfully run the following code:

# include

# include

# include

# include "iotkit-comm.h"

# include "util.h"

ServiceSpec *srvSpec = NULL;

int msgnumber = 13; // sensor value

void callback(void *handle, int32_t error_code, void *serviceHandle) {

Context context;

char msg[256];

int i = 0;

CommHandle *commHandle = NULL;

if(serviceHandle != NULL) {

commHandle = (CommHandle *) serviceHandle;

int (**publish) (char *message,Context context);

publish = commInterfacesLookup(commHandle, "publish");

if(publish == NULL) {

fprintf(stderr, "Function \'publish\' is not available; please verify the Plugin documentation !!\n");

return;

}

context.name = "topic";

context.value = "data";

while(i < 10) { // Event Loop

sprintf(msg, "{\"name\": \"garage_sensor\", \"value\": %d}", msgnumber++);

printf("Publishing msg:%s\n", msg);

(*publish)(msg, context);

sleep(2);

i ++;

}

}

// clean the objects

cleanUpService(&srvSpec, &commHandle);

exit(0);

}

int main(void) {

puts("Sample program to publish data to IoT Cloud !!");

srvSpec = (ServiceSpec *) parseServiceSpec("/usr/share/iotkit-comm/examples/c/serviceSpecs/temperatureServiceEnableIot.json");

if (srvSpec){

advertiseServiceBlocking(srvSpec, callback);

}

return 0;

}

But when I tried to run the code again the following day I get this error at my console:

Sample program to publish data to IoT Cloud !!

Warning: Optional user config file not found. Continuing...

Error Parsing response: [Unauthorized]

Publishing msg:{"name": "garage_sensor", "value": 13}

Publishing msg:{"name": "garage_sensor", "value": 14}

Publishing msg:{"name": "garage_sensor", "value": 15}

The underlined line is new and now I don't get any data published to my dashboard anymore. I've updated the iotkit-agent and went through the getting started process of activating the device several times with no success. I've been sitting with this problem for a while and cant seem to get around it. Could anyone please offer some assistance on this matter?

0 Kudos
8 Replies
idata
Community Manager
48 Views

Hi

 

 

When you say you run the code on the following day you mean that you left the program running overnight or that the program was stopped and restarted the next day. Which iotkit version are you using? In case you're not using the latest one you can see instructions on how to update here https://github.com/enableiot/iotkit-agent https://github.com/enableiot/iotkit-agent . Read through this guide and make sure you're not missing previous steps related to the configuration.

 

 

In what OS are you running the tests, what Eclipse version are you using, what image are you using on the Edison?

 

 

-Sergio

 

idata
Community Manager
48 Views

Hi

I stopped the program and ran it the next day. I didn't make any changes that I can recall before it stopped working. I was running version 1.7.0 of the iotkit-agent at the time but have since upgraded to 1.8.2 which fixed another problem of observations not being displayed on my chart.

I'm using Eclipse version Luna SR2 (4.4.2) on Windows 10 and Yocto 1.7.3 although when I try to run "configure_edison --version" to get the firmware version info I get "Could not retrieve latest firmware version information. Quitting."

Also I've noticed from my console that Eclipse runs some executable script in addition to my code when I run it. Just before it prints "Sample program to publish data to IoT Cloud !!" I see this:

chmod 755 /tmp/iotkit-comm;/tmp/iotkit-comm ;exit

I'm not sure but could this possibly be a permissions problem?

idata
Community Manager
48 Views

Hi PandaBanda,

 

 

Just to clarify, you mention that when you upgraded from 1.7.0 to 1.8.2 it fixed an observation problem. The main error remains the "Error Parsing response: [Unauthorized]", right? The way to check the image version in this release is using the cat /etc/version command. Check again if you're using the latest one. The output should be 201606061707. Now, the new message regarding the permissions is interesting. A chmod 755 means the file owner has read, write and execute permissions and the group and other users only have read and execute permissions. Try to see if it's possible to change the permissions of that file to chmod 777 to see if you get positive results.

 

 

Let us know your results.

 

 

-Sergio

 

idata
Community Manager
48 Views

Hi Sergio

Yes, while on 1.7.0 my Analytics dashboard would show that data was being received but it would not update on the Graph, which was fixed when I updated to 1.8.2

I found the chmod 755 line that was being executed when I checked the run configurations dialog box in Eclipse, I modified it to 777 and updated the activation code in the .json file and I got no change, still the error persists. Last thing I did was check the image version, the output was 201603.... I can't remember it all but I know its old enough that I need to update. I'm having some trouble with the Flash tool software so I've not finished updating yet but when I do I'll try and run again and post the results here as well.

idata
Community Manager
48 Views

The image you mention is not the latest one, we recommend you to update to the latest one before proceeding. You can download the latest one here https://software.intel.com/en-us/iot/hardware/edison/downloads https://software.intel.com/en-us/iot/hardware/edison/downloads . What kind of trouble are you having with the Flash Tool Lite? If you're looking for the instructions on how to download and install it you can find them here https://software.intel.com/en-us/articles/flash-tool-lite-user-manual https://software.intel.com/en-us/articles/flash-tool-lite-user-manual . As an alternative flashing method you can use the flashall script /docs/DOC-25154 https://communities.intel.com/docs/DOC-25154

 

 

Update to the latest image and let us know if you're successful using the Analytics dashboard.

 

 

We'll be waiting for your response.

 

 

-Sergio

 

idata
Community Manager
48 Views

Do you still need assistance with this thread, were you able to flash the board to use the Analytics dashboard?

 

 

-Sergio

 

idata
Community Manager
48 Views

Hi Sergio

IT WORKS!!!! Updating the image fixed it thanks. Eclipse now seems to complain that it cannot synchronize libraries with the board because it cannot detect the repository version. This doesn't bother me much as long as I can publish to the dashboard I'm happy.

Thanks so much again, I appreciate the assistance.

idata
Community Manager
48 Views

That's great news, thank you for letting us know updating the image fixed the issue. If you have any other questions don't hesitate to open a new thread to get help from the community.

 

 

-Sergio

 

Reply