Ver código fonte

1、继续补充打镜像的文档
2、恢复陈的修改,会导致io报错
3、修改打包脚本
4、完善蜂窝模组程序

guohui 1 ano atrás
pai
commit
ff70c3dd4f

+ 4 - 4
mkimg/t113i/sh/t113i镜像编译步骤.txt

@@ -1,4 +1,4 @@
-1、./build.sh config,一路选择如下:
+1、./build.sh config,一路选择如下:linux/longan/linux-5.4/t113-i/tlt113-evm-emmc/tft-lcd/default/gnueabi
 2、./build.sh menuconfig,修改内核配置,勾选下面选项:
    1)Device Drivers ->  Network device support -> Wireless LAN -> Realtek 8723d USB Wifi	(根据使用的模组型号进行勾选)
    1)Device Drivers ->  Network device support -> Wireless LAN -> Wireless RNDIS USB support  
@@ -47,8 +47,7 @@
 
 4、编译qt
    进入 platform/framework/qt/qt-everywhere-src-5.12.5/buildsetup_sf.sh 增加/删除相关模块
-  配置完执行:./build.sh qt
-  再执行:./build.sh
+  配置完执行:./build.sh qt  再执行:./build.sh
 
 
 编译系统使用的默认配置为: buildroot/buildroot-201902/configs/sun8iw20p1_t113_defconfig
@@ -58,6 +57,7 @@
 
 
 完整的编译过程:
+./build.sh config 
 ./build.sh clean(或删除out目录)  ->  配置kernel/buildroot  ->  ./build.sh  ->  ./build.sh qt  ->   ./build.sh pack
 
 简化的编译流程: 先要将cfg文件夹拷贝到T113-i_v1.0的同级目录,将cover/go/mycopy.sh拷贝到T113-i_v1.0目录内并使其有执行权限
@@ -69,7 +69,7 @@
 mycopy.sh:实现将用户程序打包到系统镜像,
 可以根据需要添加对应路径和需要拷贝的文件,不需要时,注释掉拷贝命令即可
 
-$$$ 后面可以考虑在最新版本的sdk上编译镜像
+注:后续可以考虑在最新版本的sdk上编译镜像
 
 
 

+ 32 - 32
output/t113i/pack_dir/etc/init.d/S90PDUApp

@@ -1,4 +1,4 @@
-#/bin/sh
+#!/bin/sh
 
 RUNDIR=/root/run
 APPDIR=$RUNDIR/app
@@ -8,7 +8,7 @@ SNMPDIR=$APPDIR/snmp
 source /etc/qtenv.sh
 export MIBDIRS=$SNMPDIR/mibs
 export LD_LIBRARY_PATH=$APPDIR/lib:$LD_LIBRARY_PATH
-export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/event4:rotate=0
+export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/event4:rotate=180:invertx
 
 
 start_snmpd()
