Skip to content

Commit

Permalink
Add some documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Sara Damiano <[email protected]>
  • Loading branch information
SRGDamia1 committed May 28, 2024
1 parent b0f7b36 commit f86aa13
Show file tree
Hide file tree
Showing 7 changed files with 423 additions and 21 deletions.
37 changes: 37 additions & 0 deletions src/TinyGsmBattery.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,52 @@ class TinyGsmBattery {
/*
* Battery functions
*/

/**
* @brief Get the current battery voltage.
*
* @note Unless you have a battery directly connected to your modem module,
* this will be the input voltage going to the module from your main processor
* board, not the battery voltage of your main processor.
*
* @return *int16_t* The battery voltage measured by the modem module.
*/
int16_t getBattVoltage() {
return thisModem().getBattVoltageImpl();
}

/**
* @brief Get the current battery percent.
*
* @note Unless you have a battery directly connected to your modem module,
* this will be the percent from the input voltage going to the module from
* your main processor board, not the battery percent of your main processor.
*
* @return *int8_t* The current battery percent.
*/
int8_t getBattPercent() {
return thisModem().getBattPercentImpl();
}

/**
* @brief Get the battery charging state.
*
* @return *int8_t* The battery charge state.
*/
int8_t getBattChargeState() {
return thisModem().getBattChargeStateImpl();
}

/**
* @brief Get the all battery state
*
* @param chargeState A reference to an int to set to the battery charge state
* @param percent A reference to an int to set to the battery percent
* @param milliVolts A reference to an int to set to the battery voltage
* @return *true* The battery stats were updated by the module.
* @return *false* There was a failure in updating the battery stats from the
* module.
*/
bool getBattStats(int8_t& chargeState, int8_t& percent, int16_t& milliVolts) {
return thisModem().getBattStatsImpl(chargeState, percent, milliVolts);
}
Expand Down
31 changes: 31 additions & 0 deletions src/TinyGsmBluetooth.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,46 @@ class TinyGsmBluetooth {
/*
* Bluetooth functions
*/

/**
* @brief Enable module Bluetooth
*
* @return *true* Bluetooth was succcessfully enabled
* @return *false* Bluetooth failed to enable
*/
bool enableBluetooth() {
return thisModem().enableBluetoothImpl();
}

/**
* @brief Disable module Bluetooth
*
* @return *true* Bluetooth was succcessfully disabled
* @return *false* Bluetooth failed to disable
*/
bool disableBluetooth() {
return thisModem().disableBluetoothImpl();
}

/**
* @brief Set the Bluetooth visibility
*
* @param visible True to make the modem visible over Bluetooth, false to make
* it invisible.
* @return *true* Bluetooth visibility was successfully changed.
* @return *false* Bluetooth visibility failed to change
*/
bool setBluetoothVisibility(bool visible) {
return thisModem().setBluetoothVisibilityImpl(visible);
}

/**
* @brief Set the Bluetooth host name
*
* @param name The name visible to other Bluetooth objects
* @return *true* Bluetooth host name was successfully changed.
* @return *false* Bluetooth host name failed to change
*/
bool setBluetoothHostName(const char* name) {
return thisModem().setBluetoothHostNameImpl(name);
}
Expand Down
31 changes: 31 additions & 0 deletions src/TinyGsmCalling.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,46 @@ class TinyGsmCalling {
/*
* Phone Call functions
*/

/**
* @brief Answer an incoming phone call
*
* @return *true* The call was answered.
* @return *false* The call was not answered.
*/
bool callAnswer() {
return thisModem().callAnswerImpl();
}

/**
* @brief Make a phone call
*
* @param number The number to call
* @return *true* The call was successfully made
* @return *false* The call wasn't made
*/
bool callNumber(const String& number) {
return thisModem().callNumberImpl(number);
}

/**
* @brief Hang up an in-progress phone call
*
* @return *true* The call was hung up.
* @return *false* The call was not hung up.
*/
bool callHangup() {
return thisModem().callHangupImpl();
}

/**
* @brief Sent a DTMF (dual tone multi frequency) message over a phone call.
*
* @param cmd The command to send
* @param duration_ms The tone duration
* @return *true* The message was sent
* @return *false* The message failed to send
*/
bool dtmfSend(char cmd, int duration_ms = 100) {
return thisModem().dtmfSendImpl(cmd, duration_ms);
}
Expand Down
17 changes: 17 additions & 0 deletions src/TinyGsmCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ static void DBG(Args... args) {
#define DBG(...)
#endif

/*
* CRTP Helper
*/
template <typename modemType, template <typename> class crtpType>
struct tinygsm_crtp {
modemType& thisModem() {
return static_cast<modemType&>(*this);
}
modemType const& thisModem() const {
return static_cast<modemType const&>(*this);
}

private:
tinygsm_crtp() {}
friend crtpType<modemType>;
};

/*
* Min/Max Helpers
*/
Expand Down
Loading

0 comments on commit f86aa13

Please sign in to comment.