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
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.