Trying to get a value from a library function (invalid conversion from 'int8_t*)

Hello,

I am trying to small IoT device using an Arduino compatible board from SODAQ
that has a uBlox SARA N211 module on it.
For now, I am just trying to get and display the RSSI value (signal strength indicator).

But I keep getting this error "invalid conversion from 'int8_t* "
Granted, I a newbie as far as more complex C++ programming goes, so excuse my ignorance
(or lack of knowledge of the proper nomenclature)

My code is this:

#include <Wire.h>
#include <hd44780.h>                       // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
#include <Arduino.h>
#include <Sodaq_AT_Device.h>
#include <Sodaq_nbIOT.h>
#include <Sodaq_wdt.h>

#if defined(ARDUINO_SODAQ_SARA)
// SODAQ SARA
#define DEBUG_STREAM SerialUSB  // Define Serial on USB port
#define MODEM_STREAM Serial1   // Define Serial to NB module - serial1 = pins: Ain5, Ain6 (RX, TX) on board.
#define powerPin SARA_ENABLE
#define enablePin SARA_TX_ENABLE
#else
#error "Please select the SODAQ SARA as your board"
#endif

unsigned long baud = 9600;

//hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip
hd44780_I2Cexp lcd(0x20); // specify a specific i2c address

#define DEBUG_STREAM_BAUD 9600
#define STARTUP_DELAY 5000

const char* apn = "iot";
const char* cdp = "66.102.0.0";
const char* forceOperator = "20201"; // optional - depends on SIM / network

Sodaq_nbIOT nbiot;

//void showMessageCountFromModem();  // ---??? NOT CLEAR FUNCTION ---

void setup()
{
// ---------  LCD setup   ---------
  const int LCD_COLS = 20;
  const int LCD_ROWS = 4;
  int status;
	status = lcd.begin(LCD_COLS, LCD_ROWS);
	if(status) // non zero status means it was unsuccesful
	{status = -status; // convert negative status value to positive number
	// begin() failed so blink error code using the onboard LED if possible
	hd44780::fatalError(status); // does not return} 
	}

	lcd.clear(); 
  
// ------ Initialize NB-IoT module on the board ------

  #ifdef powerPin
  // Turn the nb-iot module on
  pinMode(SARA_ENABLE, OUTPUT); 
  pinMode(SARA_TX_ENABLE, OUTPUT);
  digitalWrite(SARA_ENABLE, HIGH);       // enable power to ublox
  digitalWrite(SARA_TX_ENABLE, HIGH);  
  nbiot.init(MODEM_STREAM, powerPin);   
  nbiot.setDiag(DEBUG_STREAM); 
  #endif //powerPin

  // Start serial communications (to ublox module and USB-debug)
  DEBUG_STREAM.begin(baud);
  MODEM_STREAM.begin(baud);
  delay(3000);
  
// ------ Sent initial setup AT Commands to the NB module
  MODEM_STREAM.println("AT+NRB");
  delay(8000);
  MODEM_STREAM.println("AT+NCONFIG=\"CR_0354_0338_SCRAMBLING\",\"TRUE\"");
  delay(900);
  MODEM_STREAM.println("AT+NCONFIG=\"CR_0859_SI_AVOID\",\"TRUE\"");
  delay(900);
  MODEM_STREAM.println("AT+CFUN=0");
  delay(700);
  MODEM_STREAM.println("AT+NBAND=20");
  delay(700);
  MODEM_STREAM.println("AT+CFUN=1");
  delay(2500);
  MODEM_STREAM.println("AT+COPS=1,2,\"20201\"");
  delay(900);
  MODEM_STREAM.println("AT+CEREG=1");
  delay(900);


  //clear UBLOX buffer
  while (MODEM_STREAM.available()) {
  MODEM_STREAM.read();
  }
  
}

void loop() 
{

  int8_t* rssi;
  int8_t* ber;
  nbiot.getRSSIAndBER(rssi, ber);

  lcd.setCursor(0, 2);
  lcd.print(rssi);

  if (DEBUG_STREAM.available() > 0) {
  DEBUG_STREAM.println(rssi);
 
  
  delay(200);
  
}

An I get this error:

exit status 1
invalid conversion from 'int8_t* {aka signed char*}' to 'uint8_t* {aka unsigned char*}' [-fpermissive]"

This is the library I (want to) use to communicate with the NB_IoT module (provided by the manufacturer)

I am sure I am doing many thing wrong here, but I am not sure where to start...

Any kind of help will be greatly appreciated.

Thank you in advance for your help.

Kind regards,
Bill Geo

Is that the entire error message when you compile? I would have thought there'd be more. Usually it points out the offending statement and its line number. If there's more, please post it.

In the IDE, there is a "Copy error Messsage" button. Click it, post the results here. There are a lot of lines to the error message prior to the ones you posted. You can also scroll up on the output window in the IDE (or resize it) to see more info

  int8_t* rssi;
  int8_t* ber;
  nbiot.getRSSIAndBER(rssi, ber);

I don't know what ber means, or is trying to imply. but do you really expect to get a negative value for the relative signal strength?

The error message was pretty clear. This method appears to expect (quite reasonably) a pointer to an unsigned variable, not a signed variable. Perhaps even two of them.

Strange enough, it expects a signed RSSI and an unsigned bit error rate: Sodaq_nbIOT/Sodaq_nbIOT.cpp at 1c175e23ec320990ec8016bba4c73894b0455f10 · SodaqMoja/Sodaq_nbIOT · GitHub

 int8_t rssi;
  uint8_t ber;
  nbiot.getRSSIAndBER(&rssi, &ber);

Pieter

PieterP:
Strange enough, it expects a signed RSSI and an unsigned bit error rate: Sodaq_nbIOT/Sodaq_nbIOT.cpp at 1c175e23ec320990ec8016bba4c73894b0455f10 · SodaqMoja/Sodaq_nbIOT · GitHub

 int8_t rssi;

uint8_t ber;
  nbiot.getRSSIAndBER(&rssi, &ber);



Pieter

Jesus! That was it!
Why did they do that?
I am not expecting negative values on either variable.

I was trying declaring both singed and unsinged variables, but I was changing both rssi and ber at the same time.

Turns out it needs both! OK...

Thanks for your time all of you. Greatly appreciate it!
Now to figure out why I get zero values for both out of the module.

if you are still using this code:

  int8_t* rssi;
  int8_t* ber;
  nbiot.getRSSIAndBER(rssi, ber);

these 2 pointers are pointing to random locations in memory.

these 2 pointers are pointing to random locations in memory.

Because the function expects a pointer, the pointer will get a value assigned by the function. This use of pointers is valid, even though it looks wrong. This is exactly why the reference operator was added to C.

The two variables are never actually used as pointers.

arduino_new:
if you are still using this code:

  int8_t* rssi;

int8_t* ber;
  nbiot.getRSSIAndBER(rssi, ber);




these 2 pointers are pointing to random locations in memory.

Hi,

Why do you say that??

billgeo:
Hi,

Why do you say that??

Because you create two pointers without ever initializing them.

I think the intended usage is:

  int8_t rssi;
  uint8_t ber;
  nbiot.getRSSIAndBER(&rssi, &ber);

The "&" can be read "the address of" or "a pointer to".

By default, C and C++ pass only the VALUE of an integer variable to a function. The function can't write to the variable because it only has a copy. In this case it appears that the purpose of the function is to fill in the values. To do that it needs a pointer to the variable instead of just the value.