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 BLE_HVC by
Revision 3:29a4ed654315, committed 2015-07-25
- Comitter:
- yueee_yt
- Date:
- Sat Jul 25 07:56:30 2015 +0000
- Parent:
- 2:b94ca9b44b80
- Commit message:
- ???
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Jul 22 09:45:56 2015 +0000 +++ b/main.cpp Sat Jul 25 07:56:30 2015 +0000 @@ -23,14 +23,14 @@ char HVC_ADDRESS[]= {0xd5,0x32,0x26,0x3b,0x47,0x3d}; bool Reconnect=true; -char HumanDetect=1; -char HandDetect=1; +char HumanDetect=0; +char HandDetect=0; char FaceDetect=1; -char FaceDirection=1; +char FaceDirection=0; char FaceOld=1; char FaceSex=1; -char FaceLook=1; -char FaceEyeClose=1; +char FaceLook=0; +char FaceEyeClose=0; char FaceExpression=1; const uint8_t WriteCharacteristicAddr[]= {0x35,0x10,0x00,0x02,0xd1,0x3a,0x4f,0x39,0x8a,0xb3,0xbf,0x64,0xd4,0xfb,0xb4,0xb4}; const uint8_t NotifyCharacteristicAddr[]= {0x35,0x10,0x00,0x03,0xd1,0x3a,0x4f,0x39,0x8a,0xb3,0xbf,0x64,0xd4,0xfb,0xb4,0xb4}; @@ -50,13 +50,21 @@ DiscoveredCharacteristic HVCNotifyCharacteristic; DiscoveredCharacteristic HVCDeviceCharacteristic; +int count; + void periodicCallback(void) { alivenessLED = !alivenessLED; /* Do blinky on LED1 while we're waiting for BLE events */ + count++; + if(count>20){ + ble.gap().disconnect(connectionHandle ,Gap::CONNECTION_TIMEOUT);//connectionHandle , 0x08); + count=0; + } } void advertisementCallback(const Gap::AdvertisementCallbackParams_t *params) { + count=0; if ((params->peerAddr[5] != HVC_ADDRESS[0]) || (params->peerAddr[4] != HVC_ADDRESS[1]) || (params->peerAddr[3] != HVC_ADDRESS[2]) || @@ -79,6 +87,7 @@ void serviceDiscoveryCallback(const DiscoveredService *service) { + count=0; if (service->getUUID().shortOrLong() == UUID::UUID_TYPE_SHORT) { // pc.printf("#S UUID-%x attrs[%u %u]\r\n", service->getUUID().getShortUUID(), service->getStartHandle(), service->getEndHandle()); } else { @@ -93,6 +102,7 @@ void characteristicDiscoveryCallback(const DiscoveredCharacteristic *characteristicP) { + count=0; bool flag; if (characteristicP->getUUID().shortOrLong() == UUID::UUID_TYPE_SHORT) { printf("#short:\r\n"); @@ -158,11 +168,13 @@ void discoveryTerminationCallback(Gap::Handle_t connectionHandle) { + count=0; pc.printf("# discovery terminated CallBack %u\r\n", connectionHandle); } void connectionCallback(const Gap::ConnectionCallbackParams_t *params) { + count=0; if (params->role == Gap::CENTRAL) { connectionHandle = params->handle; ble.gattClient().onServiceDiscoveryTermination(discoveryTerminationCallback); @@ -175,6 +187,7 @@ void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason) { + count=0; pc.printf("#HVC-C1B Disconnected\r\n"); if(Reconnect==true) { state=-1; @@ -185,6 +198,7 @@ void hvxCallback(const GattHVXCallbackParams *params) { + count=0; static bool flag=false; //flag=true no toki tudukiga aru static int l; static unsigned char buffer[100]; @@ -212,6 +226,7 @@ flag=true; } } else if(state==4) { + printf("DATA_START\r\n"); k=buffer[2]+buffer[3]*0x100+buffer[4]*0x10000+buffer[5]*0x1000000; if((l+1)>(6+k-1)) { human_no=buffer[6]; @@ -254,7 +269,7 @@ if(FaceDetect==1) { j1=0; for(k=0; k<face_no; k++) { - printf("Face(%d):x=%d,y=%d,size=%d,depend=%d\r\n", + printf("Face:%d:%d:%d:%d:%d\r\n", k,buffer[j+k*j2+j1+0]+buffer[j+k*j2+j1+1]*0x100, buffer[j+k*j2+j1+2]+buffer[j+k*j2+j1+3]*0x100, buffer[j+k*j2+j1+4]+buffer[j+k*j2+j1+5]*0x100, @@ -274,7 +289,7 @@ if(FaceOld==1) { j1=FaceDetect*8+FaceDirection*8; for(k=0; k<face_no; k++) { - printf("FaceOld(%d):old=%d,depend=%d\r\n", + printf("FaceOld:%d:%d:%d\r\n", k,(signed char)(buffer[j+k*j2+j1+0]), (short)(buffer[j+k*j2+j1+1]+buffer[j+k*j2+j1+2]*0x100)); } @@ -282,7 +297,7 @@ if(FaceSex==1) { j1=FaceDetect*8+FaceDirection*8+FaceOld*3; for(k=0; k<face_no; k++) { - printf("FaceSex(%d):Sex=%d,depend=%d\r\n", + printf("FaceSex:%d:%d:%d\r\n", k,(signed char)(buffer[j+k*j2+j1+0]), //0--feminine 1---male (short)(buffer[j+k*j2+j1+1]+buffer[j+k*j2+j1+2]*0x100)); } @@ -290,7 +305,7 @@ if(FaceLook==1) { j1=FaceDetect*8+FaceDirection*8+FaceOld*3+FaceSex*3; for(k=0; k<face_no; k++) { - printf("FaceLook(%d):holizon=%d,vertical=%d\r\n", + printf("FaceLook:%d:holizon=%d:vertical=%d\r\n", k,(signed char)(buffer[j+k*j2+j1+0]), //0--feminine 1---male (signed char)(buffer[j+k*j2+j1+1])); } @@ -306,7 +321,7 @@ if(FaceExpression==1) { j1=FaceDetect*8+FaceDirection*8+FaceOld*3+FaceSex*3+FaceLook*2+FaceEyeClose*4; for(k=0; k<face_no; k++) { - printf("FaceExpression(%d):TopExpression=%d,TopScore=%d,look=%d\r\n", + printf("FaceExpression:%d:%d:%d:%d\r\n", k,(signed char)(buffer[j+k*j2+j1+0]), (signed char)(buffer[j+k*j2+j1+1]), (signed char)(buffer[j+k*j2+j1+2])); @@ -314,14 +329,15 @@ } } else { - if(FaceDetect==1) printf("FaceDetect:0\r\n"); - if(FaceDirection==1) printf("FaceDirection:0\r\n"); - if(FaceOld==1) printf("FaceOld:0\r\n"); - if(FaceSex==1) printf("FaceSex:0\r\n"); - if(FaceLook==1) printf("FaceLook:0\r\n"); - if(FaceEyeClose==1) printf("FaceEyeClose:0\r\n"); - if(FaceExpression==1) printf("FaceExpression:0\r\n"); + if(FaceDetect==1) printf("#FaceDetect:0\r\n"); + if(FaceDirection==1) printf("#FaceDirection:0\r\n"); + if(FaceOld==1) printf("#FaceOld:0\r\n"); + if(FaceSex==1) printf("#FaceSex:0\r\n"); + if(FaceLook==1) printf("#FaceLook:0\r\n"); + if(FaceEyeClose==1) printf("#FaceEyeClose:0\r\n"); + if(FaceExpression==1) printf("#FaceExpression:0\r\n"); } + printf("DATA_END\r\n"); flag=false; WaitSend=true; } else { @@ -335,6 +351,7 @@ void DataReadCallback(const GattReadCallbackParams *params) { + count=0; // pc.printf("#Data Readed \r\n"); //for (unsigned index = 0; index < params->len; index++) { // pc.printf("# %02x", params->data[index]); @@ -344,6 +361,7 @@ void DataWriteCallback(const GattWriteCallbackParams *params) { + count=0; pc.printf("#send data %x\r\n",params->writeOp); // for (unsigned index = 0; index < params->len; index++) { // pc.printf(" %02x", params->data[index]); @@ -357,6 +375,7 @@ int main(void) { + count=0; pc.baud(9600); pc.printf("#Progran Start\r\n"); Ticker ticker; //LED HertBeat