6 years, 2 months ago.

EasyCellular SMS

I have a following example for EasyCellular (CELLULAR_DEVICE = UBLOX_AT) and i would like to add SMS functions. How am i going to do this?

#include "mbed.h"
#include "EasyCellularConnection.h"
#include "CellularCommon.h"
#include "mbed-trace/mbed_trace.h"

#define TRACE_GROUP "APP"

EasyCellularConnection mdm;

void connectionCb(nsapi_event_t type, intptr_t ptr) {
    printf("event\n");

    if (type >= NSAPI_EVENT_CELLULAR_STATUS_END) {
        printf("connection END: %i\n", ptr);

    } else if (type >= NSAPI_EVENT_CELLULAR_STATUS_BASE) {
        if ((cellular_connection_status_t)type == CellularDeviceReady) {
            printf("modem is ready\n");

        } else if ((cellular_connection_status_t)type == CellularSIMStatusChanged) {
            printf("sim status: %i\n", ptr);

        } else if ((cellular_connection_status_t)type == CellularRegistrationStatusChanged) {
            printf("reg status: %i\n", ptr);
        }

    } else if (type == NSAPI_EVENT_CONNECTION_STATUS_CHANGE) {
        printf("connection status: %i\n", ptr);
    }
}


int main() {
    mbed_trace_init();
    mdm.attach(connectionCb);
    mdm.set_blocking(false);
    mdm.set_credentials("internet", NULL, NULL);
    mdm.set_sim_pin("1234");

    if (mdm.connect() == NSAPI_ERROR_OK) {
        printf("connect OK\n");

    } else {
        printf("connect FAILED\n");
    }

    while (1) {
    }
}
Be the first to answer this question.