Skip to content

Commit ce756dc

Browse files
committed
Merge branch '98-split-alp_layer-and-d7' into 'master'
Resolve "Split alp_layer and D7" Closes Sub-IoT#98 See merge request aloxy/oss-7!65
2 parents 44be049 + da1b6dd commit ce756dc

37 files changed

+1245
-998
lines changed

stack/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ ELSE()
7474
include ("cmake/platform_default_macros.cmake")
7575
ENDIF()
7676

77-
SET(MODULE_D7AP true CACHE BOOLEAN "") # D7AP module enabled by default
78-
SET(MODULE_ALP true CACHE BOOLEAN "") # ALP module enabled by default
77+
SET(MODULE_D7AP ON CACHE BOOLEAN "") # D7AP module enabled by default
78+
SET(MODULE_D7AP_FS ON CACHE BOOLEAN "") # D7AP_FS module enabled by default
79+
SET(MODULE_ALP ON CACHE BOOLEAN "") # ALP module enabled by default
7980

8081
#Then load the modules
8182
ADD_SUBDIRECTORY("modules")

stack/apps/gateway/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
#SET_PROPERTY(CACHE ${APP_PREFIX}_<param_name> PROPERTY STRINGS "value1;value2")
3030
#
3131
IF(${MODULE_LORAWAN})
32-
SET(libs alp d7ap lorawan framework)
32+
SET(libs alp d7ap d7ap_fs lorawan framework)
3333
ELSE()
34-
SET(libs alp d7ap framework)
34+
SET(libs alp d7ap d7ap_fs framework)
3535
ENDIF()
3636

3737
APP_BUILD(NAME ${APP_NAME} SOURCES app.c LIBS ${libs})

stack/apps/gateway/app.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
}
6262
#endif
6363

