|  | 
 
| Edited by Buddy at 2017-6-23 18:47 
 
 OrangePi 2G-IOT Linux distro Modem User Manual
 
 First! Thank you @Reinhard  share more important information to me, it's very useful to make Modem work well on Linux dirstro.
 OrangePi 2G-IOT has support SMS, Call phone and connect Internel via ppp. People will utilize these function on different application.
 So, I will share more information to introduce how to utilize modem on OrangePi 2G-IOT distro.
 
 Contents
 
     OrangePi 2G-IOT Modem introduce
     OrangePi 2G-IOT Linux  SMS
     OrangePi 2G-IOT Linux  Call Phone
     OrangePi 2G-IOT Linux connect Internet via ppp
 OrangePi 2G-IOT Modem Introduce
 
 SoC – RDA Micro 8810PL ARM Cortex A5 processor @ up to 1.0 GHz with 2Gbit (256 MB) on-chip LPDDR2 RAM4Gbit (512 MB) on-chip SLC NAND flash256KB L2 cache, Vivante GC860 3D GPUGSM/GPRS/EDGE Modem (Download datasheet)
 OrangePi 2G-IOT Linux distro SMS
 From OrangePi offical, OrangePi 2G-IOT Linux dirstro has support Ubuntu, Debian and Raspbian, these new dirstro all support SMS function.
 You can get newest offical Image from  http://www.orangepi.cn/downloadresourcescn/ 。And before you utilize SMS on OrangePi 2G-IOT Linux dirstro,
 Please prepare a SIM card that has been already activation.
 
 
     Dead WorkFirst, you should prepare a SIM card. for example, I use an China Unicom SIM card.
 According frequency range of Modem, you can select different SIM from different Telecom operators.
 The frequency range that OrangePi 2G-IOT supports as follow:
 
 After got a SIM card, you should cut SIM card to suit SIM slot. The format of SIM slot on OrangePi 2G-IOT is micro.| main | frequency range 
 | other |  |  | 850 |  |  |  | 900 |  |  |  | 1800 |  |  |  | 1900 |  |  |  |  |  | 
 Now, you should plug SIM into SIM slot, as follow:
 
 Note! Absence of horns on the outside. eg
 
Login OrangePiYou can utilze terminal or ssh to connect OrangePi, the band rate is 921600. Details refer offical user manual.
 Default account number: root/orangepi
 Default password: orangepi
 
Usage of SMSOrangePi 2G-IOT support different way to utilize SMS, such as terminal and C-program.
 I will introduce two way to utilize SMS on OrangePi 2G-IOT.
Terminal to SMSOn hardware, CPU connect to Modem via serial port. When Linux startup, the system will register modem on /dev/modem0.
 CPU will exchange message via this virtual port. So, you can use terminal tools to connect Modem under /dev/modem0.
 The mainstream terminal tools is  "minicom", "picocom", "kermit" and so on. The default Linux dirstro doesn't install those tools,
 and you should install it firstly. such as
 
 When finish installing minicom, you should configure minicom firstly. such as:Copy codesudo apt-get install minicom
Entry "Serial port setup"
 
 Push "A" to alter "Serial Device", and input /dev/modem0
 
 Now, we can input "AT" command to test Modem.
 If modem return OK, it means connect OK, we can input more AT command to control Modem.
 
 Then, configure modem mode as full function, use command "AT +CFUN=1",
 If command is successful implementation, termial will get some userful information. eg
 
 And then, you can select clearly mode but Modem also support Cipher mode,
 Input "AT +CMGF=1", If command is successful implementation ,terminal will return OK.
 
 Next, It's very import and fallible on this step, you should configure SMS center number.
 Differnet country and City has a unique SMS center number, If you set an incorrect number, SMS can work.
 So, please get correct SMS center number, you can search goolg to get correct SMS center number.
 We can use AT +CSCA="+86xxxx" to configure SMS center number.
 For example, The country code of China is +86, and the SMS center number of ShenZhen is 13010888500
 
 If command is successful implementation ,terminal will return OK.
 You can input "AT +CSCA?" to check current configure of SMS center number.
 Finally, we can use "AT +CMGS=+86xxx" to send message.
 The format of +86xxx contain Country Code and the number of receiver.
 For example, the country code of China is "+86" and the number of receiver is "135xxxxxxx"
 
 After input command, terminal will output a character ">", then we can input message that you want.
 When you finish input message, you should push Ctrl + Z to send message.
 If command is successful implementation ,terminal will return OK.
 
 Now, we have finish to send message via serial on OrangePi 2G-IOT.
