Ethernet+BLE prototype

Dependencies:   mbed EthernetInterface mbed-rtos

Committer:
teruo
Date:
Mon Mar 31 03:25:14 2014 +0000
Revision:
5:9fffeb949e5a
Parent:
4:78e96198c879
Serial.attach????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
teruo 0:da21a9dd2303 1 #include "mbed.h"
teruo 0:da21a9dd2303 2 #include "config.h"
teruo 0:da21a9dd2303 3 #include "log.h"
teruo 3:d9445b9e7163 4 #include "HttpSend.h"
teruo 3:d9445b9e7163 5
teruo 3:d9445b9e7163 6 Serial bleModule(p9,p10);
teruo 3:d9445b9e7163 7
teruo 5:9fffeb949e5a 8 DigitalOut led1(LED1);
teruo 5:9fffeb949e5a 9 DigitalOut led2(LED2);
teruo 4:78e96198c879 10
teruo 3:d9445b9e7163 11 HttpSend m_httpsend;
teruo 3:d9445b9e7163 12
teruo 5:9fffeb949e5a 13 message_t *m_message;
teruo 5:9fffeb949e5a 14 unsigned char serialBufferLoc = 0;
teruo 5:9fffeb949e5a 15
teruo 5:9fffeb949e5a 16 void rxInterrupt() {
teruo 5:9fffeb949e5a 17 if( serialBufferLoc==0 ){
teruo 5:9fffeb949e5a 18 led1=true;
teruo 5:9fffeb949e5a 19 m_message = m_httpsend.getMessageBuffer();
teruo 3:d9445b9e7163 20 }
teruo 5:9fffeb949e5a 21 led2=!led2;
teruo 5:9fffeb949e5a 22 m_message->data[serialBufferLoc] = LPC_UART3->RBR;
teruo 5:9fffeb949e5a 23 // LPC_UART0->RBR = m_message->data[serialBufferLoc];
teruo 5:9fffeb949e5a 24 if( m_message->data[serialBufferLoc] == '\n' ){
teruo 5:9fffeb949e5a 25 if(// "004C " or "004c "
teruo 5:9fffeb949e5a 26 m_message->data[0]=='0' &&
teruo 5:9fffeb949e5a 27 m_message->data[1]=='0' &&
teruo 5:9fffeb949e5a 28 m_message->data[2]=='4' &&
teruo 5:9fffeb949e5a 29 (m_message->data[3]=='C'||m_message->data[3]=='c') &&
teruo 5:9fffeb949e5a 30 m_message->data[4]==' ' &&
teruo 5:9fffeb949e5a 31 // "1502 "
teruo 5:9fffeb949e5a 32 m_message->data[5]=='1' &&
teruo 5:9fffeb949e5a 33 m_message->data[6]=='5' &&
teruo 5:9fffeb949e5a 34 m_message->data[7]=='0' &&
teruo 5:9fffeb949e5a 35 m_message->data[8]=='2' &&
teruo 5:9fffeb949e5a 36 m_message->data[9]==' ')
teruo 5:9fffeb949e5a 37 {
teruo 5:9fffeb949e5a 38 m_message->data[serialBufferLoc+1]=NULL;
teruo 5:9fffeb949e5a 39 m_message->size = serialBufferLoc+1;
teruo 5:9fffeb949e5a 40 m_httpsend.send(m_message);
teruo 5:9fffeb949e5a 41 }
teruo 3:d9445b9e7163 42
teruo 5:9fffeb949e5a 43 led2=false;
teruo 5:9fffeb949e5a 44 led1=false;
teruo 5:9fffeb949e5a 45 serialBufferLoc=0;
teruo 5:9fffeb949e5a 46 }else{
teruo 5:9fffeb949e5a 47 serialBufferLoc++;
teruo 3:d9445b9e7163 48 }
teruo 3:d9445b9e7163 49 }
teruo 3:d9445b9e7163 50
teruo 0:da21a9dd2303 51 int main() {
teruo 5:9fffeb949e5a 52 INFO_LOG ("UD1_LanGateway start !!!\n");
teruo 0:da21a9dd2303 53
teruo 3:d9445b9e7163 54 /*************************/
teruo 0:da21a9dd2303 55 // Initialize
teruo 3:d9445b9e7163 56 /*************************/
teruo 4:78e96198c879 57 // EthernetInterface
teruo 4:78e96198c879 58 EthernetInterface eth;
teruo 4:78e96198c879 59 eth.init();
teruo 4:78e96198c879 60
teruo 3:d9445b9e7163 61 // HttpSend
teruo 4:78e96198c879 62 m_httpsend.init(&eth);
teruo 4:78e96198c879 63
teruo 3:d9445b9e7163 64 // Serial
teruo 3:d9445b9e7163 65 bleModule.baud(115200);
teruo 3:d9445b9e7163 66
teruo 5:9fffeb949e5a 67 bleModule.attach(&rxInterrupt);
teruo 5:9fffeb949e5a 68 while(true) {
teruo 5:9fffeb949e5a 69 wait(0.5);
teruo 0:da21a9dd2303 70 }
teruo 5:9fffeb949e5a 71 // unreachable INFO_LOG ("UD1_LanGateway stop !!!\n");
teruo 0:da21a9dd2303 72 }