Raspberry Pi, 4G, and SMS

Years ago, I was playing with a SIM900A and an Arduino, attemtping to get the modem to register on the Sprint/T-Mobile network via Ting VNO. After a couple of days with zero progress, I binned the project along with my frustration, but my desire to complete the project persisted. As 2G is being sunset this year in the United States, the SIM900A is quickly entering paperweight status. With an extra Raspberry Pi 4 laying around, I decided to give this cellular project another shot with 4G hardware, this time with a SIM7080G. Coupling the Pi with the SIM7080G and three days of searching and throwing a barrage of commands from the AT Command Manual, I was back in the same place before with the SIM900A. With power, serial, and a modem actively responding to commands, what could be wrong? During my command barrage from before, I remembered coming across AT+CBANDCFG. This command reads and writes the bands for the CAT-M and NB-IOT modes. Issuing the test command, it looked like several bands were supported. AT+CBANDCFG=? +CBANDCFG: (CAT-M,NB-IOT),(1,2,3,4,5,8,12,13,14,18,19,20,25,26,27,28,66,71,85) OK Reading out the configured bands however, there was only a small subset being used. Despite the modem telling you which bands it supports for the modes, it will throw an error if it doesnt like the band you specified when issuing the write command. E.g. AT+CBANDCFG="NB-IOT",1,2,3,4,5,8,12,13,14,18,19,20,25,26,28,66,71 ERROR Having a cellular device seems ubiquituous to being a human, but understanding the underlying specifications is not. Suffice it to say, configuring the SIM7080G led me to feeling like a cellular novice, of which I am! Nevertheless, finding the correct band combination, the SIM7080G finally registered on the network! AT+CBANDCFG? +CBANDCFG: "CAT-M",1,2,3,4,5,8,12,13,14,18,19,20,25,26,28,66,71 +CBANDCFG: "NB-IOT",1,2,4,5,12,66,71 OK AT+CREG? +CREG: 0,1 OK AT+CPSI? +CPSI: LTE CAT-M1,Online,310-260,0x580E,34670342,283,EUTRAN-BAND12,5035,2,2,-20,-91,-57,5 OK AT+CSQ +CSQ: 26,99 OK With only a serial console available, I needed the SMS messages in a structured format, eventually allowing for something more interesting than just TX/RX SMS. Working with raw data like this from a low tech serial console was really humbling and a nice change from the structured data you typically get with web based APIs. Fortunately, reading SMS messages from the SIM7080G has a format. Looking at the AT+CMGL command in the manual, the format is detailed. Sending that command through and reading the output, we can pull apart the SMS messages into a data structure. sms_struct[msg_id] = { 'status': sms_meta_data[1], 'from_address': sms_meta_data[2], 'mr': sms_meta_data[3]., 'received_date': sms_meta_data[4], 'received_time': sms_meta_data[5], 'message': sms_messages[n + 1] } With this avialable, we can loop through all the messages in storage only reading the important messages. You could also keep reading messages destined for someone else where the sender didnt update the group txt or their contacts. +CMGL: 17,"REC UNREAD","+1423464xxxx",,"22/05/30,06:49:33-28" This is Simon at Gray Epperson Hyundai This is only the foundation for this project. This had to come first before the other pieces could be put in place. Until then, here is the complete SMS parsing code. Download: [tar] [sha1sum] @nullanvoid