Skip to content

Commit 0e6fe26

Browse files
committed
first commit
0 parents  commit 0e6fe26

10 files changed

+753
-0
lines changed

Dockerfile

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM ubuntu:rolling AS build-env
2+
3+
ENV DEBIAN_FRONTEND noninteractive
4+
5+
# Install dependencies
6+
RUN apt-get update && apt-get -y install \
7+
libssl-dev \
8+
libcurl4-openssl-dev\
9+
libsqlite3-dev \
10+
libz-dev \
11+
autoconf \
12+
automake \
13+
libtool \
14+
libmosquitto-dev \
15+
libwebsockets-dev \
16+
pkg-config \
17+
make \
18+
&& apt-get clean
19+
20+
FROM build-env AS runner
21+
22+
ENV MAKE_JOBS=8
23+
ENV OBUSPA_ARGS="-v4"
24+
25+
# Copy in all of the code
26+
# Then compile, as root.
27+
COPY /obuspa/ /obuspa/
28+
RUN cd /obuspa/ && \
29+
autoreconf -fi && \
30+
./configure && \
31+
make -j${MAKE_JOBS} && \
32+
make install
33+
34+
# Then delete the code
35+
# that's no longer needed
36+
RUN rm -rf /obuspa
37+
38+
# Run obuspa with args expanded
39+
CMD obuspa ${OBUSPA_ARGS}

README.md

Whitespace-only changes.

USPython.py

+396
Large diffs are not rendered by default.

factory-reset-mqtt.txt

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#
2+
# This file contains a factory reset database in text format
3+
#
4+
# If no USP database exists when OB-USP-AGENT starts, then OB-USP-AGENT will create a database containing
5+
# the parameters specified in a text file located by the '-r' option.
6+
# Example:
7+
# obuspa -p -v 4 -r factory_reset_example.txt
8+
#
9+
# Each line of this file contains either a comment (denoted by '#' at the start of the line)
10+
# or a USP data model parameter and its factory reset value.
11+
# The parameter and value are separated by whitespace.
12+
# The value may optionally be enclosed in speech marks "" (this is the only way to specify an empty string)
13+
#
14+
##########################################################################################################
15+
#
16+
# Adding MQTT parameters to test the datamodel interface
17+
#
18+
19+
Device.LocalAgent.EndpointID "smartlock"
20+
21+
## Adding boot params
22+
Device.LocalAgent.Controller.1.BootParameter.1.Enable true
23+
Device.LocalAgent.Controller.1.BootParameter.1.ParameterName "Device.LocalAgent.EndpointID"
24+
Device.LocalAgent.Subscription.1.Alias cpe-1
25+
Device.LocalAgent.Subscription.1.Enable true
26+
Device.LocalAgent.Subscription.1.ID default-boot-event-ACS
27+
Device.LocalAgent.Subscription.1.Recipient Device.LocalAgent.Controller.1
28+
Device.LocalAgent.Subscription.1.NotifType Event
29+
Device.LocalAgent.Subscription.1.ReferenceList Device.Boot!
30+
Device.LocalAgent.Subscription.1.Persistent true
31+
32+
Device.LocalAgent.MTP.1.MQTT.ResponseTopicConfigured "oktopus/usp/v1/controller"
33+
Device.LocalAgent.MTP.1.MQTT.Reference "Device.MQTT.Client.1"
34+
Device.MQTT.Client.1.BrokerAddress "127.0.0.1"
35+
Device.MQTT.Client.1.ProtocolVersion "5.0"
36+
Device.MQTT.Client.1.BrokerPort "1883"
37+
Device.MQTT.Client.1.TransportProtocol "TCP/IP"
38+
Device.MQTT.Client.1.Username ""
39+
Device.MQTT.Client.1.Password ""
40+
Device.MQTT.Client.1.Alias "cpe-1"
41+
Device.MQTT.Client.1.Enable true
42+
Device.MQTT.Client.1.ClientID ""
43+
Device.MQTT.Client.1.KeepAliveTime "60"
44+
45+
Device.MQTT.Client.1.ConnectRetryTime "5"
46+
Device.MQTT.Client.1.ConnectRetryIntervalMultiplier "2000"
47+
Device.MQTT.Client.1.ConnectRetryMaxInterval "60"
48+
49+
50+
Device.LocalAgent.Controller.1.Alias "cpe-1"
51+
Device.LocalAgent.Controller.1.Enable true
52+
Device.LocalAgent.Controller.1.PeriodicNotifInterval "86400"
53+
Device.LocalAgent.Controller.1.PeriodicNotifTime "0001-01-01T00:00:00Z"
54+
Device.LocalAgent.Controller.1.ControllerCode ""
55+
Device.LocalAgent.Controller.1.MTP.1.Alias "cpe-1"
56+
Device.LocalAgent.Controller.1.MTP.1.Enable true
57+
Device.LocalAgent.Controller.1.MTP.1.Protocol "MQTT"
58+
Device.LocalAgent.Controller.1.EndpointID "oktopusController"
59+
Device.LocalAgent.Controller.1.MTP.1.MQTT.Reference "Device.MQTT.Client.1"
60+
Device.LocalAgent.Controller.1.MTP.1.MQTT.Topic "oktopus/usp/v1/controller"
61+
62+
63+
64+
#
65+
# The following parameters may be modified
66+
#
67+
Device.LocalAgent.MTP.1.Alias "cpe-1"
68+
Device.LocalAgent.MTP.1.Enable true
69+
Device.LocalAgent.MTP.1.Protocol "MQTT"
70+
71+
Internal.Reboot.Cause "LocalFactoryReset"

