Send/receive message from/to thread Device and global address using OpenThread API

I am currently working on establishing thread network using nRF5340DK to send/receive data between thread device(client) and global network(server). I was successful in setting up the network and able to ping the devices.

But I really don't know, how could I send packets of data from the thread device to cloud server or global network using OpenThread API calls from my application. Can someone guide me on this or share some useful examples or reference to send some messages(UDP or TCP/IP) from thread device.

Below diagram is my network configuration. Here the OTBR is connected to Ethernet. 

Note: Final goal is to send/receive data from Thread Device to Blockchain Node(Global network) via OTBR. 

Thanks and Regards

Vipin Das

Parents Reply Children
  • Hi Charlie,

    Thank you for your reply. 

    I followed the  discussion suggested by you  (+) Error -22 in mqtt_connect() - nRF52840dk with Azure IoT Hub using OpenThread and TCP - Nordic Q&A - Nordic DevZone - Nordic DevZone (nordicsemi.com) and adapted the necessary changes on echo client sample. The good thing is that I was able to ping our http server (https://mainnet.incubed.net) from the application. 

    [00:00:37.808,624] <dbg> in3_ot: ping_send: Ping Server:
    [00:00:37.808,624] <dbg> in3_ot: print_ipv6_address: Mesh Local EID Address: fd97.6739.093e.0002.0000.0000.a756.5ef8
    [00:00:37.809,265] <dbg> in3_ot: ping_send: ping send response:0
    [00:00:37.809,295] <dbg> main: main: Connected to thread network
    [00:00:37.895,446] <dbg> in3_ot: ping_reply_cb: Ping reply
    [00:00:37.895,477] <dbg> in3_ot: print_ipv6_address: Mesh Local EID Address: fd97.6739.093e.0002.0000.0000.a756.5ef8
    [00:00:47.460,449] <inf> net_l2_openthread: State changed! Flags: 0x00000064 Current role: router

    But I am unable to send TCP packets to our HTTP server. Even I integrated the http client sample by thinking if the http header format is required to have proper communication. But nothing helps. Do you have any suggestions or thoughts on this. Logs collected as follows:

    [00:00:30.631,896] <inf> usb_cdc_acm: Device resumed
    [00:00:30.748,016] <inf> usb_cdc_acm: Device suspended
    [00:00:30.987,182] <inf> usb_cdc_acm: Device resumed
    [00:00:31.048,187] <inf> usb_cdc_acm: Device configured
    [00:00:45.052,551] <inf> net_l2_openthread: State changed! Flags: 0x00004000 Current role: disabled
    [00:00:45.053,192] <inf> net_l2_openthread: State changed! Flags: 0x00020000 Current role: disabled
    [00:00:45.053,283] <inf> net_l2_openthread: State changed! Flags: 0x00040000 Current role: disabled
    [00:00:45.053,375] <inf> net_l2_openthread: State changed! Flags: 0x00000100 Current role: disabled
    [00:00:45.056,671] <inf> net_l2_openthread: State changed! Flags: 0x00010000 Current role: disabled
    [00:00:45.056,762] <inf> net_l2_openthread: State changed! Flags: 0x00008000 Current role: disabled
    [00:00:45.057,281] <inf> net_l2_openthread: State changed! Flags: 0x10000000 Current role: disabled
    [00:00:45.057,556] <inf> net_l2_openthread: State changed! Flags: 0x10000000 Current role: disabled
    [00:00:45.058,624] <inf> net_l2_openthread: State changed! Flags: 0x00001000 Current role: disabled
    [00:00:45.058,807] <wrn> net_l2_openthread: No address info provided with event, please enable CONFIG_NET_MGMT_EVENT_INFO
    [00:00:45.058,837] <wrn> net_l2_openthread: No address info provided with event, please enable CONFIG_NET_MGMT_EVENT_INFO
    [00:00:45.058,929] <inf> net_l2_openthread: State changed! Flags: 0x00000001 Current role: disabled
    [00:00:45.059,020] <wrn> net_l2_openthread: No address info provided with event, please enable CONFIG_NET_MGMT_EVENT_INFO
    [00:00:45.059,112] <inf> net_l2_openthread: State changed! Flags: 0x00000008 Current role: disabled
    [00:00:45.059,234] <inf> net_l2_openthread: State changed! Flags: 0x01000000 Current role: disabled
    [00:00:45.059,356] <inf> net_l2_openthread: State changed! Flags: 0x00000004 Current role: detached
    [00:00:45.059,509] <inf> net_l2_openthread: State changed! Flags: 0x00000001 Current role: detached
    [00:00:45.059,600] <wrn> net_l2_openthread: No address info provided with event, please enable CONFIG_NET_MGMT_EVENT_INFO
    [00:00:45.059,692] <inf> net_l2_openthread: State changed! Flags: 0x00001000 Current role: detached
    [00:00:45.059,844] <wrn> net_l2_openthread: No address info provided with event, please enable CONFIG_NET_MGMT_EVENT_INFO
    [00:00:45.059,967] <inf> net_l2_openthread: State changed! Flags: 0x00001000 Current role: detached
    [00:00:45.060,119] <wrn> net_l2_openthread: No address info provided with event, please enable CONFIG_NET_MGMT_EVENT_INFO
    [00:00:45.060,211] <inf> net_l2_openthread: State changed! Flags: 0x00000010 Current role: detached
    [00:00:45.060,943] <inf> net_l2_openthread: State changed! Flags: 0x10000000 Current role: detached
    [00:00:47.353,790] <inf> net_l2_openthread: State changed! Flags: 0x200012a4 Current role: child
    [00:00:47.354,064] <inf> net_l2_openthread: State changed! Flags: 0x00000001 Current role: child
    [00:00:47.354,187] <wrn> net_l2_openthread: No address info provided with event, please enable CONFIG_NET_MGMT_EVENT_INFO
    [00:00:47.354,217] <wrn> net_l2_openthread: No address info provided with event, please enable CONFIG_NET_MGMT_EVENT_INFO
    [00:00:47.354,278] <dbg> in3_ot: ping_send: Ping Server:
    [00:00:47.354,309] <dbg> in3_ot: print_ipv6_address: Mesh Local EID Address: fd97.6739.093e.0002.0000.0000.2e04.6974
    [00:00:47.354,919] <dbg> in3_ot: ping_send: ping send response:0
    [00:00:47.354,949] <dbg> main: main: Connected to thread network
    [00:00:47.355,499] <dbg> net_tcp: tcp_conn_ref: (main): conn: 0x20033ad8, ref_count: 1
    [00:00:47.355,529] <dbg> net_tcp: tcp_conn_alloc: (main): conn: 0x20033ad8
    [00:00:47.355,743] <dbg> net_tcp: net_tcp_connect: (main): context: 0x20013594, local: ::, remote: fd97:6739:93e:2::2e04:6974
    [00:00:47.355,895] <dbg> net_tcp: net_tcp_connect: (main): conn: 0x20033ad8 src: fd11:22::bd3f:a678:d35a:f0c1, dst: fd97:6739:93e:2::2e04:6974
    [00:00:47.356,048] <dbg> net_tcp: tcp_in: (main):  [LISTEN Seq=1179184775 Ack=0]
    [00:00:47.356,292] <dbg> net_tcp: tcp_out_ext: (main): SYN Seq=1179184775 Len=0
    [00:00:47.356,445] <dbg> net_tcp: tcp_send_process_no_lock: (main): SYN Seq=1179184775 Len=0 
    [00:00:47.356,689] <dbg> net_tcp: tcp_send: (main): SYN Seq=1179184775 Len=0
    [00:00:47.357,055] <dbg> net_tcp: tcp_in: (main): LISTEN->SYN_SENT
    [00:00:47.402,557] <dbg> in3_ot: ping_reply_cb: Ping reply
    [00:00:47.402,587] <dbg> in3_ot: print_ipv6_address: Mesh Local EID Address: fd97.6739.093e.0002.0000.0000.2e04.6974
    [00:00:47.564,208] <dbg> net_tcp: tcp_send_process_no_lock: (tcp_work): SYN Seq=1179184775 Len=0 in_retransmission
    [00:00:47.564,422] <dbg> net_tcp: tcp_send: (tcp_work): SYN Seq=1179184775 Len=0
    [00:00:47.771,697] <dbg> net_tcp: tcp_send_process_no_lock: (tcp_work): SYN Seq=1179184775 Len=0 in_retransmission
    [00:00:47.771,942] <dbg> net_tcp: tcp_send: (tcp_work): SYN Seq=1179184775 Len=0
    [00:00:47.979,217] <dbg> net_tcp: tcp_send_process_no_lock: (tcp_work): SYN Seq=1179184775 Len=0 in_retransmission
    [00:00:47.979,431] <dbg> net_tcp: tcp_send: (tcp_work): SYN Seq=1179184775 Len=0
    [00:00:48.186,706] <dbg> net_tcp: tcp_send_process_no_lock: (tcp_work): SYN Seq=1179184775 Len=0 in_retransmission
    [00:00:48.186,950] <dbg> net_tcp: tcp_send: (tcp_work): SYN Seq=1179184775 Len=0
    [00:00:48.394,226] <dbg> net_tcp: tcp_send_process_no_lock: (tcp_work): SYN Seq=1179184775 Len=0 in_retransmission
    [00:00:48.394,439] <dbg> net_tcp: tcp_send: (tcp_work): SYN Seq=1179184775 Len=0
    [00:00:48.601,715] <dbg> net_tcp: tcp_send_process_no_lock: (tcp_work): SYN Seq=1179184775 Len=0 in_retransmission
    [00:00:48.601,959] <dbg> net_tcp: tcp_send: (tcp_work): SYN Seq=1179184775 Len=0
    [00:00:48.809,234] <dbg> net_tcp: tcp_send_process_no_lock: (tcp_work): SYN Seq=1179184775 Len=0 in_retransmission
    [00:00:48.809,448] <dbg> net_tcp: tcp_send: (tcp_work): SYN Seq=1179184775 Len=0
    [00:00:49.016,723] <dbg> net_tcp: tcp_send_process_no_lock: (tcp_work): SYN Seq=1179184775 Len=0 in_retransmission
    [00:00:49.016,967] <dbg> net_tcp: tcp_send: (tcp_work): SYN Seq=1179184775 Len=0
    [00:00:49.224,243] <dbg> net_tcp: tcp_send_process_no_lock: (tcp_work): SYN Seq=1179184775 Len=0 in_retransmission
    [00:00:49.224,456] <dbg> net_tcp: tcp_send: (tcp_work): SYN Seq=1179184775 Len=0
    [00:00:49.431,732] <dbg> net_tcp: tcp_send_process_no_lock: (tcp_work): SYN Seq=1179184775 Len=0 in_retransmission
    [00:00:49.431,793] <dbg> net_tcp: tcp_conn_unref_debug: (tcp_work): conn: 0x20033ad8, ref_count=1 (tcp_send_process():568)
    [00:00:49.431,823] <dbg> net_tcp: tcp_conn_unref_debug: (tcp_work): conn: 0x20033ad8 is waiting on connect semaphore

    Regards

    Vipin Das

Related