Send message on C-ProgramThe main routine is same with serial way, we also utilize terminal on C-program.
 You can write you program as follow:
 First, you should initlize serial
 
 Next, create function to send AT command:
 
 And then, send AT command stream
 
 Above is main routine of send message.
 Running this program:
 
 
 
 
 
 
 Finally, Receive message from OrangePi 2G-IOT
 
 
 Full C-program
 
 Copy code/*
 * OrangePi 2G-IOT GSM Demo 
 *  (C) Copyright 2017 OrangePi
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/stat.h>
#define NR_CITY  30
#define MODEM_PATH  "/dev/modem0"
#define VERSION     "0.1.0"
struct Centry_number {
        char *city;
        char *number;
} City_Number[NR_CITY] = {
        { "ShenZhen",           "13010888500" },
        { "Beijing",            "13010112500" },
        { "Shanghai",           "13010314500" },
        { "Shandong",           "13010171500" },
        { "Jiangsu" ,           "13010341500" },
        { "Zhejiang",           "13010360500" },
        { "Fujian",             "13010380500" },
        { "Sichuan",            "13010811500" },
        { "Chongqing",          "13010831500" },
        { "Hainan" ,            "13010501500" },
        { "Heilongjiang",       "13010980500" },
        { "Jilin",              "13010911500" },
        { "Tianjin",            "13010130500" },
        { "Hebei",              "13010180500" },
        { "Inner Mongolia",     "13010950500" },
        { "Shanxi",             "13010701500" },
        { "Anhui",              "13010305500" },
        { "Xinjiang",           "13010969500" },
        { "Qinghai",            "13010776500" },
        { "Gansu",              "13010879500" },
        { "Ningxia",            "13010796500" },
        { "Guizhou",            "13010788500" },
        { "Yunnan",             "13010868500" },
        { "Hunan",              "13010731500" },
        { "Hubei",              "13010710500" },
        { "Guangdong",          "13010200500" },
        { "Guangxi",            "13010591500" },
        { "Henan",              "13010761500" },
        { "Jiangxi",            "13010720500" },
        { "Liaoning",           "13010240500"},
};
/*
 * Initialize serial  
 */
