STM32F103C8T6_Internal_RTC

Dependencies:   mbed-STM32F103C8T6 mbed

Fork of STM32F103C8T6_GPRS_TCP by Shivanand Gowda

main.cpp

Committer:
shivanandgowdakr
Date:
2018-07-13
Revision:
12:91de57777095
Parent:
10:4b88be251088
Child:
13:bf9a5ca067bf

File content as of revision 12:91de57777095:

#include "stm32f103c8t6.h"
#include "mbed.h"
#include "gprs.h"

    char Server[20]="119.81.0.11" ;              //write your Server IP here shoud be a static IP
    char Port[5]="8080";                         // write your port Number 
    char Phone_No[11]="1234567890";
    char Service_Provider[40]="airtelgprs.com";
    char Data[100]="Hellow World to Server";
    
    Serial      pc(PA_2, PA_3);
    DigitalOut  myled(LED1);
    GPRS   gprs(PB_6,PB_7,9600,Phone_No);
    char Reply[100]={'\0'};
int main()
 {
    confSysClock();     
        myled = 0;      // turn the LED on
        wait_ms(200);   // 200 millisecond
        myled = 1;      // turn the LED off
        wait_ms(1000);  // 1000 millisecond
        pc.printf("Blink\r\n");
        
          
    pc.printf("Am here.... GOOD\r\n"); 
    gprs.init();
    if(gprs.checkSIMStatus()==0)
    { 
        pc.printf("SIM Status is GOOD\r\n"); 
        }
    else
    {
        pc.printf("SIM NOT Preset \r\n"); 
        }
    
     if(gprs.checkSignalStrength ()>=3)
     {
         pc.printf("Signal strength Good \r\n");  
           
        }  
        else
        {
        pc.printf("Signal strength Weak\r\n");  
        }
        
        if(gprs.checkSIMStatus()==0)
        {
             pc.printf("SIM Status is GOOD\r\n"); 
        }  
            
        else
        {
             pc.printf("SIM NOT Present \r\n"); 
        }  
        
//        gprs.networkInit( "202.56.231.117:8080");
         int success= gprs.networkInit(Service_Provider);   //write your apn here
         if(success==0)
         pc.printf("Network Initialised \r\n");
         else
         pc.printf("Unable Initialise Network  \r\n");
          
          
          success=gprs.connectTCP(Server,Port);
          
         if(success==0)
         pc.printf("Connected to Server  \r\n");
         else
         pc.printf("Unable connect to Server   \r\n");
         
         success= gprs.sendTCPData(Data);
         
         if(success==0)
         pc.printf("Data Sent  \r\n");
         else
         pc.printf("Unable connect to Server   \r\n");
         
         success=gprs.waitforReply(Reply);
         
         if(success==0)
         pc.printf("Data Received form Server  \r\n");
         else
         pc.printf("No Reply from Server \r\n");

         success=gprs.closeTCP();
         
         if(success==0)
         pc.printf("Close TCP Connection  \r\n");
         else
         pc.printf("Unable to detach from Server \r\n");
         
         success=gprs.shutTCP();
         
         if(success==0)
         pc.printf("Shut TCP Connection  \r\n");
         else
         pc.printf("Unable to Shut TCP Connection \r\n");
        
    }