I'm planning to make a wireless network of my own with microcontrollers. It may sound like I'm trying to reinvent the wheel, but later on I will be using the network for other purposes besides exchanging bytes over the air.
The problem I have is that nearly all data streams being sent over end up at the other end incorrect.
This is the data format I use to send over the air with. Each entry below uses one byte:
What I have attempted is to transmit the same packet 4 times in a row in hopes the receiver gets it. Sometimes the receiver gets it but not always in the right order. sometimes bytes are missed.
This is what I have done when trying to receive data:
Sometimes when I try to read data from the transmitter that continuously transmits the same packet endlessly, the ID matches up but the checksum is incorrect, yet I use the same equation on both transmitter and receiver to generate the checksum.
Is there any other way I can do this without extending my packet size or reducing the number of bits available for generic data?
I heard someone mention the use of sliding windows but I'm not sure how that would improve the situation.
The problem I have is that nearly all data streams being sent over end up at the other end incorrect.
This is the data format I use to send over the air with. Each entry below uses one byte:
- Sender's address from 0 - 255
- Receipient's address from 0 - 255
- Command
- Data
- Data
- Data
- Checksum High byte
- Checksum Low byte
What I have attempted is to transmit the same packet 4 times in a row in hopes the receiver gets it. Sometimes the receiver gets it but not always in the right order. sometimes bytes are missed.
This is what I have done when trying to receive data:
Code:
Buffer pointer is zero - start at 1st byte.
Receiver first checks to see that the first byte isn't their ID. If it is, start read all over.
Receiver then checks to see that the second byte IS their ID. If it isn't, start read all over.
Receiver then reads all remaining 6 bytes.
Receiver checks checksum. If it doesn't match, start read all over.
When everything is valid, data is copied to userspace for application processing.
Sometimes when I try to read data from the transmitter that continuously transmits the same packet endlessly, the ID matches up but the checksum is incorrect, yet I use the same equation on both transmitter and receiver to generate the checksum.
Is there any other way I can do this without extending my packet size or reducing the number of bits available for generic data?
I heard someone mention the use of sliding windows but I'm not sure how that would improve the situation.