Your version works fine, thanks !
Can you explain me why is the "static" keyword important here ?
Actually, I thought that all PROGMEM var (in FLASH) were static, since the FLASH isn't written during the execution of the program.
I still can't do it with my program anyway because I have a few differences between what I really use in my code and this sketch. Here's a version muc longer but corresponding with what I use :
main sketch .ino
#include "file.h"
static const char *foo PROGMEM = "is";
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available() > 0)
{
char *foo2;
ble_readSerial();
Serial.print("Read : ");
Serial.println(strBleCommand);
foo2 = strstr_P(strBleCommand, foo);
Serial.println(foo2);
}
}
file.cpp
#include "file.h"
#include <Arduino.h>
//VAR
char strBleCommand[BLE_BUFFER_SIZE + 1];
unsigned char ble_readSerial(void)
{
unsigned char i = 0;
unsigned long iTime = millis();
ble_cleanBuffer();
while (millis() - iTime < 1000 or i >= BLE_BUFFER_SIZE)
{
while (Serial.available() > 0)
{
char inChar = Serial.read();
if (inChar == '
file.h
#define BLE_BUFFER_SIZE 30
//VAR
extern char strBleCommand[BLE_BUFFER_SIZE + 1];
unsigned char ble_readSerial(void);
void ble_cleanBuffer(void);
The functions in the .c files are not relevant imo, just some reading and putting in the buffer methods for the Serial. I don't understand why there's nothing in the foo2 var...)
{
strBleCommand[i] = '
file.h
§DISCOURSE_HOISTED_CODE_2§
The functions in the .c files are not relevant imo, just some reading and putting in the buffer methods for the Serial. I don't understand why there's nothing in the foo2 var...;
return 0;
}
else if (inChar != '
file.h
§_DISCOURSE_HOISTED_CODE_2_§
The functions in the .c files are not relevant imo, just some reading and putting in the buffer methods for the Serial. I don't understand why there's nothing in the foo2 var... and i <= BLE_BUFFER_SIZE)
{
strBleCommand[i] = inChar;
i++;
}
else
{
return -1;
}
}
}
return -1;
}
void ble_cleanBuffer(void)
{
unsigned char i;
for (i = 0; i < BLE_BUFFER_SIZE; i++)
{
strBleCommand[i] = ' ';
}
}
file.h
§DISCOURSE_HOISTED_CODE_2§
The functions in the .c files are not relevant imo, just some reading and putting in the buffer methods for the Serial. I don't understand why there's nothing in the foo2 var...