Summer Week #4 (6/5 – 6/11)

This past week I continued working on the example PhoneGap application that posts data to and gets data from a MySQL database. Additionally, I worked on creating code for sending data about reps via Bluetooth from the Flora to a mobile device.

PhoneGap/MySQL Example App

In my blog from last week I mentioned how I was following the steps on an online walk-through to learn how to create a simple PhoneGap app that interacts with a MySQL database. I was able to get the app running on my server but I was unable to change from the main page making me also unable to test if I could post data to the MySQL database in the app and get data from the database. I read through the walk-through again but wasn’t able to find anything helpful about changing from the main page to the page with the form to add data to the database. I figured the reason why I was unable to change pages must have something to do with the JavaScript for the button on my main page. The JavaScript code, found here at the bottom of the index.js file, implements a click event function from the JavaScript library called Zepto which is similar to JQuery.

I figured there must be something wrong inside of that click event function so I tried to simplify it and just get the button to work. I tried to do this by telling the button’s click event function to just change the css of the page by setting the color to red when the button is pressed. I was able to successfully test the button here by simply deleting everything in the left box and pasting in this code. However, when I tried to use a similar click event function in the app nothing changed when the button was pressed. I’ve spent a lot of time trying to fix this example and I’m still not sure what the problem is but I will keep trying to get my example app to work.

Using Bluetooth to Send Data from the Flora to the Phone

At my meeting with Katie on the 6th she asked me to write the code for sending data from the Flora to the phone. I looked back at the code for the bleuart cmd_mode example which sends char arrays from the serial monitor to the UART mode on the Bluefruit mobile application and vice versa. I modified the code so that I could use a switch to increase the number of completed reps on the Flora and use a second switch to send that number of completed reps over to a phone that is connected to the Flora via Bluetooth.

I decided to test my code, found here with Bluetooth configuration code found here, using the UART mode on the Bluefruit mobile app and was able to successfully send the number of completed reps over to my phone. However, I was getting a message in the serial monitor that asked me if the completed reps that I was sending (as an int) had failed to send. I asked Katie about this and she told me that I should try casting the int into a char array and see if that will get rid of the message. I casted the ints into a char array and then sent the char array to my phone and it successfully sent it, but still gave me the “Failed to send?” message. I’m a bit confused by why I’m receiving that message and by the .waitForOK method for ble, but I’m not too worried as it’s not a giant issue in the grand scheme of things as the data is still sending and being received.