u-blox / ubxlib

Portable C libraries which provide APIs to build applications with u-blox products and services. Delivered as add-on to existing microcontroller and RTOS SDKs.
Apache License 2.0
288 stars 84 forks source link

Assistance Requested for Configuring ubxlib for LEAN_R8 on Linux #210

Closed IssamSayyaf closed 3 months ago

IssamSayyaf commented 4 months ago

Hello,

I hope this message finds you well.

I am reaching out to seek your guidance on configuring the ubxlib library for use with the LEAN_R8 device on a Linux operating system. I have successfully cloned the repository and identified the specific components I need within the UBXLIB_FEATURES section of the linux.cmake file.

Following this, I executed the cmake command to configure the build environment and subsequently ran the test program, which performed as expected. However, my primary objective is to ensure that the compiled library is fully compatible with the LEAN_R8 device, which connects via USB and communicates using the Point-to-Point Protocol (PPP).

Could you please advise on the steps necessary to instruct the cmake build system to target the LEAN_R8 device specifically? My aim is to ensure seamless communication over USB with PPP protocol support. and if there are any examples of this.

I appreciate your time and look forward to your expert advice.

IssamSayyaf commented 3 months ago

Yeah, you're right about the mobile phone being the worst. Okay, I'll do it. Do you think using a different module, like the SARA R5 for example if there are no solutions on LEAN, would result in the same issue?

Because MQTT, and HTTP are vital for our application

RobMeades commented 3 months ago

It is only LENA-R8 that has this limitation. But remember that the problem is only with the clients inside the cellular module, i.e. those you would use through the ubxlib APIs. If you are planning to use PPP then you will, I assume, be using MQTT and HTTP clients that you will have installed on Linux, not the ones on the cellular module, I would guess...?

IssamSayyaf commented 3 months ago

Do you mean apply the MQTT, and HTTP from the Linux library and use the LENA just to send the messages through PPP? Did I understand correctly?

RobMeades commented 3 months ago

That is what you said at the start "...and communicates using the Point-to-Point Protocol (PPP)"...?

IssamSayyaf commented 3 months ago

Great! yeah just to be sure. Because my mission is to make everything work then the application team should build the application. yeah, I got it.

Anyway even after this modification, I still have the same error. The same problem.

RobMeades commented 3 months ago

Anyway even after this modification, I still have the same error.

Could you post the AT log output please?

IssamSayyaf commented 3 months ago

Yeah! sure this is the output.

log_LTE.txt

RobMeades commented 3 months ago

The log is the same:

AT+CGACT=1,2
+CME ERROR: operation not allowed
U_CELL_NET: unable to activate a PDP context, is APN "TM" correct?

You need to double-check that you defined U_CELL_PRIVATE_PPP_CONTEXT_ID_LENA_R8=-1 for the build of the ubxlib code.

IssamSayyaf commented 3 months ago

yeah I define them like this

export U_CELL_PRIVATE_PPP_CONTEXT_ID_LENA_R8=-1 export U_FLAGS="-DU_CFG_PPP_ENABLE"

then I applied cmake then make. I will check again

RobMeades commented 3 months ago

export U_CELL_PRIVATE_PPP_CONTEXT_ID_LENA_R8=-1 is defining the environment variable U_CELL_PRIVATE_PPP_CONTEXT_ID_LENA_R8 rather than defining a build flag U_CELL_PRIVATE_PPP_CONTEXT_ID_LENA_R8. You probably meant to do something like:

export U_FLAGS="-DU_CFG_PPP_ENABLE -DU_CELL_PRIVATE_PPP_CONTEXT_ID_LENA_R8=-1"
IssamSayyaf commented 3 months ago

Huge Thank you. it works finally, however, I can't find https://ubxlib.com/ for this reason I changed it to google. Currently, I am rebuilding the code.

I will come back with the update

RobMeades commented 3 months ago

Excellent!

can't find https://ubxlib.com/

