Skip to content

Commit

Permalink
feat(endpoint): Port endpoint onto WP76xx platform
Browse files Browse the repository at this point in the history
This commit implement the WP76xx platform for the endpoint.

[WIP] Connect success, Try to deploy on buildkite.

Close DLTcollab#718
  • Loading branch information
splasky committed Sep 22, 2020
1 parent 091aa58 commit f74d00f
Show file tree
Hide file tree
Showing 19 changed files with 109 additions and 328 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,6 @@ _build_endpoint/
endpoint.*.update
.repo
legato/
leaf-data
leaf-workspace.json
*.tgz
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ LEGATO_FLAGS += -DEP_TARGET=$(EP_TARGET)
LEGATO_FLAGS := $(foreach flags, $(LEGATO_FLAGS), -C $(flags))

# Include the build command from the specific target
include endpoint/platform/$(EP_TARGET)/build.mk
ifeq ($(EP_TARGET), simulator)
include endpoint/platform/simulator/build.mk
else
include endpoint/platform/default/build.mk
endif

export EP_TARGET

all: $(DEPS) cert
Expand Down
91 changes: 0 additions & 91 deletions docs/endpoint-hal.md

This file was deleted.

7 changes: 5 additions & 2 deletions endpoint/endpointComp/Component.cdef
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
sources:
{
${CURDIR}/../endpoint_core.c
${CURDIR}/../hal/device.c

// include the specific platform
${CURDIR}/../platform/${EP_TARGET}/impl.c
#if ${LEGATO_TARGET} = localhost
${CURDIR}/../platform/simulator/impl.c
#else
${CURDIR}/../platform/default/impl.c
#endif

${CURDIR}/../../output_base/external/org_iota_common/utils/logger_helper.c

Expand Down
3 changes: 2 additions & 1 deletion endpoint/endpointComp/endpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
*/

#include "endpoint.h"
#include "hal/device.h"

#include "common/ta_errors.h"
#include "endpoint/cipher.h"
#include "endpoint/endpoint_core.h"
#include "endpoint/platform/impl.h"

#include "le_test.h"
#include "legato.h"

Expand Down
10 changes: 0 additions & 10 deletions endpoint/hal/BUILD

This file was deleted.

62 changes: 0 additions & 62 deletions endpoint/hal/device.c

This file was deleted.

9 changes: 0 additions & 9 deletions endpoint/platform/BUILD

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

platform-build-command = \
cd endpoint && \
mkapp -v -t wp77xx $(LEGATO_FLAGS) -i ${LEGATO_ROOT}/interfaces/modemServices endpoint.adef
mkapp -t $(EP_TARGET) $(LEGATO_FLAGS) -i ${LEGATO_ROOT}/interfaces/modemServices endpoint.adef
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@
#include <termios.h>
#include <time.h>
#include <unistd.h>
#include "endpoint/hal/device.h"

#include "endpoint/platform/impl.h"

#include "legato.h"

#include "interfaces.h"
#include "le_log.h"
#include "le_mdmDefs_interface.h"
#include "le_secStore_common.h"
#include "le_sim_common.h"

#define MAXLINE 1024

Expand All @@ -33,21 +30,11 @@
#define READ_BUFFER_SIZE 32
#define DEFAULT_PORT "/dev/ttyHS0"

extern struct device_type wp77xx_device_type;

static le_sim_Id_t SimId;
/* UART file descriptor */
static int uart_fd;

static status_t wp77xx_init(void) {
status_t err = register_device(&wp77xx_device_type);
LE_ERROR_IF(err != SC_OK, "register wp77xx device error: %d", err);
return err;
}

static void wp77xx_release(void) { LE_INFO("Finalize the device success"); }

static status_t wp77xx_get_key(uint8_t *key) {
status_t get_device_key(uint8_t *key) {
// FIXME:Need to implement the private key generate algorithm
if (key == NULL) {
LE_ERROR("Failed to get key");
Expand All @@ -72,7 +59,7 @@ static status_t cm_sim_GetSimImsi(char *sim_id) {
return ret;
}

static status_t wp77xx_get_device_id(char *device_id) {
status_t get_device_id(char *device_id) {
if (cm_sim_GetSimImsi(device_id) != SC_OK) {
return SC_ENDPOINT_GET_DEVICE_ID_ERROR;
}
Expand Down Expand Up @@ -113,7 +100,7 @@ static status_t set_interface_attribs(int fd, int speed) {
return SC_OK;
}

static status_t uart_init(const char *device) {
status_t uart_init(const char *device) {
if (device == NULL) device = DEFAULT_PORT;
int fd;

Expand All @@ -129,7 +116,7 @@ static status_t uart_init(const char *device) {
return SC_OK;
}

static void uart_write(const int fd, const char *cmd) {
void uart_write(const int fd, const char *cmd) {
/* simple output */
ssize_t cmd_len = strlen(cmd);
ssize_t wlen = write(fd, cmd, cmd_len);
Expand All @@ -139,7 +126,7 @@ static void uart_write(const int fd, const char *cmd) {
tcdrain(fd); /* delay for output */
}

static char *uart_read(const int fd) {
char *uart_read(const int fd) {
unsigned char buf[READ_BUFFER_SIZE];
char *response = NULL;

Expand All @@ -155,7 +142,7 @@ static char *uart_read(const int fd) {
return response;
}

static void uart_clean(const int fd) {
void uart_clean(const int fd) {
if (tcflush(fd, TCIOFLUSH) != 0) {
LE_ERROR("tcflush error");
}
Expand Down Expand Up @@ -208,33 +195,3 @@ status_t sec_delete(const char *name) {
return SC_ENDPOINT_SEC_FAULT;
}
}

static const struct device_operations wp77xx_ops = {
.init = wp77xx_init,
.fini = wp77xx_release,
.get_key = wp77xx_get_key,
.get_device_id = wp77xx_get_device_id,
};

static const struct uart_operations wp77xx_uart = {
.init = uart_init,
.write = uart_write,
.read = uart_read,
.clean = uart_clean,
};

static const struct secure_store_operations wp77xx_sec_ops = {
.init = sec_init,
.write = sec_write,
.read = sec_read,
.delete = sec_delete,
};

struct device_type wp77xx_device_type = {
.name = "wp77xx",
.op = &wp77xx_ops,
.uart = &wp77xx_uart,
.sec_ops = &wp77xx_sec_ops,
};

DECLARE_DEVICE(wp77xx);
29 changes: 29 additions & 0 deletions endpoint/platform/impl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (C) 2019-2020 BiiLabs Co., Ltd. and Contributors
* All Rights Reserved.
* This is free software; you can redistribute it and/or modify it under the
* terms of the MIT license. A copy of the license can be found in the file
* "LICENSE" at the root of this distribution.
*/
#include <stddef.h>
#include "common/ta_errors.h"

status_t get_device_key(uint8_t *key);

status_t get_device_id(char *id);

status_t uart_init(const char *device);

void uart_write(const int fd, const char *cmd);

char *uart_read(const int fd);

void uart_clean(const int fd);

status_t sec_init(void);

status_t sec_write(const char *name, const uint8_t *buf, size_t buf_size);

status_t sec_read(const char *name, uint8_t *buf, size_t *buf_size);

status_t sec_delete(const char *name);
9 changes: 0 additions & 9 deletions endpoint/platform/simulator/BUILD

This file was deleted.

2 changes: 1 addition & 1 deletion endpoint/platform/simulator/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export LEGATO_TARGET := localhost

platform-build-command = \
sh -c "endpoint/build-legato.sh"; \
cd endpoint && mkapp -v -t localhost -C -DENABLE_ENDPOINT_TEST $(LEGATO_FLAGS) endpoint.adef;
cd endpoint && mkapp -t $(LEGATO_TARGET) -C -DENABLE_ENDPOINT_TEST $(LEGATO_FLAGS) endpoint.adef;
Loading

0 comments on commit f74d00f

Please sign in to comment.