SmartApp_Miun
SmartAppSingle.cpp@2:506fb35771f6, 2017-10-02 (annotated)
- Committer:
- biwa1400
- Date:
- Mon Oct 02 16:09:25 2017 +0000
- Revision:
- 2:506fb35771f6
201710002;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
biwa1400 | 2:506fb35771f6 | 1 | #include "SmartAppSingle.h" |
biwa1400 | 2:506fb35771f6 | 2 | #include "mbed.h" |
biwa1400 | 2:506fb35771f6 | 3 | #include "mDot.h" |
biwa1400 | 2:506fb35771f6 | 4 | #include <map> |
biwa1400 | 2:506fb35771f6 | 5 | #include <string> |
biwa1400 | 2:506fb35771f6 | 6 | #include <iostream> |
biwa1400 | 2:506fb35771f6 | 7 | |
biwa1400 | 2:506fb35771f6 | 8 | const std::string MIUN::SmartAppSingle::emptyPayload = ""; |
biwa1400 | 2:506fb35771f6 | 9 | const int MIUN::SmartAppSingle::defaultPort = 0; |
biwa1400 | 2:506fb35771f6 | 10 | |
biwa1400 | 2:506fb35771f6 | 11 | MIUN::SmartAppSingle::SmartAppSingle() |
biwa1400 | 2:506fb35771f6 | 12 | { |
biwa1400 | 2:506fb35771f6 | 13 | } |
biwa1400 | 2:506fb35771f6 | 14 | |
biwa1400 | 2:506fb35771f6 | 15 | |
biwa1400 | 2:506fb35771f6 | 16 | /*** Running Thread ***/ |
biwa1400 | 2:506fb35771f6 | 17 | void MIUN::SmartAppSingle::startRunning() |
biwa1400 | 2:506fb35771f6 | 18 | { |
biwa1400 | 2:506fb35771f6 | 19 | while(true) |
biwa1400 | 2:506fb35771f6 | 20 | { |
biwa1400 | 2:506fb35771f6 | 21 | if(lora.joinNetwork()==true) |
biwa1400 | 2:506fb35771f6 | 22 | { |
biwa1400 | 2:506fb35771f6 | 23 | execute(); |
biwa1400 | 2:506fb35771f6 | 24 | } |
biwa1400 | 2:506fb35771f6 | 25 | lora.sleep(); |
biwa1400 | 2:506fb35771f6 | 26 | } |
biwa1400 | 2:506fb35771f6 | 27 | } |
biwa1400 | 2:506fb35771f6 | 28 | |
biwa1400 | 2:506fb35771f6 | 29 | |
biwa1400 | 2:506fb35771f6 | 30 | /*** public Functions ***/ |
biwa1400 | 2:506fb35771f6 | 31 | |
biwa1400 | 2:506fb35771f6 | 32 | std::string MIUN::SmartAppSingle::sendReceive(std::string payload, int port, int* receivePort) |
biwa1400 | 2:506fb35771f6 | 33 | { |
biwa1400 | 2:506fb35771f6 | 34 | if(lora.send(payload,port)) |
biwa1400 | 2:506fb35771f6 | 35 | { |
biwa1400 | 2:506fb35771f6 | 36 | return lora.receive(receivePort); |
biwa1400 | 2:506fb35771f6 | 37 | } |
biwa1400 | 2:506fb35771f6 | 38 | else |
biwa1400 | 2:506fb35771f6 | 39 | { |
biwa1400 | 2:506fb35771f6 | 40 | return emptyPayload; |
biwa1400 | 2:506fb35771f6 | 41 | } |
biwa1400 | 2:506fb35771f6 | 42 | } |
biwa1400 | 2:506fb35771f6 | 43 | |
biwa1400 | 2:506fb35771f6 | 44 | |
biwa1400 | 2:506fb35771f6 | 45 | void MIUN::SmartAppSingle::setSleepTime(uint32_t inSleepTime) |
biwa1400 | 2:506fb35771f6 | 46 | { |
biwa1400 | 2:506fb35771f6 | 47 | lora.setSleepTime(inSleepTime); |
biwa1400 | 2:506fb35771f6 | 48 | } |
biwa1400 | 2:506fb35771f6 | 49 | |
biwa1400 | 2:506fb35771f6 | 50 | /*** virtual function ***/ |
biwa1400 | 2:506fb35771f6 | 51 | |
biwa1400 | 2:506fb35771f6 | 52 | uint8_t MIUN::SmartAppSingle::measuredBattery() |
biwa1400 | 2:506fb35771f6 | 53 | { |
biwa1400 | 2:506fb35771f6 | 54 | return 255; |
biwa1400 | 2:506fb35771f6 | 55 | } |
biwa1400 | 2:506fb35771f6 | 56 | |
biwa1400 | 2:506fb35771f6 | 57 | void MIUN::SmartAppSingle::execute() |
biwa1400 | 2:506fb35771f6 | 58 | { |
biwa1400 | 2:506fb35771f6 | 59 | logInfo("Please overwrite the execute function."); |
biwa1400 | 2:506fb35771f6 | 60 | } |