Not coming out from function in a case to another case

Hi there, my coding stucked at which it is not coming out of the function after running through it,, I wanted it to be go out of the function and move to next case assigned..The related code as below:

case 1:
// receiving data
if (xxx)
reply_message(); //this is the function it should be running thru

else 
rebroadcast_message();//this is another function

stage = case 2;
break;

case 2:
//something else

The running stops inside the function, it is not moving to case 2 as assigned.
Can anyone guide if there is any mistake or error..?
but the code runs without error..
PLS HELP ME OUT!!
TQ

Addition: I think that's all for the related part, but pls hit me up if any other information is needed..
Addition2: The case is in void loop, and those functions (reply_message and rebroadcast_message) are put before void loop..

The running stops inside the function

Check the function for problems.

For help on this forum, ALWAYS post ALL the code.

Here is the code for those functions:

void reply_message()
{
  char radiopacket1[80];
  Serial.println("Broadcasting P message ");
  strcpy(radiopacket1, "P");
  strcat(radiopacket1, ",");
  sprintf(zz, "%s", src_ID);
  strcat(radiopacket1, zz);
  strcat(radiopacket1, ",");
  sprintf(zzz, "%s", sID);
  strcat(radiopacket1, zzz);
  strcat(radiopacket1, ",");
  sprintf(zzzz, "%s", src_ID);
  strcat(radiopacket1, zzzz);
  strcat(radiopacket1, "|");
  itoa(xrssi, zzzzz, 5);
  strcat(radiopacket1, zzzzz);
  strcat(radiopacket1, "/");
  strcat(radiopacket1, "1");
  strcat(radiopacket1, ",");

  Serial.println(radiopacket1);

  rf95.send(radiopacket1, strlen(radiopacket1) + 1);
  Serial.println("Waiting for packet to complete..."); delay(10);

  randNum = random (10, 30);
  delay(randNum);
  rf95.waitPacketSent();
  Serial.println("delay at random msecond");

}//the end of reply_message function

The another function are the same as this one, just data to be added are different..

Serial monitor shows up to "delay at random msecond" only, which is the last line in the function, after that it is not moving to case 2 as expected..

What part of "ALWAYS post ALL the code" don't you understand?

They are super long and complicated plus take some time to look thru .. so I am only putting related part.. that's where I stucked... I am hoping to overcome ASAP....

This line of code is not even valid:

stage = case 2;

Please post your sketch.

If you can't bother to follow the forum rules, good luck with your project.

Sry I missed out this part:

enum State {
  1,
  2,
  3,
  4,   // for the simplicity, I have changed the name of those cases to numbers

};


enum State stage = 1;   //the stage starts from case 1

Addition:
Pls help me out if possible!! I am wrapping up my project coding!!

This is invalid code also. Doesn't help solve the problem.

enum State {
  1,
  2,
  3,
  4,   // for the simplicity, I have changed the name of those cases to numbers

};

Some of us are professionals. We have scoured millions of lines of code. You cannot scare us.

1 Like

Not likely, from what I have seen.

I am just hoping to solve the related issues...

sry but, it is not compulsory to use this enum in switch case statement or..?

Please post your FULL code, without this, you may never get an answer, your issue shows symptoms at the part you post, but the actual fault may be else where.

Is that something else than C/C++ code? I don't understand it.

Hmmm I am not posting the full code because it is my school project and I am not hoping to see others to simply use the exact code as mine.. they are all my work...especially school juinors

Thoughts and prayers

OK. I give up. The problem is not in the code you posted so I can't help.

but they are eventually stucked at the last line of the function....

Has been pointed out. I don’t know how that even compiles, nor to what.

Could you have meant

  stage = 2;

?

a7