-->
Page 1 of 2

Can someone help me with this coding issue.

PostPosted: Sat Dec 14, 2019 9:34 am
by MyESP
I have this in my sketch:

Code: Select all#define LIST_SIZE 2

uint8_t friendmac[LIST_SIZE][ESPPL_MAC_LEN] = {
  {160, 204, 43, 150, 60, 55},
  {66, 124, 12, 155, 122, 44}
};

All I'm trying to do is make the numbers come from EEPROM. I have the EEPROM setup right and I can read and write. I tried something like this but it doesn't work:

Code: Select all#define LIST_SIZE 2

uint8_t friendmac[LIST_SIZE][ESPPL_MAC_LEN] = {
{EEPROM.read(1), EEPROM.read(2), EEPROM.read(3), EEPROM.read(4), EEPROM.read(5), EEPROM.read(6)},
{EEPROM.read(7), EEPROM.read(8), EEPROM.read(9), EEPROM.read(10), EEPROM.read(11), EEPROM.read(12)}
};

Re: Can someone help me with this coding issue.

PostPosted: Sun Dec 15, 2019 9:28 am
by martinayotte
MyESP wrote:I tried something like this but it doesn't work:


You can't do EEPROM.read() in global space since EEPROM.begin() didn't been executed yet...

Re: Can someone help me with this coding issue.

PostPosted: Mon Dec 16, 2019 5:16 pm
by MyESP
Ok so if EEPROM.begin(32); is inside my void setup(); would putting the code below it work? I though if its below void setup it works? Like this:

Code: Select allvoid setup() {
...
...
...
  EEPROM.begin(32);
  }

#define LIST_SIZE 2

uint8_t friendmac[LIST_SIZE][ESPPL_MAC_LEN] = {
{EEPROM.read(1), EEPROM.read(2), EEPROM.read(3), EEPROM.read(4), EEPROM.read(5), EEPROM.read(6)},
{EEPROM.read(7), EEPROM.read(8), EEPROM.read(9), EEPROM.read(10), EEPROM.read(11), EEPROM.read(12)}
};


If not, how can I rewrite this so it works?

Re: Can someone help me with this coding issue.

PostPosted: Tue Dec 17, 2019 12:27 am
by Pablo2048
Maybe this way?:
Code: Select all#define LIST_SIZE 2
uint8_t friendmac[LIST_SIZE][ESPPL_MAC_LEN];
...
void setup(void)
{
...
  EEPROM.begin(sizeof(friendsmac));
  EEPROM.get(0, friendsmac);
...
}