void serial_init(int fd)
{
        struct termios options;
        tcgetattr(fd, &options);
        options.c_cflag |= (CLOCAL | CREAD);
        options.c_cflag &= ~CSIZE;
        options.c_cflag &= ~CRTSCTS;
        options.c_cflag |= CS8;
        options.c_cflag &= ~CSTOPB;
        options.c_iflag |= IGNPAR;
        options.c_oflag = 0;
        options.c_lflag = 0;
        cfsetispeed(&options, B9600);
        cfsetospeed(&options, B9600);
        tcsetattr(fd, TCSANOW, &options);
}
void display_message(int direction, const char *message)
{
        if (direction) {
                printf("Send Message ------> %s\n", MODEM_PATH);
                printf(">> %s\n", message);
        } else {
                printf("Rece Message <------ %s\n", MODEM_PATH);
                printf("<< %s\n", message);
        }
}
void Send_AT(int fd, const char *str1, const char *str2, const char *str3)
{
        char buff[128];
        char answer[128];
        memset(buff, 0, sizeof(buff));
        if (str1 != NULL)
                strcpy(buff, str1);
        if (str2 != NULL)
                strcat(buff, str2);
        if (str3 != NULL)
                strcat(buff, str3);
        write(fd, buff, strlen(buff));
        display_message(1, buff);
        memset(answer, 0, sizeof(answer));
        sleep(1);
        read(fd, answer, sizeof(answer));
        display_message(0, answer);
}
int send(int fd, char *cmgf, char *cmgs, char *csca, char *message)
{
        /* AT Test */
        Send_AT(fd, "AT\r", NULL, NULL);
        /* Set Modem Full Function */
        Send_AT(fd, "AT +CFUN=", "1", "\r");
        /* Set CMGF */
        Send_AT(fd, "AT +CMGF=", cmgf, "\r");
        /* Set Message Centr Number */
        Send_AT(fd, "AT +CSCA=", csca, "\r");
        /* Set Receive Number */
        Send_AT(fd, "AT +CMGS=", cmgs, "\r");
        /* Send Message */
        Send_AT(fd, message, NULL, NULL);
}
int Send_Message(int fd)
{
        char buff[128];
        char num1[64];
        char num2[64];
        int i;
        int choice;
        printf("********* City Select **********\n");
        for (i = 0; i < NR_CITY; i++) 
                printf("[%2d] %s\n", i, City_Number[i].city);
        printf("Please select your City!\n");
        scanf("%d", &choice);
        do {
                memset(num1, 0, sizeof(num1));
                printf("\nPlease Entry Receive phone number:\n");
                scanf("%s", num1);
        } while (strlen(num1) != 11);
        sleep(1);
        memset(buff, 0, sizeof(buff));
        printf("Please input Meesage:\n");
        scanf("%s", buff);
        /* Restruct buff */
        i = strlen(buff);
        buff[i] = 0x1A;
        buff[i+1] = '\r';
        buff[i+2] = '\0';
        memset(num2, 0, sizeof(num2));
        strcpy(num2, "+86");
        strcat(num2, num1);
        memset(num1, 0, sizeof(num1));
        strcpy(num1, "+86");
        strcat(num1, City_Number[choice].number);
        
        send(fd, "1", num2, num1, buff);
}
/*
 * Call Phone.
 */
void Call_Phone(int fd)
{
        char buff[128];
        char number[20];
        do {
                memset(number, 0, sizeof(number));
                printf("\nPlease input phone number:");
                scanf("%s", number);
        } while (strlen(number) != 11);
        memset(buff, 0, sizeof(buff));
        strcpy(buff, "+86");
        strcat(buff, number);
        strcat(buff, ";");
        /* AT Test */
        Send_AT(fd, "AT\r", NULL, NULL);
        /* Call */
        Send_AT(fd, "AT", " DT ", buff);
}
int main(int argc, char *argv[])
{
        int fd;
        char choice;
        fd = open(MODEM_PATH, O_RDWR | O_NOCTTY | O_NDELAY);
        if (fd < 0) {
                printf("Can't open %s\n", MODEM_PATH);
                return -1;
        }
        /* Initialize /dev/modem0 */
        serial_init(fd);
        
        printf("************************************************\n");
        printf("\tWelcome to OrangePi 2G-IOT\n");
        printf("\tModem version %s\n", VERSION);
        printf("************************************************\n");
        printf("Entry your select:\n");
        printf("1. Send Message\n");
        printf("2. Call Phone\n");
        printf("3. Exit\n");
        choice = getchar();
        switch (choice) {
        case '1': 
                        Send_Message(fd);
                        break;
        case '2':
                        Call_Phone(fd);
                        break;
        default:
                        break;
        
        }
        close(fd);
        return 0;
}
 OrangePi 2G-IOT Linux distro Call Phone
 
 
 From OrangePi offical, OrangePi 2G-IOT Linux dirstro has support Ubuntu, Debian and Raspbian, these new dirstro all support Call Phone function.
 You can get newest offical Image from  http://www.orangepi.cn/downloadresourcescn/ 。And before you utilize Call Phone on OrangePi 2G-IOT Linux dirstro,
 Please prepare a SIM card that has been already activation.
 
 
     Dead WorkFirst, you should prepare a SIM card. for example, I use an China Unicom SIM card.
 According frequency range of Modem, you can select different SIM from different Telecom operators.
 The frequency range that OrangePi 2G-IOT supports as follow:
 
 After got a SIM card, you should cut SIM card to suit SIM slot. The format of SIM slot on OrangePi 2G-IOT is micro.| main | Frequency range 
 | other |  |  | 850 |  |  |  | 900 |  |  |  | 1800 |  |  |  | 1900 |  |  |  |  |  | 
 Now, you should plug SIM into SIM slot, as follow:
 
  Note! Absence of horns on the outside. eg
 
  Plug headset
 
