Skip to content

examples/xedge: Add Xedge example with BAS integration #3120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions examples/xedge/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# Xedge IoT Toolkit - NuttX Kconfig integration
#
# Xedge is an embedded software toolkit designed to enable high-level developers
# (e.g., web and Lua programmers) to create sophisticated, secure IoT and industrial
# device applications. It abstracts low-level embedded development through a lightweight
# runtime built on top of the Barracuda App Server and Lua, giving developers direct access
# to HTTP(S), WebSockets, MQTT, file system, and device I/O - all from high-level Lua scripts.
#
# This NuttX integration allows developers to compile and run Xedge as a user application,
# bringing powerful device control capabilities and an embedded web server to NuttX-based
# systems.
#
# Use this if you want to build smart, networked embedded devices with minimal C code,
# and maximum productivity.
#

config EXAMPLES_XEDGE
tristate "Xedge IoT Toolkit"
depends on ALLOW_GPL_COMPONENTS
default n
---help---
Enable Xedge support in NuttX. Xedge is a high-level
toolkit that lets you develop complete IoT device
applications using Lua, backed by the Barracuda App
Server. This application demonstrates a complete
Xedge runtime integrated into NuttX.

if EXAMPLES_XEDGE

config EXAMPLES_XEDGE_PROGNAME
string "Program name"
default "xedge"
---help---
This is the name of the ELF executable for the Xedge application in NSH.

config EXAMPLES_XEDGE_PRIORITY
int "Xedge task priority"
default 100
---help---
Set the task priority for the Xedge runtime.

config EXAMPLES_XEDGE_STACKSIZE
int "Xedge stack size"
default 20000
---help---
Set the stack size allocated to the Xedge Lua interpreter and application runtime.

endif
24 changes: 24 additions & 0 deletions examples/xedge/Make.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
############################################################################
# apps/examples/xedge/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################

ifneq ($(CONFIG_EXAMPLES_XEDGE),)
CONFIGURED_APPS += $(APPDIR)/examples/xedge
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/examples/xedge/BAS/inc ${INCDIR_PREFIX}$(APPDIR)/examples/xedge/BAS/inc/arch/Posix ${INCDIR_PREFIX}$(APPDIR)/examples/xedge/BAS/inc/arch/NET/Posix -DNO_INIT_DISK_IO -DUSE_DBGMON=1 -DUSE_IPV6
endif
87 changes: 87 additions & 0 deletions examples/xedge/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
############################################################################
# apps/examples/xedge/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################

include $(APPDIR)/Make.defs

# Xedge, World! built-in application info

PROGNAME = $(CONFIG_EXAMPLES_XEDGE_PROGNAME)
PRIORITY = $(CONFIG_EXAMPLES_XEDGE_PRIORITY)
STACKSIZE = $(CONFIG_EXAMPLES_XEDGE_STACKSIZE)
MODULE = $(CONFIG_EXAMPLES_XEDGE)

# Repository names and specific hashes
BAS_UNPACKNAME = BAS
BAS_HASH = 9f74a2f778b002ad8441471b8a7a5b13172dbe76
BAS_RESOURCES_UNPACKNAME = BAS-Resources
BAS_RESOURCES_HASH = 227a4b998300fa4cfde871dc7dac92c09e1636c2

# Download URLs
BAS_ZIP_URL = https://github.com/RealTimeLogic/BAS/archive/$(BAS_HASH).zip
BAS_RESOURCES_ZIP_URL = https://github.com/RealTimeLogic/BAS-Resources/archive/$(BAS_RESOURCES_HASH).zip

# Xedge: BAS Example

MAINSRC = xedge_main.c BAS/src/BAS.c BAS/src/dlmalloc.c BAS/src/arch/Posix/ThreadLib.c BAS/src/arch/NET/generic/SoDisp.c BAS/src/DiskIo/posix/BaFile.c BAS/examples/xedge/src/xedge.c BAS/examples/xedge/ BAS/examples/xedge/XedgeZip.c

XEDGEZIP = BAS/examples/xedge/XedgeZip.c

xedge-repos:

# ############################################################################
# Config and Fetch xedge
# ############################################################################

@if [ ! -d $(BAS_UNPACKNAME) ]; then \
echo "Downloading BAS from hash $(BAS_HASH)..."; \
curl -f -L $(BAS_ZIP_URL) -o bas-temp.zip || \
(echo "Error downloading BAS"; exit 1); \
unzip -q bas-temp.zip; \
mv BAS-$(BAS_HASH) $(BAS_UNPACKNAME); \
rm -f bas-temp.zip; \
fi

@if [ ! -d $(BAS_RESOURCES_UNPACKNAME) ]; then \
echo "Downloading BAS-Resources from hash $(BAS_RESOURCES_HASH)..."; \
curl -f -L $(BAS_RESOURCES_ZIP_URL) -o resources-temp.zip || \
(echo "Error downloading BAS-Resources"; exit 1); \
unzip -q resources-temp.zip; \
mv BAS-Resources-$(BAS_RESOURCES_HASH) $(BAS_RESOURCES_UNPACKNAME); \
rm -f resources-temp.zip; \
fi

# ############################################################################
# Library Configuration
# ############################################################################

@if [ ! -f "$(XEDGEZIP)" ]; then \
echo "Creating XedgeZip.c"; \
cd $(BAS_RESOURCES_UNPACKNAME)/build/ && \
printf "n\nl\nn\n" | bash Xedge.sh > /dev/null && \
cp XedgeZip.c ../../$(BAS_UNPACKNAME)/examples/xedge/ || exit 1; \
fi

context:: xedge-repos

distclean::
$(call DELDIR, $(BAS_UNPACKNAME))
$(call DELDIR, $(BAS_RESOURCES_UNPACKNAME))

include $(APPDIR)/Application.mk
Loading
Loading