Skip to content

Commit 64e9b90

Browse files
committed
WIP: git reset HEAD~
1 parent 2de6873 commit 64e9b90

File tree

2 files changed

+38
-30
lines changed

2 files changed

+38
-30
lines changed

.devcontainer/devcontainer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"context": "..",
88

99
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
10-
//"dockerFile": "../.github/actions/compile-examples/Dockerfile",
11-
"dockerFile": "../.github/actions/run-tests-in-container/Dockerfile",
10+
"dockerFile": "../.github/actions/compile-examples/Dockerfile",
11+
//"dockerFile": "../.github/actions/run-tests-in-container/Dockerfile",
1212

1313
// Set *default* container specific settings.json values on container create.
1414
"settings": {},

examples/Example1_NotecardBasics/Example1_NotecardBasics.ino

+36-28
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
// Include the Arduino library for the Notecard
1818

1919
#include <Notecard.h>
20-
#include <Wire.h>
2120

2221
// If the Notecard is connected to a serial port, define it here. For example, if you are using
2322
// the Adafruit Feather NRF52840 Express, the RX/TX pins (and thus the Notecard) are on Serial1.
@@ -44,7 +43,7 @@
4443

4544
// This is the unique Product Identifier for your device
4645
#ifndef PRODUCT_UID
47-
#define PRODUCT_UID "" // "com.my-company.my-name:my-project"
46+
#define PRODUCT_UID "com.zakoverflow.test" // "com.my-company.my-name:my-project"
4847
#pragma message "PRODUCT_UID is not defined in this example. Please ensure your Notecard has a product identifier set before running this example or define it in code here. More details at https://dev.blues.io/tools-and-sdks/samples/product-uid"
4948
#endif
5049

@@ -55,6 +54,7 @@ Notecard notecard;
5554
void setup()
5655
{
5756

57+
#ifdef usbSerial
5858
// Set up for debug output. If you open Arduino's serial terminal window, you'll be able to
5959
// watch JSON objects being transferred to and from the Notecard for each request. On most
6060
// Arduino devices, Arduino's serial debug output is on the "Serial" device at 115200.
@@ -63,55 +63,63 @@ void setup()
6363
// Note that the initial 2.5s delay is required by some Arduino cards before debug
6464
// UART output can be successfully displayed in the Arduino IDE, including the
6565
// Adafruit Feather nRF52840 Express.
66-
#ifdef usbSerial
67-
delay(2500);
68-
usbSerial.begin(115200);
6966
notecard.setDebugOutputStream(usbSerial);
67+
usbSerial.begin(9600);
68+
const size_t start_wait_ms = millis();
69+
while (!usbSerial && ((millis() - start_wait_ms) < 5000));
70+
Serial.println("Serial READY");
7071
#endif
7172

7273
// Initialize the physical I/O channel to the Notecard
7374
#ifdef txRxPinsSerial
7475
notecard.begin(txRxPinsSerial, 9600);
7576
#else
76-
Wire.begin();
77-
7877
notecard.begin();
78+
Serial.println("1");
7979
#endif
8080

8181
// "newRequest()" uses the bundled "J" json package to allocate a "req", which is a JSON object
8282
// for the request to which we will then add Request arguments. The function allocates a "req"
8383
// request structure using malloc() and initializes its "req" field with the type of request.
8484
J *req = notecard.newRequest("hub.set");
85-
86-
// This command (required) causes the data to be delivered to the Project on notehub.io that has claimed
87-
// this Product ID. (see above)
88-
if (myProductID[0]) {
89-
JAddStringToObject(req, "product", myProductID);
85+
Serial.println("2");
86+
if (req) {
87+
// This command (required) causes the data to be delivered to the Project on notehub.io that has claimed
88+
// this Product ID. (see above)
89+
if (myProductID[0]) {
90+
JAddStringToObject(req, "product", myProductID);
91+
Serial.println("3");
92+
}
93+
// This command determines how often the Notecard connects to the service. If "continuous" the Notecard
94+
// immediately establishes a session with the service at notehub.io, and keeps it active continuously.
95+
// Because of the power requirements of a continuous connection, a battery powered device would instead
96+
// only sample its sensors occasionally, and would only upload to the service on a periodic basis.
97+
JAddStringToObject(req, "mode", "continuous");
98+
Serial.println("4");
99+
100+
// Issue the request, telling the Notecard how and how often to access the service.
101+
// This results in a JSON message to Notecard formatted like:
102+
// { "req" : "service.set",
103+
// "product" : myProductID,
104+
// "mode" : "continuous"
105+
// }
106+
// Note that sendRequest() always uses free() to release the request data structure, and it
107+
// returns "true" if success and "false" if there is any failure.
108+
notecard.sendRequest(req);
109+
Serial.println("5");
90110
}
91-
// This command determines how often the Notecard connects to the service. If "continuous" the Notecard
92-
// immediately establishes a session with the service at notehub.io, and keeps it active continuously.
93-
// Because of the power requirements of a continuous connection, a battery powered device would instead
94-
// only sample its sensors occasionally, and would only upload to the service on a periodic basis.
95-
JAddStringToObject(req, "mode", "continuous");
96-
97-
// Issue the request, telling the Notecard how and how often to access the service.
98-
// This results in a JSON message to Notecard formatted like:
99-
// { "req" : "service.set",
100-
// "product" : myProductID,
101-
// "mode" : "continuous"
102-
// }
103-
// Note that sendRequest() always uses free() to release the request data structure, and it
104-
// returns "true" if success and "false" if there is any failure.
105-
notecard.sendRequest(req);
111+
106112
}
107113

108114
// In the Arduino main loop which is called repeatedly, add outbound data every 15 seconds
109115
void loop()
110116
{
117+
Serial.println("Begin `loop`");
111118

112119
// Count the simulated measurements that we send to the cloud, and stop the demo before long.
113120
static unsigned eventCounter = 0;
114-
if (eventCounter++ > 25) {
121+
if (eventCounter > 25) {
122+
++eventCounter;
115123
return;
116124
}
117125

0 commit comments

Comments
 (0)