Issues connecting MKR1000 and MKR1010 via I2C

These are all bytes. That should work out of the box, no need to convert the data.

You would think, but I am getting a -1 on SRP.One instead of the value I am sending. The first value get's sent correctly

Post your code!

I would set the enum values explicitly if you have to transfer them to another platform.

Yes I actually figured out that the enums were in fact not bytes but integer so that is why I was getting the -1 no matter what. I defined them as byte and is now working.

Do you have a simple example using htons and htonl? I don't seem to be able to make it work directly. I couldn't find the library so I copy the definition of the function directly into my own file.

I would like to know how to use these for when I have to send something more complex.

Other than that, it works with just bytes.

Thank you!

Sender:

uint16_t value = analogRead(A0);
uint16_t value_to_send = htons(value);
interface.write(&value_to_send, 2);

Recipient:

uint16_t recv_value;
interface.read(&recv_value, 2);
uint16_t value = ntohs(recv_value);

This is just code that shows how to use the functions (interface must be an object of a class that supports read() and write() methods on buffers). In the Arduino world the functions are defined in the Ethernet library.

Thank you