Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "application.h"
- #include "wolfssl/ssl.h"
- #include "spark_wiring_tcpclient.h"
- //EthernetClient client;
- TCPClient client;
- WOLFSSL_CTX* ctx = 0;
- WOLFSSL* ssl = 0;
- WOLFSSL_METHOD* method = 0;
- int EthernetSend(WOLFSSL* ssl, char* msg, int sz, void* ctx) {
- int sent = 0;
- sent = client.write((byte*)msg, sz);
- return sent;
- }
- int EthernetReceive(WOLFSSL* ssl, char* reply, int sz, void* ctx) {
- int ret = 0;
- while (client.available() > 0 && ret < sz) {
- reply[ret++] = client.read();
- }
- return ret;
- }
- void setup() {
- RGB.control(true);
- ctx = wolfSSL_CTX_new(method);
- if (ctx == NULL) {
- Serial.println("unable to get ctx");
- return;
- }
- // initialize wolfSSL using callback functions
- wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0);
- wolfSSL_SetIOSend(ctx, EthernetSend);
- wolfSSL_SetIORecv(ctx, EthernetReceive);
- }
- void loop() {
- RGB.color( 128,128,0);
- delay(500);
- RGB.color( 255,0,0);
- delay(500);
- }
Advertisement
RAW Paste Data
Copied
Advertisement