Ble Demo with Raspberry PI updated

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_DEMO_SPI by HM_IOT_Demo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers hm_config.h Source File

hm_config.h

00001 
00002 
00003 #ifndef __HM_CONFIG_H__
00004 #define __HM_CONFIG_H__
00005 
00006 #include "mbed.h"
00007 #include "ble/BLE.h"
00008 #include "ble/DiscoveredCharacteristic.h"
00009 #include "ble/DiscoveredService.h"
00010 #include "ble/Gap.h"
00011 
00012 #define MAX_SERVICES 4
00013 #define DEVICE_MAC_ADDR_1   0xE5 //Raspberry PI
00014 #define DEVICE_MAC_ADDR_2   0x51 //Magic Light1
00015 #define DEVICE_MAC_ADDR_3   0x5A //Magic Light2
00016 #define DEVICE_MAC_ADDR_4   0x4F //MiniBeacon_22824
00017 #define DEVICE_MAC_ADDR_5   0xE6 //MiniBeacon_22829
00018 #define MAX_DEVICES         5
00019 
00020 static const size_t MAC_ADDR_LEN = 6;
00021 
00022 //class Magic_Light{
00023 bool connect_status = false;
00024 bool charDiscover =  false;
00025 
00026 uint8_t pre_write_data[16];
00027 int spiRX[8];
00028 uint8_t write_bufferSize;
00029 uint8_t write_data[16];
00030 
00031 static ble_error_t error_status;
00032 bool serviceDiscover = true;
00033 bool first_on=true;
00034 
00035 bool read_flag = true;
00036 bool write_flag = false;
00037 bool disconnect_status = true;
00038 void AddCharNodes(DiscoveredCharacteristic light_Characteristic);
00039 void light_actions(int service_char[]);
00040 
00041 //public:
00042 typedef enum light_action_e{
00043     TURN_OFF=0, 
00044     TURN_ON,
00045     COLOR,
00046     INVAILD
00047 }light_action;
00048 
00049 typedef enum light_color_e{
00050     RED=0,
00051     GREEN,
00052     BLUE,
00053     YELLOW,
00054     CYAN,
00055     MAGENTA,
00056     MAX_COLOR
00057 }light_color;
00058 
00059 
00060 uint8_t lightColor[MAX_COLOR][3] = {{0xFF,0x00,0x00},{0x00,0xFF,0x00},
00061                                     {0x00,0x00,0xFF},{0xFF,0xFF,0x00},
00062                                     {0x00,0xFF,0xFF},{0xFF,0x00,0xFF}
00063                                    };
00064 
00065 
00066 uint8_t Ble_address[MAX_DEVICES][MAC_ADDR_LEN];
00067 
00068 struct lightCharacteristic_t{
00069     uint8_t DeviceID;
00070     uint8_t Ble_address[MAC_ADDR_LEN];
00071     DiscoveredCharacteristic DiscoverCharacteristics;
00072     //struct lightCharacteristic_t *nextChar;
00073 };
00074 
00075 typedef struct _serviceinfo 
00076 {
00077     lightCharacteristic_t * services_Char[MAX_SERVICES];
00078 
00079 }s_serviceInfo;
00080 
00081 //};
00082 
00083 #endif /* ifndef __BLE_H__ */