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

can't send ipv6

i'm trying to send ipv6 packet over thread with function otIp6Send.
but otIp6Send doesn't work and return '6' which means  "Failed to parse message or arguments." as openthread errors says.
i don't know why !!

i'm using nrf52840.
this's part of my code

static void ip_packet_transmit(void)
{
      uint8_t err;
      uint8_t* header5;
      header5= (uint8_t*)contructip6add(source_addr,des_addr,4);
          uint8_t aData [4]={'p','l','a','y'};
        otMessage *amessage;
        amessage=otIp6NewMessage(thread_ot_instance_get(), true);
                err=otMessageAppend(amessage, header5, 40);
        if (amessage == NULL) {
         return 0;
    }  
        err=otMessageAppend(amessage, aData, 4);
             if (err!= OT_ERROR_NONE ) {
        return  0;
    }

        err=otIp6Send(thread_ot_instance_get(),amessage);
       if(err!= OT_ERROR_NONE)
       {
          NRF_LOG_INFO("fail to send with error =  %d",err);
       }
       else
      {
         NRF_LOG_INFO("sent");
       }
 
}

 uint32_t* contructip6add (uint32_t* src,uint32_t* dest,uint16_t pay_len)
{
   static uint32_t header [10];
    header[0]=(((uint32_t)ver)<<28)|(((uint32_t)TRAFFIC_CLASS)<<20)|FLOW_LABEL;
    header[1]=(((uint32_t)pay_len)<<16)|(((uint32_t)NEXT_HEADER)<<8)|HOP_LIMIT;
    header[2]=src[0];
    header[3]=src[1];
    header[4]=src[2];
    header[5]=src[3];
    header[6]=dest[0];
    header[7]=dest[1];
    header[8]=dest[2];
    header[9]=dest[3];
    return header;
}

Parents Reply Children
No Data
Related