Jacob Lashin's 4960 Project: Lab 2

Objectives


Materials


Setup and Demo

After seting up for the lab, which included creating a virtual environment and downloading Python and Artemis packages to establish BLE communication, I ran the provided demo code to verify everything set up properly. Below is a video showing such.


ECHO Command

The first task of the lab was to write an ECHO command whose function is to send a message from the computer to the Artemis chip, and then forawrd that same message received by the Artemis chip back to the computer. Below is a code snippet of the echo function on the Artemis chip, followed by a video of the desired ECHO command.

ECHO code

SEND_THREE_FLOATS Command

In the second task, I had to code a function to send three floats form the computer and receive the floats on the Artemis chip. The code snippet of this function and video demonstarting the function works as intended is shown below.

SEND_THREE_FLOATS code

Notification Handler

In this part of the lab, I set up a notification handler to receive the float value from the Artemis chip whenever it changed and print the new value. To achieve this, I called start_notify, which would call a callback function whenever a change was detected in the float value. Then, I created this callback function that converted the received data from the Artemis to a float, stored the value in a global variable, and then printed the value. My code is displayed below along with a video demonstration.

Notification Handler Code

receive_float() vs receive_string()

The functions receive_float() and receive_string() will produce the same result, but the main difference is receive_float() will produce you a float value outright, while with receive_string(), you will have to convert the string into a float. However, there are other benfits with receive_string(). For instance, if you want to send multiple float values in one go, you can benefit by sending them all in one string, using receive_string(), and then unpacking the multiple float values in the string. This is computationally less than having to send the multiple float values seperatly.