Permalink
Browse files

[android] use spi instead of uart (#2942)

  • Loading branch information...
bukepo authored and jwhui committed Aug 2, 2018
1 parent ba4b238 commit 601b99b3949e201dbb973076595ebc467f4a65b0
View
@@ -49,9 +49,10 @@ LOCAL_CFLAGS := \
-D_GNU_SOURCE \
-DMBEDTLS_CONFIG_FILE=\"mbedtls-config.h\" \
-DOPENTHREAD_CONFIG_FILE=\<openthread-config-android.h\> \
-DOPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE=0 \
-DOPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE=1 \
-DOPENTHREAD_FTD=1 \
-DOPENTHREAD_POSIX=1 \
-DOPENTHREAD_POSIX_APP=1 \
-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"openthread-core-posix-config.h\" \
-DSPINEL_PLATFORM_HEADER=\"spinel_platform.h\" \
-Wno-error=non-virtual-dtor \
@@ -168,17 +169,13 @@ LOCAL_SRC_FILES := \
src/core/utils/missing_strlcat.c \
src/core/utils/missing_strnlen.c \
src/core/utils/slaac_address.cpp \
src/diag/diag_process.cpp \
src/diag/openthread-diag.cpp \
src/ncp/hdlc.cpp \
src/ncp/hdlc.hpp \
src/ncp/ncp_spi.cpp \
src/ncp/ncp_spi.hpp \
src/ncp/spinel.c \
src/ncp/spinel.h \
src/ncp/spinel_decoder.hpp \
src/ncp/spinel_decoder.cpp \
src/ncp/spinel_encoder.hpp \
src/ncp/spinel_encoder.cpp \
src/ncp/spinel_platform.h \
src/posix/platform/alarm.c \
src/posix/platform/diag.c \
src/posix/platform/misc.c \
@@ -236,9 +233,7 @@ LOCAL_C_INCLUDES := \
LOCAL_CFLAGS := \
-D_GNU_SOURCE \
-DOPENTHREAD_CONFIG_FILE=\<openthread-config-android.h\> \
-DOPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE=0 \
-DOPENTHREAD_ENABLE_NCP_SPI=0 \
-DOPENTHREAD_ENABLE_NCP_UART=1 \
-DOPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE=1 \
-DOPENTHREAD_FTD=1 \
-DOPENTHREAD_POSIX=1 \
-DOPENTHREAD_POSIX_APP=2 \
@@ -247,6 +242,9 @@ LOCAL_CFLAGS := \
-Wno-error=non-virtual-dtor \
$(NULL)
LOCAL_LDLIBS := \
-lutil
LOCAL_SRC_FILES := \
src/cli/cli.cpp \
src/cli/cli_coap.cpp \
@@ -277,9 +275,7 @@ LOCAL_C_INCLUDES := \
LOCAL_CFLAGS := \
-D_GNU_SOURCE \
-DOPENTHREAD_CONFIG_FILE=\<openthread-config-android.h\> \
-DOPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE=0 \
-DOPENTHREAD_ENABLE_NCP_SPI=1 \
-DOPENTHREAD_ENABLE_NCP_UART=0 \
-DOPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE=1 \
-DOPENTHREAD_FTD=1 \
-DOPENTHREAD_POSIX=1 \
-DOPENTHREAD_POSIX_APP=1 \
@@ -288,18 +284,17 @@ LOCAL_CFLAGS := \
-Wno-error=non-virtual-dtor \
$(NULL)
LOCAL_LDLIBS := \
-lutil
LOCAL_SRC_FILES := \
src/ncp/changed_props_set.cpp \
src/ncp/changed_props_set.hpp \
src/ncp/ncp_base.cpp \
src/ncp/ncp_base.hpp \
src/ncp/ncp_base_mtd.cpp \
src/ncp/ncp_base_ftd.cpp \
src/ncp/ncp_base_dispatcher.cpp \
src/ncp/ncp_buffer.cpp \
src/ncp/ncp_buffer.hpp \
src/ncp/ncp_uart.cpp \
src/ncp/ncp_uart.hpp \
src/posix/main.c \
$(NULL)
@@ -115,7 +115,7 @@
#define OPENTHREAD_ENABLE_DHCP6_SERVER 1
/* Define to 1 if you want to use diagnostics module */
#define OPENTHREAD_ENABLE_DIAG 0
#define OPENTHREAD_ENABLE_DIAG 1
/* Define to 1 if you want to enable DNS Client */
#define OPENTHREAD_ENABLE_DNS_CLIENT 1
@@ -143,13 +143,13 @@
#define OPENTHREAD_ENABLE_MULTIPLE_INSTANCES 0
/* Define to 1 to enable the NCP SPI interface. */
#define OPENTHREAD_ENABLE_NCP_SPI 0
#define OPENTHREAD_ENABLE_NCP_SPI 1
/* Define to 1 if using NCP Spinel Encrypter */
#define OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER 0
/* Define to 1 to enable the NCP UART interface. */
#define OPENTHREAD_ENABLE_NCP_UART 1
#define OPENTHREAD_ENABLE_NCP_UART 0
/* Define to 1 if using NCP vendor hook */
#define OPENTHREAD_ENABLE_NCP_VENDOR_HOOK 0
View
@@ -36,7 +36,7 @@
#include "common/code_utils.hpp"
#if OPENTHREAD_ENABLE_NCP_UART
#if OPENTHREAD_ENABLE_NCP_UART || OPENTHREAD_POSIX_APP
namespace ot {
namespace Hdlc {
@@ -334,4 +334,4 @@ void Decoder::Decode(const uint8_t *aInBuf, uint16_t aInLength)
} // namespace Hdlc
} // namespace ot
#endif // OPENTHREAD_ENABLE_NCP_UART
#endif // OPENTHREAD_ENABLE_NCP_UART || OPENTHREAD_POSIX_APP
@@ -53,36 +53,6 @@
#define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED
#endif
#if OPENTHREAD_RADIO
/**
* @def OPENTHREAD_CONFIG_ENABLE_SOFTWARE_ACK_TIMEOUT
*
* Define to 1 if you want to enable software ACK timeout logic.
*
*/
#define OPENTHREAD_CONFIG_ENABLE_SOFTWARE_ACK_TIMEOUT 1
/**
* @def OPENTHREAD_CONFIG_ENABLE_SOFTWARE_RETRANSMIT
*
* Define to 1 if you want to enable software retransmission logic.
*
* Applicable only if raw link layer API is enabled (i.e., `OPENTHREAD_ENABLE_RAW_LINK_API` is set).
*
*/
#define OPENTHREAD_CONFIG_ENABLE_SOFTWARE_RETRANSMIT 1
/**
* @def OPENTHREAD_CONFIG_ENABLE_SOFTWARE_CSMA_BACKOFF
*
* Define to 1 if you want to enable software CSMA-CA backoff logic.
*
* Applicable only if raw link layer API is enabled (i.e., `OPENTHREAD_ENABLE_RAW_LINK_API` is set).
*
*/
#define OPENTHREAD_CONFIG_ENABLE_SOFTWARE_CSMA_BACKOFF 1
#endif // OPENTHREAD_RADIO
/**
* @def OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
*
@@ -45,6 +45,7 @@ extern "C" {
#endif
#include <stdarg.h>
#include <stdlib.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <syslog.h>
@@ -252,19 +253,20 @@ static int OpenPty(const char *aFile, const char *aConfig)
if (0 == pid)
{
const int kMaxCommand = 255;
char cmd[kMaxCommand];
int rval;
const int dtablesize = getdtablesize();
const int kMaxCommand = 255;
char cmd[kMaxCommand];
int rval;
struct rlimit limit;
rval = getrlimit(RLIMIT_NOFILE, &limit);
rval = setenv("SHELL", SOCKET_UTILS_DEFAULT_SHELL, 0);
VerifyOrExit(rval == 0, perror("setenv failed"));
// Close all file descriptors larger than STDERR_FILENO.
for (int i = (STDERR_FILENO + 1); i < dtablesize; i++)
for (rlim_t i = (STDERR_FILENO + 1); i < limit.rlim_cur; i++)
{
close(i);
close(static_cast<int>(i));
}
rval = snprintf(cmd, sizeof(cmd), "%s %s", aFile, aConfig);
@@ -617,12 +619,15 @@ void RadioSpinel::HandleValueIs(spinel_prop_key_t aKey, const uint8_t *aBuffer,
}
else if (aKey == SPINEL_PROP_STREAM_DEBUG)
{
const char * message = NULL;
char logStream[OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE + 1];
unsigned int len = sizeof(logStream);
spinel_ssize_t unpacked;
unpacked = spinel_datatype_unpack(aBuffer, aLength, SPINEL_DATATYPE_UTF8_S, &message);
VerifyOrExit(unpacked > 0 && message, error = OT_ERROR_PARSE);
otLogDebgPlat(mInstance, "NCP DEBUG INFO: %s", message);
unpacked = spinel_datatype_unpack_in_place(aBuffer, aLength, SPINEL_DATATYPE_DATA_S, logStream, &len);
assert(len < sizeof(logStream));
VerifyOrExit(unpacked > 0, error = OT_ERROR_PARSE);
logStream[len] = '\0';
otLogDebgPlat(mInstance, "NCP DEBUG INFO: %s", logStream);
}
exit:

0 comments on commit 601b99b

Please sign in to comment.