64-
static void on_unsolicited_response_received(d7ap_session_result_t d7asp_result, uint8_t *alp_command, uint8_t alp_command_size)
64+
static void on_unsolicited_response_received(alp_interface_status_t* result, uint8_t *alp_command, uint8_t alp_command_size)
6565
{
6666
#if PLATFORM_NUM_LEDS > 0
6767
led_blink();

stack/apps/modem/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
#
3131

3232
IF(${MODULE_LORAWAN})
33-
SET(libs alp d7ap lorawan framework)
33+
SET(libs alp d7ap d7ap_fs lorawan framework)
3434
ELSE()
35-
SET(libs alp d7ap framework)
35+
SET(libs alp d7ap d7ap_fs framework)
3636
ENDIF()
3737

3838
APP_BUILD(NAME ${APP_NAME} SOURCES modem.c LIBS ${libs})

stack/apps/sensor_action/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
#
3131

3232
IF(${MODULE_LORAWAN})
33-
SET(libs alp d7ap lorawan framework)
33+
SET(libs alp d7ap d7ap_fs lorawan framework)
3434
ELSE()
35-
SET(libs alp d7ap framework)
35+
SET(libs alp d7ap d7ap_fs framework)
3636
ENDIF()
3737

3838
APP_BUILD(NAME ${APP_NAME} SOURCES sensor.c LIBS ${libs})

stack/apps/sensor_action/sensor.c

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,34 @@ void init_user_files()
101101
d7ap_fs_init_file(ACTION_FILE_ID, &action_file_header, alp_command);
102102

103103
// define the D7 interface configuration used for sending the result of above ALP command on
104-
d7ap_session_config_t session_config = {
105-
.qos = {
106-
.qos_resp_mode = SESSION_RESP_MODE_NO,
107-
.qos_retry_mode = SESSION_RETRY_MODE_NO
108-
},
109-
.dormant_timeout = 0,
110-
.addressee = {
111-
.ctrl = {
112-
.nls_method = AES_NONE,
113-
.id_type = ID_TYPE_NOID,
114-
},
115-
.access_class = 0x01,
116-
.id = 0
104+
alp_interface_config_t itf_cfg = {
105+
.itf_id = ALP_ITF_ID_D7ASP,
106+
.d7ap_session_config = {
107+
.qos = {
108+
.qos_resp_mode = SESSION_RESP_MODE_NO,
109+
.qos_retry_mode = SESSION_RETRY_MODE_NO
110+
},
111+
.dormant_timeout = 0,
112+
.addressee = {
113+
.ctrl = {
114+
.nls_method = AES_NONE,
115+
.id_type = ID_TYPE_NOID,
116+
},
117+
.access_class = 0x01,
118+
.id = 0
119+
}
117120
}
118121
};
119122

120-
d7ap_fs_init_file_with_d7asp_interface_config(INTERFACE_FILE_ID, &session_config);
123+
d7ap_fs_file_header_t itf_file_header = (d7ap_fs_file_header_t){
124+
.file_properties.action_protocol_enabled = 0,
125+
.file_properties.storage_class = FS_STORAGE_PERMANENT,
126+
.file_permissions = 0, // TODO
127+
.length = sizeof(alp_interface_config_t),
128+
.allocated_length = sizeof(alp_interface_config_t),
129+
};
130+
131+
d7ap_fs_init_file(INTERFACE_FILE_ID, &itf_file_header, (const uint8_t *)&itf_cfg);
121132

122133
// finally, register the sensor file, configured to use D7AActP
123134
d7ap_fs_file_header_t file_header = (d7ap_fs_file_header_t){

stack/apps/sensor_multimodal/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@
2929
#SET_PROPERTY(CACHE ${APP_PREFIX}_<param_name> PROPERTY STRINGS "value1;value2")
3030
#
3131

32-
APP_BUILD(NAME ${APP_NAME} SOURCES sensor_multimodal.c LIBS alp d7ap lorawan framework)
32+
APP_BUILD(NAME ${APP_NAME} SOURCES sensor_multimodal.c LIBS alp d7ap d7ap_fs lorawan framework)

stack/apps/sensor_multimodal/sensor_multimodal.c

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,22 @@ network_driver_t* current_network_driver;
7171
static alp_init_args_t alp_init_args;
7272

7373
// Define the D7 interface configuration used for sending the ALP command on
74-
static d7ap_session_config_t session_config = {
75-
.qos = {
76-
.qos_resp_mode = SESSION_RESP_MODE_ANY,
77-
.qos_retry_mode = SESSION_RETRY_MODE_NO
78-
},
79-
.dormant_timeout = 0,
80-
.addressee = {
81-
.ctrl = {
82-
.nls_method = AES_NONE,
83-
.id_type = ID_TYPE_NOID,
74+
static alp_interface_config_t itf_cfg = {
75+
.itf_id = ALP_ITF_ID_D7ASP,
76+
.d7ap_session_config = {
77+
.qos = {
78+
.qos_resp_mode = SESSION_RESP_MODE_ANY,
79+
.qos_retry_mode = SESSION_RETRY_MODE_NO
8480
},
85-
.access_class = 0x01,
86-
.id = 0
81+
.dormant_timeout = 0,
82+
.addressee = {
83+
.ctrl = {
84+
.nls_method = AES_NONE,
85+
.id_type = ID_TYPE_NOID,
86+
},
87+
.access_class = 0x01,
88+
.id = 0
89+
}
8790
}
8891
};
8992

@@ -99,13 +102,21 @@ void on_alp_command_completed_cb(uint8_t tag_id, bool success) {
99102
log_print_string("Command failed, no ack received");
100103
}
101104

102-
void on_alp_command_result_cb(d7ap_session_result_t result, uint8_t* payload, uint8_t payload_length) {
103-
log_print_string("recv response @ %i dB link budget from:", result.link_budget);
104-
log_print_data(result.addressee.id, 8);
105+
void on_alp_command_result_cb(alp_interface_status_t* result, uint8_t* payload, uint8_t payload_length) {
106+
if(result->itf_id == ALP_ITF_ID_D7ASP) {
107+
d7ap_session_result_t d7_result;
108+
memcpy(&d7_result, result->itf_status, result->len);
109+
log_print_string("recv response @ %i dB link budget from:", d7_result.link_budget);
110+
log_print_data(d7_result.addressee.id, 8);
111+
}
112+
113+
log_print_string("response payload:");
114+
log_print_data(payload, payload_length);
115+
105116
}
106117

107118
static uint8_t transmit_d7ap(uint8_t* alp, uint16_t len) {
108-
alp_layer_execute_command_over_d7a(alp, len, &session_config);
119+
alp_layer_execute_command_over_itf(alp, len, &itf_cfg);
109120
return 0;
110121
}
111122

stack/apps/sensor_pull/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@
2929
#SET_PROPERTY(CACHE ${APP_PREFIX}_<param_name> PROPERTY STRINGS "value1;value2")
3030
#
3131

32-
APP_BUILD(NAME ${APP_NAME} SOURCES sensor_pull.c LIBS alp d7ap framework)
32+
APP_BUILD(NAME ${APP_NAME} SOURCES sensor_pull.c LIBS alp d7ap d7ap_fs framework)

stack/apps/sensor_push/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
#
3131

3232
IF(${MODULE_LORAWAN})
33-
SET(libs alp d7ap lorawan framework)
33+
SET(libs alp d7ap d7ap_fs lorawan framework)
3434
ELSE()
35-
SET(libs alp d7ap framework)
35+
SET(libs alp d7ap d7ap_fs framework)
3636
ENDIF()
3737

3838
APP_BUILD(NAME ${APP_NAME} SOURCES sensor_push.c LIBS ${libs})

stack/apps/sensor_push/sensor_push.c

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,13 @@
5454
static i2c_handle_t* hts221_handle;
5555
#endif
5656

57+
uint8_t alp_command[128];
58+
5759
// Define the D7 interface configuration used for sending the ALP command on
58-
static d7ap_session_config_t session_config = {
60+
61+
static alp_interface_config_t itf_config = (alp_interface_config_t){
62+
.itf_id = ALP_ITF_ID_D7ASP,
63+
.d7ap_session_config = {
5964
.qos = {
6065
.qos_resp_mode = SESSION_RESP_MODE_PREFERRED,
6166
.qos_retry_mode = SESSION_RETRY_MODE_NO
@@ -67,8 +72,9 @@ static d7ap_session_config_t session_config = {
6772
.id_type = ID_TYPE_NOID,
6873
},
6974
.access_class = 0x01,
70-
.id = 0
75+
.id = { 0 }
7176
}
77+
}
7278
};
7379

7480
void execute_sensor_measurement()
@@ -85,17 +91,18 @@ void execute_sensor_measurement()
8591
// Generate ALP command.
8692
// We will be sending a return file data action, without a preceding file read request.
8793
// This is an unsolicited message, where we push the sensor data to the gateway(s).
88-
89-
// allocate a buffer and fifo to store the command
90-
uint8_t alp_command[128];
9194
fifo_t alp_command_fifo;
9295
fifo_init(&alp_command_fifo, alp_command, sizeof(alp_command));
9396

97+
alp_append_forward_action(&alp_command_fifo, (alp_interface_config_t*)&itf_config, sizeof(itf_config));
98+
9499
// add the return file data action
95100
alp_append_return_file_data_action(&alp_command_fifo, SENSOR_FILE_ID, 0, SENSOR_FILE_SIZE, (uint8_t*)&temperature);
96101

97102
// and execute this
98-
alp_layer_execute_command_over_d7a(alp_command, fifo_get_size(&alp_command_fifo), &session_config);
103+
//alp_layer_execute_command_over_itf(alp_command, fifo_get_size(&alp_command_fifo), &session_config);
104+
alp_layer_process_command(alp_command, fifo_get_size(&alp_command_fifo), ALP_ITF_ID_HOST, NULL);
105+
99106
}
100107

101108
void on_alp_command_completed_cb(uint8_t tag_id, bool success)
@@ -109,10 +116,17 @@ void on_alp_command_completed_cb(uint8_t tag_id, bool success)
109116
timer_post_task_delay(&execute_sensor_measurement, SENSOR_INTERVAL_SEC);
110117
}
111118

112-
void on_alp_command_result_cb(d7ap_session_result_t result, uint8_t* payload, uint8_t payload_length)
119+
void on_alp_command_result_cb(alp_interface_status_t* result, uint8_t* payload, uint8_t payload_length)
113120
{
114-
log_print_string("recv response @ %i dB link budget from:", result.link_budget);
115-
log_print_data(result.addressee.id, 8);
121+
if(result->itf_id == ALP_ITF_ID_D7ASP) {
122+
d7ap_session_result_t d7_result;
123+
memcpy(&d7_result, result->itf_status, result->len);
124+
log_print_string("recv response @ %i dB link budget from:", d7_result.link_budget);
125+
log_print_data(d7_result.addressee.id, 8);
126+
}
127+
128+
log_print_string("response payload:");
129+
log_print_data(payload, payload_length);
116130
}
117131

118132
static alp_init_args_t alp_init_args;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#
2+
# OSS-7 - An opensource implementation of the DASH7 Alliance Protocol for ultra
3+
# lowpower wireless sensor communication
4+
#
5+
# Copyright 2015 University of Antwerp
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
#See the explanation of APP_OPTION and APP_PARAM in cmake/app_macros.cmake
21+
#for details on how to add application-specific CMake GUI entries
22+
23+
#By convention, application parameters should be prefixed with '${APP_PREFIX}'
24+
#Some examples:
25+
#APP_OPTION(${APP_PREFIX}_<option_name> "Option explanation" <default_value>)
26+
#APP_PARAM(${APP_PREFIX}_<param_name> "<default_value>" <type> "Parameter explanation")
27+
#
28+
#Cache properties can be set on application parameters just like on regular cache parameters
29+
#SET_PROPERTY(CACHE ${APP_PREFIX}_<param_name> PROPERTY STRINGS "value1;value2")
30+
#
31+
32+
IF(${MODULE_LORAWAN})
33+
SET(libs d7ap d7ap_fs lorawan framework)
34+
ELSE()
35+
SET(libs d7ap d7ap_fs framework)
36+
ENDIF()
37+
38+
APP_BUILD(NAME ${APP_NAME} SOURCES sensor_without_alp.c LIBS ${libs})

0 commit comments

Comments
 (0)