factory-reset-mqtt.txt.bak

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#
2+
# This file contains a factory reset database in text format
3+
#
4+
# If no USP database exists when OB-USP-AGENT starts, then OB-USP-AGENT will create a database containing
5+
# the parameters specified in a text file located by the '-r' option.
6+
# Example:
7+
# obuspa -p -v 4 -r factory_reset_example.txt
8+
#
9+
# Each line of this file contains either a comment (denoted by '#' at the start of the line)
10+
# or a USP data model parameter and its factory reset value.
11+
# The parameter and value are separated by whitespace.
12+
# The value may optionally be enclosed in speech marks "" (this is the only way to specify an empty string)
13+
#
14+
##########################################################################################################
15+
#
16+
# Adding MQTT parameters to test the datamodel interface
17+
#
18+
19+
Device.LocalAgent.EndpointID "usp-agent-mqtt"
20+
21+
## Adding boot params
22+
Device.LocalAgent.Controller.1.BootParameter.1.Enable true
23+
Device.LocalAgent.Controller.1.BootParameter.1.ParameterName "Device.LocalAgent.EndpointID"
24+
Device.LocalAgent.Subscription.1.Alias cpe-1
25+
Device.LocalAgent.Subscription.1.Enable true
26+
Device.LocalAgent.Subscription.1.ID default-boot-event-ACS
27+
Device.LocalAgent.Subscription.1.Recipient Device.LocalAgent.Controller.1
28+
Device.LocalAgent.Subscription.1.NotifType Event
29+
Device.LocalAgent.Subscription.1.ReferenceList Device.Boot!
30+
Device.LocalAgent.Subscription.1.Persistent true
31+
32+
Device.LocalAgent.MTP.1.MQTT.ResponseTopicConfigured "oktopus/usp/v1/controller"
33+
Device.LocalAgent.MTP.1.MQTT.Reference "Device.MQTT.Client.1"
34+
Device.MQTT.Client.1.BrokerAddress "127.0.0.1"
35+
Device.MQTT.Client.1.ProtocolVersion "5.0"
36+
Device.MQTT.Client.1.BrokerPort "1883"
37+
Device.MQTT.Client.1.TransportProtocol "TCP/IP"
38+
Device.MQTT.Client.1.Username ""
39+
Device.MQTT.Client.1.Password ""
40+
Device.MQTT.Client.1.Alias "cpe-1"
41+
Device.MQTT.Client.1.Enable true
42+
Device.MQTT.Client.1.ClientID ""
43+
Device.MQTT.Client.1.KeepAliveTime "60"
44+
45+
Device.MQTT.Client.1.ConnectRetryTime "5"
46+
Device.MQTT.Client.1.ConnectRetryIntervalMultiplier "2000"
47+
Device.MQTT.Client.1.ConnectRetryMaxInterval "60"
48+
49+
50+
Device.LocalAgent.Controller.1.Alias "cpe-1"
51+
Device.LocalAgent.Controller.1.Enable true
52+
Device.LocalAgent.Controller.1.PeriodicNotifInterval "86400"
53+
Device.LocalAgent.Controller.1.PeriodicNotifTime "0001-01-01T00:00:00Z"
54+
Device.LocalAgent.Controller.1.ControllerCode ""
55+
Device.LocalAgent.Controller.1.MTP.1.Alias "cpe-1"
56+
Device.LocalAgent.Controller.1.MTP.1.Enable true
57+
Device.LocalAgent.Controller.1.MTP.1.Protocol "MQTT"
58+
Device.LocalAgent.Controller.1.EndpointID "oktopusController"
59+
Device.LocalAgent.Controller.1.MTP.1.MQTT.Reference "Device.MQTT.Client.1"
60+
Device.LocalAgent.Controller.1.MTP.1.MQTT.Topic "oktopus/usp/v1/controller"
61+
62+
63+
64+
#
65+
# The following parameters may be modified
66+
#
67+
Device.LocalAgent.MTP.1.Alias "cpe-1"
68+
Device.LocalAgent.MTP.1.Enable true
69+
Device.LocalAgent.MTP.1.Protocol "MQTT"
70+
71+
Internal.Reboot.Cause "LocalFactoryReset"