@@ -24,41 +24,41 @@ start_pdu()
 led_on()
 {
     #light led
-#    echo 98 > /sys/class/gpio/export
-#    echo out > /sys/class/gpio/gpio98/direction
-#    echo 1 > /sys/class/gpio/gpio98/value
-#    echo 101 > /sys/class/gpio/export
-#    echo in  > /sys/class/gpio/gpio101/direction
-#    echo 102 > /sys/class/gpio/export
-#    echo in  > /sys/class/gpio/gpio102/direction
-#    echo 103 > /sys/class/gpio/export
-#    echo out > /sys/class/gpio/gpio103/direction
-#    echo 104 > /sys/class/gpio/export
-#    echo in  > /sys/class/gpio/gpio104/direction
-#    echo 105 > /sys/class/gpio/export
-#    echo out > /sys/class/gpio/gpio105/direction
-#    echo 106 > /sys/class/gpio/export
-#    echo out > /sys/class/gpio/gpio106/direction
-#    echo 113 > /sys/class/gpio/export
-#    echo in  > /sys/class/gpio/gpio113/direction
-#    echo 115 > /sys/class/gpio/export
-#    echo in  > /sys/class/gpio/gpio115/direction
-    echo 142 > /sys/class/gpio/export
-    echo in  > /sys/class/gpio/gpio142/direction
-    echo 143 > /sys/class/gpio/export
-    echo in  > /sys/class/gpio/gpio143/direction
-    echo 144 > /sys/class/gpio/export
-    echo in  > /sys/class/gpio/gpio144/direction
-    echo 145 > /sys/class/gpio/export
-    echo in  > /sys/class/gpio/gpio145/direction
+    echo 98 > /sys/class/gpio/export
+    echo out > /sys/class/gpio/gpio98/direction
+    echo 1 > /sys/class/gpio/gpio98/value
+    echo 101 > /sys/class/gpio/export
+    echo in  > /sys/class/gpio/gpio101/direction
+    echo 102 > /sys/class/gpio/export
+    echo in  > /sys/class/gpio/gpio102/direction
+    echo 103 > /sys/class/gpio/export
+    echo out > /sys/class/gpio/gpio103/direction
+    echo 104 > /sys/class/gpio/export
+    echo in  > /sys/class/gpio/gpio104/direction
+    echo 105 > /sys/class/gpio/export
+    echo out > /sys/class/gpio/gpio105/direction
+    echo 106 > /sys/class/gpio/export
+    echo out > /sys/class/gpio/gpio106/direction
+    echo 113 > /sys/class/gpio/export
+    echo in  > /sys/class/gpio/gpio113/direction
+    echo 115 > /sys/class/gpio/export
+    echo in  > /sys/class/gpio/gpio115/direction
+    echo 107 > /sys/class/gpio/export
+    echo in  > /sys/class/gpio/gpio107/direction
+    echo 108 > /sys/class/gpio/export
+    echo in  > /sys/class/gpio/gpio108/direction
+    echo 109 > /sys/class/gpio/export
+    echo in  > /sys/class/gpio/gpio109/direction
+    echo 110 > /sys/class/gpio/export
+    echo in  > /sys/class/gpio/gpio110/direction
 }
 start_lcd()
 {
     #light lcd
 if [ -f $APPDIR/Qt_Test ]; then
-     led_on
-#    fbinit
-    $APPDIR/Qt_Test --platform=linuxfb:tslib=/dev/input/event4 &
+    led_on
+    fbinit
+    $APPDIR/Qt_Test --platform=linuxfb &
 fi
 }
 

+ 1 - 1
output/t113i/push2/push.bat

@@ -1,6 +1,6 @@
 @ECHO OFF
 
-SET IP=192.168.1.134
+SET IP=192.168.1.132
 
 SET BAT=0
 IF "%~1" NEQ "" (

+ 1 - 1
pro/.vscode/launch.json

@@ -16,7 +16,7 @@
             "externalConsole": false,
             "MIMode": "gdb",
             "miDebuggerPath": "/home/tronlong/T113/T113-i_v1.0/out/t113_i/tlt113-evm-emmc/longan/buildroot/host/opt/ext-toolchain/bin/arm-linux-gnueabi-gdb",
-            "miDebuggerServerAddress": "192.168.1.137:1234"
+            "miDebuggerServerAddress": "192.168.1.132:1234"
         }
     ]
 }

+ 9 - 2
pro/config/cfg.h

@@ -22,8 +22,8 @@
 //#define PRJ_HYPERTEC_AC_I3_O1
 //#define PRJ_SG_I3_O3
 //#define PRJ_TEST
-//#define PRJ_TEST_AC_I1_O1
-#define PRJ_ESOUTH_DC_I1_O4_RGB5
+#define PRJ_TEST_AC_I1_O1
+//#define PRJ_ESOUTH_DC_I1_O4_RGB5
 //#define PRJ_TEST_AC_I3_O1
 //#define PRJ_IP_AC_I3_O3
 //#define PRJ_INST2302_DC_OLED
@@ -50,6 +50,12 @@
 //#define USE_BOARD_UPGRADE
 
 
