Skip to content

Commit adef938

Browse files
adding license
1 parent 40366f8 commit adef938

File tree

3 files changed

+17
-30
lines changed

3 files changed

+17
-30
lines changed

Arduino Sketch/main/BLE.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
/*
2-
Copyright (c) 2019 Andy England
3-
Header: BLE.h
4-
*/
5-
61
#include "BLE.h"
72

83
#define SERVICE_UUID_ESPOTA "d804b643-6ce7-4e81-9f8a-ce0f699085eb"
94
#define CHARACTERISTIC_UUID_ID "d804b644-6ce7-4e81-9f8a-ce0f699085eb"
105

11-
#define SERVICE_UUID_OTA "c8659210-af91-4ad3-a995-a58d6fd26145"
6+
#define SERVICE_UUID_OTA "c8659210-af91-4ad3-a995-a58d6fd26145" // UART service UUID
127
#define CHARACTERISTIC_UUID_FW "c8659211-af91-4ad3-a995-a58d6fd26145"
138
#define CHARACTERISTIC_UUID_HW_VERSION "c8659212-af91-4ad3-a995-a58d6fd26145"
149

@@ -40,6 +35,7 @@ void otaCallback::onWrite(BLECharacteristic *pCharacteristic)
4035
esp_ota_end(otaHandler);
4136
Serial.println("EndOTA");
4237
if (ESP_OK == esp_ota_set_boot_partition(esp_ota_get_next_update_partition(NULL))) {
38+
delay(2000);
4339
esp_restart();
4440
}
4541
else {
@@ -50,6 +46,7 @@ void otaCallback::onWrite(BLECharacteristic *pCharacteristic)
5046
}
5147

5248
uint8_t txData[5] = {1, 2, 3, 4, 5};
49+
//delay(1000);
5350
pCharacteristic->setValue((uint8_t*)txData, 5);
5451
pCharacteristic->notify();
5552
}

Arduino Sketch/main/BLE.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
/*
2-
Copyright (c) 2019 Andy England
3-
4-
A BLE driver for Over the Air Updates
5-
6-
Built on top of the BLE utilities by Neil Kolban
7-
https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleNotify.cpp
8-
*/
9-
10-
111
#ifndef _BLE_H_
122
#define _BLE_H_
133

WebApp/src/App.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import React from 'react';
1+
2+
/***************************************************
3+
This is a React WebApp written to Flash an ESP32 via BLE
4+
5+
Written by Andrew England (SparkFun)
6+
BSD license, all text above must be included in any redistribution.
7+
*****************************************************/
8+
9+
import React from 'react';
210
import Popup from 'react-popup';
311
import './App.css';
412

@@ -36,9 +44,7 @@ function BTConnect(){
3644
optionalServices: [otaServiceUuid]
3745
})
3846
.then(device => {
39-
esp32Device = device;
40-
esp32Device.addEventListener('gattserverdisconnected', onDisconnected);
41-
return esp32Device.gatt.connect()
47+
return device.gatt.connect()
4248
})
4349
.then(server => server.getPrimaryService(otaServiceUuid))
4450
.then(service => {
@@ -90,6 +96,8 @@ function CheckVersion(){
9096
.then(value => {
9197
currentHardwareVersion = 'v' + value.getUint8(0) + '.' + value.getUint8(1);
9298
softwareVersion = 'v' + value.getUint8(2) + '.' + value.getUint8(3) + '.' + value.getUint8(4);
99+
document.getElementById('hw_version').innerHTML = "Hardware: " + currentHardwareVersion;
100+
document.getElementById('sw_version').innerHTML = "Software: " + softwareVersion;
93101
})
94102
//Grab our version numbers from Github
95103
.then(_ => fetch('https://raw.githubusercontent.com/sparkfun/ESP32_OTA_BLE_React_WebApp_Demo/master/GithubRepo/version.json'))
@@ -99,8 +107,6 @@ function CheckVersion(){
99107
})
100108
.then(function (data) {
101109
// JSON should be formatted so that 0'th entry is the newest version
102-
document.getElementById('hw_version').innerHTML = "Hardware: " + currentHardwareVersion;
103-
document.getElementById('sw_version').innerHTML = "Software: " + softwareVersion;
104110
if (latestCompatibleSoftware === softwareVersion)
105111
{
106112
//Software is updated, do nothing.
@@ -109,10 +115,10 @@ function CheckVersion(){
109115
var softwareVersionCount = 0;
110116
latestCompatibleSoftware = data.firmware[softwareVersionCount]['software'];
111117
versionFindLoop:
112-
while (latestCompatibleSoftware !=='undefined') {
118+
while (latestCompatibleSoftware !== undefined) {
113119
var compatibleHardwareVersion = "N/A"
114120
var hardwareVersionCount = 0;
115-
while (compatibleHardwareVersion !== 'undefined') {
121+
while (compatibleHardwareVersion !== undefined) {
116122
compatibleHardwareVersion = data.firmware[softwareVersionCount]['hardware'][hardwareVersionCount++];
117123
if (compatibleHardwareVersion === currentHardwareVersion)
118124
{
@@ -212,12 +218,6 @@ function SendBufferedData() {
212218
console.log("remaining: " + remaining);
213219
esp32Service.getCharacteristic(fileCharacteristicUuid)
214220
.then(characteristic => RecursiveSend(characteristic, dataToSend))
215-
.then(_ => {
216-
if (remaining === 0)
217-
{
218-
esp32Device.gatt.disconnect()
219-
}
220-
})
221221
.then(_ => {
222222
return document.getElementById('completion').innerHTML = (100 * (currentPosition/totalSize)).toPrecision(3) + '%';
223223
})

0 commit comments

Comments
 (0)