Skip to content

Commit

Permalink
Merge pull request #52 from toniebox-reverse-engineering/develop
Browse files Browse the repository at this point in the history
Next Version
  • Loading branch information
SciLor authored Sep 8, 2023
2 parents 4d2f9fe + 3586cf7 commit 2faa8bc
Show file tree
Hide file tree
Showing 45 changed files with 5,751 additions and 1,066 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@
[submodule "cyclone/cyclone_crypto"]
path = cyclone/cyclone_crypto
url = https://github.com/Oryx-Embedded/CycloneCrypto.git
[submodule "opus"]
path = opus
url = https://github.com/xiph/opus.git
[submodule "ogg"]
path = ogg
url = https://github.com/xiph/ogg.git
27 changes: 26 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@
"MIMode": "gdb",
},
},
{
"name": "[linux] teddyCloud dencode test",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/teddycloud",
"args": [
"DENCODE",
"https://download.samplelib.com/mp3/sample-15s.mp3",
"data/library/dencode.taf",
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/",
"environment": [],
"externalConsole": false,
"preLaunchTask": "build",
"linux": {
"MIMode": "gdb",
},
},
{
"name": "[wsl] teddyCloud",
"type": "cppdbg",
Expand All @@ -49,7 +68,13 @@
],
"pipeTransport": {
"pipeProgram": "wsl",
"pipeArgs": [ "--cd", "${workspaceFolder}", "-e", "bash", "-c" ]
"pipeArgs": [
"--cd",
"${workspaceFolder}",
"-e",
"bash",
"-c"
]
},
"preLaunchTask": "[wsl] build",
"logging": {
Expand Down
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"C_Cpp.default.configurationProvider": "ms-vscode.makefile-tools",
"files.associations": {
"*.v": "bsv",
"*.h": "c"
"*.h": "c",
"algorithm": "c",
"limits": "c",
"utility": "c"
},
"C_Cpp.autocompleteAddParentheses": true,
"editor.formatOnSave": true,
Expand Down
30 changes: 16 additions & 14 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
"cwd": "${workspaceRoot}"
},
"windows": {
"options": {
"shell": {
"executable": "cmd.exe",
"args": [
"/C",
// The path to VsDevCmd.bat depends on the version of Visual Studio you have installed.
"\"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/VsDevCmd.bat\"",
"&&"
]
"options": {
"shell": {
"executable": "cmd.exe",
"args": [
"/C",
// The path to VsDevCmd.bat depends on the version of Visual Studio you have installed.
"\"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/VsDevCmd.bat\"",
"&&"
]
}
}
}
},
"tasks": [
{
"label": "build",
"group": "build",
"command": "make build",
"command": "make build OPTI_LEVEL=-Og",
"type": "shell",
"problemMatcher": []
},
Expand All @@ -51,7 +51,8 @@
"type": "process",
"command": "bash",
"args": [
"-c", "make build"
"-c",
"make build"
]
},
{
Expand All @@ -63,7 +64,8 @@
"type": "process",
"command": "bash",
"args": [
"-c", "make clean"
"-c",
"make clean"
]
},
{
Expand All @@ -72,7 +74,7 @@
"kind": "build",
"isDefault": true
},
"command": "make PLATFORM=windows build",
"command": "make PLATFORM=windows OPTI_LEVEL=-Og build",
"type": "shell",
"problemMatcher": [
"$msCompile"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ FROM ubuntu:latest
EXPOSE 80 443

RUN apt-get update \
&& apt-get install -y --no-install-recommends faketime openssl libubsan1 \
&& apt-get install -y --no-install-recommends faketime openssl libubsan1 ffmpeg \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir -p /teddycloud/certs \
Expand Down
84 changes: 72 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ZIP_DIR = install/zip
EXECUTABLE = $(BIN_DIR)/teddycloud$(EXEC_EXT)
LINK_LO_FILE = $(EXECUTABLE).lo
PLATFORM ?= linux
OPTI_LEVEL ?= -O2

ifeq ($(OS),Windows_NT)
SHELL_ENV ?= cmd
Expand Down Expand Up @@ -112,12 +113,14 @@ SOURCES_linux = \
src/platform/platform_$(PLATFORM).c \
src/cyclone/common/os_port_posix.c \
cyclone/common/fs_port_posix.c
CFLAGS_linux += -Wall -Werror
CFLAGS_linux += -Wall -Werror -Wno-error=format-overflow -Wno-error=stringop-truncation -Wno-error=maybe-uninitialized -Wno-error=stringop-overflow= -Wno-error=cpp
CFLAGS_linux += -ggdb
CFLAGS_linux += -DFFMPEG_DECODING

# for now enable extensive error checking
CFLAGS_linux += -fsanitize=undefined -fsanitize=address -Og
CFLAGS_linux += -fsanitize=undefined -fsanitize=address
LFLAGS_linux += -fsanitize=undefined -fsanitize=address -static-libasan
CFLAGS_linux += $(OPTI_LEVEL)

## win32 specific headers/sources
HEADERS_windows =
Expand All @@ -142,25 +145,33 @@ INCLUDES = \
-Icyclone/cyclone_tcp \
-Icyclone/cyclone_crypto \
-Icyclone/cyclone_crypto/pkix \
-Icyclone/cyclone_crypto/pkc \
-Icyclone/cyclone_crypto/rng \
-IcJSON \
-Ifat/source
-Ifat/source \
-Iogg/include \
-Iogg/src \
-Iopus/include \
-Iopus/celt \
-Iopus/silk \
-Iopus/silk/float

SOURCES = \
$(wildcard $(SRC_DIR)/*.c) \
$(wildcard $(SRC_DIR)/proto/*.c) \
$(CYCLONE_SOURCES) \
cJSON/cJSON.c \
cJSON/cJSON_Utils.c \
fat/source/ff.c \
fat/source/ffsystem.c \
fat/source/ffunicode.c
$(LIBOPUS_SOURCES) \
$(LIBOGG_SOURCES) \
$(CJSON_SOURCES) \
$(FAT_SOURCES)

HEADERS = \
$(wildcard include/*.h) \
$(CYCLONE_SOURCES:.c=.h) \
cJSON/cJSON.h \
cJSON/cJSON_Utils.h \
fat/source/ff.h
$(LIBOPUS_HEADERS) \
$(LIBOGG_HEADERS) \
$(CJSON_HEADERS) \
$(FAT_HEADERS)


#
Expand All @@ -172,6 +183,45 @@ INCLUDES += $(INCLUDES_$(PLATFORM))
CFLAGS += $(CFLAGS_$(PLATFORM))
LFLAGS += $(LFLAGS_$(PLATFORM))

FAT_SOURCES = \
fat/source/ff.c \
fat/source/ffsystem.c \
fat/source/ffunicode.c

FAT_HEADERS =\
fat/source/ff.h

CJSON_SOURCES = \
cJSON/cJSON.c \
cJSON/cJSON_Utils.c

CJSON_HEADERS = \
cJSON/cJSON.h \
cJSON/cJSON_Utils.h

LIBOGG_SOURCES = \
ogg/src/framing.c \
ogg/src/bitwise.c \

include opus/silk_sources.mk
include opus/celt_sources.mk
include opus/opus_sources.mk
include opus/silk_headers.mk
include opus/celt_headers.mk
include opus/opus_headers.mk

LIBOPUS_SOURCES = \
$(addprefix opus/,$(SILK_SOURCES)) \
$(addprefix opus/,$(SILK_SOURCES_FLOAT)) \
$(addprefix opus/,$(CELT_SOURCES)) \
$(addprefix opus/,$(OPUS_SOURCES)) \
$(addprefix opus/,$(OPUS_SOURCES_FLOAT))

LIBOPUS_HEADERS = \
$(addprefix opus/,$(SILK_HEAD)) \
$(addprefix opus/,$(CELT_HEAD)) \
$(addprefix opus/,$(OPUS_HEAD)) \

CYCLONE_SOURCES = \
cyclone/common/cpu_endian.c \
cyclone/common/date_time.c \
Expand Down Expand Up @@ -231,7 +281,6 @@ CYCLONE_SOURCES = \
cyclone/cyclone_crypto/ecc/ecdh.c \
cyclone/cyclone_crypto/ecc/ecdsa.c \
cyclone/cyclone_crypto/ecc/eddsa.c \
cyclone/cyclone_crypto/mpi/mpi.c \
cyclone/cyclone_crypto/encoding/base64.c \
cyclone/cyclone_crypto/encoding/asn1.c \
cyclone/cyclone_crypto/encoding/oid.c \
Expand All @@ -246,12 +295,17 @@ CYCLONE_SOURCES = \
cyclone/cyclone_crypto/pkix/x509_cert_parse.c \
cyclone/cyclone_crypto/pkix/x509_cert_ext_parse.c \
cyclone/cyclone_crypto/pkix/x509_cert_validate.c \
cyclone/cyclone_crypto/pkix/x509_cert_create.c \
cyclone/cyclone_crypto/pkix/x509_cert_format.c \
cyclone/cyclone_crypto/pkix/x509_cert_ext_format.c \
cyclone/cyclone_crypto/pkix/x509_crl_parse.c \
cyclone/cyclone_crypto/pkix/x509_crl_validate.c \
cyclone/cyclone_crypto/pkix/x509_crl_ext_parse.c \
cyclone/cyclone_crypto/pkix/x509_common.c \
cyclone/cyclone_crypto/pkix/x509_sign_verify.c \
cyclone/cyclone_crypto/pkix/x509_sign_parse.c \
cyclone/cyclone_crypto/pkix/x509_sign_generate.c \
cyclone/cyclone_crypto/pkix/x509_sign_format.c \
cyclone/cyclone_crypto/kdf/hkdf.c \
cyclone/cyclone_crypto/rng/yarrow.c

Expand All @@ -267,6 +321,7 @@ CYCLONE_SOURCES := $(filter-out \
# and add modified ones
CYCLONE_SOURCES += \
src/cyclone/common/debug.c \
src/cyclone/cyclone_crypto/mpi.c \
src/cyclone/cyclone_tcp/http/http_server.c \
src/cyclone/cyclone_tcp/http/http_server_misc.c \
src/cyclone/cyclone_tcp/mqtt/mqtt_client_transport.c \
Expand All @@ -277,6 +332,11 @@ CFLAGS += -D TRACE_NOPATH_FILE
CFLAGS += ${CFLAGS_VERSION}
CFLAGS += $(INCLUDES)

# for opus encoder
CFLAGS += -DUSE_ALLOCA -DOPUS_BUILD
CFLAGS_linux += -Wno-error=stringop-overflow= -Wno-error=stringop-overread


THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))

# Location of your .proto files
Expand Down
32 changes: 25 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# TeddyCloud

## Features
TeddyCloud is an alternative server for your Toniebox, allowing you to host the could services locally.
TeddyCloud is an alternative server for your Toniebox, allowing you to host the cloud services locally.
This gives you the control about which data is sent to the original manufacturer's cloud and allows you
to host your own figurine audio files on e.g. your NAS or any other server.

Expand All @@ -10,21 +10,23 @@ Currently implemented are:
* Cache original tonie audio content
* Simulate live content (.live)
* Passthrough original tonie audio content
* Convert any audio file to a tonie audio file (web)
* On-the-fly convert audio streams via ffmpeg for webradio and streams
* Basic Web fronted
* Filter custom tags to prevent deletion (.nocloud)
* Configure maximum volume for speaker and headphones
* Configure LED
* Configure slapping
* Customize original box sounds (ex. jingle) over the air
* Extract/Inject certitifcates on a esp32 firmware dump

## Planned
* Decode RTNL logs
* MQTT client
* Home Assistant integration (ideas welcome)
* TeddyBench integration
* Home Assistant integration (MQTT)
* [Web frontend](https://github.com/toniebox-reverse-engineering/teddycloud_web) (full stack developers welcome)

## Planned
* TeddyBench integration

## Preparation
### Generate certificates
First of all you'll need to generate the CA and certificates with the starting date 2015-11-03: ```./gencerts.sh``` Those will be placed in ```/certs/server/```.
Expand Down Expand Up @@ -83,13 +85,29 @@ esptool.py -b 921600 write_flash 0x0 tb.esp32.fakeca.bin

### DNS
#### CC3200 with altUrl patch
With a CC3200 box it is recommened to use the altUrl patch. Set the DNS entries for ```prod.revvox``` and ```rtnl.revvox``` to the TeddyCloud servers ip-address.
With a CC3200 box it is recommened to use the altUrl patch. Set the DNS entries for ```prod.revvox``` and ```rtnl.revvox``` to the TeddyCloud servers ip-address.
If you have a fritzbox you can use the [altUrl tc.fritz.box](https://github.com/toniebox-reverse-engineering/hackiebox_cfw_ng/blob/master/sd-bootloader-ng/bootmanager/sd/revvox/boot/patch/altUrl.tc.fritz.box.json) patch. You'll just have to set the name of your server in your fritzbox to ```tc``` (Heimnetz -> Netzwerk -> Netzwerkverbindungen -> bearbeiten
).
You may also edit the patch yourself to set the ip-address directly. Please beware, it should not be longer than the original url, which is 12 characters.

#### CC3235 / ESP32
Set the DNS entries for ```prod.de.tbs.toys``` and ```rtnl.bxcl.de``` to the TeddyCloud servers ip-address. Beware, this will cut off the connection of all tonieboxes within your network, which arn't patched with your replacement CA!
As an alternative you can set the gateway for the tonieboxes to the ip of teddyCloud. With OpenWRT it works this way:
```
uci set dhcp.teddycloud="tag"
uci set dhcp.teddycloud.dhcp_option="3,1.2.3.4" # 1.2.3.4=teddycloud ip
uci add dhcp host
uci set dhcp.@host[-1].name="toniebox_1"
uci set dhcp.@host[-1].mac="00:11:22:33:44:55" # toniebox mac
uci set dhcp.@host[-1].ip="1.2.3.101" # toniebox_1 ip
uci set dhcp.@host[-1].tag="teddycloud"
uci commit dhcp
/etc/init.d/dnsmasq restart
```

### Content
Please put your content into the ```/data/content/default/``` in the same structure as on your toniebox. You can place an empty ```500304E0.live``` file beside the content files to mark them as live. With ```500304E0.nocloud``` you can prevent the usage of the Boxine cloud for that tag.
Please put your content into the ```/data/content/default/``` in the same structure as on your toniebox. You can edit ```500304E0.json``` file beside the content files to mark them as live or you can prevent the usage of the Boxine cloud for that tag with the nocloud parameter. By setting a source teddyCloud can stream any content that ffmpeg can decode (urls and files).

### Webinterface
Currently the interface to teddycloud is reachable through the IP of the docker container at port 80 or 443 (depending on your ```docker-compose.yaml```). Changes affecting the toniebox (volume, LED) which are made through this interface will only be reflected onto the toniebox after pressing the big ear for a few seconds until a beep occurs.
Expand Down
Loading

0 comments on commit 2faa8bc

Please sign in to comment.