Login OrangePiYou can utilze terminal or ssh to connect OrangePi, the band rate is 921600. Details refer offical user manual.
 Default account number: root/orangepi
 Default password: orangepi
 
 Usage of Call PhoneOrangePi 2G-IOT support different way to utilize Call Phone, such as terminal and C-program.
 I will introduce two way to utilize Call Phone on OrangePi 2G-IOT.
Terminal to Call PhoneOn hardware, CPU connect to Modem via serial port. When Linux startup, the system will register modem on /dev/modem0.
 CPU will exchange message via this virtual port. So, you can use terminal tools to connect Modem under /dev/modem0.
 The mainstream terminal tools is  "minicom", "picocom", "kermit" and so on. The default Linux dirstro doesn't install those tools,
 and you should install it firstly. such as
 
 When finish installing minicom, you should configure minicom firstly. such as:Copy codesudo apt-get install minicom
Entry "Serial port setup"
 
  Push "A" to alter "Serial Device", and input /dev/modem0
 
  Now, we can input "AT" command to test Modem.
 If modem return OK, it means connect OK, we can input more AT command to control Modem.
 
  Then, use command AT DT "+86xxxxx;" . The format of "+86xxxxx;" contain country code, call number and a character ';'
 For example, the country code of China is "+86" and call numer is "xxxxxx", at last, adding ';'.
 
C-program The main routine of Call phone is same as serial way on C-program.
 So, at first, we should initialize serial.
 
 Then, create Send At function
 
 Final, Send AT command
 
 
 Running this C-program
 
 
 Full source code of Call Phone on OrangePi 2G-IOT
 
 Copy code/*
 * OrangePi 2G-IOT GSM Demo 
 *  (C) Copyright 2017 OrangePi
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/stat.h>
#define NR_CITY  30
#define MODEM_PATH  "/dev/modem0"
#define VERSION     "0.1.0"
struct Centry_number {
        char *city;
        char *number;
} City_Number[NR_CITY] = {
        { "ShenZhen",           "13010888500" },
        { "Beijing",            "13010112500" },
        { "Shanghai",           "13010314500" },
        { "Shandong",           "13010171500" },
        { "Jiangsu" ,           "13010341500" },
        { "Zhejiang",           "13010360500" },
        { "Fujian",             "13010380500" },
        { "Sichuan",            "13010811500" },
        { "Chongqing",          "13010831500" },
        { "Hainan" ,            "13010501500" },
        { "Heilongjiang",       "13010980500" },
        { "Jilin",              "13010911500" },
        { "Tianjin",            "13010130500" },
        { "Hebei",              "13010180500" },
        { "Inner Mongolia",     "13010950500" },
        { "Shanxi",             "13010701500" },
        { "Anhui",              "13010305500" },
        { "Xinjiang",           "13010969500" },
        { "Qinghai",            "13010776500" },
        { "Gansu",              "13010879500" },
        { "Ningxia",            "13010796500" },
        { "Guizhou",            "13010788500" },
        { "Yunnan",             "13010868500" },
        { "Hunan",              "13010731500" },
        { "Hubei",              "13010710500" },
        { "Guangdong",          "13010200500" },
        { "Guangxi",            "13010591500" },
        { "Henan",              "13010761500" },
        { "Jiangxi",            "13010720500" },
        { "Liaoning",           "13010240500"},
};
/*
 * Initialize serial  
 */
