![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
BLE fota Lamp Demo
Dependencies: mbed-rtos mbed mbed_fota_fan_control
Fork of mbed_fota_fan_control by
ext_fota/SerialManager.h@13:e714e2971c49, 2015-10-13 (annotated)
- Committer:
- dudnwjs
- Date:
- Tue Oct 13 06:35:19 2015 +0000
- Revision:
- 13:e714e2971c49
- Parent:
- 9:fcf91f563147
lamp demo;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dudnwjs | 9:fcf91f563147 | 1 | /** |
dudnwjs | 9:fcf91f563147 | 2 | * @file SerialManager.h |
dudnwjs | 9:fcf91f563147 | 3 | * @brief Serial Communication Management |
dudnwjs | 9:fcf91f563147 | 4 | * Copyright 2015 SEVENCORE Co., Ltd. |
dudnwjs | 9:fcf91f563147 | 5 | * |
dudnwjs | 9:fcf91f563147 | 6 | * @author HyeongJun Kim |
dudnwjs | 9:fcf91f563147 | 7 | * @version 1.0.0 |
dudnwjs | 9:fcf91f563147 | 8 | * @date 2015-08-19 |
dudnwjs | 9:fcf91f563147 | 9 | */ |
dudnwjs | 2:dba344c91bce | 10 | #ifndef SERIALMANAGER_H |
dudnwjs | 2:dba344c91bce | 11 | #define SERIALMANAGER_H |
dudnwjs | 2:dba344c91bce | 12 | |
dudnwjs | 2:dba344c91bce | 13 | #include "mbed.h" |
dudnwjs | 9:fcf91f563147 | 14 | /** |
dudnwjs | 9:fcf91f563147 | 15 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 16 | * @addtogroup ext_fota module |
dudnwjs | 9:fcf91f563147 | 17 | * @brief Serial Manager Class Header. |
dudnwjs | 9:fcf91f563147 | 18 | * |
dudnwjs | 9:fcf91f563147 | 19 | * @{ |
dudnwjs | 9:fcf91f563147 | 20 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 21 | */ |
dudnwjs | 2:dba344c91bce | 22 | namespace sevencore_fota{ |
dudnwjs | 2:dba344c91bce | 23 | |
dudnwjs | 2:dba344c91bce | 24 | class SerialManager |
dudnwjs | 2:dba344c91bce | 25 | { |
dudnwjs | 2:dba344c91bce | 26 | public: |
dudnwjs | 9:fcf91f563147 | 27 | /** |
dudnwjs | 9:fcf91f563147 | 28 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 29 | * @brief Serial Manager constructor only connected Device |
dudnwjs | 9:fcf91f563147 | 30 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 31 | */ |
dudnwjs | 2:dba344c91bce | 32 | SerialManager(Serial *_device); |
dudnwjs | 9:fcf91f563147 | 33 | /** |
dudnwjs | 9:fcf91f563147 | 34 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 35 | * @brief Serial Manager constructor with connected Device & HostPC |
dudnwjs | 9:fcf91f563147 | 36 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 37 | */ |
dudnwjs | 2:dba344c91bce | 38 | SerialManager(Serial *_device,Serial *_hostpc); |
dudnwjs | 9:fcf91f563147 | 39 | /** |
dudnwjs | 9:fcf91f563147 | 40 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 41 | * @brief Serial Manager destructor |
dudnwjs | 9:fcf91f563147 | 42 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 43 | */ |
dudnwjs | 2:dba344c91bce | 44 | ~SerialManager(void); |
dudnwjs | 9:fcf91f563147 | 45 | /** |
dudnwjs | 9:fcf91f563147 | 46 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 47 | * @brief Send ble message to serial port |
dudnwjs | 9:fcf91f563147 | 48 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 49 | */ |
dudnwjs | 2:dba344c91bce | 50 | int SendToSerial(uint8_t *data,unsigned short size); |
dudnwjs | 9:fcf91f563147 | 51 | /** |
dudnwjs | 9:fcf91f563147 | 52 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 53 | * @brief Receive ble message from serial port |
dudnwjs | 9:fcf91f563147 | 54 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 55 | */ |
dudnwjs | 2:dba344c91bce | 56 | int ReceiveToSerial(unsigned char *receive_msg); |
dudnwjs | 9:fcf91f563147 | 57 | /** |
dudnwjs | 9:fcf91f563147 | 58 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 59 | * @brief Receive data for size |
dudnwjs | 9:fcf91f563147 | 60 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 61 | */ |
dudnwjs | 6:8dd20294b2aa | 62 | void DataReceive(uint8_t *databuf, unsigned short size); |
dudnwjs | 9:fcf91f563147 | 63 | /** |
dudnwjs | 9:fcf91f563147 | 64 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 65 | * @brief Receive data test function |
dudnwjs | 9:fcf91f563147 | 66 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 67 | */ |
dudnwjs | 9:fcf91f563147 | 68 | void ReceiveToSerialTest(void); |
dudnwjs | 9:fcf91f563147 | 69 | |
dudnwjs | 2:dba344c91bce | 70 | private: |
dudnwjs | 9:fcf91f563147 | 71 | /** |
dudnwjs | 9:fcf91f563147 | 72 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 73 | * @brief Serial Manager Start title print function. |
dudnwjs | 9:fcf91f563147 | 74 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 75 | */ |
dudnwjs | 2:dba344c91bce | 76 | void PrintSerialManager(void); |
dudnwjs | 2:dba344c91bce | 77 | |
dudnwjs | 2:dba344c91bce | 78 | bool print_flag; |
dudnwjs | 2:dba344c91bce | 79 | Serial *device; |
dudnwjs | 2:dba344c91bce | 80 | Serial *hostpc; |
dudnwjs | 2:dba344c91bce | 81 | uint8_t FE_MSG_PACKET_TYPE; |
dudnwjs | 2:dba344c91bce | 82 | int MAX_PACKET_LENGTH; |
dudnwjs | 2:dba344c91bce | 83 | unsigned char bReceiveState; |
dudnwjs | 2:dba344c91bce | 84 | unsigned short wDataLength; |
dudnwjs | 2:dba344c91bce | 85 | unsigned short wReceivePos; |
dudnwjs | 2:dba344c91bce | 86 | unsigned char bHdrBytesRead; |
dudnwjs | 2:dba344c91bce | 87 | unsigned char bReceiveElementArr[512]; |
dudnwjs | 2:dba344c91bce | 88 | |
dudnwjs | 2:dba344c91bce | 89 | }; |
dudnwjs | 2:dba344c91bce | 90 | |
dudnwjs | 2:dba344c91bce | 91 | }//namespace |
dudnwjs | 2:dba344c91bce | 92 | |
dudnwjs | 9:fcf91f563147 | 93 | /// @} ext_fota module |
dudnwjs | 2:dba344c91bce | 94 | #endif//SERIALMANAGER_H |