Do you mean you are unable to resolve the IP address for ubxlib.com or that you are unable to connect to an HTTP server on ubxlib.com? If the latter, you need to use the correct port number for the HTTP echo server that is running on ubxlib.com.

IssamSayyaf commented 3 months ago

yeah, I can't resolve the IP address. I will fix it thanks. I will come back. Thanks

RobMeades commented 3 months ago

If you mean that ubxlib is unable to resolve the IP address for ubxlib.com, that will be because of LENA-R8: DNS look-up is a local client on the LENA-R8 module and it will not work if LENA-R8 has PPP using the PDP context I'm afraid.

Linux, of course, should be able to resolve the IP address of ubxlib.com through the PPP link.

IssamSayyaf commented 3 months ago

Still have some problems with the DNS! With Google, I was able to resolve the IP address however the program was stuck after this.

This is the log file for the ublox.com :8080

log_LTE.txt

RobMeades commented 3 months ago

Not sure I understand: I don't see any attempt to resolve ubxlib.com, or google.com in that AT log. Are you talking about Linux being able to resolve the DNS address, or ubxlib?

IssamSayyaf commented 3 months ago

OK U_CELL_NET: unable to read DNS addresses. AT+CMUX=0,0,,128

OK ATE0 ATE0

OK AT+CMEE=2

OK U_CELL_PPP: sent ATD*99*1#[0d] U_CELL_PPP: received ATD991#[0d][0d][0a]CONNECT[0d][0a] U_PORT_PPP: socket connected to module. Unable to find ubxlib.com (errno 11)! Taking down network...

IssamSayyaf commented 3 months ago

I will try with google now and send to you the log.

RobMeades commented 3 months ago

I'm not going to be able to determine why DNS address look-ups fail I'm afraid, that's a Linux/networking thing.

IssamSayyaf commented 3 months ago

For google.com:80. I think the situation is better. however I still have this DNS. and It stopped. If the problem from the OS. I will try to fix it just could you check this, and tell me your opnion.

log_LTE _google.txt

RobMeades commented 3 months ago

Well I can see that it found a Google server but of course, unless that Google server happens to be running a TCP echo server on whatever port you are connecting to then the example isn't going to do very much more.

ubxlib.com is a DNS address hosted on AWS so there should be no problem finding it.

IssamSayyaf commented 3 months ago

the model print this after the last line in the file

No reply received! Closing socket... Taking down network... U_CELL_PPP: sent ~[ff]}#[c0]!}%}"} }0User requestS3~ U_CELL_PPP: received ~[ff]}#[c0]!}%}"} }0User requestS3~ U_CELL_PPP: WARNING PPP did not terminate, it may not connect next time, you may wish to reboot the module. U_PORT_PPP: socket disconnected from module (but pppd still connected to socket). AT+COPS?

+COPS: 0,0,"Orange F",7

OK AT+CFUN=4

OK

+CREG: 0,"0000","0000",0

+CEREG: 0,"0000","00000000", 0,,,"00000000","00000000"

+CREG: 0,"0000","0000"

+CGREG: 0,"0000","0000" -1: NReg -1: NReg -1: NReg -1: NReg U_CELL_NET: disconnected. AT+CEER

+CEER:No Error Call

OK Closing device... Deinitializing ubxlib... U_PORT_PPP: pppd has been disconnected from socket. U_PORT_PPP: no longer listening for pppd on socket. Done.

RobMeades commented 3 months ago

the model print this after the last line in the file

Not sure I understand?

IssamSayyaf commented 3 months ago

I will try again with ubxlib.com I mean yeah as you told me because there are no server to make an echo so it doesn't receive any reply the problem with ubxlib.com I will check again.

IssamSayyaf commented 3 months ago

unfortently, Unable to find ubxlib.com (errno 11)! the same problem for ubxlib.com. I don't know what is the problem. If you have an idea please share it with me. Huge thanks in advance

+CGCONTRDP: 1,6,"TM.mnc050.mcc234.gprs","10.6.57.92.0.0.0.0"

OK U_CELL_NET: unable to read DNS addresses. AT+CMUX=0,0,,128

