Skip to content
/ BTM Public

A simple library to handle sending/receiving messages on any hardware Serial on arduino

Notifications You must be signed in to change notification settings

rem2718/BTM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BLUETOOTH MODULE LIBRARY

A simple library to handle sending/receiving messages using hardware/software Serial on Arduino

INSTALL THE LIBRARY

1.Download BTM.zip file

2.In Arduino IDE go to Sketch>Include library>Add .ZIP Library

3.Locate BTM.zip and click on it

IMPORT THE LIBRARY

-Just write at the begining of your code:

#include <BTM.h>

NOTES:

-Create BTM for each serial you will use:

  //BTM constructor, Param: the serial youre using
  BTM btm(&Serial)

-The format for the messages is ?id=i&xy&xy; i for id, x for start symbols and, y for data (to change the const characters check and modify BTM.h)

-The symbols/data can be in any length

-You can use any number of data

-Create Message for each collection of data youre sending/receiving(this class takes only vectors):

  //Message constructor, Params: a Vector for start Symbols in your message, A vector for your data
  byte message = btm.createMessage(&startSymbols1, &data);

-The max number for messages is 10(you might change it(MAX_SIZE) in BTM.h)

-The IDs of the messages depends on the order of messages creation(first messge created: 0, second: 1 third: 2...and so on)

-Start symbols can be shared across messages(they are read-only vectors)

-Data arrays have to be unique for each message

-all data are string you can convert them to any type using(.toInt()/.toFloat()/...)

-You can check a simple example for receiving coordinates(x,y) and sending their signs in simpleExample.ino file, and another one for receiveing two different messages in twoMessagesExample.ino file.

BTM Methods

Method Params Return Description
createMessage start symbols (Vector<String>), data (Vector<String>) message's id (byte) dont use message constructor, use this instead
receiveMessage none message's id (byte) return the message's id if it recieve a full correct message using the start symbols given in the message or -1 otherwise
sendMessage message's id (byte) void send the data in the correct format using the start symbols/data given in the message

THANK YOU!

Hope this simple library help you :)

Made by: @rem2718

For any suggestions/comments/questions email me at: rem.e2.718@gmail.com

About

A simple library to handle sending/receiving messages on any hardware Serial on arduino

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages