Programming styles of BLuetooth

joehaase
Posts: 8
Joined: Thu Aug 09, 2018 12:51 am

Programming styles of BLuetooth

Postby joehaase » Mon Aug 27, 2018 11:41 pm

So I am going to show my ignorance here, and ask how everyone programs Bluetooth, and seek guidance. I have been working on a datalogger for the last few months, and have it working perfectly as I want. It records right about 12,000 entries per day, and stores it all on a SD card in CSV format. I have a 4x20 LCD wired in to show live data as it comes in. Since I have about 40 of these loggers we are looking to deploy, if I could save the $20 a piece and just use a mobile device, i could save quite a bit of money.

Using the MIT app builder, displaying what I need shouldnt be a issue, so the issue for me is the Arduino code with Bluetooth. The examples in the IDE are less than desirable for what I am looking to accomplish, which is transmit 6 text strings about every second from the ESP to my phone. I uploaded the samples, and can get a string in no problem, but getting multiple strings in continuously seems to be escaping me. It looks like most of the examples write the one value during the setup phase of the program, and thats it.

I would suspect you would create the server in the setup, and assign the value to the characteristic UUID. But can you have more than one characteristic in the same service with a different UUID? Do you just dump all of the data into one long delimited field and sort it out on the app end, or do you make a new service for each characteristic UUID?

I found https://randomnerdtutorials.com/esp32-b ... duino-ide/

Are there any other must reads for the complete noob with BTLE?

Many thanks, Joe

chegewara
Posts: 2378
Joined: Wed Jun 14, 2017 9:00 pm

Re: Programming styles of BLuetooth

Postby chegewara » Mon Aug 27, 2018 11:57 pm

Hi,
im not professional programmer but personally i like to use library written by Neil Kolban. Its c++ library that can be used with esp-idf as component or with arduino-ide. I like it because its very easy to use.

Yes, you can use few characteristics in the same service. Bluetooth specification allows to have more than one service with the same uuid and/or more than one characteristic with the same uuid in one service, but its not recommended for someone who just start with ble.

Now more about Neil's library. It allows you to write your app with just minimal amount of code and easy send 6 packets or more every second.

https://github.com/nkolban/esp32-snippets

Who is online

Users browsing this forum: No registered users and 53 guests