problem in implementing states using referance time from boot

Status
Not open for further replies.

raushankumar586

Junior Member level 1
Joined
Jun 26, 2017
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
191
Hello guys,

I am implementing states for connecting pic microcontroller to sim800 module.
here is the code written in main:
Code:
while (1) {
        delay(2);
        timeFromBoot();
        if (state == 1) {
            refTime = time;
            checkStart();
            if (checkStartsuccess == 1) {
                printToArduino("I am in state 1\n");
                nextState();
            } else {
                   while ((checkStartsuccess != 1) || (time - refTime) > 10) {
                    timeFromBoot();
                    checkStart();
                }
            }
            delay(40);
        }

        if (state == 2) {
            checkNetwork();
            while (checkNetworksuccess != 1) {
                //                if (timeFromBoot() - refTime > 30) {
                //                    state = 2;
                //                    break;
                //                }
            }
            printToArduino("I am in state 2\n");
            delay(80);
            nextState();
        }
        if (state == 3) {
            checkGprsCon();
            while (checkGprssuccess != 1) {
                //                if (timeFromBoot() - refTime > 30) {
                //                    state = 3;
                //                    break;
                //                }
            }
            printToArduino("I am in state 3!!\n");
            delay(80);
            nextState();
        }

        state = 1;

    }
my code is stucking in becoz of following line of codes
Code:
while ((checkStartsuccess != 1) || (time - refTime) > 10) {
                    timeFromBoot();
                    checkStart();
                }


can anyone help me out
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…