B4R Question How to Configure GSM Sheild

Status
Not open for further replies.

pokhraj_d

Member
Hello All,
I have read the post from @Erel
B4X:
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
 

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 :
B4X:
#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
 
Upvote 0

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
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
For my knowledge, why you have used API_KEY at the example?
This is the Firebase key that is used to send a push notification. It is specific to that example.

The log shows "Connect State : 1"
Does that mean GSM cannot able to connect the webserver successfully?
I don't remember all details but 1 = true so it looks it it connected successfully.
 
Upvote 0

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 ...
B4X:
#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
 
Upvote 0
Status
Not open for further replies.
Top