Arduino Forum

Using Arduino => Programming Questions => Topic started by: dgelectron on Sep 11, 2013, 05:41 pm

Title: [SOLVED]GSM moden library conflict?
Post by: dgelectron on Sep 11, 2013, 05:41 pm
Hi guys.

I just get the new arduino gsm moden and when I try to integrate the gsm code in a program of my own I get this error:

Quote
C:\Documents and Settings\german\Escritorio\arduino-1.0.1\libraries\Keypad/utility/Key.h:46: error: conflicting declaration 'IDLE'
C:\Documents and Settings\german\Escritorio\arduino-1.0.1\libraries\GSM/GSM3MobileAccessProvider.h:37: error: 'IDLE' has a previous declaration as 'GSM3_NetworkStatus_t IDLE'


It seems to be a conflict between libraries Keypad and GSM...
Any idea how to solve it?

Thanks!
Title: Re: GSM moden library conflict?
Post by: JB_AU on Sep 11, 2013, 07:08 pm
With the absence of code or pertinent details, comes the absence of answers!
Title: Re: GSM moden library conflict?
Post by: PeterH on Sep 11, 2013, 07:51 pm

It seems to be a conflict between libraries Keypad and GSM...
Any idea how to solve it?


It does seem to be a conflict, but it seems to be a simple name clash rather than something more fundamental.

The C++ solution would probably be to put the libraries in separate namespaces.