OK ATE0 ATE0

OK AT+CMEE=2

OK U_CELL_PPP: sent ATD*991#[0d] U_CELL_PPP: received ATD99**1#[0d][0d][0a]CONNECT[0d][0a] U_PORT_PPP: socket connected to module. Unable to find ubxlib.com (errno 11)! Taking down network... U_CELL_PPP: sent ~[ff]}#[c0]!}%}"} }0User requestS3~ U_CELL_PPP: received ~[ff]}#[c0]!}%}"} }0User requestS3~ U_CELL_PPP: WARNING *** PPP did not terminate, it may not connect next time, you may wish to reboot the module. U_PORT_PPP: socket disconnected from module (but pppd still connected to socket). AT+COPS?

+COPS: 0,0,"Orange F",7

OK AT+CFUN=4

OK

+CREG: 0,"0000","0000",0

+CEREG: 0,"0000","00000000", 0,,,"00000000","00000000"

+CREG: 0,"0000","0000"

+CGREG: 0,"0000","0000" -1: NReg -1: NReg -1: NReg -1: NReg U_CELL_NET: disconnected. AT+CEER

+CEER:No Error Call

OK Closing device... Deinitializing ubxlib... U_PORT_PPP: pppd has been disconnected from socket. U_PORT_PPP: no longer listening for pppd on socket. Done.

RobMeades commented 3 months ago

It is definitely there because I can resolve it on the internet from the laptop in front of me:

Pinging ubxlib.com [18.133.144.142]...

You could try using the IP address instead if DNS is failing you.

IssamSayyaf commented 3 months ago

Hello, I think the problem is from the server, ubxlib.com when I tried to implement ping ubxlib.com. I didn't receive anything from the server. With Google, I can resolve the domain. and I think the problem is the server itself ubxlib.com

Anyway, I still have a strange message.

U_CELL_NET: unable to read DNS addresses. AT+CMUX=0,0,,128

RobMeades commented 3 months ago

Hello, I think the problem is from the server, ubxlib.com when I tried to implement ping ubxlib.com. I didn't receive anything from the server.

Can you explain what you mean? I can use ping from my laptop here and ping resolves the IP address of ubxlib.com successfully. The server will NOT respond to ping, it is not meant to, but it will accept TCP connections on port 5055, which is what the example does: I know 'cos it is doing it now!

You will get the message U_CELL_NET: unable to read DNS addresses. because LENA-R8 does not support reading the DNS addresses it has been assigned:

https://github.com/u-blox/ubxlib/blob/a2d986e2944141176eedaee6dc4be87be7eea57b/cell/api/u_cell_net.h#L859-L863

IssamSayyaf commented 3 months ago

Finally, I received something from the server it was 400 bad requests. Huge thank. Oh god, it is very complex :). log_LTE.txt

RobMeades commented 3 months ago

Eh? Which port are you making your TCP connection to on ubxlib.com? Port 5055 on ubxlib.com is a TCP echo server, it cannot possibly return an HTTP response!

IssamSayyaf commented 3 months ago

5055 it doesn't work at all. I tried to connect with http 8080 :( however, Do you think the problem was from the server, or I had a problem with my code?

IssamSayyaf commented 3 months ago

I will try again, hold on. I don't know maybe I made a mistake

IssamSayyaf commented 3 months ago

this the output with 5055. unable to connect to server.

U_CELL_PPP: sent ATD*99*1#[0d] U_CELL_PPP: received ATD991#[0d][0d][0a]CONNECT[0d][0a] U_PORT_PPP: socket connected to module. Found 18.133.144.142 at 18.133.144.142. Unable to connect to server (errno 101)! Closing socket... Taking down network...

+CREG: 5,"35c5","00dcf205",7 7: RegR

RobMeades commented 3 months ago

Well, I can't explain that. Here I can open PuTTY, ask to open a raw socket to ubxlib.com (or 18.133.144.142) on port 5055 and, when I type in the PuTTY terminal, what I type is echoed back to me (on a line-buffered basis). So the server is accepting connections on port 5055, just for some reason your Linux box doesn't want to make one.