factory-reset-websockets.txt

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
##########################################################################################################
2+
#
3+
# This file contains a factory reset database in text format
4+
#
5+
# If no USP database exists when OB-USP-AGENT starts, then OB-USP-AGENT will create a database containing
6+
# the parameters specified in a text file located by the '-r' option.
7+
# Example:
8+
# obuspa -p -v 4 -r factory_reset_example.txt
9+
#
10+
# Each line of this file contains either a comment (denoted by '#' at the start of the line)
11+
# or a USP data model parameter and its factory reset value.
12+
# The parameter and value are separated by whitespace.
13+
# The value may optionally be enclosed in speech marks "" (this is the only way to specify an empty string)
14+
#
15+
##########################################################################################################
16+
17+
#
18+
# The following parameters will definitely need modifying
19+
#
20+
21+
Device.LocalAgent.EndpointID "usp-agent-ws"
22+
23+
# Controller's websocket server (for agent initiated sessions)
24+
Device.LocalAgent.Controller.1.MTP.1.WebSocket.Host "127.0.0.1"
25+
Device.LocalAgent.Controller.1.MTP.1.WebSocket.Port "8080"
26+
Device.LocalAgent.Controller.1.MTP.1.WebSocket.Path "/ws/agent"
27+
Device.LocalAgent.Controller.1.MTP.1.WebSocket.EnableEncryption "false"
28+
Device.LocalAgent.Controller.1.MTP.1.WebSocket.KeepAliveInterval "30"
29+
Device.LocalAgent.Controller.1.MTP.1.WebSocket.SessionRetryMinimumWaitInterval "5"
30+
Device.LocalAgent.Controller.1.MTP.1.WebSocket.SessionRetryMinimumWaitInterval "2000"
31+
32+
# Agent's websocket server (for controller initiated sessions)
33+
Device.LocalAgent.MTP.1.WebSocket.Port "5683"
34+
Device.LocalAgent.MTP.1.WebSocket.Path ""
35+
Device.LocalAgent.MTP.1.WebSocket.EnableEncryption "true"
36+
Device.LocalAgent.MTP.1.WebSocket.KeepAliveInterval "30"
37+
38+
#
39+
# The following parameters may be modified
40+
#
41+
Device.LocalAgent.MTP.1.Alias "cpe-1"
42+
Device.LocalAgent.MTP.1.Enable "true"
43+
Device.LocalAgent.MTP.1.Protocol "WebSocket"
44+
Device.LocalAgent.Controller.1.Alias "cpe-1"
45+
Device.LocalAgent.Controller.1.Enable "true"
46+
Device.LocalAgent.Controller.1.AssignedRole "Device.LocalAgent.ControllerTrust.Role.1"
47+
Device.LocalAgent.Controller.1.PeriodicNotifInterval "86400"
48+
Device.LocalAgent.Controller.1.PeriodicNotifTime "0001-01-01T00:00:00Z"
49+
Device.LocalAgent.Controller.1.USPNotifRetryMinimumWaitInterval "5"
50+
Device.LocalAgent.Controller.1.USPNotifRetryIntervalMultiplier "2000"
51+
Device.LocalAgent.Controller.1.ControllerCode ""
52+
Device.LocalAgent.Controller.1.EndpointID "oktopusController"
53+
Device.LocalAgent.Controller.1.MTP.1.Alias "cpe-1"
54+
Device.LocalAgent.Controller.1.MTP.1.Enable "true"
55+
Device.LocalAgent.Controller.1.MTP.1.Protocol "WebSocket"
56+
Internal.Reboot.Cause "LocalFactoryReset"