The easy and crude solution would be to divide the parts of your code that need to access the keypad library into separate functions implemented in a separate file that does not include the GSM library. I'd expect to need to do a bit of work to overcome the half-baked mucking about that the IDE does with your sketch before it compiles it - probably it would be sufficient to include the keypad header file in your main sketch .INO file (so the IDE recognises that it is required by your sketch) but put a #ifdef 0 / #endif around that so it didn't actually get included in the compilation (which would then provoke the error you're trying to fix).
Title: Re: GSM moden library conflict?
Post by: JB_AU on Sep 11, 2013, 08:17 pm
Quote
It does seem to be a conflict, but it seems to be a simple name clash rather than something more fundamental.


/utilty/key.h Line 46
Quote
typedef enum{ IDLE, PRESSED, HOLD, RELEASED } KeyState;

GSM3MobileAccessProvider.h Line 37
Quote
enum GSM3_NetworkStatus_t { ERROR, IDLE, CONNECTING, GSM_READY, GPRS_READY, TRANSPARENT_CONNECTED};
Title: Re: GSM moden library conflict?
Post by: mstanley on Sep 13, 2013, 07:20 pm

It seems to be a conflict between libraries Keypad and GSM...
Any idea how to solve it?

I made a first attempt at including a namespace in the keypad library which I just attached below.  I did this while at work so I haven't had a chance to test it out.  If you want to use the attached copy of the keypad library then you will need to change the KeyState variables (IDLE, PRESSED, HOLD, or RELEASED) in your sketch to m_key::IDLE, m_key::PRESSED, m_key::HOLD, and m_key::RELEASED.
Title: Re: GSM moden library conflict?
Post by: dgelectron on Sep 16, 2013, 09:27 am
Hi PeterH and mstanley.

Thanks a lot for your responses and your time. I was out all the weekend so i'm going to start trying the solutions you told me. I´ll be back to post my results. Many thanks again!!
Title: Re: GSM moden library conflict?
Post by: dgelectron on Sep 16, 2013, 10:15 am
I try at first mstanley solution.
I just downloaded your library and put it in the place of the old one. The error doesnt come around any more, but i have a new one:

Quote

iCONTROL_V11.cpp:2101:14: error: empty character constant


I don't have any KeyState variables declared in my sketch so I cant change their names as you told me...

This is what I have declared in the sketch related to keypad librarie.

Quote
const byte ROWS = 4; //4 filas
const byte COLS = 3; //3 columnas
char keys[ROWS][COLS] = {
 {    '1','2','3'  }
 ,
 {    '4','5','6'  }
 ,
 {    '7','8','9'  }
 ,
 {    '*','0','#'  }
};
byte rowPins[ROWS] = { 7, 6, 5, 4}; // reserva de memoria en bytes, conectar a los pines de filas del teclado
byte colPins[COLS] = { 10, 9, 8}; // reserva de memoria en bytes, conectar a los pines de columnas del teclado
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
keypad.setHoldTime(50); // Tiempo de pulsado de boton. Default is 1000mS
keypad.setDebounceTime(20); // Tiempo de rebote de bootn. Default is 50mS  


Title: Re: GSM moden library conflict?
Post by: dgelectron on Sep 16, 2013, 05:18 pm
ok the empty character error is resolved. that was my mistake, a beginner one.
So, i dont have any compilation problems. The problems is that when I connect the GSM shield from Arduino and Telefonico to the Arduino Mega my keypad doesn't respond. I use the keypad to enter some pin codes and now it doesn´t work!!
Title: Re: GSM moden library conflict?
Post by: PaulS on Sep 16, 2013, 09:23 pm
Quote
The problems is that when I connect the GSM shield from Arduino and Telefonico to the Arduino Mega my keypad doesn't respond.

The GSM Shield? you say that like there is just one. Guess again.
Title: Re: GSM moden library conflict?
Post by: dgelectron on Sep 17, 2013, 09:53 am
The one developed between arduino anda telefonica. There is just one developed between these two companys.

http://arduino.cc/en/Main/ArduinoGSMShield (http://arduino.cc/en/Main/ArduinoGSMShield)
Title: Re: GSM moden library conflict?
Post by: PaulS on Sep 17, 2013, 11:40 am
The link you provided shows the pins that the shield uses - pins 2, 3, and 7.

If you reuse those pins for the keypad, as you do pin 7, do not be surprised when one or the other of the devices does not work.
Title: Re: GSM moden library conflict?
Post by: dgelectron on Sep 17, 2013, 03:43 pm
I tried with different pins for the keypad and it works. I guess is not possible to make the shield use another pin for the reset so...i will have to make changes in all the keypads  :smiley-eek-blue:
Thanks all for your help!!

This topic could be mark as solved. It's up to me to do that??

Regards.
Title: Re: GSM moden library conflict?
Post by: PaulS on Sep 17, 2013, 03:48 pm
Quote
It's up to me to do that??

Yes. Just add [SOLVED] to the thread title.
Title: Re: GSM moden library conflict?[SOLVED]
Post by: dgelectron on Sep 19, 2013, 04:08 pm
Done.
Thanks!
Title: Re: GSM moden library conflict?
Post by: msavooo on Jan 16, 2014, 11:35 am


It seems to be a conflict between libraries Keypad and GSM...
Any idea how to solve it?

I made a first attempt at including a namespace in the keypad library which I just attached below.  I did this while at work so I haven't had a chance to test it out.  If you want to use the attached copy of the keypad library then you will need to change the KeyState variables (IDLE, PRESSED, HOLD, or RELEASED) in your sketch to m_key::IDLE, m_key::PRESSED, m_key::HOLD, and m_key::RELEASED.


it works fine with me now, could you please how you make change to the keypad.h file
Title: Re: [SOLVED]GSM moden library conflict?
Post by: maggieYong on May 18, 2015, 04:56 am
Hey everyone, I meet the same problem.
I downloaded the new keypad library and replaced the old one.
But it seemed not work for me, I meet the compile the problem.
The compiling error is


FV1.ino: In function 'void keypadEvent(KeypadEvent)':
FV1.ino:211:10: error: 'PRESSED' was not declared in this scope
FV1.ino:211:10: note: suggested alternative:
In file included from C:\Users\130028T\Desktop\arduino-1.6.3-windows\arduino-1.6.3\libraries\Keypad/Keypad.h:36:0,
                 from FV1.ino:12:
C:\Users\130028T\Desktop\arduino-1.6.3-windows\arduino-1.6.3\libraries\Keypad/utility/Key.h:48:22: note:   'PRESSED'
  typedef enum{ IDLE, PRESSED, HOLD, RELEASED } KeyState;
                      ^
Error compiling.





Could anyone kindly offer me the instructions about how to "change the KeyState variables (IDLE, PRESSED, HOLD, or RELEASED) in your sketch to m_key::IDLE, m_key::PRESSED, m_key::HOLD, and m_key::RELEASED."???

Thank you in advance!

Title: Re: [SOLVED]GSM moden library conflict?
Post by: PaulS on May 18, 2015, 01:27 pm
Quote
Could anyone kindly offer me the instructions
Edit Key.h. Change the enum values to keyPRESSED, keyRELEASED, etc.

Change PRESSED to keyPRESSED, in the sketch. Change the other constants, as needed.