Hello guys,
I created custom classes for my bluetooth and wi-fi modules each with SoftwareSerial data field.
After that i create two objects from these classes, and i call initialize function for each of them.
First i initialize wifi and after that bluetooth, and here comes the problem. I can read only from bluetooth wrapper object. If i changed initializing order first bluetooth after that wifi, read is available only for wifi.
Here is my code with only basics.
class SoftwareSerial;
class Wifi {
public:
** Wifi ();**
** ~Wifi ();**
** void initialize();**
private:
SoftwareSerial* wifi_serial;
};
Wifi::Wifi ()
{
}
Wifi::~Wifi ()
{
** delete wifi_serial;**
}
void Wifi::initialize (const int speed_serial)
{
** wifi_serial = new SoftwareSerial(PIN_WIFI_RX, PIN_WIFI_TX);**
** pinMode(PIN_WIFI_TX, OUTPUT);**
** digitalWrite(PIN_WIFI_TX, HIGH);**
** wifi_serial->begin(speed_serial);**
}
class SoftwareSerial;
class Bluetooth {
public:
** Bluetooth ();**
** ~Bluetooth ();**
** void initialize();**
private:
SoftwareSerial* bluetooth_serial;
};
Bluetooth::Bluetooth ()
{
}
Bluetooth::~Bluetooth ()
{
** delete bluetooth_serial;**
}
void Bluetooth::initialize (const int serial_speed)
{
** bluetooth_serial = new SoftwareSerial(PIN_BTH_RX, PIN_BTH_TX);**
** pinMode(PIN_BTH_TX, OUTPUT);**
** digitalWrite(PIN_BTH_TX, HIGH);**
** bluetooth_serial->begin(serial_speed);**
}
So... i created two instance from each class
Bluetooth bluetooth;
Wifi wifi;
void setup ()
{
bluetooth.initialize();
wifi.initialize();
}
In this case only wifi is available for read.
If order is changed like this
void setup ()
{
wifi.initialize();
bluetooth.initialize();
}
Now i can read only from bluetooth.
Please someone to explain where i am wrong.