I want to broadcast an array of integers using the broadcast function in the Contiki OS. However, the packetbuf_copyfrom() function does not seem to work for me, when giving an integer array as input. When monitoring the Messages over Cooja's "Radio Message Tool" the packets seem to be empty.
This is what it looks like using a char array as parameter and like that when trying to do exactly the same, just using an integer array.
According to the Contiki Documentation the function expects a void pointer and calls the memcpy function, which should not be a problem regarding integers?
int packetbuf_copyfrom(const void *from, uint16_t len)
{
uint16_t l;
packetbuf_clear();
l = len > PACKETBUF_SIZE? PACKETBUF_SIZE: len;
memcpy(packetbufptr, from, l);
buflen = l;
return l;
}
I'm using the
/contiki/examples/rime/example-broadcast.c
file on Z1 Motes in the Cooja Simulator with contiki 2.7.
Where might my mistake be?
I don't know Contiki, but the code seems fine, as long as you call packetbuf_copyfrom
correctly. Just note that the tool tries to decode the packet contents as ASCII and so shows Hello67890
but integers are not ASCII and so are shown as ........
.
Call the funtion as:
int myArray[10]= {1,2,3,4,5,6,7,8,9,0};
packetbuf_copyfrom(myArray, sizeof(myArray));