image

Anyway, getting something back from port 8080 of ubxlib.com, which is of course the port for the HTTP echo server running on the same machine, is good enough proof that connectivity is working as expected.

IssamSayyaf commented 3 months ago

Yeah! I agree, it is good enough to say everything is working well! Thank you very much! For your support, I appreciate a lot your help. A huge thank you. The work with your company is more than brilliant.

RobMeades commented 3 months ago

Thanks! Good to get you working this far.

IssamSayyaf commented 3 months ago

Hello, I am here again, I am sorry. I need to build an example based on http.

I tried the http client example, and it works, but it can't create a http connection. I will attache the log, and the issam_LTE.c If you can help me. I think the error coming from this

pContext = pUHttpClientOpen(devHandle, &connection, &tlsSettings); if (pContext != NULL)

log.txt

issam_LTE.txt

RobMeades commented 3 months ago

This is never going to work I'm afraid; remember what I said above.

LENA-R8 has a limitation that it will not let you use the same PDP context for the internal module clients (MQTT, HTTP, sockets) and for PPP...

...you can try defining the conditional compilation flag U_CELL_PRIVATE_PPP_CONTEXT_ID_LENA_R8=-1 when compiling the ubxlib code. As I say the on-board module clients for MQTT, HTTP and sockets won't work with that set but it should allow you to use PPP with a single PDP context...

...remember that the problem is only with the clients inside the cellular module, i.e. those you would use through the ubxlib APIs. If you are planning to use PPP then you will, I assume, be using MQTT and HTTP clients that you will have installed on Linux, not the ones on the cellular module...

[also described here] So if you want to use PPP with LENA-R8, with the SIM card/cellular network you have, you CANNOT use the uSock, uHttp or uMqtt APIs, And in any case, as noted here the uHttp API would not work on LENA-R8, even if you did have a SIM card/cellular network that supported two PDP contexts.

You need to use a HTTP client on Linux, not from ubxlib; Linux will then form the HTTP connection etc. over the PPP connection.

IssamSayyaf commented 3 months ago

Update: I am reading the link that you provided to me.

so, I am a little bit confused, Could you give me a small example how will I configure the hardware, and then send the message using http for example.

Just a small example, I think I need to use ublox.h to configure the LENA_R8.

IssamSayyaf commented 3 months ago

I solved it works. Thanks, I will share with you just to check if there are any problem

OK U_CELL_PPP: sent ATD*99*1#[0d] U_CELL_PPP: received ATD991#[0d][0d][0a]CONNECT[0d][0a] U_PORT_PPP: socket connected to module. getaddrinfo is done... Create socket is done.. Connect is done.. prepare the request is done.. Write the request is done.. HTTP/1.1 200 OK Content-Type: text/html; charset=utf-8 Last-Modified: Fri, 05 Apr 2024 15:40:56 GMT Date: Sat, 06 Apr 2024 22:53:21 GMT Content-Length: 13 Connection: close


Read the response is done.. Taking down network... U_CELL_PPP: sent ~[ff]}#[c0]!}%}"} }0User requestS3~ U_CELL_PPP: received ~[ff]}#[c0]!}%}"} }0User requestS3~ U_CELL_PPP: WARNING PPP did not terminate, it may not connect next time, you may wish to reboot the module. U_PORT_PPP: socket disconnected from module (but pppd still connected to socket). AT+COPS?

+COPS: 0,0,"Orange F",7

OK AT+CFUN=4

OK

+CREG: 0,"0000","0000",0

+CEREG: 0,"0000","00000000", 0,,,"00000000","00000000"

+CREG: 0,"0000","0000"

+CGREG: 0,"0000","0000" -1: NReg -1: NReg -1: NReg -1: NReg U_CELL_NET: disconnected. AT+CEER

+CEER:No Error Call

