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
tasks/tasks.cpp@8:2bf886335fd0, 2018-11-30 (annotated)
- Committer:
- jurica238814
- Date:
- Fri Nov 30 16:19:41 2018 +0100
- Revision:
- 8:2bf886335fd0
- Child:
- 9:f943c09d9173
Aconno init commit
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| jurica238814 | 8:2bf886335fd0 | 1 | /** |
| jurica238814 | 8:2bf886335fd0 | 2 | * Collection of all tasks |
| jurica238814 | 8:2bf886335fd0 | 3 | * Made by Jurica @ aconno |
| jurica238814 | 8:2bf886335fd0 | 4 | * More info @ aconno.de |
| jurica238814 | 8:2bf886335fd0 | 5 | * |
| jurica238814 | 8:2bf886335fd0 | 6 | */ |
| jurica238814 | 8:2bf886335fd0 | 7 | |
| jurica238814 | 8:2bf886335fd0 | 8 | #include "tasks.h" |
| jurica238814 | 8:2bf886335fd0 | 9 | #include "aconnoHelpers.h" |
| jurica238814 | 8:2bf886335fd0 | 10 | #include "gnss.h" |
| jurica238814 | 8:2bf886335fd0 | 11 | #include "aconnoConfig.h" |
| jurica238814 | 8:2bf886335fd0 | 12 | |
| jurica238814 | 8:2bf886335fd0 | 13 | extern MainStates state; |
| jurica238814 | 8:2bf886335fd0 | 14 | extern char locationGlobal[UDP_MSG_SIZE_B]; |
| jurica238814 | 8:2bf886335fd0 | 15 | |
| jurica238814 | 8:2bf886335fd0 | 16 | void idleCallback() |
| jurica238814 | 8:2bf886335fd0 | 17 | { |
| jurica238814 | 8:2bf886335fd0 | 18 | while(1) |
| jurica238814 | 8:2bf886335fd0 | 19 | { |
| jurica238814 | 8:2bf886335fd0 | 20 | Thread::signal_wait(IDLE_SIGNAL); |
| jurica238814 | 8:2bf886335fd0 | 21 | Thread::signal_clr(IDLE_SIGNAL); |
| jurica238814 | 8:2bf886335fd0 | 22 | printf("In idle thread.\r\n"); |
| jurica238814 | 8:2bf886335fd0 | 23 | while(state == STATE_IDLE) |
| jurica238814 | 8:2bf886335fd0 | 24 | { |
| jurica238814 | 8:2bf886335fd0 | 25 | wait_ms(1000); |
| jurica238814 | 8:2bf886335fd0 | 26 | } |
| jurica238814 | 8:2bf886335fd0 | 27 | } |
| jurica238814 | 8:2bf886335fd0 | 28 | } |
| jurica238814 | 8:2bf886335fd0 | 29 | |
| jurica238814 | 8:2bf886335fd0 | 30 | void alarmCallback(myParams_t *myParams) |
| jurica238814 | 8:2bf886335fd0 | 31 | { |
| jurica238814 | 8:2bf886335fd0 | 32 | //char udpMsg[UDP_MSG_SIZE_B]; |
| jurica238814 | 8:2bf886335fd0 | 33 | |
| jurica238814 | 8:2bf886335fd0 | 34 | while(1) |
| jurica238814 | 8:2bf886335fd0 | 35 | { |
| jurica238814 | 8:2bf886335fd0 | 36 | Thread::signal_wait(ALARM_SIGNAL); |
| jurica238814 | 8:2bf886335fd0 | 37 | Thread::signal_clr(ALARM_SIGNAL); |
| jurica238814 | 8:2bf886335fd0 | 38 | printf("Alarm thread.\r\n"); |
| jurica238814 | 8:2bf886335fd0 | 39 | while(state == STATE_ALARM) |
| jurica238814 | 8:2bf886335fd0 | 40 | { |
| jurica238814 | 8:2bf886335fd0 | 41 | printf("Sending location on server...\r\n"); |
| jurica238814 | 8:2bf886335fd0 | 42 | myParams->sara->sendUdpMsg(locationGlobal); |
| jurica238814 | 8:2bf886335fd0 | 43 | wait_ms(5000); |
| jurica238814 | 8:2bf886335fd0 | 44 | } |
| jurica238814 | 8:2bf886335fd0 | 45 | } |
| jurica238814 | 8:2bf886335fd0 | 46 | } |
| jurica238814 | 8:2bf886335fd0 | 47 | |
| jurica238814 | 8:2bf886335fd0 | 48 | void alarmOffCallback() |
| jurica238814 | 8:2bf886335fd0 | 49 | { |
| jurica238814 | 8:2bf886335fd0 | 50 | while(1) |
| jurica238814 | 8:2bf886335fd0 | 51 | { |
| jurica238814 | 8:2bf886335fd0 | 52 | Thread::signal_wait(ALARM_OFF_SIGNAL); |
| jurica238814 | 8:2bf886335fd0 | 53 | Thread::signal_clr(ALARM_OFF_SIGNAL); |
| jurica238814 | 8:2bf886335fd0 | 54 | printf("In alarm off thread.\r\n"); |
| jurica238814 | 8:2bf886335fd0 | 55 | while(state == STATE_ALARM_OFF) |
| jurica238814 | 8:2bf886335fd0 | 56 | { |
| jurica238814 | 8:2bf886335fd0 | 57 | wait_ms(1000); |
| jurica238814 | 8:2bf886335fd0 | 58 | } |
| jurica238814 | 8:2bf886335fd0 | 59 | } |
| jurica238814 | 8:2bf886335fd0 | 60 | } |
| jurica238814 | 8:2bf886335fd0 | 61 | |
| jurica238814 | 8:2bf886335fd0 | 62 | void movementCallback() |
| jurica238814 | 8:2bf886335fd0 | 63 | { |
| jurica238814 | 8:2bf886335fd0 | 64 | while(1) |
| jurica238814 | 8:2bf886335fd0 | 65 | { |
| jurica238814 | 8:2bf886335fd0 | 66 | while(state == STATE_LIS_DETECTION) |
| jurica238814 | 8:2bf886335fd0 | 67 | { |
| jurica238814 | 8:2bf886335fd0 | 68 | printf("In movement thread.\r\n"); |
| jurica238814 | 8:2bf886335fd0 | 69 | wait_ms(1000); |
| jurica238814 | 8:2bf886335fd0 | 70 | } |
| jurica238814 | 8:2bf886335fd0 | 71 | } |
| jurica238814 | 8:2bf886335fd0 | 72 | } |
| jurica238814 | 8:2bf886335fd0 | 73 | |
| jurica238814 | 8:2bf886335fd0 | 74 | void gnssLocationCallback(GnssSerial *gnss) |
| jurica238814 | 8:2bf886335fd0 | 75 | { |
| jurica238814 | 8:2bf886335fd0 | 76 | while(1) |
| jurica238814 | 8:2bf886335fd0 | 77 | { |
| jurica238814 | 8:2bf886335fd0 | 78 | while(state == STATE_ALARM) |
| jurica238814 | 8:2bf886335fd0 | 79 | { |
| jurica238814 | 8:2bf886335fd0 | 80 | getGPSData(locationGlobal, gnss); |
| jurica238814 | 8:2bf886335fd0 | 81 | Thread::wait(UPDATE_LOCATION_TIME_MS); |
| jurica238814 | 8:2bf886335fd0 | 82 | } |
| jurica238814 | 8:2bf886335fd0 | 83 | } |
| jurica238814 | 8:2bf886335fd0 | 84 | } |
| jurica238814 | 8:2bf886335fd0 | 85 |
