kumar singh
/
Dealer_20Mar
BLE Transmitter not working
Fork of Dealer_23Feb by
Diff: Beacon.cpp
- Revision:
- 21:a5fb0ae94dc6
- Parent:
- 20:f812f85cf97e
- Child:
- 22:c2f034a13108
diff -r f812f85cf97e -r a5fb0ae94dc6 Beacon.cpp --- a/Beacon.cpp Tue Feb 21 13:33:29 2017 +0000 +++ b/Beacon.cpp Wed Feb 22 14:59:59 2017 +0000 @@ -36,8 +36,10 @@ */ unsigned char SET_UUID[21] = {0x41,0x54,0xFF,0xF1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0D}; -unsigned char SET_VIRTUAL_PACKET_UUID[23] = {0x01,0x01,0x41,0x54,0x01,0x01,0x02,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x0D}; +unsigned char SET_VIRTUAL_PACKET_UUID[23] = {0x01,0x01,0x41,0x54,0x01,0x01,0x02,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x03,0x0B,0x0C,0x05,0x0E,0x0F,0x0D}; unsigned char SET_VIRTUAL_PACKET_UUID1[23] = {0x41,0x54,0xFF,0xF1,0x02,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x02,0x0B,0x0C,0x05,0x0E,0x0F,0x0D}; +unsigned char SET_VIRTUAL_PACKET_UUID2[23] = {0x12,0x21,0x41,0x54,0xFF,0xF1,0x0F,0x0E,0x0D,0x0C,0x0B,0x0A,0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00,0x0D}; +unsigned char SET_VIRTUAL_PACKET_UUID3[23] = {0x41,0x54,0xFF,0xF1,0x0F,0x0E,0x0D,0x0C,0x0B,0x04,0x05,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00,0x0D}; unsigned char SET_MAJOR[7] = {0x41,0x54,0xFF,0xF2,0x00,0x00,0x0D}; unsigned char SET_MINOR[7] = {0x41,0x54,0xFF,0xF3,0x00,0x00,0x0D}; unsigned char SET_MEASURED_POWER[6] = {0x41,0x54,0xFF,0xF4,0x00,0x0D}; @@ -66,7 +68,7 @@ Temp_Pos = 0x02; if((Command_Received[0] == SET_BEACON_UUID_CMD0) && (Command_Received[1] == SET_BEACON_UUID_CMD1)) //Check if command is receievd for setting UUID { - DEBUG_UART2.printf("Setting UUID"); + //DEBUG_UART2.printf("Setting UUID"); Data_Length = 16; End_Position = (Start_Position + Data_Length); for(;Start_Position < End_Position;Start_Position++) @@ -77,8 +79,24 @@ } + //DEBUG_UART2.printf("UUID Set"); Change_Beacon_Parameter(SET_VIRTUAL_PACKET_UUID1); - DEBUG_UART2.printf("UUID Set"); + } + else if((Command_Received[0] == 0x12) && (Command_Received[1] == 0x21)) //Check if command is receievd for setting UUID + { + DEBUG_UART2.printf("Setting UUID2"); + Data_Length = 16; + End_Position = (Start_Position + Data_Length); + for(;Start_Position < End_Position;Start_Position++) + { + SET_UUID[Start_Position] = Command_Received[Temp_Pos++]; + //DEBUG_UART2.putc(SET_UUID[Start_Position]); + //DEBUG_UART2.printf("%s",SET_UUID); + + + } + DEBUG_UART2.printf("UUID2 Set"); + Change_Beacon_Parameter(SET_VIRTUAL_PACKET_UUID3); } else if((Command_Received[0] == SET_SET_MAJOR_CMD0) && (Command_Received[1] == SET_SET_MAJOR_CMD1)) //Check if command is received for Setting Major { @@ -148,22 +166,29 @@ } else if((Command_Received[0] == SET_SOFT_REBOOT_CMD0) && (Command_Received[1] == SET_SOFT_REBOOT_CMD1)) //Check if command is received for Stopping beacon and go to sleep mode { - DEBUG_UART2.printf("%s",SOFT_REBOOT); Beacon_Module_UART.printf("%s",SOFT_REBOOT2); //Soft Reboot Beacon Module - DEBUG_UART2.printf("Beacon Device Resetted"); + DEBUG_UART2.printf("Beacon Device Resetted %s",SOFT_REBOOT2); } } void Change_Beacon_Parameter(unsigned char* Beacon_Parameter_To_Set) { + uint8 i; + for(i = 0;i<21;i++) + { + Beacon_Module_UART.putc(Beacon_Parameter_To_Set[i]); + //DEBUG_UART2.putc(Beacon_Parameter_To_Set[i]); + } + //Beacon_Module_UART.printf('%x',0x0d); + //DEBUG_UART2.putc('%x',0x0d); Beacon_Module_UART.printf("%s",Beacon_Parameter_To_Set); - Beacon_Module_UART.printf("%s",SOFT_REBOOT); //Every Ibeacon command must be followed by Soft reset command in order to make the changes take place instantly - DEBUG_UART2.printf("%s",Beacon_Parameter_To_Set); + //Beacon_Module_UART.printf("%s",SOFT_REBOOT); //Every Ibeacon command must be followed by Soft reset command in order to make the changes take place instantly + //DEBUG_UART2.printf("%s",Beacon_Parameter_To_Set); } void Initialize_Beacon_Module(void) { - Beacon_Module_UART.baud(9600); + Beacon_Module_UART.baud(9600); //set Beacon transmitter uart baud rate to default 9600 Read_Beacon_Module_MAC_ID(); }