èšäºã®æåã®éšåã§ã¯ ãéçºããŒã«ã調æŽããã³ãŒããã©ã®ããã«æ©èœããããã©ã®ããã«ãã©ã®ããã«ãããã°ããããç解ããããšããŸããããã³ãŒãã1è¡ãèšè¿°ããŸããã§ããã 2çªç®ã®éšåã§ãããä¿®æ£ããŸãã CC2541çšã®ç¬èªã®BLEãããã¡ã€ã«ãäœæããŸãããã
1.åé¡ã®å£°æ
次ã®æ©èœããµããŒãããããã€ã¹ã®ãããã¡ã€ã«ãå¿
èŠã ãšããŸãïŒ
-2ã€ã®PWMãã£ãã«ã®å€ã®èšå®ãšèªã¿åãïŒ0ã255ïŒã
-2ã€ã®ãã¿ã³ãæŒããç¶æ
ãååŸãã
-ãããã®ãã¿ã³ã®ããããã®ã¹ããŒã¿ã¹ã®èªã¿åãã
å®éã4ã€ã®ãããã¡ã€ã«ç¹æ§ãå¿
èŠã§ãã2ã€ã¯PWMãã£ãã«ã®ç¶æ
ãã2ã€ã¯éç¥ãã¿ã³ã®ç¶æ
ãæ
åœããŸãã
2. UUIDãµãŒãã¹ãšæ©èœ
åã®éšåã§è¿°ã¹ãããã«ãåãªã人éã¯ãµãŒãã¹ã®16ãããã¢ãã¬ã¹ã䜿çšã§ããŸããã ãããè¡ãã«ã¯ãå°ãªããšãé¢é£ã¡ã³ããŒã®Bluetooth SIGã§ããå¿
èŠããããŸãã éåžžã128ãããã®UUIDãµãŒãã¹ãå²ãåœãŠãããŠããŸãã
ãã®ãµãŒãã¹ã䜿çšããŠ
ããµãŒãã¹ã®UUIDãçæã
ãŸã ã
5ã€ã®UUIDãå¿
èŠã«ãªããŸã-æ©èœçšã«4ã€ããµãŒãã¹çšã«1ã€ã UUIDãé çªã«äžŠã¹ãã«ã¯ããæé/ããŒãããŒã¹ãã¢ã«ãŽãªãºã ãéžæããŸãã çæåŸã次ã®UUIDã®ã»ããã®ãããªãã®ãåŸãããŸãã
ããã§ããããã¡ã€ã«ã³ãŒãã®èšè¿°ãéå§ããæºåããã¹ãŠæŽããŸããã HabrProfileãããã¡ã€ã«ãåŒã³åºããŠãSimpleBLEPerepherialãããžã§ã¯ãã«è¿œå ããŸãã
3.ããããŒãã¡ã€ã«ãäœæãã
\ Projects \ Profilesã¹ã¿ãã¯ãã©ã«ããŒã§ãHabrProfileãã©ã«ããŒãäœæãããã®äžã«habrprofile.hããã³habrprofile.cãã¡ã€ã«ãäœæããŸãã
次ã«ãPROFILESãã©ã«ããŒã®SimpleBLEPerepherialãããžã§ã¯ãã«ãã¡ã€ã«ãè¿œå ããŸãã
ããããŒãã¡ã€ã«ã«ã¯ä»¥äžãå«ãŸããŠããå¿
èŠããããŸãã
-ã«ãã£ãŠååŸãããUUIDãããã¡ã€ã«ãšç¹æ§
-ãããã¡ã€ã«å±æ§ã®åœåïŒã¡ã€ã³ããã°ã©ã ããã¢ã¯ã»ã¹ããããããããïŒ
-å€éšããã°ã©ã ããã®ç¹æ§ãšãããã¡ã€ã«ãæäœããããã®é¢æ°ã®å®£èš
-é¢æ°åã³ãŒã«ããã¯ãããã¡ã€ã«åŒã³åºãã®æ±ºå®
habrprofile.hãã¡ã€ã«ã®å
容#define HABR_UUID(uuid) 0x66, 0x9a, 0x0c, 0x20, 0x00, 0x08, 0xa9, 0xb4, 0xe4, 0x11, 0xd7, 0x85, uuid, 0x50 , 0x2e, 0x51 #define HH_BUTTON1_STATE_ATTR 0 #define HH_BUTTON2_STATE_ATTR 1 #define HH_CHANNEL1_PWM_ATTR 2 #define HH_CHANNEL2_PWM_ATTR 3 #define HH_SERVICE_UUID 0x10 #define HH_BUTTON1_STATE_UUID 0x11 #define HH_BUTTON2_STATE_UUID 0x12 #define HH_CHANNEL1_PWM_UUID 0x13 #define HH_CHANNEL2_PWM_UUID 0x14 #define HH_SERVICE 0x00000001 typedef void (*habrControlCB_t)( uint8 paramID ) ; typedef struct { habrControlCB_t pfnHabrCB;
æåã«ééããã®ã¯ã16ã®UUIDã®ãã¡15ãã€ããäžèŽããããšã§ãã ãããã£ãŠãBluetoothã®ãã€ããªãŒããŒãããã°ãšã³ãã£ã¢ã³ã§ãããåä¿¡ããUUIDã¬ã³ãŒãã§ã¯ãªãã«ãšã³ãã£ã¢ã³ã§ãããšããäºå®ãèæ
®ãããšãããããå
±éã®å®çŸ©ã«çµåããããšã¯åççã§ãã ãããã£ãŠãå®çŸ©ã®ãã€ãã¬ã³ãŒãã¯éã«ãªããŸãã
AddServiceããã³RegisterAppCBsé¢æ°ã¯ãã¹ã¿ãã¯ã«ãããã¡ã€ã«ãç»é²ããããã°ã©ã ã³ãŒã«ããã¯é¢æ°ããããã¡ã€ã«ã«ãã€ã³ãããããã«äœ¿çšãããŸãã
ãããã¡ã€ã«ç¹æ§ã®å€ãå¶åŸ¡ããã«ã¯ãé¢æ°SetParameterããã³GetParameterãå¿
èŠã§ãã
ããã«ããããã³ã«ã«ãã£ãŠå€æ°ãèšå®ããã³èªã¿åãã€ãã³ãã®ãã³ãã©ãŒãäœæããå¿
èŠããããŸãããããã«ã€ããŠã¯åŸã§è©³ãã説æããŸãã ãŸããå®è¡å¯èœãã¡ã€ã«ã§ãããã¡ã€ã«ããŒãã«ãããŒã¯ããŸãããã
4.ãµãŒãã¹è¡š
ãããã£ãŠã4ã€ã®ç¹æ§ãããããã®ãã¡2ã€ã¯ãç¹æ§ã®å€ã®å€åã«ã€ããŠãŠãŒã¶ãŒã¢ããªã±ãŒã·ã§ã³ã«éç¥ã§ããŸãã èšäºã®æåã®éšåã§è¿°ã¹ãããã«ã1ã€ã®å€æ°ãèªã¿åããŸãã¯æžã蟌ã¿çšã«åæåããã«ã¯ãããã€ã¹ããŒãã«ã«3ã€ã®ã¬ã³ãŒããå¿
èŠã§ããéç¥ãããå€æ°4ã«ã¯ãã€ãŸãã14ã¬ã³ãŒããå¿
èŠãªãã¹ãŠã®ãããã¡ã€ã«å€æ°ã«ããããã¡ã€ã«ã宣èšããã¬ã³ãŒããè¿œå ããŠã15ã¬ã³ãŒããååŸããŸãã
æãéèŠãªããšã¯ãããã€ã¹ããŒãã«ãæ£ããèšå®ããããšã§ãã
æåã«è¡ãããšã¯ããããã¡ã€ã«ãšç¹æ§ã®UUIDã次ã®åœ¢åŒã®å€æ°ã«åœ¢æããããšã§ãã
CONST uint8 HhServUUID[ATT_UUID_SIZE] = { HABR_UUID(HH_SERVICE_UUID) };
次ã«ãç¹å®ã®ç¹æ§ã®ãã©ã¡ãŒã¿ãŒãæ
åœããå€æ°/å®æ°ãå®çŸ©ããŸãã
static uint8 hhButton1CharProps = GATT_PROP_NOTIFY;
ãããŠã次ã®åœ¢åŒã§ããã€ã¹ç¹æ§ã®gattããŒãã«ïŒã¿ã€ãgattAttribute_tã®é
åïŒã«ç¹æ§ãå
¥åããŸãã
{ gattAttrType_t type;
ããã«ãããå°ãæ··ä¹±ãçããŸãã äžæ¹ã§ã¯ãç¹æ§ãžã®ã¢ã¯ã»ã¹æš©ãå®çŸ©ããå€æ°ããããŸãïŒåã®ãªã¹ã-GATT_PROP_NOTIFYïŒã äžæ¹ãå±æ§ãžã®ã¢ã¯ã»ã¹æš©ãæ
åœãããšã³ããªããããŸãã ãã®äŸã§ã¯ããã®éããæ確ã«ããŸãã ç§ãã¡ã®ãããã¡ã€ã«ã§ã¯ãäž¡æ¹ã®ãã¿ã³ããã®éç¥ãããããã®ãã¡ã®1ã€ïŒ2çªç®ïŒã®ã¹ããŒã¿ã¹ãèªã¿åãããšãã§ããŸãã
次ã«ãç¹æ§ã®æåã®èšå®-GATT_PROP_NOTIFYã«å¯ŸããŠãèªã¿åããŸãã¯æžã蟌ã¿ã®èš±å¯ããããŸããã
ç¹æ§ã®2çªç®ã®èšå®-GATT_PROP_NOTIFY | GATT_PROP_READãããã«ãèªã¿åãèš±å¯ã¯ããã€ã¹ã®GATTããŒãã«ã§å®£èšããå¿
èŠããããŸãïŒããã§ãªãå Žåãèªã¿åãèŠæ±ã䌎ãã³ãŒã«ããã¯ã¯åŒã³åºãããŸããïŒ-GATT_PERMIT_READã
詳现-å±æ§ã®å®å
šãªè¡šïŒ
ãããã¡ã€ã«å±æ§ãã€ã³ã¯ã«ãŒãžã§ã³ãå€æ°å®£èšã®è¡š #include "bcomdef.h" #include "OSAL.h" #include "linkdb.h" #include "att.h" #include "gatt.h" #include "gatt_uuid.h" #include "gattservapp.h" #include "habrprofile.h" #include "OSAL_Clock.h" #define SERVAPP_NUM_ATTR_SUPPORTED 15 #define UUID_SIZE 16 CONST uint8 hhServUUID[ATT_UUID_SIZE] = { HABR_UUID(HH_SERVICE_UUID) }; CONST uint8 hhButton1UUID[ATT_UUID_SIZE] = { HABR_UUID(HH_BUTTON1_STATE_UUID) }; CONST uint8 hhButton2UUID[ATT_UUID_SIZE] = { HABR_UUID(HH_BUTTON2_STATE_UUID) }; CONST uint8 hhPWM1UUID[ATT_UUID_SIZE] = { HABR_UUID(HH_CHANNEL1_PWM_UUID) }; CONST uint8 hhPWM2UUID[ATT_UUID_SIZE] = { HABR_UUID(HH_CHANNEL2_PWM_UUID) }; static HarbCBs_t *habrahabrAppCBs_t = NULL;
5.ã«ã¹ã¿ã é¢æ°
次ã®ã¹ãããã§ã¯ãã¡ã€ã³ããã°ã©ã ããåŒã³åºãããé¢æ°ã説æããŸãã
-ãããã¡ã€ã«ç»é²ã
-ã³ãŒã«ããã¯é¢æ°ã®å²ãåœãŠã
-å€æ°ã®èªã¿åãã
-å€æ°ã®èšé²ã
ãããã¡ã€ã«ãã¹ã¿ãã¯ã«ç»é²ããã«ã¯ããŸããããã¡ã€ã«ã³ãŒã«ããã¯é¢æ°ïŒå€éšã€ãã³ããçºçãããšãã«åŒã³åºãããé¢æ°ãã®ãã®ïŒãç¹æ§ã®èªã¿åããŸãã¯æžã蟌ã¿èŠæ±ãããã³æ¥ç¶ç¶æ
ãå€åãããšãã«åŒã³åºãããé¢æ°ã宣èšããå¿
èŠããããŸãã
static uint8 hh_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr, uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen ); static bStatus_t hh_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr, uint8 *pValue, uint8 len, uint16 offset ); static void hh_HandleConnStatusCB( uint16 connHandle, uint8 changeType ); CONST gattServiceCBs_t HH_CBs = { hh_ReadAttrCB,
ããŠãããã§ã¹ã¿ãã¯ã«ãããã¡ã€ã«ãç»é²ãããããã¡ã€ã«ç¹æ§ããŒãã«ã®æ£ç¢ºæ§ã確èªã§ããŸãã ã¹ã¿ãã¯ã«ãããã¡ã€ã«ãç»é²ããæ©èœã¯ãGATTServApp_RegisterServiceãçŽæ¥åŒã³åºãããšã«å ããŠãæ¥ç¶ã¹ããŒã¿ã¹ãå€æŽããæ§æå€æ°ãåæåãããšãã«ã³ãŒã«ããã¯é¢æ°ãç»é²ããããšãæå³ããŸãïŒéç¥ããå¿
èŠãããç¹æ§ã«å¯ŸããŠïŒïŒ
bStatus_t Habr_AddService() { uint8 status = SUCCESS; GATTServApp_InitCharCfg( INVALID_CONNHANDLE, hhButton1Config ); GATTServApp_InitCharCfg( INVALID_CONNHANDLE, hhButton2Config ); VOID linkDB_Register( hh_HandleConnStatusCB ); status = GATTServApp_RegisterService(HabrProfileAttrTable, GATT_NUM_ATTRS(HabrProfileAttrTable), &HH_CBs ); return ( status ); }
å±æ§ããŒãã«ã確èªããŠãã ããã ãããè¡ãã«ã¯ãSimpleBLEPeripheral_Inité¢æ°ã®SimpleBLEPerepherial.cã§ãHabr_AddServiceãåŒã³åºããå
å«ããããŒãäºåã«è¿œå ããŸãïŒã³ã³ãã€ã©ãŒã®ããããŒã«ãã¹ãè¿œå ããããšãå¿ããªãã§ãã ãã-è¡ "$ PROJ_DIR $ \ .. \ .. \ Profiles \ HabrProfile"ïŒã ãããã°ããŒããçž«ããBLEããã€ã¹ã¢ãã¿ãŒãä»ããŠæ¥ç¶ããçµæã®å±æ§ããŒãã«ã確èªããŸãã
UUIDããããã¡ã€ã«ã®æ§æã確èªããããšãéèŠã§ãã ãã¹ãŠé 調ã§ããã°ãå
ã«é²ã¿ãŸãã
æ©èœèª¬æã¯çç¥ããŸã
ãŠãŒã¶ãŒã¢ããªã±ãŒã·ã§ã³ããå€æ°ãèªã¿æžãããããã®é¢æ° bStatus_t Habr_RegisterAppCBs( HarbCBs_t *appCallbacks ){ if ( appCallbacks ) { habrahabrAppCBs_t = appCallbacks; return ( SUCCESS ); } else { return ( bleAlreadyInRequestedMode ); } } bStatus_t Habr_SetParameter( uint8 param, uint8 len, void *value ){ bStatus_t ret = SUCCESS; switch ( param ) { case HH_BUTTON1_STATE_ATTR: if(len == sizeof(uint8)) { hhButton1Value = *((uint8*)value); GATTServApp_ProcessCharCfg (hhButton1Config, (uint8 *)&hhButton1Value, FALSE, HabrProfileAttrTable ,GATT_NUM_ATTRS(HabrProfileAttrTable), INVALID_TASK_ID); } else{ ret = bleInvalidRange; } break; case HH_BUTTON2_STATE_ATTR: if(len == sizeof(uint8)) { hhButton2Value = *((uint8*)value); GATTServApp_ProcessCharCfg (hhButton2Config, (uint8 *)&hhButton2Value, FALSE, HabrProfileAttrTable ,GATT_NUM_ATTRS(HabrProfileAttrTable), INVALID_TASK_ID); } else{ ret = bleInvalidRange; } break; case HH_CHANNEL1_PWM_ATTR: if(len == sizeof(uint8)) { hhPWM1Value = *((uint8*)value); } else{ ret = bleInvalidRange; } break; case HH_CHANNEL2_PWM_ATTR: if(len == sizeof(uint8)) { hhPWM2Value = *((uint8*)value); } else{ ret = bleInvalidRange; } break; default: ret = INVALIDPARAMETER; break; } return(ret); }
ã³ãŒã«ããã¯ç»é²æ©èœãåæ¢ããŠãæå³ããããŸããã å€æ°ã®å€ã®æžã蟌ã¿ãšèªã¿åãã®æ©èœã詳ããèŠãŠã¿ãŸãããããŸãããããã¡ã€ã«ã«å€ãæžã蟌ãæ©èœãèŠãŠã¿ãŸãããã ããã§ã¯ãGATTServApp_ProcessCharCfgãåŒã³åºãå¿
èŠããããšããäºå®ã«æ³šæãã䟡å€ããããŸãããã®é¢æ°ã¯éç¥èªäœãæäŸããŸãã
å°ããªããšã¯ãã¹ã¿ãã¯ã€ãã³ããåŠçããããã®é¢æ°ãè¿œå ããããšã§ãã
6. BLEã¹ã¿ãã¯ã®ã³ãŒã«ããã¯é¢æ°
äžèšã®ã¹ã¿ãã¯ã€ãã³ãã®åŠçã¯ãå±æ§å€ãèªã¿åãããã®ã³ãŒã«ããã¯èŠæ±ãå±æ§ã¬ã³ãŒããèªã¿åãããã®ã³ãŒã«ããã¯èŠæ±ãæ¥ç¶ã¹ããŒã¿ã¹ã³ãŒã«ããã¯ã®3ã€ã®é¢æ°ã«ãã£ãŠåŠçãããŸãã
ç¹æ§ãèªã¿åãã«äžãããããã¡ã€ã«ãæããããšã¯éåžžã«ç°¡åã§ãïŒç¹ã«ãã®å Žåããã¹ãŠã®ç¹æ§ãåãuint8åã®å€ã§ããå ŽåïŒ-ãã®ããã«ã¯ãæ£ããç¹æ§ãåŠçããŠããããšã確èªããå¿
èŠããããŸãã ã¹ã¿ãã¯ã¯ãé¢æ°ããã®å¿çã§ãã¹ããŒã¿ã¹ãpLenïŒãããã£ãŠãpLenã®æ£ç¢ºãªå€ãèšå®ããããšãåžžã«éèŠã§ãïŒãpValueã®3ã€ã®å€ãåãåããŸãã 3ã€ã®å€ã¯ãã¹ãŠæž¡ãããåä¿¡åŽã§ååŸã§ããŸãã
ãµãŒãã¹æ©èœãèªã static uint8 hh_ReadAttrCB( uint16 connHandle, gattAttribute_t *pAttr, uint8 *pValue, uint8 *pLen, uint16 offset, uint8 maxLen ) { bStatus_t status = SUCCESS; if ( offset > 0 ) { return ( ATT_ERR_ATTR_NOT_LONG ); } if ( pAttr->type.len == ATT_UUID_SIZE ) {
åæã«ãç¹æ§ã®èªã¿åãå€ã確èªããŸã-ãã¹ãŠãæ£ããæ©èœããŸããïŒãšããã§ãæåã®ãã¿ã³ã®å€æ°ã®èªã¿åããšã©ãŒãäºæ³ãããŸãïŒã
å€æ°ã¯åæ§ã®æ¹æ³ã§ãããã¡ã€ã«ã«æžã蟌ãŸããŸãããèªã¿åãé¢æ°ã§å€æ°ãã°ã«ãŒãåããŸãã-ãããã¡ã€ã«ã«ãã£ãŠåŒã³åºãããã³ãŒã«ããã¯ãã©ã®ç¹å®ã®ç¹æ§ãå€æŽãããããç解ãããããããã§ã¯ãå§ãã§ããŸããã ããã¯ãå€æ°notifyãå®çŸ©ããããšã«ããå®çŸãããŸãã ã€ã³ã¹ããŒã«ãããŠããå Žåããã®é¢æ°ã§ã¯ãnotifyãã©ã¡ãŒã¿ãŒã䜿çšããŠãŠãŒã¶ãŒã¢ããªã±ãŒã·ã§ã³ã®é¢æ°ãåŒã³åºããŸãã
ããã«ãPWMå€ã®èšé²ã®åŠçã«å ããŠããã®é¢æ°ã¯ãéç¥ãããç¹æ§ã®æ§æå±æ§ã®å€ãèšé²ãããŠããå Žåãéç¥ãæå¹ã«ããŸãïŒãªãã«ããŸãïŒãããã¯ãGATTServApp_ProcessCCCWriteReqïŒïŒé¢æ°ãåŒã³åºãããšã§éæãããŸã;
ãµãŒãã¹ç¹æ§ãèšé²ãã static bStatus_t hh_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr, uint8 *pValue, uint8 len, uint16 offset ){ bStatus_t status = SUCCESS; uint8 notify = 0xFF; if ( pAttr->type.len == ATT_UUID_SIZE ) { const uint8 uuid[ATT_UUID_SIZE] = { HABR_UUID(pAttr->type.uuid[12]) }; if(osal_memcmp(uuid,hhPWM1UUID,ATT_UUID_SIZE)) { if ( offset == 0 ) { if ( len != 1 ){ status = ATT_ERR_INVALID_VALUE_SIZE; } } else { status = ATT_ERR_ATTR_NOT_LONG; } if ( status == SUCCESS ) { uint8 *pCurValue = (uint8 *)pAttr->pValue; *pCurValue = pValue[0]; notify = HH_CHANNEL1_PWM_ATTR; } } else if(osal_memcmp(uuid,hhPWM2UUID,ATT_UUID_SIZE)){ if ( offset == 0 ) { if ( len != 1 ){ status = ATT_ERR_INVALID_VALUE_SIZE; } } else { status = ATT_ERR_ATTR_NOT_LONG; } if ( status == SUCCESS ) { uint8 *pCurValue = (uint8 *)pAttr->pValue; *pCurValue = pValue[0]; notify = HH_CHANNEL2_PWM_ATTR; } } } else if (pAttr->type.len== ATT_BT_UUID_SIZE) { uint16 uuid= BUILD_UINT16(pAttr->type.uuid[0],pAttr->type.uuid[1]); switch(uuid){ case GATT_CLIENT_CHAR_CFG_UUID: status=GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len, offset, GATT_CLIENT_CFG_NOTIFY); break; default: status = ATT_ERR_ATTR_NOT_FOUND; } } else{ status = ATT_ERR_INVALID_HANDLE; }
ãããã¡ã€ã«ã¯ã»ãšãã©æºåãã§ããŠããŸãã æåŸã«è¿œå ããå¿
èŠãããã®ã¯ãæ¥ç¶ã倱ããããšãã«å€æ°ã®éç¥ãç¡å¹ã«ããé¢æ°ã§ãã
æ¥ç¶ã倱ããããšãã«éç¥ããªãã«ããæ©èœ static void hh_HandleConnStatusCB( uint16 connHandle, uint8 changeType ){ if ( connHandle != LOOPBACK_CONNHANDLE ) { if ( ( changeType == LINKDB_STATUS_UPDATE_REMOVED ) || ( ( changeType == LINKDB_STATUS_UPDATE_STATEFLAGS ) && ( !linkDB_Up( connHandle ) ) ) ) { GATTServApp_InitCharCfg ( connHandle, hhButton1Config); GATTServApp_InitCharCfg ( connHandle, hhButton2Config); } } }
ãããã£ãŒã«ã®æºåãã§ããŸããïŒ æ¬¡ã«ãæ£ããæ©èœããããšã確èªããŸãã
7.ãŠãŒã¶ãŒã¢ããªã±ãŒã·ã§ã³ãšã®éä¿¡
åšèŸºããé¢ããŠã次ã®ã·ããªãªãäœæããŸãã
PWM1ãã£ã³ãã«ã®å€ãèšå®ãããšããåãå€ãButton1å€æ°ãä»ããŠæž¡ãããŸãã åæ§ã«ãPWM2ãšButton2ãå²ãåœãŠãŸãã
ãããè¡ãã«ã¯ãSimpleBLEPerepherialãã¡ã€ã«ã§æ¬¡ãå¿
èŠã§ãã
-ãããã¡ã€ã«ã³ãŒã«ããã¯ã®å®£èšã
-ãããã£ãŒã«ã«ç»é²ãã
-ã¢ã«ãŽãªãºã ãå®è£
ããŸãã
å§ããŸãããã å®éã®ã³ãŒã«ããã¯ãšãã³ãŒã«ããã¯ã®å®è¡ã®ããã«ç»é²ãããæ§é äœã宣èšããŸãã äžèŠããã®ãããªã¬ã³ãŒãã¯è€éãããããã«æãããããããŸããããè€æ°ã®ã³ãŒã«ããã¯ã䜿çšããŠãããã¡ã€ã«ãäœæããå¿
èŠãããå ŽåïŒããšãã°ãå€æ°ã®èªã¿åãã«é¢ããéç¥ãè¿œå ããå ŽåïŒããã®ã¢ãããŒãã¯ããèªäœãæ£åœåããŸãã ãšã«ãããã¹ã¿ãã¯ã®ãã¹ãŠã®ã³ãŒã«ããã¯ã¯ãã®æ¹æ³ã§æ§ç¯ãããŸãã
static void habrProfileCB (uint8 paramID); static HarbCBs_t HabrProfCBStruct = { habrProfileCB
SimpleBLEPeripheral_Inité¢æ°ã®æ¬äœã§ããã®æ§é ããããã¡ã€ã«ã«ç»é²ããŸãã
Habr_AddService(); Habr_RegisterAppCBs(&HabrProfCBStruct);
hh_WriteAttrCBé¢æ°ã§ã¯ãèšé²ãããç¹æ§ã«é¢ããæ
å ±ã®ã³ãŒã«ããã¯ãžã®è»¢éãæ¢ã«å®è£
ããŠããŸãã å¯äžã®ããšã¯ããã®æ
å ±ãåŠçããããšã§ãã
static void habrProfileCB (uint8 paramID){ uint8 u8buffer; switch(paramID){ case HH_CHANNEL1_PWM_ATTR: Habr_GetParameter(HH_CHANNEL1_PWM_ATTR, &u8buffer); Habr_SetParameter(HH_BUTTON1_STATE_ATTR, sizeof(uint8), &u8buffer); break; case HH_CHANNEL2_PWM_ATTR: Habr_GetParameter(HH_CHANNEL2_PWM_ATTR, &u8buffer); Habr_SetParameter(HH_BUTTON2_STATE_ATTR, sizeof(uint8), &u8buffer); break; default: break; } }
æåŸã«ããã¹ãŠãæ©èœããããšã確èªããŸãã ããã¯æ¬åœã«æ©èœããŸã-ã³ã³ãœãŒã«ã確èªã§ããŸãïŒ
ã³ã³ãããŒã©ã®åšèŸºæ©åšãšã®çµ±åãèªè
ã¯èªåã§ãããè¡ãããã«æåŸ
ãããŠããŸãã
ãæž
èŽããããšãããããŸããïŒ