BLE fota Lamp Demo

Dependencies:   mbed-rtos mbed mbed_fota_fan_control

Fork of mbed_fota_fan_control by KIM HyoengJun

Committer:
dudnwjs
Date:
Mon Jun 22 07:19:59 2015 +0000
Revision:
0:a1f6b1ba8a1e
Child:
1:5cf3a6c969be
Sevencore Fota Basic Program;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dudnwjs 0:a1f6b1ba8a1e 1 #include "msg_queue.h"
dudnwjs 0:a1f6b1ba8a1e 2 #include "mbed.h"
dudnwjs 0:a1f6b1ba8a1e 3
dudnwjs 0:a1f6b1ba8a1e 4 namespace sevencore_fota{
dudnwjs 0:a1f6b1ba8a1e 5
dudnwjs 0:a1f6b1ba8a1e 6 Msg_Queue::Msg_Queue(int MaxSize):MaxNum(MaxSize)
dudnwjs 0:a1f6b1ba8a1e 7 {
dudnwjs 0:a1f6b1ba8a1e 8 Front = NULL;
dudnwjs 0:a1f6b1ba8a1e 9 Rear = NULL;
dudnwjs 0:a1f6b1ba8a1e 10 ElemCnt = 0;
dudnwjs 0:a1f6b1ba8a1e 11 }
dudnwjs 0:a1f6b1ba8a1e 12
dudnwjs 0:a1f6b1ba8a1e 13 Msg_Queue::~Msg_Queue(void)
dudnwjs 0:a1f6b1ba8a1e 14 {
dudnwjs 0:a1f6b1ba8a1e 15 }
dudnwjs 0:a1f6b1ba8a1e 16
dudnwjs 0:a1f6b1ba8a1e 17 void Msg_Queue::EnQueue(void *vData)
dudnwjs 0:a1f6b1ba8a1e 18 {
dudnwjs 0:a1f6b1ba8a1e 19 Element *tmp = new Element;
dudnwjs 0:a1f6b1ba8a1e 20 tmp->Data = vData;
dudnwjs 0:a1f6b1ba8a1e 21 tmp->Next = NULL;
dudnwjs 0:a1f6b1ba8a1e 22 ElemCnt++;
dudnwjs 0:a1f6b1ba8a1e 23 if( Front == NULL)
dudnwjs 0:a1f6b1ba8a1e 24 {
dudnwjs 0:a1f6b1ba8a1e 25 Front = tmp;
dudnwjs 0:a1f6b1ba8a1e 26 Rear = tmp;
dudnwjs 0:a1f6b1ba8a1e 27 }else
dudnwjs 0:a1f6b1ba8a1e 28 {
dudnwjs 0:a1f6b1ba8a1e 29 Rear->Next = tmp;
dudnwjs 0:a1f6b1ba8a1e 30 Rear = tmp;
dudnwjs 0:a1f6b1ba8a1e 31 }
dudnwjs 0:a1f6b1ba8a1e 32 }
dudnwjs 0:a1f6b1ba8a1e 33
dudnwjs 0:a1f6b1ba8a1e 34 void *Msg_Queue::DeQueue(void)
dudnwjs 0:a1f6b1ba8a1e 35 {
dudnwjs 0:a1f6b1ba8a1e 36 void *tmp;
dudnwjs 0:a1f6b1ba8a1e 37 Element *tmpElem;
dudnwjs 0:a1f6b1ba8a1e 38
dudnwjs 0:a1f6b1ba8a1e 39 if(Front == NULL)
dudnwjs 0:a1f6b1ba8a1e 40 return NULL;
dudnwjs 0:a1f6b1ba8a1e 41
dudnwjs 0:a1f6b1ba8a1e 42 ElemCnt--;
dudnwjs 0:a1f6b1ba8a1e 43 tmpElem = Front;
dudnwjs 0:a1f6b1ba8a1e 44 Front = tmpElem->Next;
dudnwjs 0:a1f6b1ba8a1e 45 tmp = tmpElem->Data;
dudnwjs 0:a1f6b1ba8a1e 46 free(tmpElem);
dudnwjs 0:a1f6b1ba8a1e 47
dudnwjs 0:a1f6b1ba8a1e 48 return tmp;
dudnwjs 0:a1f6b1ba8a1e 49 }
dudnwjs 0:a1f6b1ba8a1e 50
dudnwjs 0:a1f6b1ba8a1e 51 int Msg_Queue::GetElementCount(void)
dudnwjs 0:a1f6b1ba8a1e 52 {
dudnwjs 0:a1f6b1ba8a1e 53 return ElemCnt;
dudnwjs 0:a1f6b1ba8a1e 54 }
dudnwjs 0:a1f6b1ba8a1e 55
dudnwjs 0:a1f6b1ba8a1e 56 bool Msg_Queue::IsEmpty(void)
dudnwjs 0:a1f6b1ba8a1e 57 {
dudnwjs 0:a1f6b1ba8a1e 58 if( Front == NULL)
dudnwjs 0:a1f6b1ba8a1e 59 return false;
dudnwjs 0:a1f6b1ba8a1e 60 else
dudnwjs 0:a1f6b1ba8a1e 61 return true;
dudnwjs 0:a1f6b1ba8a1e 62 }
dudnwjs 0:a1f6b1ba8a1e 63
dudnwjs 0:a1f6b1ba8a1e 64 }//namespace