42 lines
880 B
C++
42 lines
880 B
C++
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
|
|
#include <gtest/gtest.h>
|
|
#include <di/drv/hl854x.h>
|
|
|
|
extern "C" {
|
|
#include "drv/hl854x/net.c"
|
|
}
|
|
|
|
static uint8_t buffer[256];
|
|
static struct di_drv_hl854x_ctx ctx;
|
|
|
|
size_t test_drv_hl854x_read_cb(void *buf, size_t nbyte)
|
|
{
|
|
const char *test = "AT+CREG?\r\n+CREG: 2,0\r\nOK\r\n\r\n+CREG: 1,\"00DF\",\"02D42D04\",2\r\n+CGREG: 1,\"00DF\",\"02D42D04\",2,\"07\"\r\nAT+COPS?\r\n+COPS: 0,0,\"vodafone NL\",2\r\nOK\r\n";
|
|
|
|
if (nbyte < strlen(test))
|
|
return 0;
|
|
|
|
memcpy(buf, test, strlen(test));
|
|
|
|
return strlen(test);
|
|
}
|
|
|
|
void test_hl854x_net_reset(void)
|
|
{
|
|
di_drv_hl854x_init(&ctx);
|
|
|
|
di_drv_hl854x_set_read(&ctx, test_drv_hl854x_read_cb);
|
|
|
|
memset(buffer, 0, sizeof(buffer));
|
|
}
|
|
|
|
TEST(drv_hl854x_net, recv) {
|
|
test_hl854x_net_reset();
|
|
di_drv_hl854x_read(&ctx);
|
|
|
|
EXPECT_EQ(HL854X_CARRIER_STATUS_REG_HOME, ctx.carrier.status);
|
|
}
|