sensor library compile problem after a change (SOLVED)



  • Hello,

    I would like to add a call to printDetails (RF24 function) in the setupradio function from the sensor lib.
    here is the code

    void MySensor::setupRadio(rf24_pa_dbm_e paLevel, uint8_t channel, rf24_datarate_e dataRate) {
    	failedTransmissions = 0;
    	//debug(PSTR("MySensor::setupRadio\n"));
    	// Start up the radio library
    	RF24::begin();
    	if (!RF24::isPVariant()) {
    		debug(PSTR("check wires\n"));
    		while(1);
    	}
    	RF24::setAutoAck(1);
    	RF24::setAutoAck(BROADCAST_PIPE,false); // Turn off auto ack for broadcast
    	RF24::enableAckPayload();
    	RF24::setChannel(channel);
    	RF24::setPALevel(paLevel);
    	RF24::setDataRate(dataRate);
    	RF24::setRetries(5,15);
    	RF24::setCRCLength(RF24_CRC_16);
    	RF24::enableDynamicPayloads();
    	
    	// All nodes listen to broadcast pipe (for FIND_PARENT_RESPONSE messages)
    	RF24::openReadingPipe(BROADCAST_PIPE, TO_ADDR(BROADCAST_ADDRESS));
    
        RF24::printDetails();    // here is the line I added !!
    }
    

    then I get this compile error :
    MySensors\MySensor.cpp.o: In function `MySensor::setupRadio(rf24_pa_dbm_e, unsigned char, rf24_datarate_e)':

    ......\Arduino\libraries\MySensors/MySensor.cpp:113: undefined reference to `RF24::printDetails()'
    collect2.exe: error: ld returned 1 exit status

    printDetails() is referenced in the RF24 lib I dont really see what I am doing wrong here ?

    anyone can give me a hint ?

    thanks a lot !
    shasha



  • Can you check your RF24.cpp and RF24.h to be certain that you have the RF24::printDetails(); function?
    Do you include the RF24.h? (I know that it would throw you more errors if you didn't, but better be sure than sorry 😄 )
    Try using it in another sketch and see if it's working.
    I used your code and it compiled.



  • I checked the RF24.cpp and the RF24.h and the function is well defined.

    The include list is correct !!

    But you said you have been able to compile so I checked again and I found that the printDetails function is in an If section

    this is controlled by MINIMAL

    #if !defined (MINIMAL)
    
    static const char rf24_datarate_e_str_0[] PROGMEM = "1MBPS";
    static const char rf24_datarate_e_str_1[] PROGMEM = "2MBPS";
    static const char rf24_datarate_e_str_2[] PROGMEM = "250KBPS";
    static const char * const rf24_datarate_e_str_P[] PROGMEM = {
      rf24_datarate_e_str_0,
      rf24_datarate_e_str_1,
      rf24_datarate_e_str_2,
    };
    static const char rf24_model_e_str_0[] PROGMEM = "nRF24L01";
    static const char rf24_model_e_str_1[] PROGMEM = "nRF24L01+";
    static const char * const rf24_model_e_str_P[] PROGMEM = {
      rf24_model_e_str_0,
      rf24_model_e_str_1,
    };
    static const char rf24_crclength_e_str_0[] PROGMEM = "Disabled";
    static const char rf24_crclength_e_str_1[] PROGMEM = "8 bits";
    static const char rf24_crclength_e_str_2[] PROGMEM = "16 bits" ;
    static const char * const rf24_crclength_e_str_P[] PROGMEM = {
      rf24_crclength_e_str_0,
      rf24_crclength_e_str_1,
      rf24_crclength_e_str_2,
    };
    static const char rf24_pa_dbm_e_str_0[] PROGMEM = "PA_MIN";
    static const char rf24_pa_dbm_e_str_1[] PROGMEM = "PA_LOW";
    static const char rf24_pa_dbm_e_str_2[] PROGMEM = "PA_HIGH";
    static const char rf24_pa_dbm_e_str_3[] PROGMEM = "PA_MAX";
    static const char * const rf24_pa_dbm_e_str_P[] PROGMEM = {
      rf24_pa_dbm_e_str_0,
      rf24_pa_dbm_e_str_1,
      rf24_pa_dbm_e_str_2,
      rf24_pa_dbm_e_str_3,
    };
    
    
    void RF24::printDetails(void)
    {
      print_status(get_status());
    
      print_address_register(PSTR("RX_ADDR_P0-1"),RX_ADDR_P0,2);
      print_byte_register(PSTR("RX_ADDR_P2-5"),RX_ADDR_P2,4);
      print_address_register(PSTR("TX_ADDR"),TX_ADDR);
    
      print_byte_register(PSTR("RX_PW_P0-6"),RX_PW_P0,6);
      print_byte_register(PSTR("EN_AA"),EN_AA);
      print_byte_register(PSTR("EN_RXADDR"),EN_RXADDR);
      print_byte_register(PSTR("RF_CH"),RF_CH);
      print_byte_register(PSTR("RF_SETUP"),RF_SETUP);
      print_byte_register(PSTR("CONFIG"),CONFIG);
      print_byte_register(PSTR("DYNPD/FEATURE"),DYNPD,2);
    
    #if defined(__arm__)
      printf_P(PSTR("Data Rate\t = %s\r\n"),pgm_read_word(&rf24_datarate_e_str_P[getDataRate()]));
      printf_P(PSTR("Model\t\t = %s\r\n"),pgm_read_word(&rf24_model_e_str_P[isPVariant()]));
      printf_P(PSTR("CRC Length\t = %s\r\n"),pgm_read_word(&rf24_crclength_e_str_P[getCRCLength()]));
      printf_P(PSTR("PA Power\t = %s\r\n"),pgm_read_word(&rf24_pa_dbm_e_str_P[getPALevel()]));
    #else
      printf_P(PSTR("Data Rate\t = %S\r\n"),pgm_read_word(&rf24_datarate_e_str_P[getDataRate()]));
      printf_P(PSTR("Model\t\t = %S\r\n"),pgm_read_word(&rf24_model_e_str_P[isPVariant()]));
      printf_P(PSTR("CRC Length\t = %S\r\n"),pgm_read_word(&rf24_crclength_e_str_P[getCRCLength()]));
      printf_P(PSTR("PA Power\t = %S\r\n"),pgm_read_word(&rf24_pa_dbm_e_str_P[getPALevel()]));
    #endif
    
    }
    
    #endif
    

    this MINIMAL is defined in the RF24_config.h file :

      /*** USER DEFINES:  ***/  
      //#define FAILURE_HANDLING
      //#define SERIAL_DEBUG  
      #define MINIMAL
      //#define SPI_UART  // Requires library from https://github.com/TMRh20/Sketches/tree/master/SPI_UART
      //#define SOFTSPI   // Requires library from https://github.com/greiman/DigitalIO
      /**********************/
    

    in my file MINIMAL was defined so the printDetails function was skipped
    if I comment the MINIMAL definition then it compiles !!!

    you led me to the solution thanks a lot.

    But seems your RF24_config.h was already modified or you use an other file. I was using the one provided with MySensor
    in this one MINIMAL is defined. As I am curious I checked the files provided with RF24 lib (not the one in the MySensor/utility and found that MINIMAL is not defined !!!

    Thanks again pb solved !!



  • Glad to be useful. I am using the tmrh20 libs.
    https://github.com/tmrh20/RF24


  • Admin

    Yep, we've defined MINIMAL in the bundled RF24 to keep size at a minimum.


Log in to reply
 

Suggested Topics

13
Online

11.4k
Users

11.1k
Topics

112.7k
Posts