Fan Control Demo

Dependencies:   mbed-rtos mbed

Fork of mbed_fota by KIM HyoengJun

ext_fota/BleMsgHandler.h

Committer:
dudnwjs
Date:
2015-07-17
Revision:
6:8dd20294b2aa
Parent:
5:e11b23f9aacc
Child:
8:9eec2c246a85

File content as of revision 6:8dd20294b2aa:

#ifndef BLEMSGHANDLER_H
#define BLEMSGHANDLER_H

#include "mbed.h"
#include "MsgQueue.h"
#include "SerialManager.h"
#include "gapc_task.h"
#include "gapm_task.h"

namespace sevencore_fota{

#define FIRMWARE_DATA_FRAGMENT_SIZE 1024

typedef struct {
    unsigned short bType;
    unsigned short bDstid;
    unsigned short bSrcid;
    unsigned short bLength;
} ble_hdr;    

class BleMsgHandler
{
public:
    BleMsgHandler(Serial* _device);
    BleMsgHandler(Serial* _device, Serial* _hostpc);
    ~BleMsgHandler(void);
    void PrintTitle(void);
    void BleMsgAlloc(unsigned short id,unsigned short dest_id,unsigned short src_id,unsigned short data_len,void *pdata,uint8_t *msg);
    int BleSendMsg(uint8_t *msg, unsigned short size);
    void BleReceiveMsg(void);
    void BleMsgHandle(void);
    void HostPcPrint(char *str);
    void ReceiveToSerialTest(void);
    void FirmwareDataReceive(unsigned short code_size, char *version);
    
    
    
private:
    void HandleGapmCmpEvt(unsigned short msgid,struct gapm_cmp_evt *param,unsigned short dest_id,unsigned short src_id);
    void HandleGapcCmpEvt(unsigned short msgid,struct gapc_cmp_evt *param,unsigned short dest_id,unsigned short src_id);
    bool print_flag;
    Serial* device;
    Serial* hostpc;
    SerialManager* SerialM;
    MsgQueue* MsgQ;
    unsigned char recv_msg[512];
    FILE *fp;
};

}//namespace

#endif //BLEMSGHANDLER_H