BLE FOTA with mbed external processor.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
dudnwjs
Date:
Mon Jun 22 07:19:59 2015 +0000
Commit message:
Sevencore Fota Basic Program;

Changed in this revision

ext_fota/BleMsgHandler.cpp Show annotated file Show diff for this revision Revisions of this file
ext_fota/BleMsgHandler.h Show annotated file Show diff for this revision Revisions of this file
ext_fota/MsgQueue.cpp Show annotated file Show diff for this revision Revisions of this file
ext_fota/MsgQueue.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r a1f6b1ba8a1e ext_fota/BleMsgHandler.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ext_fota/BleMsgHandler.cpp	Mon Jun 22 07:19:59 2015 +0000
@@ -0,0 +1,24 @@
+#include "BleMsgHandler.h"
+
+namespace sevencore_fota{
+
+BleMsgHandler::BleMsgHandler(Serial *_device)
+{
+    print_flag = 0;
+    device = _device;
+}
+
+BleMsgHandler::BleMsgHandler(Serial *_device, Serial *_hostpc)
+{
+    print_flag = 1;
+    device = _device;
+    hostpc = _hostpc;
+}
+
+void BleMsgHandler::PrintTitle(void)
+{
+    if( print_flag == 1 )
+        hostpc->printf("Sevencore Fota : BleMsg Handler Start\n");
+}
+ 
+}//namespace
diff -r 000000000000 -r a1f6b1ba8a1e ext_fota/BleMsgHandler.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ext_fota/BleMsgHandler.h	Mon Jun 22 07:19:59 2015 +0000
@@ -0,0 +1,25 @@
+#ifndef BLEMSGHANDLER_H
+#define BLEMSGHANDLER_H
+
+#include "mbed.h"
+#include "MsgQueue.h"
+
+namespace sevencore_fota{
+    
+public BleMsg_Handler
+{
+public:
+    BleMsg_Handler(Serial* _device);
+    ~BleMsg_Handler(Serial* _device, Serial* _hostpc);
+    void PrintTitle(void);
+    
+    
+private:
+    bool print_flag;
+    Serial* device;
+    Serial* hostpc;
+}
+
+}//namespace
+
+#endif //BLEMSG_HANDLER_H
\ No newline at end of file
diff -r 000000000000 -r a1f6b1ba8a1e ext_fota/MsgQueue.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ext_fota/MsgQueue.cpp	Mon Jun 22 07:19:59 2015 +0000
@@ -0,0 +1,64 @@
+#include "msg_queue.h"
+#include "mbed.h"
+
+namespace sevencore_fota{
+    
+Msg_Queue::Msg_Queue(int MaxSize):MaxNum(MaxSize)
+{
+    Front = NULL;
+    Rear = NULL;
+    ElemCnt = 0;
+}
+
+Msg_Queue::~Msg_Queue(void)
+{
+}
+
+void Msg_Queue::EnQueue(void *vData)
+{
+    Element *tmp = new Element;
+    tmp->Data = vData;
+    tmp->Next = NULL;
+    ElemCnt++;
+    if( Front == NULL)
+    {
+        Front = tmp;
+        Rear = tmp;
+    }else
+    {
+        Rear->Next = tmp;
+        Rear = tmp;
+    }    
+}
+
+void *Msg_Queue::DeQueue(void)
+{
+    void *tmp;
+    Element *tmpElem;
+    
+    if(Front == NULL)
+        return NULL;
+    
+    ElemCnt--;
+    tmpElem = Front;
+    Front = tmpElem->Next;
+    tmp = tmpElem->Data;
+    free(tmpElem);
+    
+    return tmp;
+}   
+
+int Msg_Queue::GetElementCount(void)
+{
+    return ElemCnt;
+}
+
+bool Msg_Queue::IsEmpty(void)
+{
+    if( Front == NULL)
+        return false;
+    else
+        return true;
+}
+
+}//namespace
diff -r 000000000000 -r a1f6b1ba8a1e ext_fota/MsgQueue.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ext_fota/MsgQueue.h	Mon Jun 22 07:19:59 2015 +0000
@@ -0,0 +1,34 @@
+#ifndef MSGQUEUE_H
+#define MSGQUEUE_H
+
+namespace sevencore_fota{    
+
+struct Element
+{
+    void *Data;
+    struct Element *Next;
+};
+
+class Msg_Queue
+{
+public:
+    
+    Msg_Queue(int MaxSize = 512);
+    ~Msg_Queue(void);
+    void EnQueue(void *vData);
+    void *DeQueue(void);
+    int GetElementCount(void);
+    bool IsEmpty(void);
+
+private:
+    Element *Front;
+    Element *Rear;
+    const int MaxNum;
+    int ElemCnt;
+   
+};
+
+}//namespace
+
+#endif //MSG_QUEUE_H
+
diff -r 000000000000 -r a1f6b1ba8a1e main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Jun 22 07:19:59 2015 +0000
@@ -0,0 +1,20 @@
+#include "mbed.h"
+
+Serial hostpc(USBTX,USBRX);
+Serial device(p13,p14);
+
+DigitalOut myled(LED1);
+
+int main() {
+    BleMsgHandler MYFOTA(&device,&hostpc);
+    
+    MYFOTA.PrintTitle();
+    
+    
+    while(1) {
+        myled = 1;
+        wait(0.5);
+        myled = 0;
+        wait(0.5);
+    }
+}
diff -r 000000000000 -r a1f6b1ba8a1e mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Jun 22 07:19:59 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7
\ No newline at end of file