FTP CLIENT COMMUNICATION METHOD WITH SPRESENCE LTE EXTENSION BOARD

Asked 2 years ago, Updated 2 years ago, 457 views

With the configuration of the Spresense body board + LTE expansion board, we would like to provide access (file write, file read) from the FTP client of the Spresense to the FTP server on the network server.
The Network Tutorial provides an example of an FTP Sample Application, which assumes a WiFi environment (with IDY Wi-Fi Add-on Board iS110B).
Therefore, could you tell me how to change this FTP sample application from WiFi to LTE-M?
Although LTE-M-related settings are self-resolved, I think WiFi is compatible with LTE at TCP/IP level, so it would be helpful if it could be realized by setting something.
My ultimate goal is to upload IoT data regularly to file servers via LTE-M.

spresense ftp

2022-09-30 21:56

4 Answers

Although the answer is not to say "don't worry", I think the following implementation will be helpful.

https://github.com/sonydevworld/spresense/tree/master/examples/lte_http_get

Here, I am communicating with the HTTP server via wget_initialize, and when I hooked it with grep, there was an implementation in the following places:

https://github.com/sonydevworld/spresense-nuttx-apps/blob/new-master/netutils/webclient/webclient.c
Note) If you download the Spresense SDK, it will be expanded below spresense/sdk/apps/netutils.It's a little hard to understand around here...

As you can see in webclinet.c, this is a common programming using socket.

Therefore, I think we should bring the Lte connection part in the lte_http_get sample and replace the wget_initialize(), wget() parts with FTP.If you write the broken cord as much as you can, it will look like this.

 int main (intargc, FAR char*argv[])
{
  ... Omitted....

  app_mq_create(APP_MQUEUE_NAME);
  lte_initialize();
  lte_set_report_restart(app_restart_cb);
  lte_power_on();
  lte_set_report_localtime(app_localtime_report_cb);
  lte_radio_on_sync();

  /* Set the APN to be connected.*/
  ... Omitted...
  lte_activate_pdn_sync(&apnsetting, &pdn);
  app_show_pdn(&pdn);
  data_pdn_sid = pdn.session_id;

  ... Omitted...

  /* ↓Write FTP socket code implementation here↓*/

 FTP initialization
 Connect to FTP Server
 Send data to FTP server

  /* ↑Write FTP socket code implementation here↑*/

  lte_deactivate_pdn_sync(data_pdn_sid);
  lte_radio_off_sync();
  lte_power_off();
  lte_finalize();
  app_mq_delete(APP_MQUEUE_NAME);

  return 0;
}

For FTP client socket implementation, the following sites may be helpful.For your information.

http://x68000.q-e-d.net/~68user/net/c-ftp-1.html


2022-09-30 21:56

In the SDK for Spresense, click
sdk/configs/examples/ftp/defconfig and
sdk/configs/examples/lte_http_get/defconfig

Compared to the FTP client, the difference is
+EXAMPLES_FTPC=y
+NETUTILS_FTPC=y
That's all.

In the build configuration,
$./tools/config.py examples/lte_http_get
and
$make menuconfig
In the , open the menu configuration and click

"Application Configuration" - > "Network Utilities"
in
"FTP client"
Enable and

"Application Configuration" - > "Examples"
in
"FTP client example"

after you enable
I think you can use ftpc with NuttShell.

I don't have an LTE board, so
I haven't tried it yet, so it's just a reference, but
Try it.


2022-09-30 21:56

As the second answer, based on lte_http_get, enable the following two configurations and
 "Application Configuration" - > "Network Utilities" - > "FTP client"
 "Application Configuration" - > "Examples" - > "FTP client example"
Also, by enabling LTE daemon, communication (also called put/get) to FTP servers on the Internet via LTE-M has been made!
However, there is one task left.
ftpc "..." and IP address direct typing (the global IP address of the FTP server) succeeded, but when I tried to connect with the domain name (e.g., aaa.bbb.com), I got an error and couldn't connect.
nsh>ftpc ftp://aaa.bbb.com
nsh>ftpc aaa.bbb.com
Either way, you get an error.
"The sample ""lte_http_get"" works fine with the domain name specification like ""http://www.example.com"", so the DNS server settings (below) seem to be good as they are."
+NETDB_DNSCLIENT=y
+NETDB_DNSCLIENT_MAXRESPONSE=176
+NETDB_DNSCLIENT_NAMESIZE=255
+NETDB_DNSSERVER_IPv4ADDR=0x80808
Therefore, when LTE debugging was enabled in the configuration and the error output was output as follows.
nsh>ftpc ftp://aaa.bbb.com
[ERR] getsockname_request: 134 API command response is err: 128.
[ERR] 2343 altcom_getsockname() failed=-128
Failed to connect to the server:9

The FTP server (ftp://aaa.bbb.com) is accessible from the PC (without SSL).
Is there something wrong with the settings?Or is there a restriction that only IP addressing works for the FTP client sample in Spresense?
(As I do not own the WiFi Add-on Board, I have not been able to verify the operation of FTP client+ domain designation via WiFi.The IP address of the FTP server on the Internet is subject to change, so I would like to use the domain name for access.


2022-09-30 21:56

In addition to both of you, I would like to comment on two points.

Regarding the first point, it seems that the current FTP client sample only supports IP addressing as per the help text.
Therefore, if you want to use the sample as it is, check the IP beforehand.

nsh>ftp xx.xx.xx.xx

The only way to do this is to specify the IP directly as shown in .
When you write an application, you must use a function such as getaddrinfo to convert the domain to IP.

Second, I checked the code of the FTP client sample and it seems that they are switching the type of IP address (IPv4/IPv6) specified by the configuration.
Both IPv4 and IPv6 are currently enabled for examples/lte_http_get, so you must specify an IPv6 address in this sample.
To avoid this, use the

./tools/config.py-m

After opening the menuconfig in

Networking Support --- >
  Internet Protocol Selection --- >
    IPv6 ★ Uncheck this check

It seems that you need to make configuration changes such as

With the above changes, I was able to confirm the FTP client via LTE communication in my environment.

(If you do lte_daemon start/ifup eth0, you can see how ftp xx:xx:xx:xx)

I hope it will be helpful.


2022-09-30 21:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.