void serial_init(int fd)
{
        struct termios options;
        tcgetattr(fd, &options);
        options.c_cflag |= (CLOCAL | CREAD);
        options.c_cflag &= ~CSIZE;
        options.c_cflag &= ~CRTSCTS;
        options.c_cflag |= CS8;
        options.c_cflag &= ~CSTOPB;
        options.c_iflag |= IGNPAR;
        options.c_oflag = 0;
        options.c_lflag = 0;
        cfsetispeed(&options, B9600);
        cfsetospeed(&options, B9600);
        tcsetattr(fd, TCSANOW, &options);
}
void display_message(int direction, const char *message)
{
        if (direction) {
                printf("Send Message ------> %s\n", MODEM_PATH);
                printf(">> %s\n", message);
        } else {
                printf("Rece Message <------ %s\n", MODEM_PATH);
                printf("<< %s\n", message);
        }
}
void Send_AT(int fd, const char *str1, const char *str2, const char *str3)
{
        char buff[128];
        char answer[128];
        memset(buff, 0, sizeof(buff));
        if (str1 != NULL)
                strcpy(buff, str1);
        if (str2 != NULL)
                strcat(buff, str2);
        if (str3 != NULL)
                strcat(buff, str3);
        write(fd, buff, strlen(buff));
        display_message(1, buff);
        memset(answer, 0, sizeof(answer));
        sleep(1);
        read(fd, answer, sizeof(answer));
        display_message(0, answer);
}
int send(int fd, char *cmgf, char *cmgs, char *csca, char *message)
{
        /* AT Test */
        Send_AT(fd, "AT\r", NULL, NULL);
        /* Set Modem Full Function */
        Send_AT(fd, "AT +CFUN=", "1", "\r");
        /* Set CMGF */
        Send_AT(fd, "AT +CMGF=", cmgf, "\r");
        /* Set Message Centr Number */
        Send_AT(fd, "AT +CSCA=", csca, "\r");
        /* Set Receive Number */
        Send_AT(fd, "AT +CMGS=", cmgs, "\r");
        /* Send Message */
        Send_AT(fd, message, NULL, NULL);
}
int Send_Message(int fd)
{
        char buff[128];
        char num1[64];
        char num2[64];
        int i;
        int choice;
        printf("********* City Select **********\n");
        for (i = 0; i < NR_CITY; i++) 
                printf("[%2d] %s\n", i, City_Number[i].city);
        printf("Please select your City!\n");
        scanf("%d", &choice);
        do {
                memset(num1, 0, sizeof(num1));
                printf("\nPlease Entry Receive phone number:\n");
                scanf("%s", num1);
        } while (strlen(num1) != 11);
        sleep(1);
        memset(buff, 0, sizeof(buff));
        printf("Please input Meesage:\n");
        scanf("%s", buff);
        /* Restruct buff */
        i = strlen(buff);
        buff[i] = 0x1A;
        buff[i+1] = '\r';
        buff[i+2] = '\0';
        memset(num2, 0, sizeof(num2));
        strcpy(num2, "+86");
        strcat(num2, num1);
        memset(num1, 0, sizeof(num1));
        strcpy(num1, "+86");
        strcat(num1, City_Number[choice].number);
        
        send(fd, "1", num2, num1, buff);
}
/*
 * Call Phone.
 */
