Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setBearerSetting in SIM808.Gprs.cpp return nothing #16

Closed
adelleodel opened this issue Feb 26, 2020 · 4 comments
Closed

setBearerSetting in SIM808.Gprs.cpp return nothing #16

adelleodel opened this issue Feb 26, 2020 · 4 comments

Comments

@adelleodel
Copy link

hi, it's good to see your work, i'm trying to run example of the code "HttpPost" with some editing code.

now i'm facing issue when checking sim808.enableGprs, it's stuck looping with:

N: Powering on SIM808's GPRS...
N: Powering on SIM808's GPRS...
...

after that i #define _DEBUG on the top of the code, but still the result still the same.
so i change directly _SIM808_DEBUG with 1. then it show some more like this:

N: Powering on SIM808's GPRS...

-->AT+CIPSHUT
<--
<--SHUT OK

-->AT+CGATT=1
<--
<--OK

-->AT+SAPBR=0,1
<--
<--ERROR

-->AT+SAPBR=3,1,"CONTYPE","GPRS"
<--
<--OK

-->AT+SAPBR=3,1,"",""
<--
<--ERROR
0
N: Powering on SIM808's GPRS...

the AT+SAPBR=3,1,"CONTYPE","GPRS" is after error AT+SAPBR=3,1,"",""
so i change it just like your bugfix in here. but the rest of SAPBR setting still error. it's just like nothing inserted.

i maybe can change it directly just like what you did with the CONTYPE setting, bbut i think it will be trouble in the future if it not changed in the main code.
could you please trace what happened in here?

well, i'm not really understand with your AT_COMMAND_PARAMETER line either. where the variable BEARER and CONTYPE setting started?

@blemasle
Copy link
Owner

blemasle commented Feb 28, 2020

Hi :)

#define _DEBUG should have worked. Don't forget to define it before the inclusion of SIM808.h. You find the other way so that's all good :)

What do you mean by "so i change it just like your bugfix" ? Don't you have the library with the bugfix applied ?
I cannot understand the chain of command you've get from the debug output.
After

-->AT+SAPBR=3,1,"CONTYPE","GPRS"
<--
<--OK

an +CSTT= with your apn, user & password sould be issued. So where do you get another round of -->AT+SAPBR=3,1,"","" (with empty parameter by the way, which is not possible with the current code) from ?

As for the AT_COMMAND_PARAMETER, BEARER and CONTYPE question, could you point me what lines you're referring to ?

Thanks

@adelleodel
Copy link
Author

adelleodel commented Mar 2, 2020

What do you mean by "so i change it just like your bugfix" ? Don't you have the library with the bugfix applied ?

Please click this link, this is your bugfix that i mean. i don't think it's your last fix code. it's contain direct parameter for CONTYPE like this:

AT_COMMAND(SET_BEARER_SETTING_CONTYPE_GPRS, "+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");

which in your last code become multi setting parameter like this (see SIM808.Gprs.h):

AT_COMMAND(SET_BEARER_SETTING_PARAMETER, "+SAPBR=3,1,\"%S\",\"%s\"");

this line of code is doesn't work for me.

So where do you get another round of -->AT+SAPBR=3,1,"","" (with empty parameter by the way, which is not possible with the current code) from ?

this is where the issue begin with. the value I entered in the main code did not pass correctly. that happen with the CONTYPE value too, but i've changed it directly as I said before. I'm using ATmega328p system minimum with crystal 8MHz by the way. I don't know whether it has something to do with it.

by the way, i finally found out that you used #define for executing those line, right?
i'm sorry but cmiiw, i've searched out that using #define for passing values is not good enough, it's better to use inline function rather than #define. take a look at this and this

so maybe i've faced this error because it use #define or what? what do you think?

@adelleodel
Copy link
Author

adelleodel commented Mar 2, 2020

I cannot understand the chain of command you've get from the debug output.

by the way, i'm using your example code HttpPost in here if you want to know my chain of command.
i just change GPRS_APN value and some different number of SIM_pin. this is my full original debug output:

