This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Show sensor data in open thread border router web GUI

Hi nordic community,

              I'm using Open Thread Border Router build using Linux and an nrf52840 dk board, I want to show my sensor data in open thread border router web GUI, 

             is there any possibility of getting data on Open Thread web GUI?. 

          

            Thanks!

            Senthilkumar    

Parents
No Data
Reply
  • Hello,

    I saw you gave suggestion of using COAP client to see the data. Can you please guide me a little bit more.

    Currently i have a simple setup. I have a border router setup with RCP device. From border router i am able to ping google server. So its working fine. Than i have a 2 FTD and 2 MTD in my network.

    I am sending sensor data using COAP protocol from MTD device. I am currently following the "Thread CoAP Examples" available at https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_tz_v3.1.0%2Fthread_ncp_rcp_example.html  

    For router devices, i have flashed "Simple COAP Server" example where i am just printing the data received from end device sensor on terminal. And for end devices i have flashed "Simple COAP Client" example for transmission, where i am sending sensor data using COAP send request function with multicast local address as parameter.

    From WEB GUI in border router, my networks gets formed properly. In the router  devices (FTD), i am able to see the data in the terminal that i receive from the multiple end devices (MTD).

    But how to see verify whether the sensor data from end device is getting received on border router or not ? Is there any tool  available or any guidance how can i see the data available on border router.  

    Also do point out if i am using wrong examples for my network FTD and MTD devices. Because as in Ideal scenario, the router are the only devices that routes the data. While in my case, my full thread device receive data even if it has switched from router ton child state.    

    Below is the code snippet i have used for router devices (FTD) in my network, to work as router.

    For Router:

    static void light_request_handler(void *context, otMessage *message, 				  const otMessageInfo *message_info) 
    { 	
    	uint8_t command;         
    	uint8_t buffer[50];  	
    	ARG_UNUSED(context);  	
    	
    	if (otCoapMessageGetType(message) != OT_COAP_TYPE_NON_CONFIRMABLE) 
    	{ 		
    		LOG_ERR("Light handler - Unexpected type of message"); 		
    		goto end; 	
    	}  	
    	
    	if (otCoapMessageGetCode(message) != OT_COAP_CODE_PUT) 
    	{ 		
    		LOG_ERR("Light handler - Unexpected CoAP code"); 		
    		goto end; 	
    	} 	       
    	
    	otMessageRead(message, otMessageGetOffset(message), &buffer,sizeof(buffer)); 	       
    	printf("%s\r\n", buffer);                   /*fill buffer*/         
    	
    	char* temp;         
    	float x,y,z;         
    	static unsigned int i;                    
    	
    	/*variables to store float values*/          
    	x = strtof(buffer, &temp);        
    	y = strtof(temp, &temp);       
    	z = strtof(temp, NULL); 		
    	//  printf("x:%.2f y:%.2f z:%.2f\r\n",x,y,z);       
    	if(i>210) 	
    	{          
    	//  printf("buffer fill successfully\r\n");       
        i=0;
    	} 	
    	
    	features[i++]=x; 	
    	features[i++]=y; 	
    	features[i++]=z; 	                     
    	memset(buffer,0,sizeof(buffer));     
        srv_context.on_light_request(command);     
    	end: 	return;
    
    }
    

    Below is the code snippet i have used for end devices (MTD) in my network, to work as end devices.

    For End Devices:

    static void toggle_mesh_lights(struct k_work *item)
    {
    	
        static char sensor_buffer[120];
        
    	ARG_UNUSED(item);
    	// #if defined (CONFIG_SENSOR_LPS22HH1B)
    	 sprintf(sensor_buffer,"%.2f %.2f",SENSOR_TEMPRATURE,SENSOR_PRESSURE);
        // #endif
    
    	#if defined (CONFIG_SENSOR_BME680)
    	 sprintf(sensor_buffer,"%.2f %.2f %.2f",SENSOR_TEMPRATURE,SENSOR_PRESSURE,SENSOR_HUMIDITY);
        #endif
    
    	#if defined (CONFIG_SENSOR_SI1151)
    	sprintf(sensor_buffer,"ALS:%d",SENSOR_lux);
    	#endif		
                       
                coap_send_request(COAP_METHOD_PUT,
    			  (const struct sockaddr *)&multicast_local_addr,
    			  light_option, &sensor_buffer, sizeof(sensor_buffer), NULL);
                   
                memset(sensor_buffer,0x00,sizeof(sensor_buffer));
          	    // printk("data:%s\r\n",sensor_buffer);
    	
    }

Children
  • You can try to enable syslogs in the border router to see if it receives packets (note that the name of the RCP may differ from the example, so you may need to provide a different argument to grep. Try without argument first to see the full log and capture the correct name). It is also possible to use an on-air sniffer or packet capture in the border router to view received/transmitted packets.

    Nikhil D&K said:
    Also do point out if i am using wrong examples for my network FTD and MTD devices. Because as in Ideal scenario, the router are the only devices that routes the data. While in my case, my full thread device receive data even if it has switched from router ton child state.    

    Most likely, the border router/RCP node acts as the parent for all child nodes in the network. This node will receive and relay the packets to all the receiving nodes in the network.

Related