I added functionality to get the RSSI, BER, and Cell Neighbor for reporting connection issues to M2X
Dependencies: WncControllerK64F
Sms/IOTSMS.h@18:198e9b0acf11, 2016-11-17 (annotated)
- Committer:
- JMF
- Date:
- Thu Nov 17 16:13:29 2016 +0000
- Revision:
- 18:198e9b0acf11
- Parent:
- 7:fded23f50479
Updates to mbed os resulted in mutex.h going away and rtos.h needed to be used; This fixes the Mutex typedef failure. Also cast data buffers from 'char *' to (const std::uint8_t*) to conform with Fred's changes in WncController
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JMF | 7:fded23f50479 | 1 | /* ===================================================================== |
JMF | 7:fded23f50479 | 2 | Copyright © 2016, Avnet (R) |
JMF | 7:fded23f50479 | 3 | |
JMF | 7:fded23f50479 | 4 | Contributors: |
JMF | 7:fded23f50479 | 5 | * James M Flynn, www.em.avnet.com |
JMF | 7:fded23f50479 | 6 | |
JMF | 7:fded23f50479 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); |
JMF | 7:fded23f50479 | 8 | you may not use this file except in compliance with the License. |
JMF | 7:fded23f50479 | 9 | You may obtain a copy of the License at |
JMF | 7:fded23f50479 | 10 | |
JMF | 7:fded23f50479 | 11 | http://www.apache.org/licenses/LICENSE-2.0 |
JMF | 7:fded23f50479 | 12 | |
JMF | 7:fded23f50479 | 13 | Unless required by applicable law or agreed to in writing, |
JMF | 7:fded23f50479 | 14 | software distributed under the License is distributed on an |
JMF | 7:fded23f50479 | 15 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
JMF | 7:fded23f50479 | 16 | either express or implied. See the License for the specific |
JMF | 7:fded23f50479 | 17 | language governing permissions and limitations under the License. |
JMF | 7:fded23f50479 | 18 | |
JMF | 7:fded23f50479 | 19 | @file IOTSMS.h |
JMF | 7:fded23f50479 | 20 | @version 1.0 |
JMF | 7:fded23f50479 | 21 | @date Oct 2016 |
JMF | 7:fded23f50479 | 22 | |
JMF | 7:fded23f50479 | 23 | ======================================================================== */ |
JMF | 7:fded23f50479 | 24 | |
JMF | 7:fded23f50479 | 25 | #ifndef WNCSms_H_ |
JMF | 7:fded23f50479 | 26 | #define WNCSms_H_ |
JMF | 7:fded23f50479 | 27 | |
JMF | 7:fded23f50479 | 28 | #include "mbed.h" |
JMF | 7:fded23f50479 | 29 | #include "rtos.h" |
JMF | 7:fded23f50479 | 30 | |
JMF | 7:fded23f50479 | 31 | #include "WNCInterface.h" |
JMF | 7:fded23f50479 | 32 | #include "RtosTimer.h" |
JMF | 7:fded23f50479 | 33 | #include "Callback.h" |
JMF | 7:fded23f50479 | 34 | |
JMF | 7:fded23f50479 | 35 | typedef struct SmsMsg { |
JMF | 7:fded23f50479 | 36 | string number; |
JMF | 7:fded23f50479 | 37 | string date; |
JMF | 7:fded23f50479 | 38 | string time; |
JMF | 7:fded23f50479 | 39 | string msg; |
JMF | 7:fded23f50479 | 40 | } WNCSmsMsg; |
JMF | 7:fded23f50479 | 41 | |
JMF | 7:fded23f50479 | 42 | /** Component to use the Short Messages Service (SMS) **/ |
JMF | 7:fded23f50479 | 43 | class WNCSms |
JMF | 7:fded23f50479 | 44 | { |
JMF | 7:fded23f50479 | 45 | private: |
JMF | 7:fded23f50479 | 46 | unsigned int m_smsinit; |
JMF | 7:fded23f50479 | 47 | void m_smscheck(void); |
JMF | 7:fded23f50479 | 48 | uint32_t m_timer; |
JMF | 7:fded23f50479 | 49 | |
JMF | 7:fded23f50479 | 50 | protected: |
JMF | 7:fded23f50479 | 51 | WNCSmsMsg m_MsgText; |
JMF | 7:fded23f50479 | 52 | RtosTimer *m_SMStimer; |
JMF | 7:fded23f50479 | 53 | struct WncController_fk::WncController::WncSmsList m_smsmsgs; //use the WncSmsList structure to hold messages |
JMF | 7:fded23f50479 | 54 | mbed::Callback<void (WNCSmsMsg&)> m_callback; //pointer to the call-back function the user specified |
JMF | 7:fded23f50479 | 55 | |
JMF | 7:fded23f50479 | 56 | public: |
JMF | 7:fded23f50479 | 57 | WNCSms(); /** Create SMSInterface instance */ |
JMF | 7:fded23f50479 | 58 | |
JMF | 7:fded23f50479 | 59 | /** Initialize interface **/ |
JMF | 7:fded23f50479 | 60 | int init(uint32_t poll=0, void ((*cb)(WNCSmsMsg& s))=NULL); |
JMF | 7:fded23f50479 | 61 | |
JMF | 7:fded23f50479 | 62 | /** Send a SM |
JMF | 7:fded23f50479 | 63 | @param string& receiver's contact number |
JMF | 7:fded23f50479 | 64 | @param string& the message to send |
JMF | 7:fded23f50479 | 65 | @return 0 on success, error code on failure |
JMF | 7:fded23f50479 | 66 | */ |
JMF | 7:fded23f50479 | 67 | int send(const string& number, const string& message); |
JMF | 7:fded23f50479 | 68 | |
JMF | 7:fded23f50479 | 69 | |
JMF | 7:fded23f50479 | 70 | /** Receive a SM |
JMF | 7:fded23f50479 | 71 | @param string Pointer to the sender's phone number |
JMF | 7:fded23f50479 | 72 | @param string Pointer to store the the incoming message into |
JMF | 7:fded23f50479 | 73 | @return 0 on success, error code on failure |
JMF | 7:fded23f50479 | 74 | */ |
JMF | 7:fded23f50479 | 75 | int get(string& number, string& message); |
JMF | 7:fded23f50479 | 76 | |
JMF | 7:fded23f50479 | 77 | /** Get the users number to use for SMS messaging |
JMF | 7:fded23f50479 | 78 | @param none |
JMF | 7:fded23f50479 | 79 | @return character pointer on success, NULL on failure |
JMF | 7:fded23f50479 | 80 | */ |
JMF | 7:fded23f50479 | 81 | char * getSMSNbr( void ); |
JMF | 7:fded23f50479 | 82 | |
JMF | 7:fded23f50479 | 83 | /** Attached a callback function for a Receive SMS |
JMF | 7:fded23f50479 | 84 | @param fp(string&) a function that takes a string as an input argument |
JMF | 7:fded23f50479 | 85 | */ |
JMF | 7:fded23f50479 | 86 | void attach(void (*fp)(WNCSmsMsg& s)) {m_callback.attach(fp);} |
JMF | 7:fded23f50479 | 87 | |
JMF | 7:fded23f50479 | 88 | }; |
JMF | 7:fded23f50479 | 89 | |
JMF | 7:fded23f50479 | 90 | #endif /* WNCSms_H_ */ |