Need help building GPS library

Hi!

I am trying to build a library for my gps module and am having a hard time implementing the SoftwareSerial library within the private class. How might I go about this?

Here is my header file:

  #include "uBlox.h"
#include "Arduino.h"
#include "SoftwareSerial.h"

uBlox::uBlox(int rx, int tx) {
  SoftwareSerial gps(rx, tx);//initialize the serial connection  (This needs to be as uBlox private so that future functions can access it.)
}

uBlox::~uBlox() {  } //Why do I need this??

void configure() {

}

And the C++ file.

#include "uBlox.h"
#include "Arduino.h"
#include "SoftwareSerial.h"

uBlox::uBlox(int rx, int tx) {
  SoftwareSerial gps(rx, tx);//initialize the serial connection  (This needs to be as uBlox private so that future functions can access it.)
}

uBlox::~uBlox() {  } //Why do I need this??

void configure() {

}

How could I assign the pins when the SoftwareSerial instance is outside of the class?

You have to define the instance of SoftwareSerial at the same time as your constructor is created:

uBlox::uBlox(int rx, int tx) : gps(rx, tx)
{
}

after declaring that gps is an instance of SoftwareSerial in the header file:

SoftwareSerial gps;

Got it! Thanks for you help!

I have a feeling that something else may come up later, so for now, I won't mark it as solved :slight_smile: