I have the following platformio.ini file
[env]
build_flags = -D $PIOENV
[env:adafruit_feather_m0_rf95_client_env]
platform = atmelsam
board = adafruit_feather_m0
src_filter = +<LoraxClient.cpp>
framework = arduino
lib_deps = Time
[env:raspberrypi_3b_dragino_pi_hat__server_env]
platform = linux_arm
board = raspberrypi_3b
src_filter = +<LoraxServer.cpp>
build_flags = -D RASPBERRY_PI
Note the [env]
section. If I am understanding it correctly, -D $PIOENV
should define the macro #define adafruit_feather_m0_rf95_client_env
for the first environment and #define raspberrypi_3b_dragino_pi_hat__server_env
for the second. I am trying to use these macros in the following C++ file. Note the #if define(...)
near the beginning.
#include "LoraxRF95.h"
#include <stdlib.h>
#include <RH_RF95.h>
static RH_RF95 *__driver = NULL; //Initialized by init()
#if defined(adafruit_feather_m0_rf95_client_env)
#define SLAVE_SELECT 8
#define INTERRUPT_PIN 3
#elif defined(raspberrypi_3b_dragino_pi_hat__server_env)
#define SLAVE_SELECT 25
#define INTERRUPT_PIN 4
#else
#error "Environment not supported. Please either define SLAVE_SELECT and INTERRUPT_PIN for the environment or add this library to lib_ignore in platformio.ini file"
#endif
bool rf95Init()
{
if (__driver == NULL)
{
static RH_RF95 driver(SLAVE_SELECT, INTERRUPT_PIN);
__driver = &driver;
}
return __driver->init();
}
This works for the first environment but not for the raspberry pi
Is there any reason why this is not working?