Bluetooth - how to? (using btlistener, class in C++)

6 posts / 0 new
Last post
mirekk36
mirekk36's picture
Offline
Mobile Conjurer
Joined: 14 Aug 2010
Posts:
Bluetooth - how to? (using btlistener, class in C++)

Hi all,

i'm new in MoSync but i can make GUI. It's simple and beautyfull with MoSync.

but... is only one small sample with Bluetooth in C (console program)

How can i use it with normal C++ classes programing. How use BTListener ???

Can anyone write some simple sample ???

I want to discover bluetooth for devices and/or services. Next i woud like to send/receive some data via SPP - it's possible with MoSync ???

thx for answer

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Sam Pickard
rival's picture
Online
Mobile Archmage
Joined: 19 Mar 2009
Posts:

OK, there are some Bluetooth tutorials, but they aren't in their final form. I will fix them next week, and add a zip file with the code, and maybe a video. There are three tutorials.
http://www.mosync.com/documentation/tutorials/discovering-devices-and-services-bluetooth
http://www.mosync.com/documentation/tutorials/creating-bluetooth-clients
http://www.mosync.com/documentation/tutorials/creating-bluetooth-server

They cover just about everything you could want to do, and with C++ example code.

mirekk36
mirekk36's picture
Offline
Mobile Conjurer
Joined: 14 Aug 2010
Posts:

rival ---> a very very BIG THX Wink

that's it - now all start working for me

THX !!!

mirekk36
mirekk36's picture
Offline
Mobile Conjurer
Joined: 14 Aug 2010
Posts:

rival --> what is it?

mContentBox->clear(); // ---> mContentBox is ListBox

clear() ???? is it some hidden method? Wink

next question:

when i clear all lisbox children with:

Vector_each(Widget*, itr, mContentBox->getChildren())
delete *itr;

it work's, but.... when i want add once more any labels as children - i have PANIC

Have ListBox any method to clear all or some children ?

Sam Pickard
rival's picture
Online
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Which version are you using? Did you download from the front screen or from the nightly builds? If you're still using r767, you may want to try a nightly build from http://www.mosync.com/nightly-builds. I'm using r1566

clear() is a public method on ListBox. It removes the pointers to the widgets in the listbox. This means that clearing out a listbox is a two stage process. You need to do

Vector_each(Widget*, itr, mContentBox->getChildren())
delete *itr;

Which actually deletes the widgets off the heap and
mContentBox->clear()

which deletes the pointers to those widgets. If you've not got a clear() method (and I think you should have), then this should also work
Vector_each(Widget*, itr, mContentBox->getChildren())
delete *itr;
while(mContentBox->getChildren().size > Innocent
mContentBox->remove(0);

You're getting panic because the widgets have been deleted, but the pointers to them are still in mContentBox->getChildren(). mContentBox->clear() removes the pointers as well.

**Edit**

I've just looked at the ListBox code (code.google.com/p/mosync), and the children of the listbox must still exist before you call clear(). This means you will need to do this:

Vector oldChildren = mContentBox->getChildren();
mContentBox->clear();
Vector_each(Widget*, itr, oldChildren)
delete *itr;

Sorry about this. I published those tutorials early for you as you had a specific requirement. I'll check them against the latest build this week and correct them where they're wrong.

mirekk36
mirekk36's picture
Offline
Mobile Conjurer
Joined: 14 Aug 2010
Posts:

rival --> ok, i will check newer build