obuspa

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 7a4d29b831bde4381b96aeaedfc659ad88e5d546

run-docker.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sed -i '/return USP_ERR_OK;/i\printf("Primera ocurrencia encontrada\\n");' vendor.c

test.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import os
2+
3+
transformed_data_clean = "transformed_data_clean"
4+
test = "test"
5+
6+
command = (r'''sed -i "/int VENDOR_Init(void)/{
7+
N;
8+
/{/{N;
9+
s/\$/\n\tint ''' + test + ''' = USP_REGISTER_DBParam_ReadWrite(\\"''' + transformed_data_clean + '''\\", \\"MyModelNumber\\", NULL, NULL, DM_STRING);\\n\\tif (''' + test + ''' != USP_ERR_OK)\\n\\t{\\n\\t\\treturn ''' + test + ''';\\n\\t}\\n/
10+
}
11+
}" vendor.c''')
12+
13+
os.system(command)

vendor.c

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
*
3+
* Copyright (C) 2019-2024, Broadband Forum
4+
* Copyright (C) 2016-2024 CommScope, Inc
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions
8+
* are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright
11+
* notice, this list of conditions and the following disclaimer.
12+
*
13+
* 2. Redistributions in binary form must reproduce the above copyright
14+
* notice, this list of conditions and the following disclaimer in the
15+
* documentation and/or other materials provided with the distribution.
16+
*
17+
* 3. Neither the name of the copyright holder nor the names of its
18+
* contributors may be used to endorse or promote products derived from
19+
* this software without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31+
* THE POSSIBILITY OF SUCH DAMAGE.
32+
*
33+
*/
34+
35+
/**
36+
* \file vendor.c
37+
*
38+
* Implements the interface to all vendor implemented data model nodes
39+
*
40+
*/
41+
42+
#include <stdio.h>
43+
#include <stdlib.h>
44+
#include <stdbool.h>
45+
46+
#include "usp_err_codes.h"
47+
#include "vendor_defs.h"
48+
#include "vendor_api.h"
49+
#include "usp_api.h"
50+
51+
/*********************************************************************//**
52+
**
53+
** VENDOR_Init
54+
**
55+
** Initialises this component, and registers all parameters and vendor hooks, which it implements
56+
**
57+
** \param None
58+
**
59+
** \return USP_ERR_OK if successful
60+
**
61+
**************************************************************************/
62+
int VENDOR_Init(void)
63+
{
64+
65+
return USP_ERR_OK;
66+
}
67+
68+
69+
/*********************************************************************//**
70+
**
71+
** VENDOR_Start
72+
**
73+
** Called after data model has been registered and after instance numbers have been read from the USP database
74+
** Typically this function is used to seed the data model with instance numbers or
75+
** initialise internal data structures which require the data model to be running to access parameters
76+
**
77+
** \param None
78+
**
79+
** \return USP_ERR_OK if successful
80+
**
81+
**************************************************************************/
82+
int VENDOR_Start(void)
83+
{
84+
85+
return USP_ERR_OK;
86+
}
87+
88+
/*********************************************************************//**
89+
**
90+
** VENDOR_Stop
91+
**
92+
** Called when stopping USP agent gracefully, to free up memory and shutdown
93+
** any vendor processes etc
94+
**
95+
** \param None
96+
**
97+
** \return USP_ERR_OK if successful
98+
**
99+
**************************************************************************/
100+
int VENDOR_Stop(void)
101+
{
102+
103+
return USP_ERR_OK;
104+
}
105+

0 commit comments

Comments
 (0)