B4R Question How to Configure GSM Sheild

Discussion in 'B4R Questions' started by pokhraj_d, Sep 23, 2018.

Thread Status:
Not open for further replies.
  1. pokhraj_d

    pokhraj_d Member

    Hello All,
    I have read the post from @Erel
    Code:
    https://www.b4x.com/android/forum/threads/http-requests-with-gsm-shield.81382/#content
    Download the attached file GSMPushMessages.zip. Copied 2 files Globalstores.bas, GSM.bas to the location "C:\Program Files (x86)\Anywhere Software\B4R\Libraries"

    But I am not able to initialize the GSM.initialize as it is throwing error.

    Could you please advice.

    Thanks-
    Pokhraj Das
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    This is a mistake. The two 'bas' files are code modules that should be added to your project.
     
  3. pokhraj_d

    pokhraj_d Member

    Hello @Erel,
    Thanks for your advice. My Mistake. I have included the two files as project->Add Existing Modules from the IDE.
    Now I wanted to connect to webserver. I have one cloud server as "srv30.cloudserverzone.com" with domain name as "cryptappz.in"
    I am trying to connect as below :
    Code:
    #Region Project Attributes
        
    #AutoFlushLogs: True
        
    #CheckArrayBounds: True
        
    #StackBufferSize: 300
    #End Region

    Sub Process_Globals
        
    'These global variables will be declared once when the application starts.
        'Public variables can be accessed from all modules.
        Public Serial1 As Serial
        
    Public APN As String = "airtelgrps.com"
        
    Public Host As String = "srv30.cloudserverzone.com"
    End Sub

    Private Sub AppStart
        Serial1.Initialize(
    115200)
        
    Log("AppStart")
        GSM.Init(
    10,12)
        GSM.Start
    End Sub
    But when I wanted to compile I am getting compilation error as below
    upload_2018-9-30_13-9-29.png

    Am I doing any wrong thing? Please advice on this.

    Thanks-
    Pokhraj Das
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You should post the text instead of the screenshot. Add a reference to rRandomAccessFile library.
     
  5. pokhraj_d

    pokhraj_d Member

    @Erel,
    Yes.... I have done that. Also I have commented the API_KEY part at GSM.bas. Now my code has been compiled successfully.
    The log shows "Connect State : 1"
    Does that mean GSM cannot able to connect the webserver successfully?

    For my knowledge, why you have used API_KEY at the example?

    Thanks-
    Pokhraj Das
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    This is the Firebase key that is used to send a push notification. It is specific to that example.

    I don't remember all details but 1 = true so it looks it it connected successfully.
     
  7. pokhraj_d

    pokhraj_d Member

    Hello @Erel,
    Thanks for your suggestion. It is now connected successfully.
    One more confusion now:(...
    Now I wanted to send the temp and Humidity to that cloud server by http request which I am now able to connect.

    I have the below sketch which is running fine ...
    Code:
    #Region Project Attributes
        
    #AutoFlushLogs: True
        
    #CheckArrayBounds: True
        
    #StackBufferSize: 300
    #End Region

    Sub Process_Globals
        
    Public Serial1 As Serial
        
    Public Humid,temperature As Float
        
    Private pin10 As Pin
        
    Private pin6 As Pin
        
    Private timer1 As Timer
    End Sub

    Private Sub AppStart
        Serial1.Initialize(
    115200)
        
    Log("AppStart")
        pin10.Initialize(
    10,pin10.MODE_OUTPUT)
        pin6.Initialize(
    6,pin6.MODE_OUTPUT)
        timer1.Initialize(
    "timer1_Tick",1000)
        timer1.Enabled=
    True
        RunNative(
    "setup",Null)
    End Sub

    Private Sub timer1_tick()
        RunNative(
    "read"Null)
        
    'Dim currentstate As Boolean = pin6.DigitalRead 'Now the state is zero[0]
        Dim newstate As Boolean = True
        
    Dim currentstate As Boolean = Not(newstate)
        
    Log("Humidity :",Humid)
        
    If Humid > 90 Then
            
    Log("Maximum Humidity")
            
    'newstate=Not(currentstate)
            pin6.DigitalWrite(newstate)
            
    Log("the Newstate is :" , newstate)
        
    Else
            
    'Dim currentstate As Boolean = Not(newstate)
            pin6.DigitalWrite(currentstate)
            
    Log("the Currentstate is :" , currentstate)
        
    End If
        
    'Log("Temperature :", temperature)
        
    End Sub


    #if C
    #include "DHT.h"
    #define DHTPIN 10
    #define DHTTYPE DHT11
    DHT dht(DHTPIN, DHTTYPE);
    void setup(B4R::Object* o){
    dht.begin();
    }
    void read (B4R::Object* o) {
       b4r_main::_humid = dht.readHumidity();
       b4r_main::_temperature =dht.readTemperature();
    }
    #End if
    How Do I send the data as http request? Could you please suggest?

    Thanks-
    Pokhraj Das
     
  8. tigrot

    tigrot Well-Known Member Licensed User

    The argument was already introduced. Search for HTTP POST or GET in this forum and you can find a lot of informations.
    But pls. open a new conversation when you change the subject...
    Ciao!
     
    Erel likes this.
Thread Status:
Not open for further replies.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice