Skip to content

Commit

Permalink
Added ESp8266
Browse files Browse the repository at this point in the history
Code cleanup
  • Loading branch information
beegee-tokyo committed Aug 2, 2019
1 parent 282993e commit 45dc3fa
Show file tree
Hide file tree
Showing 61 changed files with 12,937 additions and 12,610 deletions.
64 changes: 34 additions & 30 deletions .library.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
{
"name": "SX126x-Arduino",
"version": "1.0.0",
"keywords": [
"lora",
"semtach",
"sx126x"
],
"description": "Arduino library to use Semtech SX126x LoRa chips and modules to communicate",
"frameworks": [
"arduino"
],
"platforms": [
"espressif32, nrf52"
],
"license": [
"MIT License"
],
"authors": [
{
"email": "[email protected]",
"url": "https://www.desire.giesecke.tk",
"maintainer": true,
"name": "Bernd Giesecke"
}
],
"repository": {
"type": "git",
"url": "https://github.com/beegee-tokyo/SX126x-ESP32"
},
"homepage": "https://github.com/beegee-tokyo/SX126x-ESP32"
"name": "SX126x-Arduino",
"version": "1.0.0",
"keywords": [
"lora",
"Semtech",
"SX126x"
],
"description": "Arduino library to use Semtech SX126x LoRa chips and modules to communicate",
"frameworks": [
"arduino"
],
"platforms": [
"espressif32, nrf52, esp8266"
],
"license": [
"MIT License"
],
"examples":
[
"examples/*/*.ino"
],
"authors": [
{
"email": "[email protected]",
"url": "https://www.desire.giesecke.tk",
"maintainer": true,
"name": "Bernd Giesecke"
}
],
"repository": {
"type": "git",
"url": "https://github.com/beegee-tokyo/SX126x-Arduino"
},
"homepage": "https://github.com/beegee-tokyo/SX126x-Arduino"
}
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SX126x-Arduino

General info
--------
Arduino library for LoRa communication with Semtech SX126x chips. It is based on Semtech's SX126x libraries and adapted to the Arduino framework for ESP32 and nRF52832. It will not work with other uC's like AVR or Espressif 8266 (yet).
Arduino library for LoRa communication with Semtech SX126x chips. It is based on Semtech's SX126x libraries and adapted to the Arduino framework for ESP32. ESP8266 and nRF52832. It will not work with other uC's like AVR.

