kevinl95 / KeychainSkimmerScanner

A compact keychain device powered by M5CoreInk that detects and alerts you to potential credit card skimmers at payment terminals.
MIT License
4 stars 2 forks source link

Code won't compile #4

Open johnwargo opened 4 hours ago

johnwargo commented 4 hours ago

@kevinl95 I purchased a new M5Stack CoreInk device, downloaded the code, and tried to compile it with no success..

The code generates some warnings, but I assume the sketch will compile even with those warnings. Did you see those warnings when you worked on the code?

D:\dev\hardware\M5Stack\KeychainSkimmerScanner\main\main.ino: In function 'void Scan()':
D:\dev\hardware\M5Stack\KeychainSkimmerScanner\main\main.ino:76:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   76 |         if (StrContains(success, "HC-05") == 1) {
      |                                  ^~~~~~~
D:\dev\hardware\M5Stack\KeychainSkimmerScanner\main\main.ino:78:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   78 |         } else if (StrContains(success, "HC-06") == 1) {
      |                                         ^~~~~~~
D:\dev\hardware\M5Stack\KeychainSkimmerScanner\main\main.ino:80:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   80 |         } else if (StrContains(success, "Name: , ") == 1) {
      |                                         ^~~~~~~~~~

The IDE also generates a bunch of errors based on issues it sees with the M5Stack M5Core-Ink library (listed below). But looking at the M5Core-Ink project I do see that ledcSetup and ledcAttachPin aren't in the library (as I expected based on the error). So I'm trying to understand how you were able to compile the code. I tried compiling this with the M5Stack libraries installed in the Arduino IDE then deleted them and installed just the M5StackCore-Ink libraries.

c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp: In member function 'void SPEAKER::begin()':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp:10:5: error: 'ledcSetup' was not declared in this scope
   10 |     ledcSetup(TONE_PIN_CHANNEL, 0, 13);
      |     ^~~~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp:11:5: error: 'ledcAttachPin' was not declared in this scope; did you mean 'ledcAttach'?
   11 |     ledcAttachPin(SPEAKER_PIN, TONE_PIN_CHANNEL);
      |     ^~~~~~~~~~~~~
      |     ledcAttach
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp: In member function 'void SPEAKER::end()':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp:17:5: error: 'ledcDetachPin' was not declared in this scope; did you mean 'ledcDetach'?
   17 |     ledcDetachPin(SPEAKER_PIN);
      |     ^~~~~~~~~~~~~
      |     ledcDetach
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp: In member function 'void SPEAKER::playMusic(const uint8_t*, uint16_t)':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\Speaker.cpp:79:5: error: 'ledcAttachPin' was not declared in this scope; did you mean 'ledcAttach'?
   79 |     ledcAttachPin(SPEAKER_PIN, TONE_PIN_CHANNEL);
      |     ^~~~~~~~~~~~~
      |     ledcAttach
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp: In member function 'uint8_t RTC::byteToBcd2(uint8_t)':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:66:10: error: 'uint_fast8_t' is not a member of 'std'; did you mean 'uint_fast8_t'?
   66 |     std::uint_fast8_t bcdhigh = value / 10;
      |          ^~~~~~~~~~~~
In file included from c:\users\john\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\lib\gcc\xtensa-esp32-elf\12.2.0\include\stdint.h:9,
                 from C:\Users\john\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7\cores\esp32/esp32-hal.h:23,
                 from C:\Users\john\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.7\libraries\Wire\src/Wire.h:32,
                 from c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.h:4,
                 from c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:1:
c:\users\john\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\xtensa-esp32-elf\sys-include\stdint.h:52:31: note: 'uint_fast8_t' declared here
   52 |   typedef __UINT_FAST8_TYPE__ uint_fast8_t;
      |                               ^~~~~~~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:67:13: error: 'bcdhigh' was not declared in this scope
   67 |     return (bcdhigh << 4) | (value - (bcdhigh * 10));
      |             ^~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp: In member function 'void RTC::SetDate(RTC_DateTypeDef*)':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:105:28: error: 'uint8_t' is not a member of 'std'; did you mean 'uint8_t'?
  105 |                      (std::uint8_t)(byteToBcd2(RTC_DateStruct->Month) +
      |                            ^~~~~~~
In file included from c:\users\john\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\xtensa-esp32-elf\sys-include\stdint.h:14:
c:\users\john\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\xtensa-esp32-elf\sys-include\sys\_stdint.h:24:19: note: 'uint8_t' declared here
   24 | typedef __uint8_t uint8_t ;
      |                   ^~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp: In member function 'int RTC::SetAlarmIRQ(int)':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:113:10: error: 'uint8_t' is not a member of 'std'; did you mean 'uint8_t'?
  113 |     std::uint8_t reg_value = _i2c.readByte(BM8563_I2C_ADDR, 0x01) & ~0x0C;
      |          ^~~~~~~
c:\users\john\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\xtensa-esp32-elf\sys-include\sys\_stdint.h:24:19: note: 'uint8_t' declared here
   24 | typedef __uint8_t uint8_t ;
      |                   ^~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:116:47: error: 'reg_value' was not declared in this scope
  116 |         _i2c.writeByte(BM8563_I2C_ADDR, 0x01, reg_value & ~0x01);
      |                                               ^~~~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:122:10: error: 'uint8_t' is not a member of 'std'; did you mean 'uint8_t'?
  122 |     std::uint8_t type_value = 0x82;
      |          ^~~~~~~
c:\users\john\appdata\local\arduino15\packages\esp32\tools\esp-x32\2302\xtensa-esp32-elf\sys-include\sys\_stdint.h:24:19: note: 'uint8_t' declared here
   24 | typedef __uint8_t uint8_t ;
      |                   ^~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:133:9: error: 'type_value' was not declared in this scope; did you mean 'typename'?
  133 |         type_value = 0x83;
      |         ^~~~~~~~~~
      |         typename
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:136:43: error: 'type_value' was not declared in this scope; did you mean 'typename'?
  136 |     _i2c.writeByte(BM8563_I2C_ADDR, 0x0E, type_value);
      |                                           ^~~~~~~~~~
      |                                           typename
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:138:44: error: 'reg_value' was not declared in this scope
  138 |     _i2c.writeByte(BM8563_I2C_ADDR, 0x01, (reg_value | 0x01) & ~0x80);
      |                                            ^~~~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp: In member function 'void RTC::disableIRQ()':
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:222:33: error: 'uint8_t' in namespace 'std' does not name a type
  222 |     static constexpr const std::uint8_t buf[4] = {0x80, 0x80, 0x80, 0x80};
      |                                 ^~~~~~~
c:\Users\john\Documents\Arduino\libraries\M5Core-Ink\src\utility\BM8563.cpp:223:55: error: 'buf' was not declared in this scope
  223 |     _i2c.writeBytes(BM8563_I2C_ADDR, 0x09, (uint8_t *)buf, 4);
      |                                                       ^~~

exit status 1

Compilation error: exit status 1
johnwargo commented 3 hours ago

I decided to start over from scratch and deleted all of the M5Stack libraries from the IDE. Next, I restated the Arduino IDE and installed the M5Stack library as you described in the instructions. When I compile the sketch after the library installation, I get the following error:

D:\dev\hardware\M5Stack\KeychainSkimmerScanner\main\main.ino:9:10: fatal error: M5CoreInk.h: No such file or directory
    9 | #include "M5CoreInk.h"
      |          ^~~~~~~~~~~~~
compilation terminated.
exit status 1

Compilation error: M5CoreInk.h: No such file or directory

So I added the M5Core-Ink library to my Arduino IDE configuration and got the error messages shown above.

Can you please share how you were able to compile this sketch?