Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
F23-BLE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container 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
cheng-en.chiang@duke.edu
F23-BLE
Commits
30ca51c9
Commit
30ca51c9
authored
1 year ago
by
Jason Chiang
Browse files
Options
Downloads
Patches
Plain Diff
final
parent
2741616e
Branches
main
No related tags found
No related merge requests found
Pipeline
#459899
passed
1 year ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
prj.conf
+2
-2
2 additions, 2 deletions
prj.conf
src/Connected.jpeg
+0
-0
0 additions, 0 deletions
src/Connected.jpeg
src/main.c
+10
-24
10 additions, 24 deletions
src/main.c
with
12 additions
and
26 deletions
prj.conf
+
2
−
2
View file @
30ca51c9
...
...
@@ -11,11 +11,11 @@ CONFIG_SENSOR=y
# BLE
CONFIG_BT
=
y
CONFIG_BT_PERIPHERAL
=
y
CONFIG_BT_DEVICE_NAME
=
"
Final_Project
"
CONFIG_BT_DEVICE_NAME
=
"
Jason's device
"
CONFIG_BT_DEVICE_APPEARANCE
=
0
CONFIG_BT_MAX_CONN
=
1
CONFIG_BT_LL_SOFTDEVICE
=
y
CONFIG_BT_BAS
=
y
//
Battery
Service
GATT
CONFIG_BT_BAS
=
y
CONFIG_BT_SETTINGS
=
y
CONFIG_SETTINGS_RUNTIME
=
y
CONFIG_SETTINGS
=
y
...
...
This diff is collapsed.
Click to expand it.
src/Connected.jpeg
0 → 100644
+
0
−
0
View file @
30ca51c9
622 KiB
This diff is collapsed.
Click to expand it.
src/main.c
+
10
−
24
View file @
30ca51c9
...
...
@@ -105,8 +105,8 @@ K_WORK_DEFINE(pressure_work, pressure_handler);
#define VOLTAGE_RANGE 3.3
#define NUM_STEPS 20
#define INTERVALS 40
#define MEASUREMENT_DELAY_MS 1000
// delay between measurements
#define OVERSAMPLE 10
// number of samples to average together
#define MEASUREMENT_DELAY_MS 1000
#define OVERSAMPLE 10
#define MAX_BRIGHTNESS 1000000
// ADC value variables
...
...
@@ -123,7 +123,6 @@ bool usbregstatus;
// Pressure sensor
static
int32_t
atm_pressure_kPa
;
// maybe change the sine and min to floats?
// 100Hz variables
int32_t
sine_value_0
[
10
];
int32_t
min_value_0
;
...
...
@@ -753,6 +752,12 @@ static int init_entry(void *o)
LOG_INF
(
"MPR pressure sensor %s is ready"
,
pressure_in
->
name
);
}
/* Initialize Bluetooth */
int
err
=
bluetooth_init
(
&
bluetooth_callbacks
,
&
remote_service_callbacks
);
if
(
err
)
{
LOG_ERR
(
"BT init failed (err = %d)"
,
err
);
}
}
...
...
@@ -770,13 +775,11 @@ static void init_exit(void *o)
//Start the battery timer
k_timer_start
(
&
battery_timer
,
K_MSEC
(
LED_ON_TIME_MS
),
K_MSEC
(
LED_ON_TIME_MS
));
LOG_ERR
(
"Leaving init state"
);
}
/***************** READ STATE *******************/
static
void
read_entry
(
void
*
o
)
{
LOG_ERR
(
"Entered read state"
);
// start read timers
k_timer_start
(
&
read_100hz_timer
,
K_MSEC
(
10
),
K_MSEC
(
10
));
...
...
@@ -800,13 +803,11 @@ static void read_exit(void *o)
wave_counter_0
=
0
;
wave_counter_1
=
0
;
LOG_ERR
(
"Leaving read state"
);
}
/***************** ACTION STATE *******************/
static
void
action_entry
(
void
*
o
)
{
LOG_ERR
(
"Entered action state"
);
// Configure and add callbacks to button
ret
=
gpio_pin_interrupt_configure_dt
(
&
save
,
GPIO_INT_EDGE_TO_ACTIVE
);
...
...
@@ -838,15 +839,12 @@ static void action_entry(void *o)
static
void
action_run
(
void
*
o
)
{
// Check for vbus and pressure
if
(
usbregstatus
==
true
||
atm_pressure_kPa
<=
0
){
// VBUS detected or no pressure (go to error)
smf_set_state
(
SMF_CTX
(
&
s_obj
),
&
device_states
[
error
]);
}
}
static
void
action_exit
(
void
*
o
)
...
...
@@ -854,15 +852,11 @@ static void action_exit(void *o)
// Remove callbacks associated with the buttons
gpio_remove_callback
(
save
.
port
,
&
save_cb
);
gpio_remove_callback
(
send
.
port
,
&
send_cb
);
// Stop the timers?
LOG_INF
(
"Leaving action state"
);
}
/***************** ERROR STATE *******************/
static
void
error_entry
(
void
*
o
)
{
LOG_ERR
(
"Entered error state"
);
{;
if
(
usbregstatus
==
true
)
{
// VBUS detected, start error led timer (make led3 blink)
...
...
@@ -894,22 +888,14 @@ static void error_exit(void *o)
// turn off error led
gpio_pin_set_dt
(
&
error_led
,
0
);
LOG_ERR
(
"Leaving error state"
);
}
/***************** CONNECT STATE *******************/
static
void
connect_entry
(
void
*
o
)
{
LOG_INF
(
"Entered connect state"
);
/* Initialize Bluetooth */
int
err
=
bluetooth_init
(
&
bluetooth_callbacks
,
&
remote_service_callbacks
);
if
(
err
)
{
LOG_ERR
(
"BT init failed (err = %d)"
,
err
);
}
// send a notification that "data" is ready to be read...
err
=
send_data_notification
(
current_conn
,
data_array
,
1
);
int
err
=
send_data_notification
(
current_conn
,
data_array
,
1
);
if
(
err
)
{
LOG_ERR
(
"Could not send BT notification (err: %d)"
,
err
);
}
...
...
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