Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- #include <SPI.h>
- #define PIN_BLUETOOTH_RX 17
- #define PIN_BLUETOOTH_TX 16
- #define PIN_GSM_RX 19
- #define PIN_GSM_TX 18
- SoftwareSerial BluetoothSerial(PIN_BLUETOOTH_RX, PIN_BLUETOOTH_TX);
- SoftwareSerial Gsm(PIN_GSM_RX, PIN_GSM_TX);
- String m_strIncomeBluetooth, m_strSerialIncome, m_strGsmIncome;
- void setup()
- {
- Serial.begin(57600);
- Gsm.begin(57600); //Sim800L Modul
- BluetoothSerial.begin(57600); //HC06 Bluetooth Modul kann gelesen werden, da es zuletzt initialisiert wurde
- }
- void loop()
- {
- int c;
- while ((c = Gsm.read()) != -1)m_strGsmIncome += (char)c; //Lese GSM Input und in einen String speichern
- while ((c = BluetoothSerial.read()) != -1) m_strIncomeBluetooth += (char)c; //Lese Bluetooth Input und in einen String speichern
- while (Serial.available())
- {
- c = Serial.read(); m_strSerialIncome += (char)c; //Lese HW-Serial und in einen String speichern
- Gsm.write(c); //Übertrage Befehl an das GSM Modul
- }
- if (m_strGsmIncome.length() > 0) { Serial.println("Gsm: " + m_strGsmIncome); m_strGsmIncome = ""; }
- if (m_strIncomeBluetooth.length() > 0) { Serial.println("Bluetooth Data: " + m_strIncomeBluetooth); m_strIncomeBluetooth = ""; }
- if (m_strSerialIncome.length() > 0) {
- Serial.println(m_strSerialIncome);
- m_strSerialIncome = "";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement