Appiko
Modules | Macros | Enumerations | Functions | Variables
The code for the active IR based Sense units.

The active IR sense application's main file that makes it operate. More...

Modules

 The support code for the PIR based Sense units.
 The PIR sense application's support file that handles ble operations.
 
 The support code to control IR transmission and reception.
 The active IR sense application's support file that handles motion detection\ and timer based operations.
 
 The support code to store configurations.
 The support code to store configurations received from other BLE device.
 
 The header file to handle resource allocation.
 The header file which contains system definitions for resources allocation.
 

Macros

#define APP_DEVICE_NAME_CHAR   'S','e','n','s','e','B','e'
 
#define APP_UUID_COMPLETE   0x0a, 0xde, 0xfb, 0x07, 0x74, 0x83, 0x66, 0xb0, 0x0d, 0x48, 0xf5, 0x07, 0x60, 0xdc, 0x73, 0x3c
 
#define APP_ADV_DATA
 
#define APP_SCAN_RSP_DATA
 
#define WDT_PERIOD_MS   301000
 
#define ENABLE_WDT   1
 
#define SENSE_FAST_TICK_INTERVAL_MS   60
 
#define SENSE_SLOW_TICK_INTERVAL_MS   300000
 
#define ADV_FAST_TICK_INTERVAL_MS   60
 
#define ADV_SLOW_TICK_INTERVAL_MS   1100
 
#define CONN_FAST_TICK_INTERVAL_MS   60
 
#define CONN_SLOW_TICK_INTERVAL_MS   1100
 
#define CONN_TIMEOUT_MS   (10*60*1000)
 
#define APP_DEVICE_NAME_CHAR   'S','e','n','s','e','B','e'
 
#define APP_UUID_COMPLETE   0x0a, 0xde, 0xfb, 0x07, 0x74, 0x83, 0x66, 0xb0, 0x0d, 0x48, 0xf5, 0x07, 0x60, 0xdc, 0x73, 0x3c
 
#define APP_ADV_DATA
 
#define APP_SCAN_RSP_DATA
 
#define WDT_PERIOD_MS   301000
 
#define ENABLE_WDT   1
 
#define SENSE_FAST_TICK_INTERVAL_MS   60
 
#define SENSE_SLOW_TICK_INTERVAL_MS   300000
 
#define ADV_FAST_TICK_INTERVAL_MS   60
 
#define ADV_SLOW_TICK_INTERVAL_MS   1100
 
#define CONN_FAST_TICK_INTERVAL_MS   60
 
#define CONN_SLOW_TICK_INTERVAL_MS   1100
 
#define CONN_TIMEOUT_MS   (10*60*1000)
 
#define APP_DEVICE_NAME_CHAR   'S','e','n','s','e','B','e'
 
#define APP_UUID_COMPLETE   0x0a, 0xde, 0xfb, 0x07, 0x74, 0x83, 0x66, 0xb0, 0x0d, 0x48, 0xf5, 0x07, 0x60, 0xdc, 0x73, 0x3c
 
#define APP_ADV_DATA
 
#define APP_SCAN_RSP_DATA
 
#define WDT_PERIOD_MS   30100
 
#define ENABLE_WDT   1
 
#define SENSE_FAST_TICK_INTERVAL_MS   60
 
#define SENSE_SLOW_TICK_INTERVAL_MS   30000
 
#define ADV_FAST_TICK_INTERVAL_MS   60
 
#define ADV_SLOW_TICK_INTERVAL_MS   1100
 
#define CONN_FAST_TICK_INTERVAL_MS   60
 
#define CONN_SLOW_TICK_INTERVAL_MS   1100
 
#define CONN_TIMEOUT_MS   (10*60*1000)
 

Enumerations

enum  sense_states {
  SENSING, ADVERTISING, CONNECTED, SENSING,
  ADVERTISING, CONNECTED, SENSING, ADVERTISING,
  CONNECTED, SENSING, ADVERTISING, CONNECTED
}
 
enum  sense_states {
  SENSING, ADVERTISING, CONNECTED, SENSING,
  ADVERTISING, CONNECTED, SENSING, ADVERTISING,
  CONNECTED, SENSING, ADVERTISING, CONNECTED
}
 
enum  sense_states {
  SENSING, ADVERTISING, CONNECTED, SENSING,
  ADVERTISING, CONNECTED, SENSING, ADVERTISING,
  CONNECTED, SENSING, ADVERTISING, CONNECTED
}
 

Functions

void wdt_prior_reset_callback (void)
 
void next_interval_handler (uint32_t interval)
 The next interval handler is used for providing a periodic tick to be used by the various modules of the application. More...
 
void state_change_handler (uint32_t new_state)
 The handler that is called whenever the application transitions to a new state. More...
 
void button_handler (button_ui_steps step, button_ui_action act)
 Handler for all button related events. More...
 
void leds_init (void)
 Initialize and blink the LEDs momentarily. To be used at the start of the program.
 
void boot_pwr_config (void)
 Prints the reason for the last reset, enables the internal DC-DC converter if the board supports it and puts the nRF SoC to the low power mode.
 
void load_last_config ()
 function to load previous sensebe configuration present in flash memory
 
void slumber (void)
 
int main (void)
 Function for application main entry.
 

Variables

sense_states current_state
 
sense_states current_state
 
sense_states current_state
 

Detailed Description

Macro Definition Documentation

◆ ADV_FAST_TICK_INTERVAL_MS [1/3]

#define ADV_FAST_TICK_INTERVAL_MS   60

The fast tick interval in ms in the Advertising mode

Definition at line 104 of file main.c.

◆ ADV_FAST_TICK_INTERVAL_MS [2/3]

#define ADV_FAST_TICK_INTERVAL_MS   60

The fast tick interval in ms in the Advertising mode

Definition at line 104 of file main.c.

◆ ADV_FAST_TICK_INTERVAL_MS [3/3]

#define ADV_FAST_TICK_INTERVAL_MS   60

The fast tick interval in ms in the Advertising mode

Definition at line 104 of file main.c.

◆ ADV_SLOW_TICK_INTERVAL_MS [1/3]

#define ADV_SLOW_TICK_INTERVAL_MS   1100

The slow tick interval in ms in the Advertising mode

Definition at line 106 of file main.c.

◆ ADV_SLOW_TICK_INTERVAL_MS [2/3]

#define ADV_SLOW_TICK_INTERVAL_MS   1100

The slow tick interval in ms in the Advertising mode

Definition at line 106 of file main.c.

◆ ADV_SLOW_TICK_INTERVAL_MS [3/3]

#define ADV_SLOW_TICK_INTERVAL_MS   1100

The slow tick interval in ms in the Advertising mode

Definition at line 106 of file main.c.

◆ APP_ADV_DATA [1/3]

#define APP_ADV_DATA
Value:
{ \
0x02, BLE_GAP_AD_TYPE_FLAGS, BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE, \
sizeof(app_device_name) + 1, BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME, APP_DEVICE_NAME_CHAR, \
0x11, BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE, APP_UUID_COMPLETE \
}
#define APP_DEVICE_NAME_CHAR
Definition: main.c:67
#define APP_UUID_COMPLETE
Definition: main.c:72

The data to be sent in the advertising payload. It is of the format of a sequence of {Len, type, data}

Definition at line 76 of file main.c.

◆ APP_ADV_DATA [2/3]

#define APP_ADV_DATA
Value:
{ \
0x02, BLE_GAP_AD_TYPE_FLAGS, BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE, \
sizeof(app_device_name) + 1, BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME, APP_DEVICE_NAME_CHAR, \
0x11, BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE, APP_UUID_COMPLETE \
}
#define APP_DEVICE_NAME_CHAR
Definition: main.c:67
#define APP_UUID_COMPLETE
Definition: main.c:72

The data to be sent in the advertising payload. It is of the format of a sequence of {Len, type, data}

Definition at line 76 of file main.c.

◆ APP_ADV_DATA [3/3]

#define APP_ADV_DATA
Value:
{ \
0x02, BLE_GAP_AD_TYPE_FLAGS, BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE, \
sizeof(app_device_name) + 1, BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME, APP_DEVICE_NAME_CHAR, \
0x11, BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE, APP_UUID_COMPLETE \
}
#define APP_DEVICE_NAME_CHAR
Definition: main.c:67
#define APP_UUID_COMPLETE
Definition: main.c:72

The data to be sent in the advertising payload. It is of the format of a sequence of {Len, type, data}

Definition at line 76 of file main.c.

◆ APP_DEVICE_NAME_CHAR [1/3]

#define APP_DEVICE_NAME_CHAR   'S','e','n','s','e','B','e'

< Name of device, to be included in the advertising data.

Definition at line 67 of file main.c.

◆ APP_DEVICE_NAME_CHAR [2/3]

#define APP_DEVICE_NAME_CHAR   'S','e','n','s','e','B','e'

< Name of device, to be included in the advertising data.

Definition at line 67 of file main.c.

◆ APP_DEVICE_NAME_CHAR [3/3]

#define APP_DEVICE_NAME_CHAR   'S','e','n','s','e','B','e'

< Name of device, to be included in the advertising data.

Definition at line 67 of file main.c.

◆ APP_SCAN_RSP_DATA [1/3]

#define APP_SCAN_RSP_DATA
Value:
{ \
0x02, BLE_GAP_AD_TYPE_TX_POWER_LEVEL, 0 , \
0x11, BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME, \
'x', 'x','x', 'x', 'x', 'x' , 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', \
0x04, BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA, 0 , 0 , 0 \
}

The data to be sent in the scan response payload. It is of the format of a sequence of {Len, type, data}

Definition at line 84 of file main.c.

◆ APP_SCAN_RSP_DATA [2/3]

#define APP_SCAN_RSP_DATA
Value:
{ \
0x02, BLE_GAP_AD_TYPE_TX_POWER_LEVEL, 0 , \
0x11, BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME, \
'x', 'x','x', 'x', 'x', 'x' , 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', \
0x04, BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA, 0 , 0 , 0 \
}

The data to be sent in the scan response payload. It is of the format of a sequence of {Len, type, data}

Definition at line 84 of file main.c.

◆ APP_SCAN_RSP_DATA [3/3]

#define APP_SCAN_RSP_DATA
Value:
{ \
0x02, BLE_GAP_AD_TYPE_TX_POWER_LEVEL, 0 , \
0x11, BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME, \
'x', 'x','x', 'x', 'x', 'x' , 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', \
0x04, BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA, 0 , 0 , 0 \
}

The data to be sent in the scan response payload. It is of the format of a sequence of {Len, type, data}

Definition at line 84 of file main.c.

◆ APP_UUID_COMPLETE [1/3]

#define APP_UUID_COMPLETE   0x0a, 0xde, 0xfb, 0x07, 0x74, 0x83, 0x66, 0xb0, 0x0d, 0x48, 0xf5, 0x07, 0x60, 0xdc, 0x73, 0x3c

Complete 128 bit UUID of the SenseBe service 3c73dc60-07f5-480d-b066-837407fbde0a

Definition at line 72 of file main.c.

◆ APP_UUID_COMPLETE [2/3]

#define APP_UUID_COMPLETE   0x0a, 0xde, 0xfb, 0x07, 0x74, 0x83, 0x66, 0xb0, 0x0d, 0x48, 0xf5, 0x07, 0x60, 0xdc, 0x73, 0x3c

Complete 128 bit UUID of the SenseBe service 3c73dc60-07f5-480d-b066-837407fbde0a

Definition at line 72 of file main.c.

◆ APP_UUID_COMPLETE [3/3]

#define APP_UUID_COMPLETE   0x0a, 0xde, 0xfb, 0x07, 0x74, 0x83, 0x66, 0xb0, 0x0d, 0x48, 0xf5, 0x07, 0x60, 0xdc, 0x73, 0x3c

Complete 128 bit UUID of the SenseBe service 3c73dc60-07f5-480d-b066-837407fbde0a

Definition at line 72 of file main.c.

◆ CONN_FAST_TICK_INTERVAL_MS [1/3]

#define CONN_FAST_TICK_INTERVAL_MS   60

The fast tick interval in ms in the Connected mode

Definition at line 109 of file main.c.

◆ CONN_FAST_TICK_INTERVAL_MS [2/3]

#define CONN_FAST_TICK_INTERVAL_MS   60

The fast tick interval in ms in the Connected mode

Definition at line 109 of file main.c.

◆ CONN_FAST_TICK_INTERVAL_MS [3/3]

#define CONN_FAST_TICK_INTERVAL_MS   60

The fast tick interval in ms in the Connected mode

Definition at line 109 of file main.c.

◆ CONN_SLOW_TICK_INTERVAL_MS [1/3]

#define CONN_SLOW_TICK_INTERVAL_MS   1100

The slow tick interval in ms in the Connected mode

Definition at line 111 of file main.c.

◆ CONN_SLOW_TICK_INTERVAL_MS [2/3]

#define CONN_SLOW_TICK_INTERVAL_MS   1100

The slow tick interval in ms in the Connected mode

Definition at line 111 of file main.c.

◆ CONN_SLOW_TICK_INTERVAL_MS [3/3]

#define CONN_SLOW_TICK_INTERVAL_MS   1100

The slow tick interval in ms in the Connected mode

Definition at line 111 of file main.c.

◆ CONN_TIMEOUT_MS [1/3]

#define CONN_TIMEOUT_MS   (10*60*1000)

The time in ms (min*sec*ms) to timeout of the Connected mode

Definition at line 114 of file main.c.

◆ CONN_TIMEOUT_MS [2/3]

#define CONN_TIMEOUT_MS   (10*60*1000)

The time in ms (min*sec*ms) to timeout of the Connected mode

Definition at line 114 of file main.c.

◆ CONN_TIMEOUT_MS [3/3]

#define CONN_TIMEOUT_MS   (10*60*1000)

The time in ms (min*sec*ms) to timeout of the Connected mode

Definition at line 114 of file main.c.

◆ ENABLE_WDT [1/3]

#define ENABLE_WDT   1

Flag to specify if the Watchdog timer is used or not

Definition at line 96 of file main.c.

◆ ENABLE_WDT [2/3]

#define ENABLE_WDT   1

Flag to specify if the Watchdog timer is used or not

Definition at line 96 of file main.c.

◆ ENABLE_WDT [3/3]

#define ENABLE_WDT   1

Flag to specify if the Watchdog timer is used or not

Definition at line 96 of file main.c.

◆ SENSE_FAST_TICK_INTERVAL_MS [1/3]

#define SENSE_FAST_TICK_INTERVAL_MS   60

The fast tick interval in ms in the Sense mode

Definition at line 99 of file main.c.

◆ SENSE_FAST_TICK_INTERVAL_MS [2/3]

#define SENSE_FAST_TICK_INTERVAL_MS   60

The fast tick interval in ms in the Sense mode

Definition at line 99 of file main.c.

◆ SENSE_FAST_TICK_INTERVAL_MS [3/3]

#define SENSE_FAST_TICK_INTERVAL_MS   60

The fast tick interval in ms in the Sense mode

Definition at line 99 of file main.c.

◆ SENSE_SLOW_TICK_INTERVAL_MS [1/3]

#define SENSE_SLOW_TICK_INTERVAL_MS   300000

The slow tick interval in ms in the Sense mode

Definition at line 101 of file main.c.

◆ SENSE_SLOW_TICK_INTERVAL_MS [2/3]

#define SENSE_SLOW_TICK_INTERVAL_MS   300000

The slow tick interval in ms in the Sense mode

Definition at line 101 of file main.c.

◆ SENSE_SLOW_TICK_INTERVAL_MS [3/3]

#define SENSE_SLOW_TICK_INTERVAL_MS   30000

The slow tick interval in ms in the Sense mode

Definition at line 101 of file main.c.

◆ WDT_PERIOD_MS [1/3]

#define WDT_PERIOD_MS   301000

The WDT bites if not fed every 301 sec (5 min)

Warning
All the tick intervals must be lower than this

Definition at line 93 of file main.c.

◆ WDT_PERIOD_MS [2/3]

#define WDT_PERIOD_MS   30100

The WDT bites if not fed every 301 sec (5 min)

Warning
All the tick intervals must be lower than this

Definition at line 93 of file main.c.

◆ WDT_PERIOD_MS [3/3]

#define WDT_PERIOD_MS   301000

The WDT bites if not fed every 301 sec (5 min)

Warning
All the tick intervals must be lower than this

Definition at line 93 of file main.c.

Enumeration Type Documentation

◆ sense_states [1/3]

Defines the states possible in the SensePi device

Enumerator
SENSING 

Use PIR sensor to sense motion based on the set configuration.

ADVERTISING 

BLE advertising to get connected to an app.

CONNECTED 

BLE connection established with an app.

SENSING 

Use IR Tx-Rx to sense motion based on the set configuration.

ADVERTISING 

BLE advertising to get connected to an app.

CONNECTED 

BLE connection established with an app.

SENSING 

Use IR Tx-Rx to sense motion based on the set configuration.

ADVERTISING 

BLE advertising to get connected to an app.

CONNECTED 

BLE connection established with an app.

SENSING 

Use IR Tx-Rx to sense motion based on the set configuration.

ADVERTISING 

BLE advertising to get connected to an app.

CONNECTED 

BLE connection established with an app.

Definition at line 117 of file main.c.

◆ sense_states [2/3]

Defines the states possible in the SensePi device

Enumerator
SENSING 

Use PIR sensor to sense motion based on the set configuration.

ADVERTISING 

BLE advertising to get connected to an app.

CONNECTED 

BLE connection established with an app.

SENSING 

Use IR Tx-Rx to sense motion based on the set configuration.

ADVERTISING 

BLE advertising to get connected to an app.

CONNECTED 

BLE connection established with an app.

SENSING 

Use IR Tx-Rx to sense motion based on the set configuration.

ADVERTISING 

BLE advertising to get connected to an app.

CONNECTED 

BLE connection established with an app.

SENSING 

Use IR Tx-Rx to sense motion based on the set configuration.

ADVERTISING 

BLE advertising to get connected to an app.

CONNECTED 

BLE connection established with an app.

Definition at line 117 of file main.c.

◆ sense_states [3/3]

Defines the states possible in the SensePi device

Enumerator
SENSING 

Use PIR sensor to sense motion based on the set configuration.

ADVERTISING 

BLE advertising to get connected to an app.

CONNECTED 

BLE connection established with an app.

SENSING 

Use IR Tx-Rx to sense motion based on the set configuration.

ADVERTISING 

BLE advertising to get connected to an app.

CONNECTED 

BLE connection established with an app.

SENSING 

Use IR Tx-Rx to sense motion based on the set configuration.

ADVERTISING 

BLE advertising to get connected to an app.

CONNECTED 

BLE connection established with an app.

SENSING 

Use IR Tx-Rx to sense motion based on the set configuration.

ADVERTISING 

BLE advertising to get connected to an app.

CONNECTED 

BLE connection established with an app.

Definition at line 117 of file main.c.

Function Documentation

◆ button_handler()

void button_handler ( button_ui_steps  step,
button_ui_action  act 
)
Parameters
stepThe step reached by the button press
actThe action of the button press i.e. if a step is crossed or the button is released

Definition at line 372 of file main.c.

References BUTTON_UI_ACT_CROSS, button_ui_config_wake(), BUTTON_UI_STEP_QUICK, BUTTON_UI_STEP_WAKE, current_state, DEVICE_TICK_FAST, device_tick_init(), irq_msg_push(), MS_TIMER_TICKS_MS, SENSE_FAST_TICK_INTERVAL_MS, SENSE_SLOW_TICK_INTERVAL_MS, and SENSING.

◆ next_interval_handler()

void next_interval_handler ( uint32_t  interval)
Parameters
intervalThe interval from the last call of this function

Definition at line 247 of file main.c.

References ADVERTISING, button_ui_add_tick(), CONNECTED, current_state, sensebe_tx_rx_add_ticks(), and SENSING.

◆ slumber()

void slumber ( void  )

Different calls to sleep depending on the status of Softdevice

Definition at line 520 of file main.c.

◆ state_change_handler()

void state_change_handler ( uint32_t  new_state)
Parameters
new_stateThe state to which the application has transitioned to.

Get config from sensebe_cam_trigger and send to the BLE module

Get config from sensebe_cam_trigger and send to the BLE module

Get config from sensebe_cam_trigger and send to the BLE module

Definition at line 279 of file main.c.

References current_state, DEVICE_TICK_SAME, led_ui_type_stop_all(), MS_TIMER_TICKS_MS, SENSE_FAST_TICK_INTERVAL_MS, SENSE_SLOW_TICK_INTERVAL_MS, and SENSING.

◆ wdt_prior_reset_callback()

void wdt_prior_reset_callback ( void  )

Function called just before reset due to WDT

Definition at line 177 of file main.c.

Variable Documentation

◆ current_state [1/3]

sense_states current_state

Stores the current state of the device

Definition at line 128 of file main.c.

◆ current_state [2/3]

sense_states current_state

Stores the current state of the device

Definition at line 128 of file main.c.

◆ current_state [3/3]

sense_states current_state

Stores the current state of the device

Definition at line 128 of file main.c.