Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
November 2021 Blimp Competition
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Shahrul Kamil bin Hassan
November 2021 Blimp Competition
Commits
406c3e77
Commit
406c3e77
authored
3 years ago
by
Zhaoliang Zheng
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/main' into main
parents
402c32ed
355f5a24
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Code/ESP32_communication/Two-way/ESP32_master/ESP32_master.ino
+20
-29
20 additions, 29 deletions
...ESP32_communication/Two-way/ESP32_master/ESP32_master.ino
with
20 additions
and
29 deletions
Code/ESP32_communication/Two-way/ESP32_master/ESP32_master.ino
+
20
−
29
View file @
406c3e77
...
...
@@ -10,7 +10,6 @@ String strdata = "";
String
valdata
=
""
;
String
quedata
=
""
;
int
count
=
0
;
double
memory
=
0
;
// Define variables to store incoming readings
String
incomingStr
=
""
;
...
...
@@ -25,6 +24,7 @@ typedef struct struct_message {
double
ValD
;
String
DebugM
;
String
QueM
;
String
VarM
;
}
struct_message
;
// Create a struct_message to hold incoming sensor readings
...
...
@@ -48,6 +48,8 @@ void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) {
// Serial.print("Bytes received: ");
// Serial.println(len);
// incomingDebug = incomingReadings.DebugM;
Serial
.
print
(
"Var message:"
);
Serial
.
println
(
sentData
.
VarM
);
Serial
.
print
(
"Debug message:"
);
Serial
.
println
(
sentData
.
DebugM
);
}
...
...
@@ -93,7 +95,7 @@ void loop()
strdata
+=
char
(
inChar
);
delay
(
10
);
count
+=
1
;
if
(
count
==
3
&&
!
isDigit
(
inChar
)
){
if
(
count
==
3
){
sentData
.
StrD
=
strdata
;
Serial
.
println
(
sentData
.
StrD
);
}
...
...
@@ -104,16 +106,24 @@ void loop()
quedata
+=
char
(
inChar
);
sentData
.
QueM
=
quedata
;
}
if
(
inChar
==
'\n'
){
//after message is sent
if
(
valdata
!=
""
){
// memory = valdata.toDouble();
sentData
.
ValD
=
valdata
.
toDouble
();
valdata
=
""
;
Serial
.
println
(
sentData
.
ValD
);
sentData
.
QueM
=
""
;
Serial
.
print
(
"quedata:"
);
Serial
.
println
(
quedata
);
if
(
quedata
!=
"?"
){
sentData
.
ValD
=
valdata
.
toDouble
();
Serial
.
print
(
"ValD"
);
Serial
.
println
(
sentData
.
ValD
);
valdata
=
""
;
sentData
.
QueM
=
""
;
}
else
{
// sentData.ValD = 0;
Serial
.
print
(
"ValD"
);
Serial
.
println
(
sentData
.
ValD
);
Serial
.
print
(
"QueM:"
);
Serial
.
println
(
sentData
.
QueM
);
}
esp_err_t
result
=
esp_now_send
(
broadcastAddress
,
(
uint8_t
*
)
&
sentData
,
sizeof
(
sentData
));
// esp_now_send(RxMACaddress, (uint8_t *) &sentData, sizeof(sentData));
//-------------------------------------------------------------------------------------
...
...
@@ -122,7 +132,6 @@ void loop()
//-------------------------------------------------------------------------------------
delay
(
500
);
strdata
=
""
;
// valdata = "";
quedata
=
""
;
count
=
0
;
}
...
...
@@ -132,21 +141,3 @@ void loop()
//-------------------------------------------------------------------------------------
}
/*
void loop() {
// Send message via ESP-NOW
esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &BME280Readings, sizeof(BME280Readings));
if (result == ESP_OK) {
Serial.println("Sent with success");
}
else {
Serial.println("Error sending the data");
}
delay(10000);
}
*/
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment