How to receive 2 types of data using one BT module

I am working on a project right now which have to receive a string message as well as some phone numbers from a Android app.
Here i am using HC-05 BT Module,i want the device should to receive the string first for one time and then it should receive the phone numbers one by one.
Here the main goal is it will receive the phone number and send the stoerd string message to the phone number using GSM module.

So, how should i code it to arduino for this purpose(only how i can store the sent message and then phone number one by one)

Will the Arduino be receiving the message and the numbers all at the same time?

Or will it receive a message on one occasion and a phone number on another occasion?

Have a look at the examples in Serial Input Basics - simple reliable non-blocking ways to receive data. The second example may be most relevant for your project.

Phone numbers are usually sent a text so, as far as receiving is concerned the Arduino does not have to distinguish between a number and a message. It only needs to do that after the message (or number) has been received.

It would help if you post an example of a message and an example of a phone number (not a real number) so we can consider how the Arduino can distinguish the message from a number?

Actually it is probably better to think of everything the Arduino receives as a "message". It will make it easier to discuss the matter. Some messages will contain text and others will contain phone-numbers. Or maybe the message could contain both.

...R

I want to store a message and some phone numbers from Bluetooth module in Arduino.How can I code here to store this message and phone number in different arrays to differentiate these two?

Why didn't you respond to Robin2's suggestions in your previous posting on the same topic? Why did you start a new thread?
https://forum.arduino.cc/index.php?topic=692806.msg4657519#msg4657519

Duplicate topics merged

I just posted a lengthy response and it doesn't appear. Was it lost in the merging?

HillmanImp:
I just posted a lengthy response and it doesn't appear. Was it lost in the merging?

You might find it in your own list of posts if you check your Profile.

...R

Robin, I looked already & it's not there. Perhaps I didn't post it, but I'm pretty sure I pressed the "Post" buttton.

Oh well....

My suggestion is to have in the app buttons that command the Arduino sketch as to what kind of data will be sent next.

So a button "Recieve msg" will send the text "RCV_MSG". The sketch then prepares to receive and store the text message.

Another button labelled "Receive ph num" sends the text "RCV_PH_NUM". The sketch prepares to receive the phone number and stores it.

Continue sending phone numbers.

A button labelled "Send Message" sends the command "SND_MSG". The sketch then sends the message to all the phone numbers.

You would need buttons to command the sketch to clear the message and phone numbers.

The message itself and the phone numbers are entered into the app via the Text Box component.

All of this would not be hard to code. (I use MIT App Inventor). The scheme could be improved.

John.

I rather think the OP has omitted a vital consideration - where does the information come from? If it all comes from the one Android app, presumably a plain-vanilla terminal or something that looks like one, it is only one type of data and there is really no problem, it would just be a matter of providing markers between the message and the numbers.

If the information comes from a text source and a contacts list, two apps, an Android problem needs to be solved first, as Bluetooth transmission would be broken between the apps.

walidhasan:
I want to store a message and some phone numbers from Bluetooth module in Arduino.How can I code here to store this message and phone number in different arrays to differentiate these two?

Can you show us an example of the data as it would appear coming in to the Arduino?

HillmanImp:
I just posted a lengthy response and it doesn't appear. Was it lost in the merging?

It won't have been lost due to any deliberate action, but it is possible that you were writing your reply having selected the topic that was merged into the original one and that when you clicked Post it was not saved to the now merged topic. I would, however, have expected you to get a message on screen that the Post had failed

Have you looked at your drafts ?

I don't see it my drafts. I really couldn't have done anything other than "Post", so I think something untoward happened.

Not a big deal.

HillmanImp:
I don't see it my drafts. I really couldn't have done anything other than "Post", so I think something untoward happened.

It is not unusual for strange things to happen to Forum posts - you are not the first and, unfortunately, are unlikely to be the last.

In case it is not your normal habit it is a good idea to proof read your Post after it has been received - that keeps you focused on the possibility that it may not be received and you need to re-send / reload.

It is also a good idea to copy a long Post to the clipboard (ctrl-A and ctrl-C) before you click send.

...R

@Robin2 i want to store the text message like next day class schedule first and store it an array and then phone numbers in another array.

let say 96xxxxxxxxx has been received,now first i want to send the text message(next day class schedule) to this number using GSM and then while is message is sending to this number,next number should be received or stored in that particular array overwriting previous number.
would you please help me!!?

walidhasan:
let say 96xxxxxxxxx has been received,

I presume that is the style of a phone number. You also need to provide an example of the message that might be received.

For example you could check if the first character is one of the digits 0 to 9 and if it is you could assume it is a phone number, and if it is not then you could assume what was received is a message.

But that won't work if it is possible for a message to begin with a digit - such as a time or a date.

Another thing, have you any control over the style or content of these messages (including the phone numbers)? In other words can you have their content changed to make them easier to work with?

...R

@Robin2

The message style would be like this:
date
Course Name
Class room no.

if i fix xxx for phone number in code..then the received phone number will always start with 1.

Now what i can do here in this sense??

walidhasan:
The message style would be like this:
date
Course Name
Class room no.

I suspect that is a description of the message rather than an example of a message. I need to see an example of what is actually received. Maybe it's something like

27/03/2020\r\nHistory\r\nB7\r\n

where \r means a carriage-return character and \n means a linefeed character

...R

Can you please tell us: what efforts have you made so far in terms of making an Arduino sketch and building an app to build your project?

John.