Browse Source

First SIM808 support commit. Added template base class and some basic functionality

dependabot/github_actions/actions/checkout-4
Adrian Cervera Andes 4 years ago
parent
commit
54c25cce23
2 changed files with 94 additions and 1 deletions
  1. +57
    -0
      src/TinyGsmBluetooth.tpp
  2. +37
    -1
      src/TinyGsmClientSIM808.h

+ 57
- 0
src/TinyGsmBluetooth.tpp View File

@ -0,0 +1,57 @@
/**
* @file TinyGsmGPS.tpp
* @author Adrian Cervera Andes
* @license LGPL-3.0
* @copyright Copyright (c) 2021 Adrian Cervera Andes
* @date Jan 2021
*/
#ifndef SRC_TINYGSMBLUETOOTH_H_
#define SRC_TINYGSMBLUETOOTH_H_
#include "TinyGsmCommon.h"
#define TINY_GSM_MODEM_HAS_BLUETOOTH
template <class modemType>
class TinyGsmBluetooth {
public:
/*
* Bluetooth functions
*/
bool enableBluetooth() {
return thisModem().enableBluetoothImpl();
}
bool disableBluetooth() {
return thisModem().disableBluetoothImpl();
}
bool setBluetoothVisibility(bool visible) {
return thisModem().setBluetoothVisibilityImpl(visible);
}
bool setBluetoothHostName(const char* name) {
return thisModem().setBluetoothHostNameImpl(name);
}
/*
* CRTP Helper
*/
protected:
inline const modemType& thisModem() const {
return static_cast<const modemType&>(*this);
}
inline modemType& thisModem() {
return static_cast<modemType&>(*this);
}
/*
* Bluetooth functions
*/
bool enableBluetoothImpl() TINY_GSM_ATTR_NOT_IMPLEMENTED;
bool disableBluetoothImpl() TINY_GSM_ATTR_NOT_IMPLEMENTED;
bool setBluetoothVisibilityImpl(bool visible) TINY_GSM_ATTR_NOT_IMPLEMENTED;
bool setBluetoothHostNameImpl(const char* name) TINY_GSM_ATTR_NOT_IMPLEMENTED;
};
#endif // SRC_TINYGSMBLUETOOTH_H_

+ 37
- 1
src/TinyGsmClientSIM808.h View File

@ -12,9 +12,11 @@
#include "TinyGsmClientSIM800.h" #include "TinyGsmClientSIM800.h"
#include "TinyGsmGPS.tpp" #include "TinyGsmGPS.tpp"
#include "TinyGsmBluetooth.tpp"
class TinyGsmSim808 : public TinyGsmSim800, public TinyGsmGPS<TinyGsmSim808> {
class TinyGsmSim808 : public TinyGsmSim800, public TinyGsmGPS<TinyGsmSim808>, public TinyGsmBluetooth<TinyGsmSim808> {
friend class TinyGsmGPS<TinyGsmSim808>; friend class TinyGsmGPS<TinyGsmSim808>;
friend class TinyGsmBluetooth<TinyGsmSim808>;
public: public:
explicit TinyGsmSim808(Stream& stream) : TinyGsmSim800(stream) {} explicit TinyGsmSim808(Stream& stream) : TinyGsmSim800(stream) {}
@ -127,6 +129,40 @@ class TinyGsmSim808 : public TinyGsmSim800, public TinyGsmGPS<TinyGsmSim808> {
waitResponse(); waitResponse();
return false; return false;
} }
/*
* Bluetooth functions
*/
bool enableBluetoothImpl() {
sendAT(GF("+BTPOWER=1"));
if (waitResponse() != 1) { return false; }
return true;
}
bool disableBluetoothImpl() {
sendAT(GF("+BTPOWER=0"));
if (waitResponse() != 1) { return false; }
return true;
}
bool setBluetoothVisibilityImpl(bool visible) {
sendAT(GF("+BTVIS="), visible);
if (waitResponse() != 1) {
return false;
}
return true;
}
bool setBluetoothHostNameImpl(const char* name) {
sendAT(GF("+BTHOST="), name);
if (waitResponse() != 1) {
return false;
}
return true;
}
}; };
#endif // SRC_TINYGSMCLIENTSIM808_H_ #endif // SRC_TINYGSMCLIENTSIM808_H_

Loading…
Cancel
Save