Hi everyone,
This last week, I worked on nRF and Android. First, I implemented all the missing services. I can write or read data from a characteristic using the UART. I implemented a simple protocol to communicate between the nRF and the STM:
A frame is composed of:
- start delimiter: 0x7E, 1 byte
- type of message: 1 byte
0x10: battery level
0x11: altitude level
0x12: compass level
0x13: collision status
0x14: left motor thrust
0x15: right motor thrust
0x16: left servo level
0x17: right servo level - data: 1 byte
We don’t need an escape byte as we have only one byte of data every time.
We also need a software flow control. The nRF chip we use (nRF51822QFAAC0) has a 1 byte Rx buffer. Each time the nRF receives a byte, it sends an ACK back to the STM.
I also improved the Android app. The priority was to be able to command the balloon as soon as possible using the 2 servos and the 2 motors. Then, using Android, we can control the balloon and do many tests.
Here’s a screenshot of the current state of the application:
The 2 vertical seek bars are used to control the motors and the horizontal seek bars are used to control the servos. The app also displays data coming from the balloon.
The “Send command” field is obsolete for now.
I am now working on flashing our nRF software to the LEDzep board. It’s not as easy as expected because we developed the software targeting the nRF51822QFAAG0.
Unfortunately, our supplier made a mistake and gave us a nRF51822QFAAC0. This is quite a problem because I had to switch the SDK from 5.2.0 to 4.4.2.
I’m able to flash our card but it doesn’t advertise BLE advertisements yet.
More to come soon!
Why do you need to escape 0x10..0x17? Don’t you have to escape 0x7d as well?
Yep, I forgot to add 0x7D. We also have to escape it.
I edited my post.
You still haven’t explained why you need to escape 0x10..0x17. What is the point? 0x7e is the frame marker, so it cannot be escaped as “0x7d 0x7e” or it is useless. Why don’t you keep the same format as the XBee modules?
You’re right, we don’t need to escape anything as we have only one byte of data every time.