Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
neOCampus-arduino
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GIS-neOCampus
neOSensor
neOCampus-arduino
Commits
049b84be
Commit
049b84be
authored
1 year ago
by
Marie Bureau
Browse files
Options
Downloads
Patches
Plain Diff
get temperature update
parent
48e9f506
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/BLE_ThermoPro/BLE_ThermoPro.ino
+11
-6
11 additions, 6 deletions
tests/BLE_ThermoPro/BLE_ThermoPro.ino
with
11 additions
and
6 deletions
tests/BLE_ThermoPro/BLE_ThermoPro.ino
+
11
−
6
View file @
049b84be
/*******************************/
/*******************************/
/*********** INCLUDES***********/
/*********** INCLUDES***********/
/*******************************/
/*******************************/
#include
<M5StickCPlus.h>
#include
<Arduino.h>
#include
<Arduino.h>
#include
<BLEDevice.h>
#include
<BLEDevice.h>
#include
<BLEUtils.h>
#include
<BLEUtils.h>
...
@@ -13,7 +14,7 @@
...
@@ -13,7 +14,7 @@
#define SCAN_TIME 5 // scan period in second
#define SCAN_TIME 5 // scan period in second
bool
BLEScanActivated
=
false
;
bool
BLEScanActivated
=
false
;
#define ENDIAN_CHANGE_U16(x) ((((x)&0xFF00) >> 8) + (((x)&0xFF) << 8))
/*****************************/
/*****************************/
/********* FONCTIONS *********/
/********* FONCTIONS *********/
/*****************************/
/*****************************/
...
@@ -45,14 +46,18 @@ class Advertised : public BLEAdvertisedDeviceCallbacks {
...
@@ -45,14 +46,18 @@ class Advertised : public BLEAdvertisedDeviceCallbacks {
// ***** getTemperature *****
// ***** getTemperature *****
float
getTemperature
(
BLEAdvertisedDevice
device
)
{
float
getTemperature
(
BLEAdvertisedDevice
device
)
{
uint8_t
*
pTemp
=
(
uint8_t
*
)
&
device
.
getManufacturerData
().
c_str
()[
1
];
return
((
float
)
*
pTemp
)
/
10
;
uint8_t
temp_lb
=
(
uint8_t
)
device
.
getManufacturerData
().
c_str
()[
1
];
// temperature lower byte
uint8_t
temp_hb
=
(
uint8_t
)(
device
.
getManufacturerData
().
c_str
()[
2
]);
// temperature higher byte
int16_t
temperature
=
(
int16_t
)((
uint16_t
)(
temp_hb
)
<<
8
)
+
(
uint16_t
)
temp_lb
;
return
((
float
)(
temperature
)
/
10
);
return
((
float
)(
temperature
));
}
}
// ***** getHumidity *****
// ***** getHumidity *****
uint8_t
getHumidity
(
BLEAdvertisedDevice
device
)
{
uint8_t
getHumidity
(
BLEAdvertisedDevice
device
)
{
const
uint8_t
*
pHum
=
(
const
uint8_t
*
)
&
device
.
getManufacturerData
()
const
uint8_t
*
pHum
=
(
const
uint8_t
*
)
&
device
.
getManufacturerData
().
c_str
()[
3
];
.
c_str
()[
3
];
return
*
pHum
;
return
*
pHum
;
}
}
};
};
...
@@ -60,7 +65,7 @@ class Advertised : public BLEAdvertisedDeviceCallbacks {
...
@@ -60,7 +65,7 @@ class Advertised : public BLEAdvertisedDeviceCallbacks {
void
setup
()
{
void
setup
()
{
//init serial port
//init serial port
setupSerial
();
setupSerial
();
M5
.
begin
();
//init BLE
//init BLE
BLEDevice
::
init
(
""
);
BLEDevice
::
init
(
""
);
Serial
.
printf
(
"Starting
\n
"
);
Serial
.
printf
(
"Starting
\n
"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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