diff --git a/firmware/httpsclient-particle.cpp b/firmware/httpsclient-particle.cpp index c527dcb..cf9932c 100644 --- a/firmware/httpsclient-particle.cpp +++ b/firmware/httpsclient-particle.cpp @@ -70,10 +70,13 @@ void httpsclientSetPath(const char * path) { g_path = path; } -int httpsclientSetup(const char * host, const char * path) { +void (*g_weatherCallback_func)(unsigned char*, int); + +int httpsclientSetup(const char * host, const char * path, void (*pFunc)(unsigned char*, int)) { int rc; g_host = host; g_path = path; + g_weatherCallback_func = pFunc; if ((rc = matrixSslOpen()) < 0) { if (g_https_trace) _psTrace("MatrixSSL library init failure."); return rc; @@ -455,6 +458,7 @@ int httpsClientConnection(unsigned char * requestContent, uint32 msg_len, case MATRIXSSL_APP_DATA: case MATRIXSSL_APP_DATA_COMPRESSED: g_bytes_received += len; + (*g_weatherCallback_func)(g_buf,len); if (g_https_trace) { for (int i = 0 ; i < len; i++) { Serial.print((char)g_buf[i]); diff --git a/firmware/httpsclient-particle.h b/firmware/httpsclient-particle.h index 58445bf..f39f930 100644 --- a/firmware/httpsclient-particle.h +++ b/firmware/httpsclient-particle.h @@ -20,8 +20,11 @@ extern TCPClient client; extern bool g_https_complete; extern uint32 g_bytes_received; extern const bool g_https_trace; + +typedef void (*callback_function)(unsigned char*, int); +extern callback_function g_weatherCallback_func; -int httpsclientSetup(const char * host, const char * path); +int httpsclientSetup(const char * host, const char * path, callback_function pFunc); int httpsClientConnection(unsigned char * requestContent, uint32 msg_len, const char * msg); void httpsclientCleanUp(); diff --git a/spark.json b/spark.json index 2aee707..a241da4 100644 --- a/spark.json +++ b/spark.json @@ -2,6 +2,6 @@ "name": "httpsclient-particle", "author": "Vamsi Vytla", "license": "GPL", - "version": "0.0.8", + "version": "0.0.9", "description": "A library that helps photon boards talk https to web servers" }