Own fork of MbedSmartRestMain

Dependencies:   C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed

Fork of MbedSmartRestMain by Cumulocity Official

Files at this revision

API Documentation at this revision

Comitter:
xinlei
Date:
Mon Aug 08 10:54:40 2016 +0000
Parent:
136:a52821cdb108
Child:
138:f8ab852e83e7
Commit message:
remove unmaintained ssl code

Changed in this revision

C027_Support.lib Show annotated file Show diff for this revision Revisions of this file
CyaSSL.lib Show diff for this revision Revisions of this file
util/SmartRestConf.cpp Show annotated file Show diff for this revision Revisions of this file
util/SmartRestSSLSocket.cpp Show diff for this revision Revisions of this file
util/SmartRestSSLSocket.h Show diff for this revision Revisions of this file
--- a/C027_Support.lib	Mon Feb 15 09:49:35 2016 +0000
+++ b/C027_Support.lib	Mon Aug 08 10:54:40 2016 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/xinlei/code/C027_Support/#27043e7c9de3
+http://developer.mbed.org/users/xinlei/code/C027_Support/#1f6b7f9b5805
--- a/CyaSSL.lib	Mon Feb 15 09:49:35 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/wolfSSL/code/CyaSSL/#64d4f7cb83d5
--- a/util/SmartRestConf.cpp	Mon Feb 15 09:49:35 2016 +0000
+++ b/util/SmartRestConf.cpp	Mon Aug 08 10:54:40 2016 +0000
@@ -10,6 +10,9 @@
 //const char *srX_ID = "com_cumulocity_MbedAgent_1.5.2";
 const char *srX_ID = NULL;
 const char *srHost = "developer.cumulocity.com";
+//const char *srHost = "iot.etisalat.eg";
+//const char *srHost = "management.teleena-iot.com";
+//const char *srHost = "post-iot.lu";
 //const char *srHost = "dev-a.cumulocity.com";
 //const char *srHost = "dev-c.cumulocity.com";
 //const char *srHost = "management.m2m-devicecloud.com";
--- a/util/SmartRestSSLSocket.cpp	Mon Feb 15 09:49:35 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-#include <string.h>
-#include "MDM.h"
-#include "SmartRestSSLSocket.h"
-#include "SmartRestConf.h"
-#include "logging.h"
-
-char SmartRestSSLSocket::cachedIP[16] = {0};
-
-int SmartRestSSLSocket::connect()
-{
-        sockfd = pMdm->socketSocket(MDMParser::IPPROTO_TCP);
-        if (sockfd < 0)
-                return -1;
-        bool n = false;
-        ipLock.lock();
-        for (size_t i = 0; i < 3; ++i) {
-                if (cachedIP[0] == 0) {
-                        MDMParser::IP ip = pMdm->gethostbyname(srHost);
-                        if (ip == NOIP) continue;
-                        const unsigned char *c = (const unsigned char*)&ip;
-                        snprintf(cachedIP, sizeof(cachedIP), "%u.%u.%u.%u",
-                                 c[3], c[2], c[1], c[0]);
-                }
-                n = pMdm->socketConnect(sockfd, cachedIP, srSSLPort);
-                if (n) {
-                        pMdm->socketSetBlocking(sockfd, timeout);
-                        CyaSSL_set_fd(ssl, sockfd);
-                        break;
-                } else {
-                        cachedIP[0] = 0;
-                }
-        }
-        ipLock.unlock();
-        return n ? 0 : -1;
-}
-
-int SmartRestSSLSocket::close()
-{
-        if (ssl)
-                CyaSSL_shutdown(ssl);
-        bool ret = true;
-        if (sockfd >= 0)
-                pMdm->socketFree(sockfd);
-//                ret = pMdm->socketClose(sockfd);
-        sockfd = -1;
-        return ret ? 0 : -1;
-}
-
-int SmartRestSSLSocket::sendOnly(char *buf, int size)
-{
-        int l = connect();
-        if (l < 0) {
-                aError("%s\n", "SO: connect");
-                return -3;
-        }
-        l = CyaSSL_write(ssl, buf, size);
-        close();
-        if (l < 0) {
-                char errorString[80];
-                int err = CyaSSL_get_error(ssl, 0);
-                CyaSSL_ERR_error_string(err, errorString);
-                aError("SO: %s\n", errorString);
-                return -2;
-        } else {
-                return l;
-        }
-}
-
-int SmartRestSSLSocket::sendAndReceive(char *buf, int size, int maxSize)
-{
-        int l = connect();
-        if (l < 0)
-                return -3;
-        l = CyaSSL_write(ssl, buf, size);
-        if (l < 0) {
-                char errorString[80];
-                int err = CyaSSL_get_error(ssl, 0);
-                CyaSSL_ERR_error_string(err, errorString);
-                aError("S: %s\n", errorString);
-                close();
-                return -2;
-        } else {
-                l = CyaSSL_read(ssl, buf, maxSize);
-                if (l >= 0)
-                        buf[l] = 0;
-                else {
-                        char errorString[80];
-                        int err = CyaSSL_get_error(ssl, 0);
-                        CyaSSL_ERR_error_string(err, errorString);
-                        printf("R: %s\n", errorString);
-                }
-                close();
-                return l;
-        }
-}
\ No newline at end of file
--- a/util/SmartRestSSLSocket.h	Mon Feb 15 09:49:35 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-#ifndef SMARTRESTSSLSOCKET_H
-#define SMARTRESTSSLSOCKET_H
-#include "mbed.h"
-#include "rtos.h"
-#include "MDM.h"
-#include "cyassl/ssl.h"
-
-extern MDMSerial *pMdm;
-extern CYASSL_CTX *pCtx;
-
-class SmartRestSSLSocket
-{
-public:
-        SmartRestSSLSocket(): timeout(3000), sockfd(-1), ssl(NULL) {
-//                sockfd = pMdm->socketSocket(MDMParser::IPPROTO_TCP);
-                ssl = CyaSSL_new(pCtx);
-        }
-        virtual ~SmartRestSSLSocket() {
-                close(); 
-//                pMdm->socketFree(sockfd);
-                CyaSSL_free(ssl);
-        }
-        int sendOnly(char *buf, int size);
-        int sendAndReceive(char *buf, int size, int maxSize);
-        void setBlocking(int _timeout = -1) {
-                // timeout in milliseconds
-                timeout = _timeout;
-        }
-protected:
-        int connect();
-        int close();
-private:
-        static char cachedIP[16];
-        int timeout;
-        int sockfd;
-        CYASSL *ssl;
-        Mutex ipLock;
-};
-
-#endif /* SMARTRESTSSLSOCKET_H */
\ No newline at end of file