Skip to content

Commit

Permalink
EventHub working with TinyGsmClientSecure
Browse files Browse the repository at this point in the history
Commiting work from 4/20/22.

The key was to use `TinyGsmClientSecure` rather than `TinyGsmClient` in src/modems/SIMComSIM7080.h
  • Loading branch information
aufdenkampe committed May 3, 2022
1 parent 4b624c7 commit 8bc473c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
6 changes: 3 additions & 3 deletions sensor_tests/HMACEventHubTest/HMACEventHubTest.ino
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ const char* UUIDs[] = // UUID array for device sensors
"measurement", // Board Temperature (EnviroDIY_Mayfly_Temp)
// "LTEB_Signal", // Percent full scale (EnviroDIY_LTEB_SignalPercent)
};
const char* registrationToken = "SharedAccessSignature sr=https%3A%2F%2Fevent-hub-data-logger.servicebus.windows.net%2Fdevices%2Fmessages&sig=pDocq7bRcZpKgt%2BWmNQHsJjz36mcssxF0EQ6jnVjd/g%3D&se=1650317059&skn=mayfly-device"; // Device registration token
const char* registrationToken = "SharedAccessSignature sr=https%3A%2F%2Fevent-hub-data-logger.servicebus.windows.net%2Fdevices%2Fmessages&sig=KCT4Hdnh2iL2prxOsKO03RFHqhho5VTokIZHrGPYpaQ%3D&se=1650474173&skn=mayfly-device"; // Device registration token
const char* samplingFeature = "7d37e135-0e26-4bc7-aa81-f9443283582d"; // Sampling feature UUID


Expand Down Expand Up @@ -205,7 +205,7 @@ Logger dataLogger(LoggerID, loggingInterval, &varArray);
/** Start [publishers] */
// Create a data publisher for the Monitor My Watershed/EnviroDIY POST endpoint
#include <publishers/EventHubPublisher.h>
EventHubPublisher EnviroDIYPOST(dataLogger, &modem.gsmClient,
EventHubPublisher EventHubPOST(dataLogger, &modem.gsmClient,
registrationToken, samplingFeature);
/** End [publishers] */

Expand Down Expand Up @@ -291,7 +291,7 @@ void setup() {
const char* text_to_hash = "what do ya want for nothing?";

// Call method of dataPublisher object
EnviroDIYPOST.writeHMACtoken(key, text_to_hash);
EventHubPOST.writeHMACtoken(key, text_to_hash);


// Note: Please change these battery voltages to match your battery
Expand Down
4 changes: 2 additions & 2 deletions sensor_tests/HMACEventHubTest_Digi/HMACEventHubTest_Digi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ Logger dataLogger(LoggerID, loggingInterval, &varArray);
/** Start [publishers] */
// Create a data publisher for the Monitor My Watershed/EnviroDIY POST endpoint
#include <publishers/EventHubPublisher.h>
EventHubPublisher EnviroDIYPOST(dataLogger, &modem.gsmClient,
EventHubPublisher EventHubPOST(dataLogger, &modem.gsmClient,
registrationToken, samplingFeature);
/** End [publishers] */

Expand Down Expand Up @@ -292,7 +292,7 @@ void setup() {
const char* text_to_hash = "what do ya want for nothing?";

// Call method of dataPublisher object
EnviroDIYPOST.writeHMACtoken(key, text_to_hash);
EventHubPOST.writeHMACtoken(key, text_to_hash);


// Note: Please change these battery voltages to match your battery
Expand Down
11 changes: 9 additions & 2 deletions src/modems/SIMComSIM7080.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,16 @@ class SIMComSIM7080 : public loggerModem {
*/
TinyGsm gsmModem;
/**
* @brief Public reference to the TinyGSM Client.
* @brief Public reference to the TinyGSM Client (HTTP).
*/
TinyGsmClient gsmClient;
TinyGsmClientSecure gsmClient;
// /**
// * @brief Public reference to a secure TinyGSM Client (HTTPS).
// */
// #ifdef MS_HTTPS
// TinyGsmClientSecure gsmClient;
// #endif


protected:
bool isInternetAvailable(void) override;
Expand Down
3 changes: 3 additions & 0 deletions src/publishers/EventHubPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ int16_t EventHubPublisher::publishData(Client* outClient) {
MS_START_DEBUG_TIMER;
if (outClient->connect(eventHubHost, eventHubPort)) {
MS_DBG(F("Client connected after"), MS_PRINT_DEBUG_TIMER, F("ms\n"));
#ifdef MS_HTTPS
MS_DBG(F("Performing HTTPS POST request... "));
#endif

// copy the initial post header into the tx buffer
strcpy(txBuffer, postHeader);
Expand Down
3 changes: 3 additions & 0 deletions src/publishers/EventHubPublisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#define MS_DEBUGGING_STD "EventHubPublisher"
#endif

// Specify HTTPS Secure Client for this Publisher
#define MS_HTTPS

// Included Dependencies
#include "ModSensorDebugger.h"
#undef MS_DEBUGGING_STD
Expand Down

0 comments on commit 8bc473c

Please sign in to comment.