Exemplo n.º 1
0
static void test_information_interface()
{
    CellularDevice *dev = CellularDevice::get_default_instance();

    CellularInformation *info = dev->open_information();
    const int kbuf_size = 100;
    char *buf = new char[kbuf_size];

    TEST_ASSERT(info->get_manufacturer(buf, kbuf_size) == NSAPI_ERROR_OK);
    TEST_ASSERT(info->get_model(buf, kbuf_size) == NSAPI_ERROR_OK);
    TEST_ASSERT(info->get_revision(buf, kbuf_size) == NSAPI_ERROR_OK);
    TEST_ASSERT((info->get_serial_number(buf, kbuf_size, CellularInformation::SN) == NSAPI_ERROR_OK) ||
                ((((AT_CellularInformation *)info)->get_device_error().errType == 3) &&    // 3 == CME error from the modem
                 (((AT_CellularInformation *)info)->get_device_error().errCode == 4)));     // 4 == "operation not supported"

    nsapi_error_t err = info->get_serial_number(buf, kbuf_size, CellularInformation::IMEI);
    TEST_ASSERT(err == NSAPI_ERROR_UNSUPPORTED || err == NSAPI_ERROR_OK);

    err = info->get_serial_number(buf, kbuf_size, CellularInformation::IMEISV);
    TEST_ASSERT(err == NSAPI_ERROR_UNSUPPORTED || err == NSAPI_ERROR_OK);

    err = info->get_serial_number(buf, kbuf_size, CellularInformation::SVN);
    TEST_ASSERT(err == NSAPI_ERROR_UNSUPPORTED || err == NSAPI_ERROR_OK);

    dev->close_information();

    delete [] buf;
}
Exemplo n.º 2
0
Arquivo: main.cpp Projeto: betzw/mbed
static void test_information_interface()
{
    CellularInformation *info = cellular.get_device()->open_information(&cellular_serial);
    const int kbuf_size = 100;
    char *buf = (char *)malloc(sizeof(char) * kbuf_size);

    TEST_ASSERT(info->get_manufacturer(buf, kbuf_size) == NSAPI_ERROR_OK);
    TEST_ASSERT(info->get_model(buf, kbuf_size) == NSAPI_ERROR_OK);
    TEST_ASSERT(info->get_revision(buf, kbuf_size) == NSAPI_ERROR_OK);
    TEST_ASSERT((info->get_serial_number(buf, kbuf_size, CellularInformation::SN) == NSAPI_ERROR_OK) ||
               ((((AT_CellularInformation *)info)->get_device_error().errType == 3) &&    // 3 == CME error from the modem
               (((AT_CellularInformation *)info)->get_device_error().errCode == 4)));     // 4 == "operation not supported"

    nsapi_error_t err = info->get_serial_number(buf, kbuf_size, CellularInformation::IMEI);
    TEST_ASSERT(err == NSAPI_ERROR_UNSUPPORTED || err == NSAPI_ERROR_OK);

    err = info->get_serial_number(buf, kbuf_size, CellularInformation::IMEISV);
    TEST_ASSERT(err == NSAPI_ERROR_UNSUPPORTED || err == NSAPI_ERROR_OK);

    err = info->get_serial_number(buf, kbuf_size, CellularInformation::SVN);
    TEST_ASSERT(err == NSAPI_ERROR_UNSUPPORTED || err == NSAPI_ERROR_OK);

    cellular.get_device()->close_information();

    free(buf);
}
Exemplo n.º 3
0
nsapi_error_t AT_CellularDevice::init_module()
{
#if MBED_CONF_MBED_TRACE_ENABLE
    CellularInformation *information = open_information();
    if (information) {
        char *pbuf = new char[100];
        nsapi_error_t ret = information->get_model(pbuf, sizeof(*pbuf));
        close_information();
        if (ret == NSAPI_ERROR_OK) {
            tr_info("Model %s", pbuf);
        }
        delete[] pbuf;
    }
#endif
    return NSAPI_ERROR_OK;
}