I stumbled over the [SX126x LoRa family](https://www.semtech.com/products/wireless-rf/lora-transceivers) in a customer project. The existing Arduino libraries for Semtech's SX127x family are unfortunately not working with this new generation LoRa chip. I found a usefull base library from Insight SIP which is based on the original Semtech SX126x library and changed it to work with the ESP32.
For now the library is tested with an [eByte E22-900M22S](http://www.ebyte.com/en/product-view-news.aspx?id=437) module connected to an ESP32 and an [Insight SIP ISP4520](https://www.insightsip.com/products/combo-smart-modules/isp4520) which combines a Nordic nRF52832 and a Semtech SX1262 in one module
Expand All @@ -22,7 +22,7 @@ Licenses
--------
Library published under MIT license

Semtech revised BSD license
Semtech revised BSD license for codeparts used from Semtech S.A.
```
--- Revised BSD License ---
Copyright (c) 2013, SEMTECH S.A.
Expand Down Expand Up @@ -53,7 +53,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Changelog
--------
- 2019-07-31: Added LoRaWan support
- 2019-08-01: Added Espressif ESP8266 support
- 2019-07-31: Added LoRaWan support (only partly tested)
- 2019-07-28: Restructure of folders, added nRF52832 support
- 2019-07-26: First commit.

Expand All @@ -68,7 +69,7 @@ Functions
-----
WORK IN PROGRESS
**_Check out the example provided with this library to learn the basic functions._**
See [examples](https://github.com/beegee-tokyo/SX126x-ESP32/tree/master/examples)
See [examples](https://github.com/beegee-tokyo/SX126x-Android/tree/master/examples)

Module specific setup
--------
Expand Down Expand Up @@ -118,10 +119,10 @@ DIO3 as antenna switch is used by e.g. [Insight SIP ISP4520](https://www.insight

Usage
-----
See [examples](https://github.com/beegee-tokyo/SX126x-ESP32/examples).
There is one example for [ArduinoIDE](https://github.com/beegee-tokyo/SX126x-ESP32/tree/master/examples/PingPong) and one example for [PlatformIO](https://github.com/beegee-tokyo/SX126x-ESP32/tree/master/examples/PingPongPio) available.
See [examples](https://github.com/beegee-tokyo/SX126x-Android/examples).
There is one example for [ArduinoIDE](https://github.com/beegee-tokyo/SX126x-Android/tree/master/examples/PingPong) and one example for [PlatformIO](https://github.com/beegee-tokyo/SX126x-Android/tree/master/examples/PingPongPio) available.
The PingPong examples show how to define the HW connection between the MCU and the SX126x chip/module.
Another example is only partly tested. It is for LoRaWan and I could only test it as far as I know the application is sending out packages. But as I don't own a LoRaWan gateway I cannot test the functionality. Theoretically it should support Class A, B and C nodes. The examples can be found here: [ArduinoIDE](https://github.com/beegee-tokyo/SX126x-ESP32/tree/master/examples/LoRaWan) and one example for [PlatformIO](https://github.com/beegee-tokyo/SX126x-ESP32/tree/master/examples/LoRaWanPio)
Another example is only partly tested. It is for LoRaWan and I could only test it as far as I know the application is sending out packages. But as I don't own a LoRaWan gateway I cannot test the functionality. Theoretically it should support Class A, B and C nodes. The examples can be found here: [ArduinoIDE](https://github.com/beegee-tokyo/SX126x-Android/tree/master/examples/LoRaWan) and one example for [PlatformIO](https://github.com/beegee-tokyo/SX126x-Android/tree/master/examples/LoRaWanPio)
To use these examples you need to edit the header file ```Commissioning.h``` in the library folder ```src/mac```

Structure to define the connection between the MCU and the SX126x
Expand Down Expand Up @@ -325,6 +326,6 @@ Installation
In Arduino IDE open Sketch->Include Library->Manage Libraries then search for _**SX126x-Arduino**_
In PlatformIO open PlatformIO Home, switch to libraries and search for _**SX126x-Arduino**_. Or install the library in the terminal with _**`platformio lib install SX126x-Arduino`**_

For manual installation [download](https://github.com/beegee-tokyo/SX126x-Arduino) the archive, unzip it and place the SX126x-ESP32 folder into the library directory.
For manual installation [download](https://github.com/beegee-tokyo/SX126x-Arduino) the archive, unzip it and place the SX126x-Android folder into the library directory.
In Arduino IDE this is usually _**`<arduinosketchfolder>/libraries/`**_
In PlatformIO this is usually _**`<user/.platformio/lib>`**_
File renamed without changes.
19 changes: 19 additions & 0 deletions examples/LoRaWanPio/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[platformio]
default_envs =
esp32dev
nrf52
esp8266

[env:esp32dev]
platform = https://github.com/platformio/platform-espressif32.git#feature/stage
board = esp32dev
Expand All @@ -25,3 +31,16 @@ framework = arduino
build_flags =
-DCFG_DEBUG=2
-DREGION_US915

[env:esp8266]
platform = https://github.com/platformio/platform-espressif8266.git#feature/stage
; platform = espressif8266
board = nodemcuv2
framework = arduino
upload_port = COM10
upload_speed = 921600
board_build.f_cpu = 160000000L
build_flags =
-Wl,-Tesp8266.flash.4m1m.ld
-Og
-DREGION_US915
54 changes: 27 additions & 27 deletions examples/LoRaWanPio/src/ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,34 @@ bool bleUARTisConnected = false;

void initBLE(void)
{
Bluefruit.begin();
// Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
Bluefruit.setTxPower(4);
Bluefruit.setName("PPG_LORA_SX126x_TEST");
Bluefruit.begin();
// Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
Bluefruit.setTxPower(4);
Bluefruit.setName("PPG_LORA_SX126x_TEST");

Bluefruit.autoConnLed(false);
Bluefruit.autoConnLed(false);

Bluefruit.Periph.setConnectCallback(connect_callback);
Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
Bluefruit.Periph.setConnectCallback(connect_callback);
Bluefruit.Periph.setDisconnectCallback(disconnect_callback);

// To be consistent OTA DFU should be added first if it exists
bledfu.begin();
// To be consistent OTA DFU should be added first if it exists
bledfu.begin();

// Configure and Start BLE Uart Service
bleuart.begin();
// Configure and Start BLE Uart Service
bleuart.begin();

// Set up and start advertising
startAdv();
// Set up and start advertising
startAdv();
}

void startAdv(void)
{
// Advertising packet
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
Bluefruit.Advertising.addTxPower();
Bluefruit.Advertising.addName();
// Advertising packet
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
Bluefruit.Advertising.addTxPower();
Bluefruit.Advertising.addName();

/* Start Advertising
/* Start Advertising
* - Enable auto advertising if disconnected
* - Interval: fast mode = 20 ms, slow mode = 152.5 ms
* - Timeout for fast mode is 30 seconds
Expand All @@ -50,17 +50,17 @@ void startAdv(void)
* For recommended advertising interval
* https://developer.apple.com/library/content/qa/qa1931/_index.html
*/
Bluefruit.Advertising.restartOnDisconnect(true);
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
Bluefruit.Advertising.restartOnDisconnect(true);
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
}

// callback invoked when central connects
void connect_callback(uint16_t conn_handle)
{
(void)conn_handle;
bleUARTisConnected = true;
(void)conn_handle;
bleUARTisConnected = true;
}

/**
Expand All @@ -70,8 +70,8 @@ void connect_callback(uint16_t conn_handle)
*/
void disconnect_callback(uint16_t conn_handle, uint8_t reason)
{
(void)conn_handle;
(void)reason;
bleUARTisConnected = false;
(void)conn_handle;
(void)reason;
bleUARTisConnected = false;
}
#endif
Loading

0 comments on commit 45dc3fa

Please sign in to comment.