OK U_PORT_PPP: pppd has been disconnected from socket. U_PORT_PPP: no longer listening for pppd on socket. Done.

RobMeades commented 3 months ago

Excellent: I can't tell from the log but I guess that around the prints "Connect is done..", "prepare the request is done..", "Write the request is done.." and "Read the response is done.." you are performing your HTTP client operations in Linux, which is the right place to do them for the way you have chosen to use LENA-R8 (i.e. via PPP).

IssamSayyaf commented 3 months ago

Great! I am happy thank you. A huge thank you.

Now, I can go forward to see the GNSS I hope will be easy. :)

RobMeades commented 3 months ago

Ref. GNSS and LENA-R8, note the first bullet point here. If you want "easy" you chose the wrong module ;-).

RobMeades commented 3 months ago

To be specific, for whatever reason, we did not include support for access to the built-in GNSS chip in LENA-R8 over CMUX, the protocol which allows you to run AT commands (and PPP) at the same time as using the UBX protocol to talk to the GNSS chip, all over the same UART.

EDIT: there should be no need to define U_NETWORK_GNSS_CFG_CELL_USE_AT_ONLY as indicated in an earlier version of this message; the ubxlib code will fall back to AT+UGUBX operation if CMUX activation for GNSS fails.

HOWEVER, AT+UGUBX will only get you "polled" position, i.e. the ubxlib code can ask for position, sending an AT+UGUBX command, and get the answer back, you CANNOT get "streamed" position, i.e. tell the built-in GNSS chip to send position at a given rate (e.g. once per second) and simply receive the answer; AT commands don't work that way, they are always "ask and get response", so you cannot use any of the position APIs that have continuous in the name.

If you want to obtain streamed/continuous position, you must do as it says in the link above: physically connect either the secondary UART or the USB port of the cellular module to a second input on your MCU and receive GNSS position that way.

IssamSayyaf commented 3 months ago

Okay, thank you very much. I think we will communicate with it using a different port, specifically a UART. I'll study it, build the example, and then get back to you. Moreover, could you suggest another model from UBLOX that supports LTE-CAT1 and GNSS and is compatible with all the capabilities in the repo?

RobMeades commented 3 months ago

could you suggest another model from UBLOX that supports LTE-CAT1 and GNSS and is compatible with all the capabilities in the repo

LARA-R6 is LTE Cat 1 but we don't release a variant with GNSS inside I'm afraid, so you're stuck with LENA-R8, that or LARA-R6 and a separate GNSS chip. There shouldn't be an issue with using the built-in GNSS device via the secondary UART or USB, it just needs a bit more work in SW terms, being an unusual arrangement, and, since you are using PPP so as to get a cellular-based IP transport into the Linux kernel, not being able to use the HTTP client on-board the cellular module shouldn't be a particular issue.

IssamSayyaf commented 2 months ago

Hello, Good evening,

I hope you are doing well! I have a small question, when I tried to connect with the GNSS through the UART peripheral directly, I couldn't see ttyUSBX, or anything that allowed me to communicate with the UART.

Do you have any advice? This is the code that I am working on. Should I see the device under /dev/?

issam_GNSS.txt

RobMeades commented 2 months ago

Hi, good evening. You will first need to call uDeviceOpen() on the cellular module, since the GNSS module is inside the cellular module it won't be powered up or available or anything unless you do that.

Once the cellular module is open you will need to call uCellCfgSetGnssProfile() to tell the cellular module where you would like the GNSS information to be routed; please consult the AT+UGPRF AT command in the LENA-R8 AT manual to find the bit-map you need for the auxiliary UART (I think it is probably 1).

With that done and the secondary UART connected to your MCU you should hopefully be able to call uDeviceOpen() on it as a GNSS device, as you have done in the code you have attached.

IssamSayyaf commented 2 months ago

Okay, great I will follow these instructions. Thank you very much.

Can I use LTE and GNSS at the same time? Will not be a problem!

RobMeades commented 2 months ago

Can I use LTE and GNSS at the same time?

I can't see a reason why that would be a problem.