Bluetooth again ~~

For the week before, I finally get my bluetooth devices connected to each other, but the communication is one direction (iPhone sends data to Mac) which means that is not a very health relationship. Therefore for this week, I try to implement the code that makes my laptop talk back to my phone.

And this has a bunch to do with the communication/connection mode for bluetooth. So for bluetooth LE, in order to save energy in the data transfer process, instead of constantly requiring data from the peripheral device (the server, the device that has data) in a certain time interval, the central device only gets data when the data on the peripheral data is updated.

The format for the data being stored in the characteristic in the bluetooth profile, the way I understand it is something similar to the concept of package for network. It is a way that bluetooth carries data.

The function provided by the <CoreBluetooth> framework is to fill the function below … which is essentially parse the data and check if the data has the field/key word “EOM” and is so append the data to the textfield and show the text to the users.

code0

But before that you need to set the peripheral to continuously send updated values of the characteristic, without the central having to constantly ask for it by turn on the notify value to be true.
code1As for making the central device to be able to send data back, is works the same way to able the central to be able to write the data in the characteristics.

///////

The other way to do it is turning the device to be both central and peripheral at the same time, but I’m not very sure how to make the same device switch between these two role. I need to do more research on this.

 

Bluetooth

Progress on bluetooth.

For last week, I finally figured out how to make bluetooth work for mac osx. The framework I used for bluetooth is for OSX and for iOS.
The result is getting my phone connected to my laptop through bluetooth and sending random text message between them.

testblt

The next step is to actually integrating the game idea I have with bluetooth tech. the game uses the embedded camera on iphone to capture realtime video stream and analysis the color of each frame, i.e, the RBG value, histogram, brightness etc and map these information to sound and animation in the game.

The game is current on mobile only and the final project will be experienced both in laptop and mobile.

pictureforgame

BlueTooth – Week8

This week I’m trying to develop apps that build a connection between my laptop and smartphone and try to transfer data between them.Essentially, I’m trying to write an app for OS X that works as a central manager that receive the data and the iOS app as a peripheral that sends data to the laptop.

Currently, I have trouble with the service UUID. After the two devices connected to each other, the central manager is not able to find the service that the peripheral specified in the advertisement packet and thus unable to subscribe to it.

Another problem I need to figure out is how to transfer data from my laptop to my phone.