void Call_Phone(int fd)
{
        char buff[128];
        char number[20];
        do {
                memset(number, 0, sizeof(number));
                printf("\nPlease input phone number:");
                scanf("%s", number);
        } while (strlen(number) != 11);
        memset(buff, 0, sizeof(buff));
        strcpy(buff, "+86");
        strcat(buff, number);
        strcat(buff, ";");
        /* AT Test */
        Send_AT(fd, "AT\r", NULL, NULL);
        /* Call */
        Send_AT(fd, "AT", " DT ", buff);
}
int main(int argc, char *argv[])
{
        int fd;
        char choice;
        fd = open(MODEM_PATH, O_RDWR | O_NOCTTY | O_NDELAY);
        if (fd < 0) {
                printf("Can't open %s\n", MODEM_PATH);
                return -1;
        }
        /* Initialize /dev/modem0 */
        serial_init(fd);
        
        printf("************************************************\n");
        printf("\tWelcome to OrangePi 2G-IOT\n");
        printf("\tModem version %s\n", VERSION);
        printf("************************************************\n");
        printf("Entry your select:\n");
        printf("1. Send Message\n");
        printf("2. Call Phone\n");
        printf("3. Exit\n");
        choice = getchar();
        switch (choice) {
        case '1': 
                        Send_Message(fd);
                        break;
        case '2':
                        Call_Phone(fd);
                        break;
        default:
                        break;
        
        }
        close(fd);
        return 0;
}
 OrangePi 2G-IOT Linux connect Internet via pppFrom OrangePi offical, OrangePi 2G-IOT Linux dirstro has support Ubuntu, Debian and Raspbian, these new dirstro all support connect Internet via ppp.
 You can get newest offical Image from  http://www.orangepi.cn/downloadresourcescn/ 。And before you utilize ppp on OrangePi 2G-IOT Linux dirstro,
 Please prepare a SIM card that has been already activation.
 
 
     Dead WorkFirst, you should prepare a SIM card. for example, I use an China Unicom SIM card.
 According frequency range of Modem, you can select different SIM from different Telecom operators.
 The frequency range that OrangePi 2G-IOT supports as follow:
 
 After got a SIM card, you should cut SIM card to suit SIM slot. The format of SIM slot on OrangePi 2G-IOT is micro.| Main | Frequency | Other |  |  | 850 |  |  |  | 900 |  |  |  | 1800 |  |  |  | 1900 |  |  |  |  |  | 
 Now, you should plug SIM into SIM slot, as follow:
 
  Note! Absence of horns on the outside. eg
 
 Login OrangePiYou can utilze terminal or ssh to connect OrangePi, the band rate is 921600. Details refer offical user manual.
 Default account number: root/orangepi
 Default password: orangepi
 
 Utilize ppp to connect InternetOrangePi 2G-IOT currently support GSM to connect Internet, and base on ppp and wvdial tools.
 First, you should install tools on OrangePi 2G-IOT, such as:
 
 Then, alter /etc/wvdial.conf to configure wvdialCopy codesudo apt-get install ppp wvdial
 Next, alter /etc/ppp/peers/wvdial to configure pppCopy code[Dialer defaults]
ISDN = 0
Modem Type = Analog Modem
Phone = *99***1#
Stupid Mode = 1
Dial Command = ATDT
Modem = /dev/modem0
Baud = 460800
Init1 = AT+COPS=0
Init2 = AT+CFUN=1
Init3 = AT+CGATT=1
Init4 = AT+CGDCONT=1,"IP","OrangePi_2G-IOT","",0,0
Init5 = AT+CGACT=1,1
Username = " "
Password = " "
 Final, connect Internal via wvdialCopy codenoauth
name wvdial
defaultroute
replacedefaultroute
 Check net state
 
 Utilize "ping" to test Internel state
 
 
 | 
 
xThis thread contains more resourcesYou need to Log in to download or view,No account?   
  Register  |