Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Contributor
yruz2bu
Posts: 23
Registered: ‎03-26-2013
My Device: Z30 + Z10 + Playbook 32GB
My Carrier: Telenor

Question about bluetooth profile name

[ Edited ]

I'm just testing the BB10 platform and am looking at the Bluetooth functionality.

 

I understand that you can monitor whenever you get a Bluetooth connection; but is it possible to read the DUN profile name of the connection?

 

Also, it seems that info.newType works fine but info.oldType doesn't contain the relevant information about latest connection. At least not when you run your application in the Ripple context.

 

Thanks in advance.

/Jorgen

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Question about bluetooth profile name

Hi Jorgen,

 

Could you post a "Hello World" sample with the functionality you're after and I can go ahead and test it on a physical device and provide feedback. Ripple may be somewhat limited in what it can provide, but if you provide a sample and steps to gather the info you're after, I'd be happy to test it out.


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
Contributor
yruz2bu
Posts: 23
Registered: ‎03-26-2013
My Device: Z30 + Z10 + Playbook 32GB
My Carrier: Telenor

Re: Question about bluetooth profile name

[ Edited ]

Hi Erik,

 

Thanks for your quick reply.

 

Will do :0)

 

/Jorgen

Please use plain text.
Contributor
yruz2bu
Posts: 23
Registered: ‎03-26-2013
My Device: Z30 + Z10 + Playbook 32GB
My Carrier: Telenor

Re: Question about bluetooth profile name

Hi Erik,

 

What I'm looking for is a service set for BB10 connected to a car via Bluetooth. The first test is to understand when the Z10 is connected to the car and when it loses its connection.

 

This is to get a function to understand where you parked your car last time you parked it....

 

<!DOCTYPE html>
<html>
     <head>   

          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">   
          <title>Connection listener</title>
     </head>
     <body>   
          <script type="text/javascript">
               function dialogCallBack(selection){

                    // Exception code goes here
               }
               function standardDialog(message) {
                    try {
                         blackberry.ui.dialog.standardAskAsync(message, blackberry.ui.dialog.D_OK, dialogCallBack, {title : "Bluetooth"});
                    }catch (e) {

                         //Exception code goes here
                    }

               }
               function onChange(info) {
                    if(info.newType == "bluetooth_dun") {
                         standardDialog("Connecting");
                         // I would like to understand which DUN-profile is connected here (i.e. the bluetooth connection in the car)

                    } else if (onChange.oldType == "bluetooth_dun") { // Since I can't get info.oldType to work correctly
                         standardDialog("Disconnecting");
                         // When the bluetooth profile is lost I will save the GPS position to be able to show the route back to the car

                    }
                    onChange.oldType = info.newType; // Since I can't get info.oldType to work correctly

               }
               blackberry.event.addEventListener("connectionchange", onChange);

          </script>
     </body>
</html>

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Question about bluetooth profile name

Hello Jorgen,

 

I'm having an issue getting the Bluetooth status to trigger a connection notification and was wondering if you're doing anything extra in particular to get that to happen. You can see in the following image that the event triggered when I turned off Wifi and then subsequently turned on Wifi.

 

Logging the entire info object on each state change, I see that the oldType is correctly being set as well:

 

connection.png

 

But turning bluetooth on/off, or connecting/disconnecting bluetooth between my device and PC all do not trigger the connectionchange event.

 

For reference, my config.xml:

 

<?xml version="1.0" encoding="utf-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
		xmlns:rim="http://www.blackberry.com/ns/widgets"
		version="1.0.0.0"
		id="com.oros.connections">

	<name>Connections</name>
	<author>Oros</author>
	<content src="index.html" />

	<feature id="blackberry.event" />
	<feature id="blackberry.connection" />
	<feature id="blackberry.ui.toast" />
</widget>

And my index.html:

 

<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Connections</title>
	</head>
	<body>
		<script type="text/javascript" src="local:///chrome/webworks.js"></script>
		<script type="text/javascript">
			/*global blackberry */

			function onconnectionchange(info) {
				console.log(info);

				if (info.newType === 'bluetooth_dun') {
					blackberry.ui.toast.show('Connecting.');
				} else if (onconnectionchange.oldType === 'bluetooth_dun') {
					blackberry.ui.toast.show('Disconnecting.');
				}

				onconnectionchange.oldType = info.newType;
			}

			window.addEventListener('DOMContentLoaded', function () {
				document.addEventListener('webworksready', function () {
					blackberry.event.addEventListener('connectionchange', onconnectionchange);
				}, false);
			}, false);
		</script>
	</body>
</html>

Does this sample trigger connectionchange event for you? If so, can you provide the steps that you took to trigger the event? Also, can you provide the device model and full OS version you are using?


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.