Skip to content

Commit 5ee1d6f

Browse files
author
AJ Keller
authored
Merge pull request #44 from aj-ptw/dev
Dev
2 parents 8df7997 + 26f1b15 commit 5ee1d6f

File tree

9 files changed

+161
-64
lines changed

9 files changed

+161
-64
lines changed

OpenBCI_Wifi.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ void OpenBCI_Wifi_Class::initVariables(void) {
7373
head = 0;
7474
lastSampleNumber = 0;
7575
lastTimeWasPolled = 0;
76+
mqttPort = DEFAULT_MQTT_PORT;
7677
passthroughPosition = 0;
7778
tail = 0;
7879
tcpPort = 80;
@@ -222,7 +223,7 @@ String OpenBCI_Wifi_Class::getInfoBoard(void) {
222223
}
223224

224225
String OpenBCI_Wifi_Class::getInfoMQTT(boolean clientMQTTConnected) {
225-
const size_t bufferSize = JSON_OBJECT_SIZE(6) + 1400;
226+
const size_t bufferSize = JSON_OBJECT_SIZE(7) + 2000;
226227
StaticJsonBuffer<bufferSize> jsonBuffer;
227228
String json;
228229
JsonObject& root = jsonBuffer.createObject();
@@ -231,6 +232,7 @@ String OpenBCI_Wifi_Class::getInfoMQTT(boolean clientMQTTConnected) {
231232
root[JSON_MQTT_USERNAME] = String(mqttUsername);
232233
root[JSON_TCP_OUTPUT] = getCurOutputModeString();
233234
root[JSON_LATENCY] = getLatency();
235+
root[JSON_MQTT_PORT] = mqttPort;
234236
root.printTo(json);
235237
return json;
236238
}
@@ -336,12 +338,12 @@ unsigned long OpenBCI_Wifi_Class::getLatency(void) {
336338
uint8_t OpenBCI_Wifi_Class::getJSONMaxPackets(uint8_t numChannels) {
337339
switch (numChannels) {
338340
case NUM_CHANNELS_GANGLION:
339-
return 7; // Size of
341+
return 10; // Size of
340342
case NUM_CHANNELS_CYTON_DAISY:
341-
return 2;
343+
return 6;
342344
case NUM_CHANNELS_CYTON:
343345
default:
344-
return 5;
346+
return 10;
345347
}
346348
}
347349

@@ -616,10 +618,11 @@ void OpenBCI_Wifi_Class::setGains(uint8_t *raw) {
616618
* @param username {String} - The username for the MQTT broker to user
617619
* @param password {String} - The password for you to connect to
618620
*/
619-
void OpenBCI_Wifi_Class::setInfoMQTT(String brokerAddress, String username, String password) {
621+
void OpenBCI_Wifi_Class::setInfoMQTT(String brokerAddress, String username, String password, int port) {
620622
mqttBrokerAddress = brokerAddress;
621623
mqttUsername = username;
622624
mqttPassword = password;
625+
mqttPort = port;
623626
setOutputProtocol(OUTPUT_PROTOCOL_MQTT);
624627
}
625628

OpenBCI_Wifi.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ class OpenBCI_Wifi_Class {
4141
OUTPUT_PROTOCOL_TCP,
4242
OUTPUT_PROTOCOL_MQTT,
4343
OUTPUT_PROTOCOL_WEB_SOCKETS,
44-
OUTPUT_PROTOCOL_SERIAL
44+
OUTPUT_PROTOCOL_SERIAL,
45+
OUTPUT_PROTOCOL_AZURE_EVENT_HUB
4546
};
4647

4748
typedef enum CYTON_GAIN {
@@ -139,7 +140,7 @@ class OpenBCI_Wifi_Class {
139140
void sampleReset(Sample *, uint8_t);
140141
void setGains(uint8_t *);
141142
void setGains(uint8_t *, uint8_t *);
142-
void setInfoMQTT(String, String, String);
143+
void setInfoMQTT(String, String, String, int);
143144
void setInfoTCP(String, int, boolean);
144145
void setLatency(unsigned long);
145146
void setNumChannels(uint8_t);
@@ -169,6 +170,7 @@ class OpenBCI_Wifi_Class {
169170

170171
IPAddress tcpAddress;
171172

173+
int mqttPort;
172174
int tcpPort;
173175

174176
OUTPUT_MODE curOutputMode;

OpenBCI_Wifi_Definitions.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef __OpenBCI_Wifi_Definitions__
1010
#define __OpenBCI_Wifi_Definitions__
1111

12-
#define SOFTWARE_VERSION "v1.1.3"
12+
#define SOFTWARE_VERSION "v1.3.0"
1313

1414
#define ADS1299_VREF 4.5
1515
#define MCP3912_VREF 1.2
@@ -20,12 +20,9 @@
2020
// #define DEBUG 1
2121
#define MAX_SRV_CLIENTS 2
2222
#define BYTES_PER_CHANNEL 3
23-
// #define NUM_PACKETS_IN_RING_BUFFER 45
24-
#define NUM_PACKETS_IN_RING_BUFFER 2000
25-
#define NUM_PACKETS_IN_RING_BUFFER_JSON 20
23+
#define NUM_PACKETS_IN_RING_BUFFER_JSON 1
2624
#define NUM_RAW_BUFFERS 2
27-
// #define MAX_PACKETS_PER_SEND_TCP 20
28-
#define MAX_PACKETS_PER_SEND_TCP 30
25+
#define MAX_PACKETS_PER_SEND_TCP 50
2926
#define BYTES_PER_RAW_BUFFER MAX_PACKETS_PER_SEND_TCP * BYTES_PER_OBCI_PACKET
3027
#define WIFI_SPI_MSG_LAST 0x01
3128
#define WIFI_SPI_MSG_MULTI 0x02
@@ -39,6 +36,7 @@
3936
#define LED_NOTIFY 5
4037
#define GANGLION_GAIN 51
4138
#define DEFAULT_LATENCY 10000
39+
#define DEFAULT_MQTT_PORT 1883
4240
// #define bit(b) (1UL << (b)) // Taken directly from Arduino.h
4341
// Arduino JSON needs bytes for duplication
4442
// to recalculate visit:
@@ -57,7 +55,7 @@
5755
#define CLIENT_RESPONSE_NO_BODY_IN_POST 402
5856
#define CLIENT_RESPONSE_MISSING_REQUIRED_CMD 403
5957
#define NANO_VOLTS_IN_VOLTS 1000000000.0
60-
#define MAX_JSON_BUFFER_SIZE 3000
58+
#define MAX_JSON_BUFFER_SIZE 4000
6159

6260
#define ADS_GAIN_1 1
6361
#define ADS_GAIN_2 2
@@ -101,6 +99,7 @@
10199
#define JSON_MQTT_BROKER_ADDR "broker_address"
102100
#define JSON_MQTT_PASSWORD "password"
103101
#define JSON_MQTT_USERNAME "username"
102+
#define JSON_MQTT_PORT "port"
104103
#define JSON_NAME "name"
105104
#define JSON_NUM_CHANNELS "num_channels"
106105
#define JSON_SAMPLE_NUMBERS "sample_numbers"

WiFiClientPrint.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <WiFiClient.h>
55
#include <Print.h>
66

7-
template<size_t BUFFER_SIZE = MAX_JSON_BUFFER_SIZE>
7+
template<size_t BUFFER_SIZE = 1000>
88
class WiFiClientPrint : public Print
99
{
1010
public:
@@ -42,6 +42,9 @@ class WiFiClientPrint : public Print
4242
void flush()
4343
{
4444
if (_length != 0) {
45+
// for (size_t i = 0; i < _length; i++) {
46+
// Serial.print((char)_buffer[i]);
47+
// }
4548
_client.write((const uint8_t*)_buffer, _length);
4649
_length = 0;
4750
}

changelog.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
# v1.3.0
2+
3+
At this time, can no longer support both RAW and JSON modes with a single binary file. Need optimized builds. We ended up having two modes that didnt work that well instead of highly optimized builds for the different operating modes.
4+
5+
### Breaking Changes
6+
7+
* For RAW only (can't do Raw to JSON or MQTT) - upload the binary for `DefaultWifiShield_v1.3.0.bin`
8+
* This is the default firmware to be shipped with WiFi Shields
9+
* Sample rates of 1000Hz with Cyton (with or without Daisy) possible
10+
* Use the OpenBCI_GUI/OpenBCIHub
11+
* For JSON over (TCP/MQTT) (can't use OpenBCI GUI) - upload the binary for `WifiShield_RawToJSON_v1.3.0.bin`
12+
* Only tested with 200Hz with Ganglion
13+
* Only tested with 250Hz with Cyton
14+
15+
# v1.2.0
16+
17+
### Bug Fixes
18+
19+
* Allow for CORS on HTTP server for every call. Closes #41
20+
* Extend max tcp packets per send
21+
* Optimize JSON packet streaming for better performance, allows for latency up to 39ms for 8 channel and 4 channel and 25ms for 16 channel when streaming out JSON
22+
* Changed return of route of /cloud
23+
124
# v1.1.4
225

326
### Bug Fixes

0 commit comments

Comments
 (0)