N: Powering on SIM808...
powerOnOff: T
Init...
Waiting for echo...

-->AT
Waiting for echo...

-->AT
Waiting for echo...

-->AT
<--⸮Waiting for echo...

-->AT
<--AT
<--OK
<--
<--RDY

-->ATE0
<--
<--+CFUN: 1
<--
<--+CPIN: READY
<--ATE0
<--OK

-->AT+CGREG?
<--
<--+CGREG: 0,2
<--
<--OK

-->AT+CSQ
<--
<--+CSQ: 0,0
<--
<--OK
N: No network yet...

-->AT+CGREG?
<--
<--Call Ready
<--
<--SMS Ready
<--
<--+CGREG: 0,2
<--
<--OK

-->AT+CSQ
<--
<--+CSQ: 9,0
<--
<--OK
N: No network yet...

-->AT+CGREG?
<--
<--+CGREG: 0,1
<--
<--OK

-->AT+CSQ
<--
<--+CSQ: 9,0
<--
<--OK
N: Network is ready.
N: Attenuation : -96 dBm, Estimated quality : 9
N: Powering on SIM808's GPRS...

-->AT+CIPSHUT
<--
<--SHUT OK

-->AT+CGATT=1
<--
<--OK

-->AT+SAPBR=3,1,"",""
<--
<--ERROR
N: Powering on SIM808's GPRS...

-->AT+CIPSHUT
<--
<--SHUT OK

-->AT+CGATT=1
<--
<--OK

-->AT+SAPBR=3,1,"",""
<--
<--ERROR
N: Powering on SIM808's GPRS...

-->AT+CIPSHUT
<--
<--SHUT OK

-->AT+CGATT=1
<--
<--OK

-->AT+SAPBR=3,1,"",""
<--
<--ERROR
N: Powering on SIM808's GPRS...

-->AT+CIPSHUT
<--
<--SHUT OK

-->AT+CGATT=1
<--
<--OK

-->AT+SAPBR=3,1,"",""
<--
<--ERROR
N: Powering on SIM808's GPRS...
...... ( it keeps looping)

Thanks for reply :)

@blemasle
Copy link
Owner

blemasle commented Mar 3, 2020

Please click this link, this is your bugfix that i mean. i don't think it's your last fix code. it's contain direct parameter for CONTYPE like this:

Yep I already clicked the link in your first comment thansk. Got confused between files versions, sorry :)

I'm using ATmega328p system minimum with crystal 8MHz by the way. I don't know whether it has something to do with it.

That does not make a difference, I primarily develop that library to use with a custom board that use this exact same configuration.

by the way, i finally found out that you used #define for executing those line, right?
i'm sorry but cmiiw, i've searched out that using #define for passing values is not good enough, it's better to use inline function rather than #define. take a look at this and this

Both link you provided don't state that macros are bad :) They however say that macros should be used appropriately depending on the use case, which is exactly what has been done here. The library has been optimized to minimize ram and flash usage to a minimum. The macros you're referring to are just used to make life easier in both declaring and using flash stored variables (see here).
Most SIM808 libraries declare inline variables even when the token are reused accross the application which drastically increase the used flash storage space.
The library has been written for a project were flash space was a concern (at one point, I filled the ATmega328 entirely). The library string management is a result of those constraints. I even sometimes changed the code and de-factorized it in some places (if I recall correctly, it has been a while) to save some precious bytes of RAM and/or flash.

As for your issue. I must confess I'm a bit clueless. With the explanation you've given, I cannot see the actual code you're using. The fix you linked has been changed again for a reason I cannot remember and shouldn't be used, plus I'm not sure if you reverted all of it or just a part. Don't take this badly, but "I just changed" is not a reproductible situation. History tells me that sometimes, something else has been changed and the user don't remember it in all these forward/backward changes :) Could you please make sure you revert all your library changes and post an extract of the code your using, especially APN variables declaration and usage ?

I do not have hands on an Arduino right now and won't until at least a week, so I cannot test if "recent" changes in say Arduino SDK or Arduino-Log might cause the issue either :(

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants