nerves-networking / vintage_net_mobile

Mobile networking for VintageNet
Apache License 2.0
27 stars 11 forks source link

sisCOM modules SIM7xxx series #76

Open FGMGIT opened 4 years ago

FGMGIT commented 4 years ago

Hi, what about support for SIMCom chipsets. This from Waveshare, there are some other manufacturers of board for Raspberry using that chipset.

[SIM7000E NB-IoT HAT] (https://www.waveshare.com/wiki/SIM7000E_NB-IoT_HAT 1) [SIM7080G Cat-M/NB-IoT HAT] (https://www.waveshare.com/wiki/SIM7080G_Cat-M/NB-IoT_HAT 1) [SIM7600G-H 4G HAT] (https://www.waveshare.com/wiki/SIM7600G-H_4G_HAT)

fhunleth commented 4 years ago

While none of these are currently supported, I have access to a SIM7080G so I'll be able to try that one out at some point.

FGMGIT commented 4 years ago

That's perfect it's the newest one, and the sample code is in python. So that's the better option. Thanks i'll be following

fhunleth commented 3 years ago

@FGMGIT Have you gotten a SIM7080G to work? I was able to do a couple AT commands and get my GPS position, but it seems too flaky to be usable. By flaky, I mean that sending AT over doesn't always get an OK response. It does appear to echo the AT command properly, so I don't think it's a UART issue. I looked at the sample Python code, and it didn't seem to be doing anything fancy to make it work.

I do have a Cat M1 SIM in it, so I should be able to connect once I get it configured. It was just too frustrating to send AT commands to manually, so I stopped trying. I can try again. I'm hoping to hear that someone else has seen it work, though.

FGMGIT commented 3 years ago

Hi @fhunleth yes I'm using NB-IoT band, are your SIM provider giving you the APN automatically if not you need to setup using AT+CGDCONT=1,"IP","your.apn.com". And also you can force the band Cat-M or NB-IoT by using AT+CMNB=2 SIM7080G would chose LTE-NB network and AT+CMNB=1 is Cat-M network or AT+CMNB=3 for both of them. I'll copy the lines of the python code sample in the waveshare wiki adding the lines for set the APN and check for IP.

try:
        power_on(power_key)
        print('wait for signal')
        time.sleep(10)
        send_at('AT+CGDCONT=1,"IP","your.apn.com"','OK',1)
        send_at('AT+CGATT=1','OK',1)
        send_at('AT+CSCON?','OK',1)
        send_at('AT+CGPADDR','OK',1)
        send_at('AT+CSQ','OK',1)
        send_at('AT+CPSI?','OK',1)
        send_at('AT+CGREG?','+CGREG: 0,1',0.5)
        send_at('AT+CNACT=0,1','OK',1)
        send_at('AT+CACID=0', 'OK',1)
        send_at('AT+SMCONF=\"URL\",broker.emqx.io,1883','OK',1)
        send_at('AT+SMCONF=\"KEEPTIME\",60','OK',1)
        send_at('AT+SMCONN','OK',5)
        send_at('AT+SMSUB=\"waveshare_pub\",1','OK',1)
        send_at('AT+SMPUB=\"waveshare_sub\",17,1,0','OK',1)
        ser.write(Message.encode())
        time.sleep(10);
        print('send message successfully!')
        send_at('AT+SMDISC','OK',1)
        send_at('AT+CNACT=0,0', 'OK', 1)
        power_down(power_key)

This is the sample for the mqtt.py but it is working also on the tcp.py sample they provide with my first 4 lines added.

Regarding the UART issue I don't know exactly what is the problem. I was able to test it using:

sudo systemctl stop serial-getty@ttyS0.service see for reference.

And then using minicom:

sudo minicom -D /dev/ttyS0

press CONTROL+A E to echo the commands.

If I use only the setup waveshare propose I'm having UART issues in Raspberry Pi Zero W also with AT commands.

image

Please let me know if it helped, or can I give you some more advice as it took a long time to get it working as well, but the main problem was related to the SIM provider that needs to activate my SIM for NB-IoT. It does not come by default.

fhunleth commented 3 years ago

Thanks for all of the info. You gave me a couple ideas of things I might have done wrong. I will try again.

FGMGIT commented 3 years ago

Great thank you.

FGMGIT commented 3 years ago

HI @fhunleth any advance with the test? Please let me know if I can help with anything.

fhunleth commented 3 years ago

Sorry, I got busy with adding automatic power management support for the Quectel modems and that took all of my time. The SIM7080G is sitting on my desk. I'm not sure that it's far off. My recollection was that some other process (login prompt, kernel logging, or something) was interfering with the UART, and that if I fixed that, it would probably work.

With all that I've read about the modem, I honestly think that after AT commands can be reliably sent back and forth, it's probably not much different from the other modems.

I'm seriously trying to catch up with so many OSS projects, I'm not sure when I'll get to try next. I'd suggest giving it a try and if you can get AT commands working with Circuits.UART reliably - (AT -> OK working reliably would be sufficient) that would be a huge help. Or if you can put a logic analyzer on the UART (or anything else to capture it), and give me hints has to what's interfering, that would save me a lot of time and I might be able to push the rest of the port more quickly.

FGMGIT commented 3 years ago

That sounds good, please have a look on the Elixir forum about Circuits. I’m stuked setting up my environmental and let see if I can start testing.

FGMGIT commented 3 years ago

Hi Frank,

I have been doing tests with Circuits.UART without result and without receiving any communication in ttyS0 or ttyAMA0

As I mentioned before, it seems that in Raspberry Pi Z the default port associated with GPIO 14 and 15 serial communication is ttyS0 and what worked for me on raspbian was to disable the console service of the ttyS0 port by stopping the service with sudo systemctl stop serial-getty@ttyS0.service and remove the line console = serial0,115200 from cmdline.txt

I have also seen in Nerves that in "config.txt" it is overlaying ttyAMA0 on ttyS0 with dtoverlay = pi3-miniuart-bt so that the GPIO serial port is ttyAMA0.

According to the documentation that I have read to use serial communication over GPIO without problems it is necessary to deactivate the console, which also according to the Waveshare documentation is necessary through raspi-config-

https://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3-4/

https://www.raspberrypi.org/documentation/configuration/uart.md

https://www.waveshare.com/wiki/SIM7080G_Cat-M/NB-IoT_HAT

I have tried to modify cmdline.txt and config.txt removing the overlap dtoverlay = pi3-miniuart-bt and console=serial0,115200 editing the files directly on my MicroSD but it seems to affect how ssh communications are being mapped so I have not been able to log back in with ssh. If I undo the modifications by ssh circuits@ip or via USB ssh circuits@nerves.local I can log back into the system.

So I don't know where to continue testing.

I think the key is to disable the serial port console, is there any way in nerves to stop this service or run sudo systemctl stop serial-getty@ttyAMA0.service for the ttyAMA0 port?

FGMGIT commented 3 years ago

Thanks for all of the info. You gave me a couple ideas of things I might have done wrong. I will try again.

Hello again @fhunleth , could please point me, what do you think could be wrong according to your comment. I have tried to test again with same result nothing coming out from ttyAMA0 with the sample use in Circuits.UART documentation. If you can give some direction or sample method to use in that particular case I can try to test.

fhunleth commented 3 years ago

Sorry, I really don't have time to help out on this right now. I'd recommend switching to a supported modem (the Quectel BG96, EC96, EG96 all have multiple users here) so that you can see a working setup and use it as a reference.

nadsat commented 3 years ago

I've successfully tested the SIM7600 using the configuration of the Quetcel EC25 on a rpi4

this is part of the dmesg

[    7.247597] usb 1-1.3: Product: SimTech, Incorporated
[    7.252835] usb 1-1.3: Manufacturer: SimTech, Incorporated
[    7.258466] usb 1-1.3: SerialNumber: 0123456789ABCDEF
[    9.900627] usbcore: registered new interface driver option
[    9.906352] usbserial: USB Serial support registered for GSM modem (1-port)
[    9.913642] option 1-1.3:1.0: GSM modem (1-port) converter detected
[    9.920234] usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB0
[    9.927482] option 1-1.3:1.1: GSM modem (1-port) converter detected
[    9.934058] usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB1
[    9.941300] option 1-1.3:1.2: GSM modem (1-port) converter detected
[    9.947836] usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB2
[    9.955063] option 1-1.3:1.3: GSM modem (1-port) converter detected
[    9.961630] usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB3
[    9.968882] option 1-1.3:1.4: GSM modem (1-port) converter detected
[    9.975384] usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB4
[   10.153328] usbcore: registered new interface driver cdc_wdm
[   10.162970] qmi_wwan 1-1.3:1.5: cdc-wdm0: USB WDM device
[   10.168941] qmi_wwan 1-1.3:1.5 wwan0: register 'qmi_wwan' at usb-0000:01:00.0-1.3, WWAN/QMI device, 5a:e6:67:ac:3b:84
[   10.180098] usbcore: registered new interface driver qmi_wwan
[   10.238749] PPP generic driver version 2.4.2
[   11.069187] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[   14.759035] PPP BSD Compression module registered
[   14.777187] PPP Deflate Compression module registered
iex(7)> 

asking for the info I got:

iex(7)> VintageNet.Info.info()      
VintageNet 0.9.1

All interfaces:       ["eth0", "lo", "ppp0", "wlan0", "wwan0"]
Available interfaces: ["wlan0", "ppp0"]

Interface eth0
  Type: VintageNetEthernet
  Present: true
  State: :configured (0:16:25)
  Connection: :disconnected (0:16:25)
  Configuration:
    %{ipv4: %{method: :dhcp}, type: VintageNetEthernet}

Interface ppp0
  Type: VintageNetMobile
  Present: true
  State: :configured (0:16:20)
  Connection: :internet (0:04:41)
  Addresses: 10.9.27.195/32
  Configuration:
    %{
      type: VintageNetMobile,
      vintage_net_mobile: %{
        modem: VintageNetMobile.Modem.QuectelEC25,
        service_providers: [%{apn: "imovil.virginmobile.cl"}]
      }
    }
gabrielmancini commented 2 years ago

hey @nadsat nadsat, do you have to do this to make work?

As I mentioned before, it seems that in Raspberry Pi Z the default port associated with GPIO 14 and 15 serial communication is ttyS0 and what worked for me on raspbian was to disable the console service of the ttyS0 port by stopping the service with sudo systemctl stop serial-getty@ttyS0.service and remove the line console = serial0,115200 from cmdline.txt

I have also seen in Nerves that in "config.txt" it is overlaying ttyAMA0 on ttyS0 with dtoverlay = pi3-miniuart-bt so that the GPIO serial port is ttyAMA0.

i am trying to implement the SIM800L but the ppp port dont show as a interface on vintagenet. i already enabled a lot of stuff in my custom_rpi3, the moden is setup on a protoboard. via Elixircom i can talk to the moden, but vintagenet dont up the interface.

+CONFIG_PPP=m +CONFIG_PPP_BSDCOMP=m +CONFIG_PPP_DEFLATE=m +CONFIG_PPP_FILTER=y +CONFIG_PPP_MPPE=m +CONFIG_PPP_MULTILINK=y +CONFIG_PPP_ASYNC=m +CONFIG_PPP_SYNC_TTY=m +CONFIG_USB_WDM=m +CONFIG_USB_SERIAL_CONSOLE=y +CONFIG_USB_SERIAL_GENERIC=y +CONFIG_USB_SERIAL_SIMPLE=m +CONFIG_USB_SERIAL_QUALCOMM=m +CONFIG_USB_SERIAL_SIERRAWIRELESS=m +CONFIG_USB_SERIAL_OPTION=m +CONFIG_USB_GADGET=m +CONFIG_USB_SERIAL_WWAN=m

when i run cmd "pppd", i have an error that tell me to set "mknod /dev/ppp c 108 0" and i see this is on source code of vintagenetmobile here https://github.com/nerves-networking/vintage_net_mobile/blob/main/lib/vintage_net_mobile.ex#L148 after the 'mknod' command, when i call, the cmd "pppd" run as usual, the ppp interface up and the modem comunication starts.

i need to create something in /etc/ppp/options ? https://www.linuxjournal.com/article/2109 this works

i dont try to remove the command.txt lines and other stuff, can u give me some gotchas, or just point to right north?

nadsat commented 2 years ago

Hi @gabrielmancini I didn't do anything special apart from including the right modules. The SIM7600 and EC25 are really similar (almost identical set of AT commands) that's why making it work was straightforward.

gabrielmancini commented 2 years ago

@nadsat your modem must be attached on usb? how up the wwan interface?

nadsat commented 2 years ago

Yes, it was attached to a USB port. When I tested, VintageNetMobile used ppp behind the scenes for the EC25 (in my case SIM7600) and I didn't do anything related with wwan0. I wonder if you are using a newer version of VintageNetMobile because AFAIK latest versions use qmi for some modems and if you are using that configuration and your modem doesn't support qmi probably it won't work.

gabrielmancini commented 2 years ago

@nadsat thanks for reply,

but i have a question here, to test the moden u use the usb port, but when go to production, the modem will comunicate via usb too? the question here is, how i implement a gprs modem without the usb port to comunicate. i set the modem to comunicate via uart on ttyAMA0, but all implementations use 2 ports, i guess its one to uart and other to ppp mode. how i found this other ppp port on my rasp 3b+ other thing, there is a requirement for wwan here https://github.com/nerves-networking/vintage_net_mobile/blob/21377bd98c3c2b32e3684db746f3922774a68247/lib/vintage_net_mobile.ex#L132 so i understand i need to up this interface, but i dont know how in this gprs modem

nadsat commented 2 years ago

@gabrielmancini I use a hat (sixfab). I used de configuration of the EC25 which uses ttyUSB2 and ttyUSB3

https://github.com/nerves-networking/vintage_net_mobile/blob/06930470f12e96cddcd6e5467594d94ff5913d46/lib/vintage_net_mobile/modem/quectel_EC25.ex#L98

maybe you need https://github.com/nerves-networking/vintage_net_mobile#custom-modems