pkarashchenko commented on code in PR #1349: URL: https://github.com/apache/incubator-nuttx-apps/pull/1349#discussion_r996262853
########## examples/client_tcp/protocol.h: ########## @@ -0,0 +1,41 @@ +/**************************************************************************** + * apps/examples/client_tcp/protocol.h + * + * 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. + * + ****************************************************************************/ + +#ifndef __APPS_EXAMPLES_CLIENT_TCP_PROTOCOL_H +#define __APPS_EXAMPLES_CLIENT_TCP_PROTOCOL_H + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +typedef struct __attribute__((__packed__)) Review Comment: Let's use defines from compiler.h ########## examples/server_tcp/Server_main.c: ########## @@ -0,0 +1,274 @@ +/**************************************************************************** + * apps/examples/server_tcp/Server_main.c + * + * 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. + * + ****************************************************************************/ + +/* This program consists of a server socket & custom messages to establish + * IPC for multiple applications (clients) and one process that controls + * LoRaWAN connectivity (server). Both client and server work on local + * network. + * For more details about client side, see client-tcp example. + * + * IMPORTANT NOTE: + * + * In order to test client_tcp & server_tcp together, there are two + * ways to proceed: + * + * 1) Init server manually (command: SERVER &), and after successfull + * server init, also init client manually (CLIENT 127.0.0.1) + * 2) init server automatically after boot using NuttShell start up scripts: + * https://nuttx.apache.org/docs/latest/applications/nsh/installation.html#nuttshell-start-up-scripts + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <stdio.h> +#include <stdlib.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <string.h> +#include <arpa/inet.h> +#include <fcntl.h> +#include <unistd.h> +#include <pthread.h> + +#include "protocol.h" +#include <uart_lorawan_layer.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static int socket_clients_counter = 0; Review Comment: ```suggestion static int socket_clients_counter; ``` ########## examples/server_tcp/lorawan/uart_lorawan_layer.h: ########## @@ -0,0 +1,57 @@ +/**************************************************************************** + * apps/examples/server_tcp/lorawan/uart_lorawan_layer.h + * + * 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. + * + ****************************************************************************/ + +#ifndef __APPS_EXAMPLES_SERVER_TCP_LORAWAN_H Review Comment: Does not match the file path ########## examples/tcp_ipc_server/lorawan/uart_lorawan_layer.h: ########## @@ -0,0 +1,57 @@ +/**************************************************************************** + * apps/examples/server_tcp/lorawan/uart_lorawan_layer.h + * + * 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. + * + ****************************************************************************/ + +#ifndef __APPS_EXAMPLES_SERVER_TCP_LORAWAN_H Review Comment: Does not match the file path ########## examples/tcp_ipc_client/protocol.h: ########## @@ -0,0 +1,41 @@ +/**************************************************************************** + * apps/examples/tcp_ipc_client/protocol.h + * + * 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. + * + ****************************************************************************/ + +#ifndef __APPS_EXAMPLES_CLIENT_TCP_PROTOCOL_H Review Comment: Does not match the file path ########## examples/server_tcp/lorawan/uart_lorawan_layer.h: ########## @@ -0,0 +1,57 @@ +/**************************************************************************** + * apps/examples/server_tcp/lorawan/uart_lorawan_layer.h + * + * 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. + * + ****************************************************************************/ + +#ifndef __APPS_EXAMPLES_SERVER_TCP_LORAWAN_H +#define __APPS_EXAMPLES_SERVER_TCP_LORAWAN_H + +/**************************************************************************** + * Definitions + ****************************************************************************/ +#define APP_SESSION_KEY_SIZE 60 +#define NW_SESSION_KEY_SIZE 60 +#define APP_EUI_SIZE 30 +#define DEVICE_ADDRESS_SIZE 15 +#define CHANNEL_MASK_SIZE 35 + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +typedef struct __attribute__((__packed__)) Review Comment: Let's use defines from compiler.h -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org