G
Greg Duncan
Guest
A couple weeks ago we highlighted something that was a "Hit of Build 2103" (my personal award... Chris Walker and SecretLabs had a table which was always packed with people and everyone seemed interested and impressed)", You dont have to be a Secret Agent to develop for the AGENT SmartWatch (You just have to read this...)
Today were taking another look, this time into one specific detail, brought to us by Mike Hole...
Agent Emulator & Bluetooth Device Communications
Yay the Agent smart watch preview SDK is available. You can find it here:
http://www.agentwatches.com/
One of the 1st questions that springs to mind is how do we go about some sort of Bluetooth communication with anything from the emulator? Then I spotted this in the comments section of the Agent kickstarter page:
...
So that got me looking onto how this works so I set about following the instructions and here is the results of my findings:
PC Settings
The diagram above depicts how your host PC should be set up . Basically what you see here is that standard Bluetooth on the host machine is capable of providing COM Port based communication.
COM ports go back to the days of RS232 serial and Centronics parallel communication.They take care of the transmission of bytes between machines, Once you have a COM port open each device can send bytes down the wire.
To enable paired devices to open the COM port on your host PC you need to ensure that there is an incoming com port this is done in the Bluetooth settings:
...
You need one incoming COM port, this is done by tapping the add button and selecting incoming as the connection type.
Emulator settings
When you install the Agent SDK it installs the emulator with a standard settings configuration file if you have used the defaults then this config file will be located here:
...
The diagram above depicts how your host PC should be set up . Basically what you see here is that standard Bluetooth on the host machine is capable of providing COM Port based communication.
COM ports go back to the days of RS232 serial and Centronics parallel communication.They take care of the transmission of bytes between machines, Once you have a COM port open each device can send bytes down the wire.
To enable paired devices to open the COM port on your host PC you need to ensure that there is an incoming com port this is done in the Bluetooth settings:
...
The Agent Application
NOTE: The rest of the code mentioned here will be based upon the AGENT SDK v0.1.1 (June 2013, Preview Release) and will be subject to change as the SDK gets closer to it;s version 1 release.
Given that the Agent emulator has a virtual COM port all the work is carried out using Stream based objects. The System.IO.Ports.SerialPort object is derived from System.Stream, so if you are familiar with working with streams then this should be familiar territory.
To add a serial port to your code that uses the host Bluetooth connection you just add the following line of code:
...
The Windows Phone Application
A good place to start when writing a Bluetooth application for Windows Phone 8 is the Bluetooth App to device sample.
NOTE: One thing to remember when writing a Windows Phone application that uses Bluetooth is to set the ID_CAP_PROXIMITY app capability within your WMAppManifest.xml file (double click the file within VisualStudio) :
...
The source code can be found here:
https://projects.developer.nokia.com/agentexamples/browser/agentexamples
...
BTW, if youre interested in see more apps, run, dont walk, to Watch App and Watch Face Showcase and also AGENT.Contrib (which I think is going to get its own post in the future... [Broken External Image]:http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-5.gif?v=c9
Continue reading...
Today were taking another look, this time into one specific detail, brought to us by Mike Hole...
Agent Emulator & Bluetooth Device Communications
Yay the Agent smart watch preview SDK is available. You can find it here:
http://www.agentwatches.com/
One of the 1st questions that springs to mind is how do we go about some sort of Bluetooth communication with anything from the emulator? Then I spotted this in the comments section of the Agent kickstarter page:
...
So that got me looking onto how this works so I set about following the instructions and here is the results of my findings:
PC Settings
The diagram above depicts how your host PC should be set up . Basically what you see here is that standard Bluetooth on the host machine is capable of providing COM Port based communication.
COM ports go back to the days of RS232 serial and Centronics parallel communication.They take care of the transmission of bytes between machines, Once you have a COM port open each device can send bytes down the wire.
To enable paired devices to open the COM port on your host PC you need to ensure that there is an incoming com port this is done in the Bluetooth settings:
...
You need one incoming COM port, this is done by tapping the add button and selecting incoming as the connection type.
Emulator settings
When you install the Agent SDK it installs the emulator with a standard settings configuration file if you have used the defaults then this config file will be located here:
...
The diagram above depicts how your host PC should be set up . Basically what you see here is that standard Bluetooth on the host machine is capable of providing COM Port based communication.
COM ports go back to the days of RS232 serial and Centronics parallel communication.They take care of the transmission of bytes between machines, Once you have a COM port open each device can send bytes down the wire.
To enable paired devices to open the COM port on your host PC you need to ensure that there is an incoming com port this is done in the Bluetooth settings:
...
The Agent Application
NOTE: The rest of the code mentioned here will be based upon the AGENT SDK v0.1.1 (June 2013, Preview Release) and will be subject to change as the SDK gets closer to it;s version 1 release.
Given that the Agent emulator has a virtual COM port all the work is carried out using Stream based objects. The System.IO.Ports.SerialPort object is derived from System.Stream, so if you are familiar with working with streams then this should be familiar territory.
To add a serial port to your code that uses the host Bluetooth connection you just add the following line of code:
...
The Windows Phone Application
A good place to start when writing a Bluetooth application for Windows Phone 8 is the Bluetooth App to device sample.
NOTE: One thing to remember when writing a Windows Phone application that uses Bluetooth is to set the ID_CAP_PROXIMITY app capability within your WMAppManifest.xml file (double click the file within VisualStudio) :
...
The source code can be found here:
https://projects.developer.nokia.com/agentexamples/browser/agentexamples
...
BTW, if youre interested in see more apps, run, dont walk, to Watch App and Watch Face Showcase and also AGENT.Contrib (which I think is going to get its own post in the future... [Broken External Image]:http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-5.gif?v=c9
Continue reading...