Skip to content
Snippets Groups Projects
Commit 1d49a5e0 authored by Zbigniew Bodek's avatar Zbigniew Bodek
Browse files

main: Remove CONFIG_USERSPACE


Another app simplification by removing CONFIG_USERSPACE related
code that is not intended to be used on Nitrogen.

Signed-off-by: default avatarZbigniew Bodek <zbigniew.bodek@huawei.com>
parent 96dbefee
No related branches found
No related tags found
No related merge requests found
......@@ -17,31 +17,20 @@ LOG_MODULE_REGISTER(net_mqtt_publisher_sample, LOG_LEVEL_DBG);
#include "config.h"
#if defined(CONFIG_USERSPACE)
#include <app_memory/app_memdomain.h>
K_APPMEM_PARTITION_DEFINE(app_partition);
struct k_mem_domain app_domain;
#define APP_BMEM K_APP_BMEM(app_partition)
#define APP_DMEM K_APP_DMEM(app_partition)
#else
#define APP_BMEM
#define APP_DMEM
#endif
/* Buffers for MQTT client. */
static APP_BMEM uint8_t rx_buffer[APP_MQTT_BUFFER_SIZE];
static APP_BMEM uint8_t tx_buffer[APP_MQTT_BUFFER_SIZE];
static uint8_t rx_buffer[APP_MQTT_BUFFER_SIZE];
static uint8_t tx_buffer[APP_MQTT_BUFFER_SIZE];
/* The mqtt client struct */
static APP_BMEM struct mqtt_client client_ctx;
static struct mqtt_client client_ctx;
/* MQTT Broker details. */
static APP_BMEM struct sockaddr_storage broker;
static struct sockaddr_storage broker;
static APP_BMEM struct zsock_pollfd fds[1];
static APP_BMEM int nfds;
static struct zsock_pollfd fds[1];
static int nfds;
static APP_BMEM bool connected;
static bool connected;
#if defined(CONFIG_MQTT_LIB_TLS)
......@@ -51,7 +40,7 @@ static APP_BMEM bool connected;
#define APP_CA_CERT_TAG 1
#define APP_PSK_TAG 2
static APP_DMEM sec_tag_t m_sec_tags[] = {
static sec_tag_t m_sec_tags[] = {
#if defined(MBEDTLS_X509_CRT_PARSE_C) || defined(CONFIG_NET_SOCKETS_OFFLOAD)
APP_CA_CERT_TAG,
#endif
......@@ -253,12 +242,12 @@ void mqtt_evt_handler(struct mqtt_client *const client,
static char *get_mqtt_payload(enum mqtt_qos qos)
{
#if APP_BLUEMIX_TOPIC
static APP_BMEM char payload[30];
static char payload[30];
snprintk(payload, sizeof(payload), "{d:{temperature:%d}}",
(uint8_t)sys_rand32_get());
#else
static APP_DMEM char payload[] = "DOORS:OPEN_QoSx";
static char payload[] = "DOORS:OPEN_QoSx";
payload[strlen(payload) - 1] = '0' + qos;
#endif
......@@ -560,22 +549,6 @@ static int start_app(void)
return r;
}
#if defined(CONFIG_USERSPACE)
#define STACK_SIZE 2048
#if IS_ENABLED(CONFIG_NET_TC_THREAD_COOPERATIVE)
#define THREAD_PRIORITY K_PRIO_COOP(CONFIG_NUM_COOP_PRIORITIES - 1)
#else
#define THREAD_PRIORITY K_PRIO_PREEMPT(8)
#endif
K_THREAD_DEFINE(app_thread, STACK_SIZE,
start_app, NULL, NULL, NULL,
THREAD_PRIORITY, K_USER, -1);
static K_HEAP_DEFINE(app_mem_pool, 1024 * 2);
#endif
void main(void)
{
#if defined(CONFIG_MQTT_LIB_TLS)
......@@ -585,21 +558,5 @@ void main(void)
PRINT_RESULT("tls_init", rc);
#endif
#if defined(CONFIG_USERSPACE)
struct k_mem_partition *parts[] = {
#if Z_LIBC_PARTITION_EXISTS
&z_libc_partition,
#endif
&app_partition
};
k_mem_domain_init(&app_domain, ARRAY_SIZE(parts), parts);
k_mem_domain_add_thread(&app_domain, app_thread);
k_thread_heap_assign(app_thread, &app_mem_pool);
k_thread_start(app_thread);
k_thread_join(app_thread, K_FOREVER);
#else
exit(start_app());
#endif
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment