@@ -48,6 +48,8 @@ const char AT_CMD_CFUN4[] PROGMEM = "AT+CFUN=4"; //
4848const char AT_CMD_CREG_TEST[] PROGMEM = " AT+CREG?" ; // Check the network registration status
4949const char AT_CMD_SAPBR_GPRS[] PROGMEM = " AT+SAPBR=3,1,\" Contype\" ,\" GPRS\" " ; // Configure the GPRS bearer
5050const char AT_CMD_SAPBR_APN[] PROGMEM = " AT+SAPBR=3,1,\" APN\" ," ; // Configure the APN for the GPRS
51+ const char AT_CMD_SAPBR_USER[] PROGMEM = " AT+SAPBR=3,1,\" USER\" ," ; // Configure the USER for the GPRS (linked to APN)
52+ const char AT_CMD_SAPBR_PWD[] PROGMEM = " AT+SAPBR=3,1,\" PWD\" ," ; // Configure the PWD for the GPRS (linked to APN)
5153const char AT_CMD_SAPBR1[] PROGMEM = " AT+SAPBR=1,1" ; // Connect GPRS
5254const char AT_CMD_SAPBR0[] PROGMEM = " AT+SAPBR=0,1" ; // Disconnect GPRS
5355
@@ -639,6 +641,34 @@ bool SIM800L::setupGPRS(const char* apn) {
639641 return readResponseCheckAnswer_P (20000 , AT_RSP_OK);
640642}
641643
644+ /* *
645+ * Setup the GPRS connectivity with user and password
646+ * As input, give the APN string of the operator, the user and the password
647+ */
648+ bool SIM800L::setupGPRS (const char * apn, const char * user, const char * password) {
649+ // Prepare the GPRS connection as the bearer
650+ sendCommand_P (AT_CMD_SAPBR_GPRS);
651+ if (!readResponseCheckAnswer_P (20000 , AT_RSP_OK)) {
652+ return false ;
653+ }
654+
655+ // Set the config of the bearer with the APN
656+ sendCommand_P (AT_CMD_SAPBR_APN, apn);
657+ if (!readResponseCheckAnswer_P (20000 , AT_RSP_OK)) {
658+ return false ;
659+ }
660+
661+ // Set the config of the bearer with the USER
662+ sendCommand_P (AT_CMD_SAPBR_USER, user);
663+ if (!readResponseCheckAnswer_P (20000 , AT_RSP_OK)) {
664+ return false ;
665+ }
666+
667+ // Set the config of the bearer with the PWD
668+ sendCommand_P (AT_CMD_SAPBR_PWD, password);
669+ return readResponseCheckAnswer_P (20000 , AT_RSP_OK);
670+ }
671+
642672/* *
643673 * Open the GPRS connectivity
644674 */
0 commit comments