bluetooth souce selector

Erel

B4X founder
Staff member
Licensed User
Longtime User
Looks great. Note that you can embed it in the forum:

[youtube]5cVDc5mJJZA[/youtube]

This is how:

SS-2013-06-20_17.39.19.png
 
Upvote 0

IanMc

Well-Known Member
Licensed User
Longtime User
If Objects were meatballs

So Joe, you want to learn how to program your own Bluetooth stuff in B4a seing' as you've got it :)

There are some pretty cool tutorials on the forum and I've knocked up something called SimpleBluetooth which uses just one activity.

It's not really 'simple' to be honest, it does take a bit of getting your head around it but at least you'll have some of my delightful spaghetti code to start off with :)

I've included the project for you to download and tear into :)
 

Attachments

  • SimpleBluetooth.zip
    8.3 KB · Views: 355
Upvote 0

merlin2049er

Well-Known Member
Licensed User
Longtime User
Hmm, I should add a progress bar to my bluetooth attenuator. Should be able to squeeze it into my display.
 
Upvote 0

merlin2049er

Well-Known Member
Licensed User
Longtime User
1016629_10152955160585022_1731821236_n.jpg


Actually I found this vu meter. I can pop it into the designer. Question is, can I resize the image to show volume levels?

I'll have to pop it in and play with it.
 
Upvote 0

merlin2049er

Well-Known Member
Licensed User
Longtime User
hmm, is it necessary to write code to discover and pair a bt module?

I find it quite easy to pair it using the android os. How about just checking to see if you have a connection? If not connected, display a message to pair it with the os.

Sent from my ZP950+ using Tapatalk 2
 
Upvote 0

merlin2049er

Well-Known Member
Licensed User
Longtime User
Hi, just installed the simple bluetooth demo. Trying to send the same commands to my arduino b1, b2, b3, b4

nothing seems to work.

I've tried discovering the bt module, not sure if it's connected... but it connected no problems with btinterface.
 
Upvote 0

merlin2049er

Well-Known Member
Licensed User
Longtime User
ok, took a while to discover the bluetooth module in simple bluetooth demo.
When I attempted to pair it, it gave me some sort of java i/o error.

Does this demo work?
 
Upvote 0

merlin2049er

Well-Known Member
Licensed User
Longtime User
wow, awesome.

I've looked at the automatic bt pairing demo. I see that you can use the mac address and pin for a quick hassble free connection in your app.

Now, I've got to figure out how to send a few bt commands to my arduino.
 
Upvote 0

Graham

Member
Licensed User
Longtime User
I can't remember where I found them...one late night after several beers I am sure. I attached a ZIP file with the three 'LED' files.
 

Attachments

  • leds.zip
    67.2 KB · Views: 319
Upvote 0

Graham

Member
Licensed User
Longtime User
I send my data from the Samsung tablet to a board I made that has a Roving Networks BT chip.

Once I figured out the format to config the BT chip, sending data to the BT chip from B4A was a piece of cake. Here is an example
B4X:
   txtOutputRPM.Text="R,"& EPDCount & "," & RPM1 & "," & RPM2 &"," & RPM3 & "," & RPM4 & "," & RPM5 & "," & RPM6 & "," & RPM7 & "," & RPM8 & "," & RPM9 & "," & RPM10 & "," & RPM11 & "," & RPM12 _
    & "," & RPM13 & "," & RPM14 & "," & RPM15 & "," & RPM16 & "," & RPM17 & "," & RPM18 & "," & RPM19 & "," & RPM20 & "," & RPM21 & "," & RPM22 & "," & RPM23 & "," & RPM24 & "$"' _
    '& "," & RPM25 & "," & RPM26 & "," & RPM27 & "," & RPM28 & "," & RPM29 & "," & RPM30 & "," & RPM31 & "," & RPM32 & "," & RPM33 & "," & RPM34 & "," & RPM35 & "," & RPM36 _ 
   '& "," & RPM37 & "," & RPM38 & "," & RPM39 & "," & RPM40 & "," & RPM41 & "," & RPM42 & "," & RPM43 & "," & RPM44 & "," & RPM45 & "," & RPM46 & "," & RPM47 & "," & RPM48
   AStream.Write(txtOutputRPM.Text.GetBytes("ISO8859_1"))

I use a Microchip processor behind the roving networks BT chip to read in the required rpm numbers.

I had to work a few days to get the PIC chip to Roving Networks BT chip to B4A to work right. I send back from the board to the B4a app through the BT chip this code. I use PicBasic Pro to program the PIC chip so this should be easy code to understand for you.

B4X:
  Prefix1=248'248'248 '248 for 48 rows/123 for 24 rows
  Prefix2=0
  Prefix3=0
  Prefix4=0

  debug Prefix1,Prefix2,Prefix3,Prefix4,"R,",dec4 RadarTotal,",",dec4 RPM1R,",",dec4 RPM2R,",",dec4 RPM3R,",",dec4 RPM4R,",",dec4 RPM5R,",",dec4 RPM6R,",",dec4 RPM7R,",",dec4 RPM8R,",",dec4 RPM9R,",",dec4 RPM10R,_
                                                       ",",dec4 RPM11R,",",dec4 RPM12R,",",dec4 RPM13R,",",dec4 RPM14R,",",dec4 RPM15R,",",dec4 RPM16R,",",dec4 RPM17R,",",dec4 RPM18R,_
                                                       ",",dec4 RPM19R,",",dec4 RPM20R,",",dec4 RPM21R,",",dec4 RPM22R,",",dec4 RPM23R,",",dec4 RPM24R,",",dec4 RPM25R,",",dec4 RPM26R,_
                                                       ",",dec4 RPM27R,",",dec4 RPM28R,",",dec4 RPM29R,",",dec4 RPM30R,",",dec4 RPM31R,",",dec4 RPM32R,",",dec4 RPM33R,",",dec4 RPM34R,_
                                                       ",",dec4 RPM35R,",",dec4 RPM36R,",",dec4 RPM37R,",",dec4 RPM38R,",",dec4 RPM39R,",",dec4 RPM40R,",",dec4 RPM41R,",",dec4 RPM42R,_
                                                       ",",dec4 RPM43R,",",dec4 RPM44R,",",dec4 RPM45R,",",dec4 RPM46R,",",dec4 RPM47R,",",dec4 liftswitch,",E"',DEC2 hh,",",DEC2 mm,_

If I remember right I had to change the Endians setting within the B4A code to accept the four prefix numbers and the incoming data. Once that was handled. It all worked great.

wow, awesome.

I've looked at the automatic bt pairing demo. I see that you can use the mac address and pin for a quick hassble free connection in your app.

Now, I've got to figure out how to send a few bt commands to my arduino.
 
Upvote 0

merlin2049er

Well-Known Member
Licensed User
Longtime User
Did you automatically pair your device within your app? Or do you just do that in the android OS?

I've looked at the bluetooth autopairing library (and demo). It looks great.

Is there another library to actually send the bt commands?


I'm going to post my apps on github - I'll post details here later.
 
Upvote 0

IanMc

Well-Known Member
Licensed User
Longtime User
merlin, when you send B1 you probably need to make sure it's in lower case

b1
 
Upvote 0

merlin2049er

Well-Known Member
Licensed User
Longtime User
ok, I'm not even at the point of being able to send 'b1' or 'b2' or 'b3' or 'b4'.

Do I need some additional library, or can you point me to some code?

I've figured out how to pair it with a mac address and passkey. I'll some how merge that app into mine.

Then, I'll be able to send the commands on each button press.
 
Upvote 0
Top