Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed nRF51822
Fork of SmartPlugBLE by
Revision 4:721ae30c92f8, committed 2015-07-14
- Comitter:
- Slepnir
- Date:
- Tue Jul 14 10:10:19 2015 +0000
- Parent:
- 3:aaa92c61931a
- Commit message:
- For debugging
Changed in this revision
--- a/SPCommunication.cpp Mon Jul 13 13:14:34 2015 +0000
+++ b/SPCommunication.cpp Tue Jul 14 10:10:19 2015 +0000
@@ -21,15 +21,16 @@
}
void SPCommunication::Rxint()
{
- // SPUart.putc(SPUart.getc());
+ SPUart.printf("\r\n Por %02X",SPUart.getc());
- while (SPUart.readable()){
- uint8_t temp = SPUart.getc();
+ //while (SPUart.readable()){
+ //uint8_t temp = SPUart.getc();
+
//buff.addData(temp);
- RxBuffer[w] = temp;
+ //RxBuffer[w] = temp;
if (++w >= 128)
w = 0;
- }
+ //}
}
//Get crc remainder from table
uint8_t SPCommunication::getCRC(uint8_t val)
@@ -55,16 +56,18 @@
i++;
}
while(data[i]!='\0');
- wait(1);
+ wait(2);
+
+ SPUart.printf("\r\n data store in buffer %d",w);
uint8_t temp = readData();
- //SPUart.printf("\r\n in int %02x",temp);
+ SPUart.printf("\r\n Req data %02x",temp);
if((uint8_t) temp == 0x7E){
uint8_t err = handleData();
if(err)
handleData();
}
-
+ SPUart.printf("return");
return 0;
}
@@ -92,9 +95,9 @@
// SPUart.printf("\r\n bool Data is %d value in table %d value in ctc check %d" ,message,crc8_table[message],crccheck );
}
-// printf("arr Data");
-// for (int i=0;i<size;i++)
-// printf("%02X ",DataArr[i]);
+ printf("arr Data");
+ for (int i=0;i<size;i++)
+ printf("%02X ",DataArr[i]);
crccheck=DataArr[size-1];
@@ -128,10 +131,10 @@
RequestData(command);
uint32_t Recv ;
//crc8Compute(com,2);
- memcpy(&Recv,DataArr,32);
+ //memcpy(&Recv,DataArr+1,32);
- return Recv;
+ return 0;
//printData();
}
--- a/SPCommunication.h Mon Jul 13 13:14:34 2015 +0000
+++ b/SPCommunication.h Tue Jul 14 10:10:19 2015 +0000
@@ -52,12 +52,13 @@
void printData();
uint8_t getCRC(uint8_t val);
uint8_t readData();
+ Serial SPUart;
private:
uint8_t size;
uint8_t *DataArr;
uint8_t checkSum(uint8_t const message[], int nBytes);
- Serial SPUart;
+
uint8_t RxBuffer[128];
--- a/SmartPlugBLE.h Mon Jul 13 13:14:34 2015 +0000
+++ b/SmartPlugBLE.h Tue Jul 14 10:10:19 2015 +0000
@@ -90,11 +90,13 @@
}
void updateData(void) {
+ spComm.SPUart.printf("in update section");
smartPlug.setVoltage/*(smartPlug.getVoltage()+1);*/(spComm.getVoltage());
- smartPlug.setCurrent/*(smartPlug.getCurrent()+1);*/(spComm.getCurrent());
- smartPlug.setPower/*(smartPlug.getPower()+1);*/(spComm.getPower());
- smartPlug.setPowerFactor/*(smartPlug.getPowerFactor()+1);*/(spComm.getPowerFactor());
- smartPlug.setEnergy/*(smartPlug.getEnergy()+1);*/(spComm.getEnergy());
+ spComm.SPUart.printf("out update section");
+ //smartPlug.setCurrent/*(smartPlug.getCurrent()+1);*/(spComm.getCurrent());
+ //smartPlug.setPower/*(smartPlug.getPower()+1);*/(spComm.getPower());
+ //smartPlug.setPowerFactor/*(smartPlug.getPowerFactor()+1);*/(spComm.getPowerFactor());
+ //smartPlug.setEnergy/*(smartPlug.getEnergy()+1);*/(spComm.getEnergy());
//smartPlug.getRelay()->setState(spComm.getRelay());
notifyObservers();
}