+#if (CHIP_TYPE == CHIP_T113s)
+    #define USE_WATCHDOG
+#endif
+
+
+
 #if (defined PRJ_XIAN_AC_I1_O1_P4) || (defined PRJ_XIAN_AC_I1_O1_P8)  //GOM037
     #define LANGUAGE                            0           //chinese
     #define SMPLE_TIME                          30          //ms
@@ -274,6 +280,7 @@
 
     #define FLIP_TIME                           3
     #define SCREEN_RGB
+    #define USE_WATCHDOG
     
 #elif (defined PRJ_IP_AC_I3_O1)
     #define LANGUAGE                            0

+ 349 - 345
pro/src/Cellular.c

@@ -534,8 +534,153 @@ static mqtt_conn_t* get_mqtt_conn_free(cell_handle_t *h)
     }
     return NULL;
 }
+#define BGET(flag,mask)  ((flag)&(1<<(mask)))
+#define BSET(flag,mask)  ((flag)|=(1<<(mask)))
+
+static int get_date_time(char *d, char *t)
+{
+    time_t now;
+    struct tm* tm;
+
+    time(&now);
+    tm = localtime(&now);
+    if(!tm) {
+        return -1;
+    }
+    sprintf(d, "%04d-%02d-%02d", tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday);
+    sprintf(t, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
+    return 0;
+}
+static int get_serv(char *json)
+{
+    int i,flag=0;
+    cJSON* tmp=NULL;
+
+    if(json) {
+        cJSON* cjson=cJSON_Parse(json);
+        if(cjson) {
+            for(i=0; i<SERV_MAX; i++) {
+                tmp = cJSON_GetObjectItem(cjson, serv_str[i]);
+                if(tmp && tmp->valuestring) {
+                    flag |= (atoi(tmp->valuestring)<<i);
+                }
+            }
+
+            cJSON_Delete(cjson);
+        }
+    }
+    else {
+        if(thread_is_running(THREAD_ID_NTP)) {
+            BSET(flag, SERV_NTP);
+        }
+
+        if(thread_is_running(THREAD_ID_MAIL)) {
+            BSET(flag, SERV_SMTP);
+        }
+
+        if(thread_is_running(THREAD_ID_MQTT)) {
+            BSET(flag, SERV_MQTT);
+        }
+
+#if 0
+        if(thread_is_running(SERV_MESG)) {
+            BSET(flag, SERV_MESG);
+        }
+
+        if(thread_is_running(THREAD_ID_CLOUD)) {
+            BSET(flag, SERV_CLOUD);
+        }
+
+        if(thread_is_running(THREAD_ID_TELNET)) {
+            BSET(flag, SERV_TELNET);
+        }
+#endif
+
+        if(sys_is_running("snmpd")) {
+            BSET(flag, SERV_NTP);
+        }
+
+        if(thread_is_running(THREAD_ID_NTP)) {
+            BSET(flag, SERV_NTP);
+        }
+
+    }
+
+    return flag;
+}
+static int set_serv(int flag)
+{
+    if(BGET(flag,SERV_NTP)) {
+        if(!thread_is_running(THREAD_ID_NTP)) {
+            //thread_stop(THREAD_ID_NTP);
+        }
+    }
+    else {
+        if(thread_is_running(THREAD_ID_NTP)) {
+            thread_stop(THREAD_ID_NTP);
+        }
+    }
+
+    if(BGET(flag,SERV_SMTP)) {
+        if(!thread_is_running(THREAD_ID_MAIL)) {
+            //thread_stop(THREAD_ID_MAIL);
+        }
+    }
+    else {
+        if(thread_is_running(THREAD_ID_MAIL)) {
+            thread_stop(THREAD_ID_MAIL);
+        }
+    }
+
+    if(BGET(flag,SERV_MQTT)) {
+
+    }
+    else {
+        
+    }
+
+    if(BGET(flag,SERV_MESG)) {
+
+    }
+    else {
+        
+    }
+
+    if(BGET(flag,SERV_CLOUD)) {
+
+    }
+    else {
+        
+    }
+
+    if(BGET(flag,SERV_TELNET)) {
 
+    }
+    else {
+        
+    }
+
+    if(BGET(flag,SERV_SNMP_V1) || BGET(flag,SERV_SNMP_V2C) || BGET(flag,SERV_SNMP_V3) || BGET(flag,SERV_SNMP_TRAP)) {
+
+    }
+    else {
+        
+    }
 
+    return 0;
+}
+static char *get_int_str(int n)
+{
+    static char tmp[32];
+    snprintf(tmp, sizeof(tmp), "%d", n);
+    return tmp;
+}
+static char *get_float_str(float n)
+{
+    static char tmp[32];
+    snprintf(tmp, sizeof(tmp), "%0.3f", n);
+    return tmp;
+}
 //////////////////////////////////////////////////////////////////////////////////
 
 
@@ -687,14 +832,13 @@ static int send_cmd(cell_handle_t *h, at_cmd_t *pcmd, char *para, char *rcv, int
 
             r = port_read(h, pbuf, buflen);
             if(r>0) {
+                LOGD("___port_read: %s\n", pbuf);
                 if(pcmd->ok && strstr(pbuf, pcmd->ok)) {
-                    rsp = CELL_OK;
-                    break;
+                    rsp = CELL_OK; break;
                 }
                 
                 if(pcmd->err && strstr(pbuf, pcmd->err)) {
-                    rsp = CELL_ERR;
-                    break;
+                    rsp = CELL_ERR; break;
                 }
             }
         }
@@ -734,6 +878,7 @@ static int cell_init(cell_handle_t *h)
         {CMD_CGACT,     "=1"},
         {CMD_QGPSCFG,   "=\"gpsnmeatype\",1"},
         {CMD_QGPS,      "=1"},
+        {CMD_QCFG,      "=\"usbnet\",1"},   //set to ecm mode
         {-1,            NULL},
     };
 
