Giter Club home page Giter Club logo

attester's Introduction

AT Tester

This program is a simple "challenge-response" sketch.

It is setup to communicate to a modem over a SoftwareSerial line at 9600bps.

The sketch is extensively tested with a SIM7000 modem.

There are two example functions to send restAPI requests to a remote server. The functions restAPIget and restAPIpost are located in the tab's with the same name. You can execute the functions by entering getapi or postapi in the command prompt (the input line in the Arduino Serial Monitor).

You have to tailer these functions for your specific needs.

getAPI

===> GETAPI
getRestAPI ..
---> AT+CSQ
<--- AT+CSQ
+CSQ: 24,99
OK
---> AT+SAPBR=1,1
<--- AT+SAPBR=1,1
ERROR
---> AT+HTTPTERM
<--- AT+HTTPTERM
ERROR
---> AT+HTTPINIT
<--- AT+HTTPINIT
OK (true state)
---> AT+HTTPPARA="URL","http://httpbin.org/get"
<--- AT+HTTPPARA="URL","http://httpbin.org/get"
OK (true state)
---> AT+HTTPPARA="CID",1
<--- AT+HTTPPARA="CID",1
OK (true state)
---> AT+HTTPACTION=0
<--- AT+HTTPACTION=0
OK
+HTTPACTION: 0,200,255 (true state)
---> AT+HTTPREAD=0,500
<--- AT+HTTPREAD=0,500
+HTTPREAD: 255
{
  "args": {},
  "headers": {
    "Accept": "*/*",
    "Host": "httpbin.org",
    "User-Agent": "SIMCOM_MODULE",
    "X-Amzn-Trace-Id": "Root=1-60b3633d-4a9d49f801e25839122b33bb"
  },
  "origin": "18.197.48.88",
  "url": "http://httpbin.org/get"
}
OK (true state)
---> AT+HTTPTERM
<--- AT+HTTPTERM
OK
==>> Done..

postAPI

===> POSTAPI
postRestAPI ..
---> AT+CSQ
<--- AT+CSQ
+CSQ: 24,99
OK
---> AT+HTTPINIT
<--- AT+HTTPINIT
OK (true state)
---> AT+HTTPPARA="URL","http://httpbin.org/post"
<--- AT+HTTPPARA="URL","http://httpbin.org/post"
OK (true state)
---> AT+HTTPPARA="CID",1
<--- AT+HTTPPARA="CID",1
OK (true state)
---> AT+HTTPPARA="CONTENT","application/json"
<--- AT+HTTPPARA="CONTENT","application/json"
OK (true state)
AT+HTTPDATA=17,10000
DOWNLOAD
(true state)
---> [{"simple":"json"}]
OK
---> AT+HTTPACTION=1
<--- AT+HTTPACTION=1
OK
+HTTPACTION: 1,200,432 (true state)
---> AT+HTTPREAD=0,500
<--- AT+HTTPREAD=0,500
+HTTPREAD: 432

{
  "args": {},
  "data": "{\"simple\":\"json\"}",
  "files": {},
  "form": {},
  "headers": {
    "Accept": "*/*",
    "Content-Length": "17",
    "Content-Type": "application/json",
    "Host": "httpbin.org",
    "User-Agent": "SIMCOM_MODULE",
    "X-Amzn-Trace-Id": "Root=1-60b3627f-40a256736a4e20064daaeecf"
  },
  "json": {
   "simple" "json"
  }
  "origin: "18.197.48.88",
  "url": "http://httpbin.org/post"
}
OK (true state)
---> AT+HTTPTERM
<--- AT+HTTPTERM
OK
==>> Done..

The following functions handle the "challenge-response" and can be used for your specific needs:

sendAtCmnd(<ATcommand>)

This function sends the string ATcommand to the modem and waits for a maximum of 1000ms for a response. If the modem sends back the string "OK" the function exits immediately with a returncode "1". If the modem sends back the string "ERROR" the function exits immediately with a returncode "-1". If the modem does not send a response the function times-out (returncode "0").

sendAtCmnd(<ATcommand>, <waitTime>)

This function sends the string ATcommand to the modem and waits for a maximum of waitTimems for a response. If the modem sends back the string "OK" the function exits immediately with a returncode "1". If the modem sends back the string "ERROR" the function exits immediately with a returncode "-1". If the modem does not send a response the function times-out (returncode "0").

sendAtCmnd(<ATcommand>, <OKstring>, <ERRORstring>, <waitTime> {,showRC})

This function sends the string ATcommand to the modem and waits for a maximum of waitTimems for a response. If the modem sends back the string OKstring the function exits immediately with a returncode "1". If the modem sends back the string ERRORstring the function exits immediately with a returncode "-1". If the modem does not send a response the function times-out (returncode "0").

handleInFromSim()

This function waits 50ms for chars send by the modem and prints them.

handleInFromSim(<waitTime>)

This function waits waitTimems for chars send by the modem and prints them.

handleInFromSim(<OKstring>, <ERRORstring>, <waitTime> {,showRC})

This function checks waitTimems for chars send by the modem and prints them. if the modem sends the OKstring the function exits immediately with returncode "1". if the modem sends the ERRORstring the function exits immediately with returncode "-1". If neither is received before waitTimems the function exits with returncode "0".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.