Ball Spinner Protocal

Logan Tyran, Ryan Curry, Robert Fields

Ball Spinner Protocol

The structure of the protocol can be split into three separate operations: connecting to the Ball Spinner Controller, connecting to the SmartDot module, and sending the real-time data to and from the Ball Spinner Controller. Each message will contain a header byte that will hold the hex code for the type of message followed by a byte that incorporates the message size. There is no specific size for each message, so the message size byte will be used to locate the end of the message on both sides of the system. For error detection, a 2-byte cyclic redundancy check (CRC-16) will be appended to each message. If an error is found on either side of the system, a rejection message will be sent out which will contain the supposed header byte for the other side to resend that last message.

To initialize the connection between the Application and the Ball Spinner Controller, the Application will first send the initialization message which consists of the MAC address of the Application. This data acts more as “dummy data” and is not particularly important for the connection besides filling up the message size to a total of 10 bytes. The Ball Spinner Controller, which is continuously reading the port, will send an acknowledgment message back to the Application, in which the Application will consider the connection established. The acknowledgment and error messages will both contain 1 byte (along with the aforementioned overhead data) which will contain a hex code for the specific type of acknowledgment or error.

Backend Arch

To confirm connection to the SmartDot module, the application will send the initiate BLE signal which contains 2 Bytes to hold the integer value for the rate that the Ball Spinner Controller should be scanning for Bluetooth devices. From there, the Ball Spinner will continuously send the Bluetooth device message, which contains the name of the Bluetooth device and the MAC address. The name will be in ASCII characters with the max value being 248 bytes (including the null terminator). The Ball Spinner Controller will be sent at the specified scan rate that will also send repeated scanned values to avoid the need to send a rejection message in case an error is detected. When the user selects the appropriate module to connect to, the Application will send the MAC address of the smartDot module, which once received from the Ball Spinner Controller will stop sending the Bluetooth device message to the Application (which will act as a confirmation that the BSC received the message) and attempt to connect to the MAC Address. On connection, the Ball Spinner Controller will either send the SmartDot Confirmation message or an Error Message. The Ball Spinner Controller message will consist of the SmartDot MAC Address, and a byte for each sensor that will hold another hex code representing the max sample rates for the Accelerometer, Gyroscope, Magnetometer, and light sensor. Once the Application receives the confirmation message, the application will recognized to the user then a connection will be established. If the Application receives the error message, the Application will need to resend the BLE scan signal and restart the operation from the beginning.

Backend Arch

The final and most elaborate operation of the Ball Spinner Protocol starts from the Application sending the initiate sensor message consisting of a bit-mapping for both the sample frequency and range for each sensor in the Ball Spinner. There will be two bits representing the 4 possible ranges for the scan data (2, 4, 8, 16) and an additional 3 bits for the 7 possible sample frequencies to scan at (25, 50, 100, 200, 400, 800, 1600). This will be sent for the Accelerometer, Magnetometer, Gyroscope, Light Sensor, and the 3 auxiliary sensors for a total of 35 bits stored among 5 bytes (leaving 5 zero bits). When the initiate sensor message is received from the Ball Spinner Controller, it will send an acknowledgment and wait for the application to send the Motor Instructions message. This will consist of a byte for the speed for each motor (3 Bytes total). After receiving the first motor instruction, the Ball Spinner Controller will continuously send the sensor data from the various sensors. Each Sensor data message will contain a byte that will store the type of sensor (using 3 bits to represent the 7 sensors) and the sensor’s sample rate (using 3 bits to represent the possible sample rates previously established in the initiate sensor message). Along with that, it will contain a byte for the count of the sample for that sensor, a float that stores the elapsed time (4 bytes), and finally a float for the x,y, and z axis values (4 bytes each) for a total of 37 Bytes for the sensor data. Every so often the Application will send an acknowledgment that no frames have been lost which will be determined by the sample count number from each sensor. Every time a sensor receives an out-of-order frame, the Application will send a rejection message with the number required to resend. Finally, when the roll is finished, the Application will send the Stop message which will just be an Error message with the error code correlating to the stop function.

Backend Arch