@@ -1265,221 +1410,96 @@ static int cell_mqtt_pub(mqtt_conn_t *conn, char *topic, void *data, int len)
 
     return 0;
 }
-/////////////////////////////////////////////////////////////////////////
-static int urc_handle(char *data, int len)
+static int mqttc_init(cell_handle_t *h)
 {
-    char *key=NULL;
+    int r=-1;
 
-    key = "+QIURC: ";
-    if(strstr(data, key)) {
+    r = cell_mqtt_init(h);
 
-    }
-    
-    key = "+QMT";
-    if(strstr(data, key)) {
+    return r;
+}
+static int get_host(mqtt_server_t *ser, mqtt_para_t *para)
+{
+    char *head="mqtts";
 
+    if(!ser->server[0] || !ser->port[0] || !ser->mode) {
+        return -1;
     }
 
+    para->port = atoi(ser->port);
+    if(para->port==1883) {
+        head = "mqtt";
+    }
+    else if(para->port==8883) {
+        head = "mqtts";
+    }
+    else if(para->port==8083) {
+        head = "ws";
+    }
+    else if(para->port==8884) {
+        head = "wss";
+    }
+    sprintf(para->host, "%s://%s", head, ser->server);
 
     return 0;
 }
-
-static void* cellular_thread(void *arg)
+static int mqttc_conn(cell_handle_t *h, int flag)
 {
-    int r;
-    thread_handle_t *th=(thread_handle_t*)arg;
-    cell_handle_t *h=(cell_handle_t*)th->arg;
-
-    while (th->quit==0) {
-        if(h->pcell->mode) {
+    int i,r;
+    char host[200];
+    uint16_t port;
+    mqtt_para_t para;
+    mqtt_server_t *ser=h->dm->mqttInfo.ser;
 
-            r = port_recv(h, h->rxbuf, sizeof(h->rxbuf), QUERY_INTERVAL);
-            if(r>0) {
-                urc_handle(h->rxbuf, r);
+    if (flag) {
+        for(i=0; i<MQTT_MAX; i++) {
+            r = get_host(&ser[i], &para);
+            if((r==0)) {
+                if(h->mq_conn[i].h==NULL) {
+                    strcpy(para.username, ser->user);
+                    strcpy(para.password, ser->password);
+                    cell_mqtt_conn(h, &para);
+                }
             }
         }
-        else {
-            msleep(1000);
+    }
+    else {
+        for(i=0; i<MQTT_MAX; i++) {
+            cell_mqtt_disconn(&h->mq_conn[i]);
         }
-        
-        
     }
-    port_deinit(h);
 
-    pthread_exit(NULL);
+    return 0;
 }
-#endif
-
-int cellular_reset(void)
+static int mqttc_sub_one(mqtt_conn_t *conn)
 {
-    int r=-1;
-    char buf[100];
-    cell_handle_t *h=&ceHandle;
-
-#ifdef USE_CELL
-    at_cmd_t *pcmd = data_of(CMD_CFUN);
-    r = send_cmd(h, pcmd, "=1,1", buf, sizeof(buf), 3);
-#endif
+    int i,r=-1;
+    char buf[200];
 
-    return r;
-}
+    if(!conn->h) {
+        return -1;
+    }
+    cell_handle_t *h=(cell_handle_t*)conn->h;
 
+    for(i=0; i<MQTT_SUB_MAX; i++) {
+        sprintf(buf, topic_sub[i], h->prod_id);
+        cell_mqtt_sub(conn, buf);
+    }
 
+    return 0;
+}
+static int mqttc_sub(cell_handle_t *h)
+{
+    int i;
 
-int cellular_init(void)
+    for(i=0; i<MQTT_MAX; i++) {
+        mqttc_sub_one(&h->mq_conn[i]);
+    }
+    return 0;
+}
+static int mqttc_pub(cell_handle_t *h, char *topic, char *data)
 {
-    int r;
-    cell_handle_t *h=&ceHandle;
-
-#ifdef USE_CELL
-    memset(h, 0, sizeof(cell_handle_t));
-
-    port_init(h);
-    h->dm = &__globalDeviceManage;
-    h->pcell = &_globalCellularManager;
-    h->pcell->mode = h->dm->_globalDevInfo.cell;
-    h->prod_id = h->dm->_globalDevInfo.product.id;
-    h->lck = lock_d_init();
-    
-    r = cell_init(h);
-    if(r) {
-        LOGE("__cell_init failed\n");
-        return -1;
-    }
-
-    if (0==thread_is_running(THREAD_ID_CELLULAR)) {
-        thread_start(THREAD_ID_CELLULAR, cellular_thread, h);
-    }
-#endif
-
-    return 0;
-}
-
-int cellular_deinit(void)
-{
-    cell_handle_t *h=&ceHandle;
-
-    lock_d_deinit(h->lck);
-    cell_deinit(h);
-    thread_stop(THREAD_ID_CELLULAR);
-
-    return 0;
-}
-
-int cellular_get_info(cell_info_t *info)
-{
-    int r=-1;
-    cell_handle_t *h=&ceHandle;
-
-#ifdef USE_CELL
-    r = cell_get_info(h, info);
-#endif
-
-    return r;
-}
-
-int cellular_get_stat(cell_stat_t *stat)
-{
-    int r=-1;
-    cell_handle_t *h=&ceHandle;
-
-#ifdef USE_CELL
-    r = cell_get_stat(h, stat);
-#endif
-
-    return r;
-}
-
-
-static int mqttc_init(cell_handle_t *h)
-{
-    int r=-1;
-
-    r = cell_mqtt_init(h);
-
-    return r;
-}
-static int get_host(mqtt_server_t *ser, mqtt_para_t *para)
-{
-    char *head="mqtts";
-
-    if(!ser->server[0] || !ser->port[0] || !ser->mode) {
-        return -1;
-    }
-
-    para->port = atoi(ser->port);
-    if(para->port==1883) {
-        head = "mqtt";
-    }
-    else if(para->port==8883) {
-        head = "mqtts";
-    }
-    else if(para->port==8083) {
-        head = "ws";
-    }
-    else if(para->port==8884) {
-        head = "wss";
-    }
-    sprintf(para->host, "%s://%s", head, ser->server);
-
-    return 0;
-}
-static int mqttc_conn(cell_handle_t *h, int flag)
-{
-    int i,r;
-    char host[200];
-    uint16_t port;
-    mqtt_para_t para;
-    mqtt_server_t *ser=h->dm->mqttInfo.ser;
-
-    if (flag) {
-        for(i=0; i<MQTT_MAX; i++) {
-            r = get_host(&ser[i], &para);
-            if((r==0)) {
-                if(h->mq_conn[i].h==NULL) {
-                    strcpy(para.username, ser->user);
-                    strcpy(para.password, ser->password);
-                    cell_mqtt_conn(h, &para);
-                }
-            }
-        }
-    }
-    else {
-        for(i=0; i<MQTT_MAX; i++) {
-            cell_mqtt_disconn(&h->mq_conn[i]);
-        }
-    }
-
-    return 0;
-}
-static int mqttc_sub_one(mqtt_conn_t *conn)
-{
-    int i,r=-1;
-    char buf[200];
-
-    if(!conn->h) {
-        return -1;
-    }
-    cell_handle_t *h=(cell_handle_t*)conn->h;
-
-    for(i=0; i<MQTT_SUB_MAX; i++) {
-        sprintf(buf, topic_sub[i], h->prod_id);
-        cell_mqtt_sub(conn, buf);
-    }
-    return 0;
-}
-static int mqttc_sub(cell_handle_t *h)
-{
-    int i;
-
-    for(i=0; i<MQTT_MAX; i++) {
-        mqttc_sub_one(&h->mq_conn[i]);
-    }
-    return 0;
-}
-static int mqttc_pub(cell_handle_t *h, char *topic, char *data)
-{
-    int i,r=-1;
+    int i,r=-1;
 
     for(i=0; i<MQTT_MAX; i++) {
         if(h->mq_conn[i].h) {
@@ -1490,153 +1510,7 @@ static int mqttc_pub(cell_handle_t *h, char *topic, char *data)
 }
 
 
-#define BGET(flag,mask)  ((flag)&(1<<(mask)))
-#define BSET(flag,mask)  ((flag)|=(1<<(mask)))
-
-static int get_date_time(char *d, char *t)
-{
-    time_t now;
-    struct tm* tm;
-
-    time(&now);
-    tm = localtime(&now);
-    if(!tm) {
-        return -1;
-    }
-    sprintf(d, "%04d-%02d-%02d", tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday);
-    sprintf(t, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
-    return 0;
-}
-static int get_serv(char *json)
-{
-    int i,flag=0;
-    cJSON* tmp=NULL;
-
-    if(json) {
-        cJSON* cjson=cJSON_Parse(json);
-        if(cjson) {
-            for(i=0; i<SERV_MAX; i++) {
-                tmp = cJSON_GetObjectItem(cjson, serv_str[i]);
-                if(tmp && tmp->valuestring) {
-                    flag |= (atoi(tmp->valuestring)<<i);
-                }
-            }
-
-            cJSON_Delete(cjson);
-        }
-    }
-    else {
-        if(thread_is_running(THREAD_ID_NTP)) {
-            BSET(flag, SERV_NTP);
-        }
-
-        if(thread_is_running(THREAD_ID_MAIL)) {
-            BSET(flag, SERV_SMTP);
-        }
-
-        if(thread_is_running(THREAD_ID_MQTT)) {
-            BSET(flag, SERV_MQTT);
-        }
-
-#if 0
-        if(thread_is_running(SERV_MESG)) {
-            BSET(flag, SERV_MESG);
-        }
-
-        if(thread_is_running(THREAD_ID_CLOUD)) {
-            BSET(flag, SERV_CLOUD);
-        }
-
-        if(thread_is_running(THREAD_ID_TELNET)) {
-            BSET(flag, SERV_TELNET);
-        }
-#endif
-
-        if(sys_is_running("snmpd")) {
-            BSET(flag, SERV_NTP);
-        }
-
-        if(thread_is_running(THREAD_ID_NTP)) {
-            BSET(flag, SERV_NTP);
-        }
-
-    }
-
-    return flag;
-}
-static int set_serv(int flag)
-{
-    if(BGET(flag,SERV_NTP)) {
-        if(!thread_is_running(THREAD_ID_NTP)) {
-            //thread_stop(THREAD_ID_NTP);
-        }
-    }
-    else {
-        if(thread_is_running(THREAD_ID_NTP)) {
-            thread_stop(THREAD_ID_NTP);
-        }
-    }
-
-    if(BGET(flag,SERV_SMTP)) {
-        if(!thread_is_running(THREAD_ID_MAIL)) {
-            //thread_stop(THREAD_ID_MAIL);
-        }
-    }
-    else {
-        if(thread_is_running(THREAD_ID_MAIL)) {
-            thread_stop(THREAD_ID_MAIL);
-        }
-    }
-
-    if(BGET(flag,SERV_MQTT)) {
-
-    }
-    else {
-        
-    }
-
-    if(BGET(flag,SERV_MESG)) {
-
-    }
-    else {
-        
-    }
-
-    if(BGET(flag,SERV_CLOUD)) {
-
-    }
-    else {
-        
-    }
 
-    if(BGET(flag,SERV_TELNET)) {
-
-    }
-    else {
-        
-    }
-
-    if(BGET(flag,SERV_SNMP_V1) || BGET(flag,SERV_SNMP_V2C) || BGET(flag,SERV_SNMP_V3) || BGET(flag,SERV_SNMP_TRAP)) {
-
-    }
-    else {
-        
-    }
-
-    return 0;
-}
-static char *get_int_str(int n)
-{
-    static char tmp[32];
-    snprintf(tmp, sizeof(tmp), "%d", n);
-    return tmp;
-}
-static char *get_float_str(float n)
-{
-    static char tmp[32];
-    snprintf(tmp, sizeof(tmp), "%0.3f", n);
-    return tmp;
-}
 static int mqttc_send_stat(cell_handle_t *h, int type)
 {
     int i,r=-1;
@@ -1952,12 +1826,142 @@ static int sock_test(void)
     }
     return 0;
 }
+/////////////////////////////////////////////////////////////////////////
+static int urc_handle(char *data, int len)
+{
+    char *key=NULL;
 
-int cellular_test(void)
+    key = "+QIURC: ";
+    if(strstr(data, key)) {
+
+    }
+    
+    key = "+QMT";
+    if(strstr(data, key)) {
+
+    }
+
+
+    return 0;
+}
+
+static void* cellular_thread(void *arg)
+{
+    int r;
+    thread_handle_t *th=(thread_handle_t*)arg;
+    cell_handle_t *h=(cell_handle_t*)th->arg;
+
+    while (th->quit==0) {
+        if(h->pcell->mode) {
+
+            r = port_recv(h, h->rxbuf, sizeof(h->rxbuf), QUERY_INTERVAL);
+            if(r>0) {
+                urc_handle(h->rxbuf, r);
+            }
+        }
+        else {
+            msleep(1000);
+        }
+        
+        
+    }
+    port_deinit(h);
+
+    pthread_exit(NULL);
+}
+#endif
+
+int cellular_reset(void)
+{
+    int r=-1;
+    char buf[100];
+    cell_handle_t *h=&ceHandle;
+
+#ifdef USE_CELL
+    at_cmd_t *pcmd = data_of(CMD_CFUN);
+    r = send_cmd(h, pcmd, "=1,1", buf, sizeof(buf), 3);
+#endif
+
+    return r;
+}
+
+
+
+int cellular_init(void)
 {
-    //sock_test();
-    mqttc_test();
+    int r;
+    cell_handle_t *h=&ceHandle;
 
+#ifdef USE_CELL
+    memset(h, 0, sizeof(cell_handle_t));
+
+    port_init(h);
+    h->dm = &__globalDeviceManage;
+    h->pcell = &_globalCellularManager;
+    h->pcell->mode = h->dm->_globalDevInfo.cell;
+    h->prod_id = h->dm->_globalDevInfo.product.id;
+    h->lck = lock_d_init();
+    
+    r = cell_init(h);
+    if(r) {
+        LOGE("__cell_init failed\n");
+        return -1;
+    }
+
+    if (0==thread_is_running(THREAD_ID_CELLULAR)) {
+        thread_start(THREAD_ID_CELLULAR, cellular_thread, h);
+    }
+#endif
+
+    return 0;
+}
+
+int cellular_deinit(void)
+{
+    cell_handle_t *h=&ceHandle;
+
+#ifdef USE_CELL
+    lock_d_deinit(h->lck);
+    cell_deinit(h);
+    thread_stop(THREAD_ID_CELLULAR);
+#endif
+
+    return 0;
+}
+
+int cellular_get_info(cell_info_t *info)
+{
+    int r=-1;
+    cell_handle_t *h=&ceHandle;
+
+#ifdef USE_CELL
+    r = cell_get_info(h, info);
+#endif
+
+    return r;
+}
+
+int cellular_get_stat(cell_stat_t *stat)
+{
+    int r=-1;
+    cell_handle_t *h=&ceHandle;
+
+#ifdef USE_CELL
+    r = cell_get_stat(h, stat);
+#endif
+
+    return r;
+}
+
+
+
+
+int cellular_test(void)
+{
+#ifdef USE_CELL
+    sock_test();
+    //mqttc_test();
+#endif
 
     return 0;
 }

+ 7 - 3
pro/src/dflt.c

@@ -65,22 +65,26 @@ GlobalDeviceInfo DFLT_PARAS={
         },
 
         .misc = {
-        #if (CHIP_TYPE == CHIP_T113s)
+        
+        #ifdef USE_WATCHDOG
             .watchdog = 1,
         #else
             .watchdog = 0,
         #endif
+
         #ifdef FLIP_TIME
             .flip_time = FLIP_TIME,
         #else
             .flip_time = 0,
         #endif
-        #if USE_LED
+
+        #ifdef USE_LED
             .led = 1,
         #else
             .led = 0,
         #endif
-        #if USE_BEEP
+
+        #ifdef USE_BEEP
             .beep = 1,
         #else
             .beep = 0,

+ 5 - 8
pro/ui/gpio.c

@@ -19,9 +19,6 @@
 
 int gpio_init(int gpio, int io)
 {
-    //===============5寸屏幕gpio和屏幕显示有冲突,暂时屏蔽按键功能===============
-    return -1;
-    log_e("GPIO___INIT_%d",gpio);
     int r,fd,flag;
     char tmp[20],path[100];
     
@@ -49,7 +46,7 @@ int gpio_init(int gpio, int io)
     }
 	r = write(fd, tmp, strlen(tmp));
 	if(r<0){
-	    LOGE("write gpio direction failed\n");
+	    LOGE("gpio_init, write gpio direction failed\n");
 		return -1;
     }
     close(fd);
@@ -58,7 +55,7 @@ int gpio_init(int gpio, int io)
     sprintf(path,"/sys/class/gpio/gpio%d/value", gpio);
 	fd = open(path, flag);
 	if(fd< 0){
-		LOGE("open gpio value failed\n");
+		LOGE("gpio_init, open gpio value failed\n");
 		return -1;
 	}
     
@@ -114,15 +111,15 @@ int gpio_set2(int gpio, int hl)
 
     sprintf(path,"/sys/class/gpio/gpio%d/value", gpio);
 	fd = open(path, O_RDWR);
-	if(fd< 0){
-		LOGE("open gpio value failed\n");
+	if(fd<0){
+		LOGE("gpio_set2, open failed,%d\n", errno);
 		return -1;
 	}
 
     sprintf(tmp, "%d", hl);
 	r = write(fd, tmp, strlen(tmp));
 	if(r<0){
-		LOGE("gpio_set2 failed\n");
+		LOGE("gpio_set2, write failed,%d\n", errno);
 		return -1;
     }
     close(fd);