Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Shivaratn
    @Shivaratn
    @imratnesh Could you please help me out with any examples?
    Ratnesh Kushwaha
    @imratnesh
    LacerdaPT
    @LacerdaPT
    is there a way to send an email with HTML content?
    Boris van Galvin
    @vangalvin
    Anyone know how you mark a device inactive of it has not checked in for a while? Or create an alarm if the device has been offline for longer than a specific time?
    StartCPE
    @StartCPE
    hello , i have a problem
    my company use TB PE 2.1.2
    i try to update to PE 2.4.1 and i have error on license key
    and i not have license key because former employee he contact to thingsboard and now he resign,
    what should i do for recovery license key pls help
    Boris van Galvin
    @vangalvin
    @StartCPE have you tried sending a message to the guys at TB? https://thingsboard.io/docs/contact-us/
    Linthoisana Devi Heikham
    @linthoisana
    Hello guys! please help me out. I am new to thingsboard and IoT projects.
    I am unsing Thingsboard community edition . I am using 6LoWpan as my sensor node to gateway(border router) communication and i am trying to sending my sensors data to the remote server and the local server which i have installed in my pc using HTTP protocol. I am writing in CPP. Remote server is receiving all the datas while I try local server, it gives HTTP 400 error. I am so confused and please hlep me out. i will attach my code below
    Linthoisana Devi Heikham
    @linthoisana
    The syntax for request header is :/ / Prepare Request header send to thingboard cloud.
    memset(sbuffer, 0, sizeof(sbuffer));
        sprintf((char*)sbuffer, "POST /api/v1/localservertbhw16lab/telemetry HTTP/1.1\r\nHost: 2001:db8:abcd:a:d54c:4b07:8738:9bfc\r\nContent-Type: application/json\r\nContent-Length: %d\r\n\r\n", payload_str_len); 
    
        str_len = strlen((char*)sbuffer);
        printf("str len = %d, ", str_len); 
    Boris van Galvin
    @vangalvin
    @linthoisana Have you checked that the ports are open and that the http protocol is not being blocked by the firewall?
    Linthoisana Devi Heikham
    @linthoisana
    they are all open, i pinged. i used curl method to send data to my dahboard and they all work
    @vangalvin : my supervisor says, its http 400 erro, and there might be some mistake in the syntax. but my doubt is why it worked for remote server and its giving me error in local server. please help me.
    Boris van Galvin
    @vangalvin
    I assume you used CURL with the exact same header you have above? if that worked then the issue sounds like its with the device sending it.
    Im not sure what the windows version is but you could run a tail on the thingsboard log and see what communications you are getting
    Linthoisana Devi Heikham
    @linthoisana
    curl -v -X curl -v -X POST -d "{\"temperature\": 99}" http://[2001:db8:abcd:a:d54c:4b07:8738:9bfc]:8080/api/v1/localservertbhw16lab/telemetry --header "Content-Type:application/json"
    i used curl in this manner... and i am using windows 10.and i use wireshark to see the data traffic.. and i see http 400 error.
    Boris van Galvin
    @vangalvin
    try using IPV4. instead of IPV6 for the test. Im not 100% but think you need to tell curl that you are using an IPV6 address (i think its -6 ). also i think -d was designed for sending a file in a specific format. try --data or -X should not be required as the --data is a post option.
    Linthoisana Devi Heikham
    @linthoisana
    the problem is 6Lowpan need ipv6. i tried changing to ipv4 address but it doesnt work even, the socket doesnt get connect
    Boris van Galvin
    @vangalvin
    curl -v -6 --data "{\"temperature\": 99}" http://[2001:db8:abcd:a:d54c:4b07:8738:9bfc]:8080/api/v1/localservertbhw16lab/telemetry --header "Content-Type:application/json"
    see if that works.
    Linthoisana Devi Heikham
    @linthoisana
    yes, it works..

    C:\Users\lin>curl -v -6 --data "{\"temperature\": 99}" http://[2001:db8:abcd:a:d54c:4b07:8738:9bfc]:8080/api/v1/localservertbhw16lab/telemetry --header "Content-Type:application/json"

    • Trying 2001:db8:abcd:a:d54c:4b07:8738:9bfc...
    • TCP_NODELAY set
    • Connected to 2001:db8:abcd:a:d54c:4b07:8738:9bfc (2001:db8:abcd:a:d54c:4b07:8738:9bfc) port 8080 (#0)

      POST /api/v1/localservertbhw16lab/telemetry HTTP/1.1
      Host: [2001:db8:abcd:a:d54c:4b07:8738:9bfc]:8080
      User-Agent: curl/7.55.1
      Accept: /
      Content-Type:application/json
      Content-Length: 19

    • upload completely sent off: 19 out of 19 bytes
      < HTTP/1.1 200
      < X-Content-Type-Options: nosniff
      < X-XSS-Protection: 1; mode=block
      < Cache-Control: no-cache, no-store, max-age=0, must-revalidate
      < Pragma: no-cache
      < Expires: 0
      < Content-Length: 0
      < Date: Fri, 22 Nov 2019 13:32:09 GMT
      <
    • Connection #0 to host 2001:db8:abcd:a:d54c:4b07:8738:9bfc left intact
    Boris van Galvin
    @vangalvin
    great, now check to see if the data turned up in thingsboard
    Linthoisana Devi Heikham
    @linthoisana
    yes, i see my data in my dashboard 99.
    Boris van Galvin
    @vangalvin
    brilliant. the next part would be to check your CPP code and make sure that is handling the IPV6 address.
    Linthoisana Devi Heikham
    @linthoisana
        // Prepare Request header send to thingboard cloud.
        memset(sbuffer, 0, sizeof(sbuffer));
        // ACCESS_TOKEN = hp5sVXZjfgcl706hlHo     j(STM32_DEVICE_LIN1) / Ye2Lx6bkBYfc6nnp950g  j(STM32_DEVICE_LIN)
        sprintf((char*)sbuffer, "POST /api/v1/localservertbhw16lab/telemetry HTTP/1.1\r\nHost: 2001:db8:abcd:a:d54c:4b07:8738:9bfc\r\nContent-Type: application/json\r\nContent-Length: %d\r\n\r\n", payload_str_len); 
     //sprintf((char*)sbuffer, "POST /api/v1/localservertbhw16lab/telemetry HTTP/1.1\r\nHost: %s\r\nContent-Type: application/json\r\nContent-Length: %d\r\n\r\n", server, payload_str_len); 
        str_len = strlen((char*)sbuffer);
        printf("str len = %d, ", str_len); 
    when i compile and load the code, the socket is connecting.but my server is unable to recognise my request. shall i share you the whole cpp code?
    Boris van Galvin
    @vangalvin
    my CPP is prety rusty. how are you sending sbuffer?
    Linthoisana Devi Heikham
    @linthoisana
    sorry, it must be confusing
    while (errConnect == 0)
    {
    hum_temp->get_temperature(&temp_val);
    hum_temp->get_humidity(&hum_val);
        DigitalIn pir_out(PA_9, PullUp);             //PIR_OUTPUT    = PA_9
        PIR = pir_out;
        printf("HTS221: [temp] %7s C,   [hum] %s%%\r\n", print_double(buffer1, temp_val), print_double(buffer2, hum_val));
        printf("PIR: [Human_Status]    %s\r\n", PIR ? "Presence":"Absence");
    
    
        // Prepare Request payload data and calculate it's length to send to thingboard cloud.
        memset(sbuffer1, 0, sizeof(sbuffer1));
        sprintf((char*)sbuffer1, "{\"Temperature\": %s, \"Humidity\": %s, \"Human-Status\": %s}", print_double(buffer1, temp_val) , print_double(buffer2, hum_val) ,print_double(buffer3, PIR) ); 
        payload_str_len = strlen((char*)sbuffer1);
        printf("payload data len = %d : ", payload_str_len);    
    
    
    
        // Prepare Request header send to thingboard cloud.
        memset(sbuffer, 0, sizeof(sbuffer));
        // ACCESS_TOKEN = hp5sVXZjfgcl706hlHo     j(STM32_DEVICE_LIN1) / Ye2Lx6bkBYfc6nnp950g  j(STM32_DEVICE_LIN)
        sprintf((char*)sbuffer, "POST /api/v1/localservertbhw16lab/telemetry HTTP/1.1\r\nHost: 2001:db8:abcd:a:d54c:4b07:8738:9bfc\r\nContent-Type: application/json\r\nContent-Length: %d\r\n\r\n", payload_str_len); 
     //sprintf((char*)sbuffer, "POST /api/v1/localservertbhw16lab/telemetry HTTP/1.1\r\nHost: %s\r\nContent-Type: application/json\r\nContent-Length: %d\r\n\r\n", server, payload_str_len); 
        str_len = strlen((char*)sbuffer);
        printf("str len = %d, ", str_len); 
    
    
    
        // Send Request header to thingboard cloud.
        scount = my_socket.send(sbuffer, str_len);
        printf("sent data = %d : ", scount);    
        for(uint8_t cnt=0; cnt<scount; cnt++)
        {
            printf("%c", sbuffer[cnt]); 
        } 
    
        // Send Request payload data to thingboard cloud.
        uint8_t scount1 = my_socket.send(sbuffer1, payload_str_len);    
        printf("sent data = %d \n", scount1); 
        for(uint8_t cnt=0; cnt<scount1; cnt++)
        {
            printf("%c ", sbuffer1[cnt]); 
        }          
    
        // Recieve a simple http response and print out the response line
        rcount = my_socket.recv(rbuffer, sizeof rbuffer);
        printf("recv data = %d : ", rcount); 
        for(int cnt=0; cnt<rcount; cnt++)
        {
            printf("%c", rbuffer[cnt]);
        }
        //usleep(20);
        //sleep();
        wait(10);
    }
    Boris van Galvin
    @vangalvin
    haha, 3AM in the morning down here and im trying to work out why my ESP32 is not calculating the battery voltage properly from the divider network.. so this is a great break while I have yet another coffee.
    It looks to me like handler is not dealing with the IPV6 address but I could be wring.
    wrong
    Linthoisana Devi Heikham
    @linthoisana
    i hope i didnt disturb you this early morning. its 14:46 here. :D
    Boris van Galvin
    @vangalvin
    not at all :)
    Linthoisana Devi Heikham
    @linthoisana
    where can I change to make my ipv6 address work
    Boris van Galvin
    @vangalvin
    What headers are you using?
    the code you posted vanished on this end.
    Linthoisana Devi Heikham
    @linthoisana
    my program is so huge as 6lowpan is involved. i sentyou the separate file which is responsible for sending data to servers.
    Boris van Galvin
    @vangalvin

    Ok, how have you created my_socket ? that is the bit that will use the IPV6 address and open a connection to the remote server if i am not mistaken.
    once you have that then im not sure you need to pass the address in the data stream like you have...
    "POST /api/v1/localservertbhw16lab/telemetry HTTP/1.1\r\nHost: 2001:db8:abcd:a:d54c:4b07:8738:9bfc\r\nContent-Type: application/json\r\nContent-Length: %d\r\n\r\n", payload_str_len);

    unless there is a handler of some kind that builds the link based on this data then just passes the data over.

    Linthoisana Devi Heikham
    @linthoisana
    static void init_socket()
    {
    if (MBED_CONF_APP_BUTTON != NC) {
    my_button.fall(&my_button_isr);
    my_button.mode(MBED_CONF_APP_BUTTON_MODE);
    }
    nsapi_error_t open_result = my_socket.open(network_if);
    
    if (open_result != 0) 
    {
        printf("Error! socket.open(net) returned: %d\n", open_result);
    }
    
    int errConnect = my_socket.connect(server, 8080);  //"demo.thingsboard.io", 80
    while(true)
    {
        if(errConnect != 0) 
        {
            printf("Could not connect to socket : error = %d\r\n", errConnect);
            wait(60);
            errConnect = my_socket.connect(server, 8080);
            // TODO Manage connection issues here !!!!
        }
        else
        {
            printf("Socket connected\r\n");
            break;
        }
    this is how i created
    Boris van Galvin
    @vangalvin
    Awesome.. now if you rem out the part that sends the data is that actually making a connection to the server?
    Linthoisana Devi Heikham
    @linthoisana
    yes it does make connection to the server..
    and the server sends me back 400 error
    Linthoisana Devi Heikham
    @linthoisana
    only the local server sends me back http 400 and connection gets close. while the code works perfectly fine in my remote server demo.thingsboard.io
    Boris van Galvin
    @vangalvin
    400 = bar request so the server is rejecting something that you are sending.
    what you need to do is rem out all of the bits of code that send data with the exception of the code that builds the socket. then see if it gives you a 400 error. if it does then look in the thingsboard log. open up a windows power shell, go to where thingsboard is storing its log and run Get-Content thingsboard .log -Tail 10
    really? is the remote server windows based as well?
    400 = bad request not bar.. lol..
    Linthoisana Devi Heikham
    @linthoisana
    yes, i mean, sometime i check in my phone too for remote server and i get the datas,
    generally, for remote server, we can check in any browser in our thingsboard.io account
    Boris van Galvin
    @vangalvin
    OK, then the issue is not with the code then. definatly run "Get-Content thingsboard .log -Tail 10" and see what is in there. that will tell you what the local server is having issues with.