Go Down

Topic: Trouble with GSM library and RTClib (Read 133 times) previous topic - next topic

guerrero-1106

I'm using both libraries. Separately they work fine, but when I try to combine them this error message shows up:

Arduino:1.7.7 (Windows 8.1), Placa:"Arduino Ethernet"

In file included from C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3MobileNetworkProvider.h:37:0,

                 from C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3MobileClientService.h:37,

                 from C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM.h:48,

                 from sketch_may04a.ino:7:

C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3MobileAccessProvider.h:37:100: error: redeclaration of 'OFF'

 enum GSM3_NetworkStatus_t { ERROR, IDLE, CONNECTING, GSM_READY, GPRS_READY, TRANSPARENT_CONNECTED, OFF};

                                                                                                    ^

In file included from sketch_may04a.ino:6:0:

C:\Users\LuisArturo\Documents\Arduino\libraries\RTClib-master/RTClib.h:79:25: note: previous declaration 'Ds1307SqwPinMode OFF'

 enum Ds1307SqwPinMode { OFF = 0x00, ON = 0x80, SquareWave1HZ = 0x10, SquareWave4kHz = 0x11, SquareWave8kHz = 0x12, SquareWave32kHz = 0x13 };



PaulS

If should be fairly obvious that OFF can not belong to two different enums. Both library developers need to understand that they are NOT the center of the universe. I am.

You'll need to edit one of the libraries, to change the name OFF to something else in one (or both) of them. Of course, you'll need to make sure that you change all references to OFF to the new name.

guerrero-1106

And if I do, will it affect the code?

PaulS

And if I do, will it affect the code?
If you do it right, it will allow the code to compile and link, and then function correctly. If you do it wrong, it won't compile and link. I'd say, therefore, that it will "affect the code".

guerrero-1106

I already took the word "OFF" of both libraries, but a new error comes out:

Arduino:1.7.7 (Windows 8.1), Placa:"Arduino Ethernet"

C:\Program Files (x86)\Arduino\libraries\GSM\src\GSM3ShieldV1AccessProvider.cpp: In member function 'virtual bool GSM3ShieldV1AccessProvider::secureShutdown()':

C:\Program Files (x86)\Arduino\libraries\GSM\src\GSM3ShieldV1AccessProvider.cpp:314:37: error: 'OFF' was not declared in this scope

  theGSM3ShieldV1ModemCore.setStatus(OFF);

And now I'm afraid that this will happen with every library, I think it's a "domino effect"

PaulS

Quote
I already took the word "OFF" of both libraries, but a new error comes out:
Apparently you missed this:

Quote
Of course, you'll need to make sure that you change all references to OFF to the new name.

BulldogLowell

I already took the word "OFF" of both libraries, but a new error comes out:

Arduino:1.7.7 (Windows 8.1), Placa:"Arduino Ethernet"

C:\Program Files (x86)\Arduino\libraries\GSM\src\GSM3ShieldV1AccessProvider.cpp: In member function 'virtual bool GSM3ShieldV1AccessProvider::secureShutdown()':

C:\Program Files (x86)\Arduino\libraries\GSM\src\GSM3ShieldV1AccessProvider.cpp:314:37: error: 'OFF' was not declared in this scope

  theGSM3ShieldV1ModemCore.setStatus(OFF);

And now I'm afraid that this will happen with every library, I think it's a "domino effect"
Search one library (both files) for the NEW enumeration.

Replace them all with its replacement (i.e. WEN). And also edit your .ino file for the instances that use the modified library.

Rename the library and modify the #include so that forever you remember the modification.

guerrero-1106

Is this the correct syntax to change the name: "#define WAN OFF" because I already did and I get the same error message from the beginning.

Arduino:1.7.7 (Windows 8.1), Placa:"Arduino Ethernet"

In file included from C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3MobileNetworkProvider.h:37:0,

                from C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3MobileClientService.h:37,

                from C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM.h:48,

                from sketch_may04a.ino:7:

C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3MobileAccessProvider.h:33:16: error: redeclaration of 'OFF'

*/ #define WAN OFF

               ^

C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3MobileAccessProvider.h:37:100: note: in expansion of macro 'WAN'

enum GSM3_NetworkStatus_t { ERROR, IDLE, CONNECTING, GSM_READY, GPRS_READY, TRANSPARENT_CONNECTED, WAN};

                                                                                                   ^

In file included from sketch_may04a.ino:6:0:

C:\Users\LuisArturo\Documents\Arduino\libraries\RTClib-master/RTClib.h:79:25: note: previous declaration 'Ds1307SqwPinMode OFF'

enum Ds1307SqwPinMode { OFF = 0x00, ON = 0x80, SquareWave1HZ = 0x10, SquareWave4kHz = 0x11, SquareWave8kHz = 0x12, SquareWave32kHz = 0x13 };

PaulS

Quote
Is this the correct syntax to change the name: "#define WAN OFF" because I already did and I get the same error message from the beginning.
No. What that will do is substitute the token, WAN, everywhere that it occurs IN A COMPILATION UNIT with the token OFF.

You need to give the enum object a new name. Change OFF to WAN_OFF or (FUCK_OFF) or something that is unique, everywhere that it occurs in the library.

You could let the post-processor do it, but your #define is backwards. I wouldn't...

guerrero-1106

So if I use something like:
"typedef enum WAN_OFF
{
  OFF
};"
 Will this work?

PaulS

Quote
Will this work?
No. You MUST get rid of the name OFF in one of the files being compiled, because it conflicts with the name OFF in the other file.

Using the name in an enum is NOT getting rid of it.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy