The program sends the current location over the cellular network.

Dependencies:   aconno_I2C ublox-at-cellular-interface gnss ublox-cellular-base Lis2dh12 ublox-cellular-base-n2xx ublox-at-cellular-interface-n2xx low-power-sleep

Fork of example-gnss by u-blox

tasks/tasks.cpp

Committer:
jurica238814
Date:
2018-11-30
Revision:
8:2bf886335fd0
Child:
9:f943c09d9173

File content as of revision 8:2bf886335fd0:

/**
 * Collection of all tasks  
 * Made by Jurica @ aconno
 * More info @ aconno.de
 * 
 */

#include "tasks.h"
#include "aconnoHelpers.h"
#include "gnss.h"
#include "aconnoConfig.h"

extern MainStates state;
extern char locationGlobal[UDP_MSG_SIZE_B];

void idleCallback()
{
    while(1)
    {
        Thread::signal_wait(IDLE_SIGNAL);
        Thread::signal_clr(IDLE_SIGNAL);
        printf("In idle thread.\r\n");
        while(state == STATE_IDLE)
        {   
            wait_ms(1000);
        }
    }
}

void alarmCallback(myParams_t *myParams)
{
    //char udpMsg[UDP_MSG_SIZE_B];
    
    while(1)
    {
        Thread::signal_wait(ALARM_SIGNAL);
        Thread::signal_clr(ALARM_SIGNAL);
        printf("Alarm thread.\r\n");
        while(state == STATE_ALARM)
        {
            printf("Sending location on server...\r\n");
            myParams->sara->sendUdpMsg(locationGlobal);
            wait_ms(5000);
        }
    }
}

void alarmOffCallback()
{
    while(1)
    {   
        Thread::signal_wait(ALARM_OFF_SIGNAL);
        Thread::signal_clr(ALARM_OFF_SIGNAL);
        printf("In alarm off thread.\r\n");
        while(state == STATE_ALARM_OFF)
        {
            wait_ms(1000);
        }
    }
}

void movementCallback()
{
    while(1)
    {
        while(state == STATE_LIS_DETECTION)
        {
            printf("In movement thread.\r\n");
            wait_ms(1000);
        }
    }
}

void gnssLocationCallback(GnssSerial *gnss)
{
    while(1)
    {
        while(state == STATE_ALARM)
        {
            getGPSData(locationGlobal, gnss);
            Thread::wait(UPDATE_LOCATION_TIME_MS);
        }
    }
}