Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
abhijit-031991 authored Apr 24, 2022
0 parents commit 076b3fc
Show file tree
Hide file tree
Showing 8 changed files with 1,120 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
39 changes: 39 additions & 0 deletions include/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

This directory is intended for project header files.

A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.

```src/main.c

#include "header.h"

int main (void)
{
...
}
```

Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.

In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.

Read more about using header files in official GCC documentation:

* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes

https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
46 changes: 46 additions & 0 deletions lib/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.

The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").

For example, see a structure of the following two libraries `Foo` and `Bar`:

|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c

and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>

int main (void)
{
...
}

```

PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.

More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
16 changes: 16 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
monitor_speed = 115200
board_build.partitions = no_ota.csv
207 changes: 207 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
// #include <Arduino.h>
// #include <BluetoothSerial.h>
// #include <WiFi.h>
// #include <SPI.h>
// #include <Wire.h>
// #include <LoRa.h>
// #include <ArduinoJson.h>

// #define SCK 18 // GPIO5 -- SX1278's SCK
// #define MISO 19 // GPIO19 -- SX1278's MISnO
// #define MOSI 23 // GPIO27 -- SX1278's MOSI
// #define SS 5 // GPIO18 -- SX1278's CS
// #define RST 21 // GPIO14 -- SX1278's RESET
// #define DI0 22 // GPIO26 -- SX1278's IRQ(Interrupt Request)

// BluetoothSerial SerialBT;


// void setup() {
// // put your setup code here, to run once:
// Serial.begin(115200);
// SerialBT.begin("Arc-TraCK");
// SPI.begin(SCK,MISO,MOSI,SS);
// LoRa.setPins(SS,RST,DI0);

// WiFi.mode(WIFI_OFF);

// // if (!LoRa.begin(433E6)) {
// // Serial.println("Starting LoRa failed!");
// // while (1);
// // }
// // // LoRa.setSpreadingFactor(7);
// // Serial.println("SYSTEM READY");
// // // LoRa.onReceive(onReceive);

// }

// // void loop(){
// // while (SerialBT.available())
// // {
// // String dat;
// // dat = SerialBT.readString();
// // Serial.println(dat);
// // DynamicJsonDocument doc(256);
// // deserializeJson(doc, dat);
// // if (dat.length() < 25)
// // {
// // struct req{
// // byte tag;
// // byte req;
// // }r;
// // r.tag = doc["ID"];
// // r.req = doc["MSG"];

// // Serial.print(r.tag);
// // Serial.print(r.req);

// // LoRa.beginPacket();
// // LoRa.write((uint8_t*)&r, sizeof(r));
// // LoRa.endPacket();
// // }
// // if (dat.length() > 25)
// // {
// // struct setting{
// // byte gto;
// // byte hdop;
// // byte pfrq;
// // byte cpsw;
// // byte sttm;
// // byte sptm;
// // uint16_t gfrq;
// // }s;
// // JsonObject obj = doc.as<JsonObject>();
// // if (obj.containsKey("GTO"))
// // {
// // s.gto = obj[F("GTO")];
// // Serial.println((byte)obj[F("GTO")]);
// // }
// // if (obj.containsKey("GFRQ"))
// // {
// // s.gfrq = obj[F("GFRQ")];
// // Serial.println((byte)obj[F("GFRQ")]);
// // }
// // if (obj.containsKey("HDOP"))
// // {
// // s.hdop = obj[F("HDOP")];
// // Serial.println((byte)obj[F("HDOP")]);
// // }
// // if (obj.containsKey("PFRQ"))
// // {
// // s.pfrq = obj[F("PFRQ")];
// // Serial.println((byte)obj[F("PFRQ")]);
// // }
// // if (obj.containsKey("CPSW"))
// // {
// // s.cpsw = obj[F("CPSW")];
// // Serial.println((byte)obj[F("CPSW")]);
// // }
// // if (obj.containsKey("STTM"))
// // {
// // s.sttm = obj[F("STTM")];
// // Serial.println((byte)obj[F("STTM")]);
// // }
// // if (obj.containsKey("SPTM"))
// // {
// // s.sptm = obj[F("SPTM")];
// // Serial.println((byte)obj[F("SPTM")]);
// // }

// // // s.gfrq = doc[F("GFRQ")];
// // // s.hdop = doc[F("HDOP")];
// // // s.pfrq = doc[F("PFRQ")];
// // // s.cpsw = doc[F("CPSW")];
// // // s.sttm = doc[F("STTM")];
// // // s.sptm = doc[F("SPTM")];
// // Serial.println(s.gto);
// // Serial.println(s.gfrq);
// // Serial.println(s.hdop);
// // Serial.println(s.pfrq);
// // Serial.println(s.cpsw);
// // Serial.println(s.sttm);
// // Serial.println(s.sptm);
// // LoRa.beginPacket();
// // LoRa.write((uint8_t*)&s, sizeof(s));
// // LoRa.endPacket();
// // }

// // }

// // int x = LoRa.parsePacket();
// // if (x == 15)
// // {
// // String dat;
// // struct data{
// // uint32_t datetime;
// // uint16_t locktime;
// // float lat;
// // float lng;
// // byte hdop;
// // // byte id;
// // } __attribute__((__packed__)) d;

// // while (LoRa.available())
// // {
// // LoRa.readBytes((uint8_t*)&d, sizeof(d));
// // }
// // StaticJsonDocument<128> doc;
// // doc[F("Date")] = d.datetime;
// // doc[F("Lat")] = d.lat;
// // doc[F("Lng")] = d.lng;
// // doc[F("hdop")] = d.hdop;
// // doc[F("lktm")] = d.locktime;
// // doc[F("RSSI")] = LoRa.packetRssi();
// // serializeJson(doc, dat);
// // SerialBT.println(dat);
// // Serial.println(dat);
// // }
// // if (x == 2)
// // {
// // String dat;
// // struct resp{
// // byte tag;
// // byte res;
// // }r;

// // while (LoRa.available())
// // {
// // LoRa.readBytes((uint8_t*)&r, x);
// // }
// // StaticJsonDocument<128> doc;
// // doc[F("ID")] = r.tag;
// // doc[F("Msg")] = r.res;
// // doc[F("RSSI")] = LoRa.packetRssi();
// // serializeJson(doc, dat);

// // SerialBT.println(dat);
// // Serial.println(dat);
// // }
// // if (x == 12)
// // {
// // String dat;
// // struct ping{
// // uint8_t ta;
// // uint8_t devtyp;
// // uint16_t cnt;
// // float la;
// // float ln;
// // }p;

// // while (LoRa.available())
// // {
// // LoRa.readBytes((uint8_t*)&p, x);
// // }

// // StaticJsonDocument<256> doc;
// // doc[F("ID")] = p.ta;
// // doc[F("Lat")] = String(p.la, 6);
// // doc[F("Lng")] = String(p.ln, 6);
// // doc[F("DTyp")] = p.devtyp;
// // doc[F("cnt")] = p.cnt;
// // doc[F("RSSI")] = LoRa.packetRssi();
// // serializeJson(doc, dat);
// // SerialBT.println(dat);
// // Serial.println(dat);
// // }
// // }

Loading

0 comments on commit 076b3fc

Please sign in to comment.