CC2640R2F 添加notify 接口


-----------------------------------------------------------------------------------simple_gatt_profile.c

uint16_t GATTServApp_FindCharhandle( gattAttribute_t *pAttrTbl,
                                       uint16 numAttrs, uint16 uuid )
{
  uint16  i;
  uint8 charuuid[ATT_BT_UUID_SIZE] =
  {
    LO_UINT16(uuid), HI_UINT16(uuid)
  };    
    
  for ( i = 0; i < numAttrs; i++ )
  {
    if(memcmp(pAttrTbl[i].type.uuid,charuuid,sizeof(charuuid)) == 0)
    {
      return ( pAttrTbl[i].handle );
    }
  }


  return ( 0 );
}


bStatus_t ServApp_SendNotiInd( uint8_t *nvalue,uint16_t nlen,uint16_t char_uuid)
{
  attHandleValueNoti_t noti;
  uint16_t slen;
  bStatus_t status = FAILURE;
  slen  = nlen;
  
  uint16 notify_Handle;  
  
  GAPRole_GetParameter(GAPROLE_CONNHANDLE,&notify_Handle); //获取当前连接的handle


  if  ( notify_Handle != INVALID_CONNHANDLE )
  {
      noti.pValue = (uint8 *)GATT_bm_alloc( notify_Handle, ATT_HANDLE_VALUE_NOTI,slen,&slen);
      
      if ( noti.pValue != NULL )               
      {
          noti.handle =  GATTServApp_FindCharhandle(simpleProfileAttrTbl,GATT_NUM_ATTRS( simpleProfileAttrTbl ),char_uuid);
          noti.len = slen;
          memcpy(noti.pValue, nvalue, slen);
          
          if(noti.handle != 0)
          {
              status = GATT_Notification( notify_Handle, &noti, FALSE );
          }


        if ( status != SUCCESS )
        {
          GATT_bm_free( (gattMsg_t *)&noti, ATT_HANDLE_VALUE_NOTI );
        }
      }
      else
      {
        GATT_bm_free( (gattMsg_t *)&noti, ATT_HANDLE_VALUE_NOTI );
        status = bleNoResources;
      }
  }


  return ( status );
}
-----------------------------------------------------------------------------------simple_gatt_profile.h

extern bStatus_t CoolBan_SendNotiInd_Char4( uint8 *nvalue,uint8 nlen);   // add


-----------------------------------------------------------------------------------simple_peripheral.

static void SimpleBLEPeripheral_performPeriodicTask(void)    // event= SBP_PERIODIC_EVT     period= SBP_PERIODIC_EVT_PERIOD 
{
  bStatus_t ret;
  static uint8 Txbuf[300]= {0};
  static uint8 TxLen = 10;
  
  uint8 i = 0;
  for(i = 0; i < 0xFF ;i++){
    Txbuf[i] = i;
  }
  
  ret =  CoolBan_SendNotiInd_Char4( Txbuf,TxLen);
  if(ret == SUCCESS){
  }else{
  }
}






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
以下是使用Java SDK调用alipay.user.opencard.result.notify接口的示例代码: ``` import com.alipay.api.AlipayClient; import com.alipay.api.AlipayConstants; import com.alipay.api.DefaultAlipayClient; import com.alipay.api.request.AlipayUserOpenCardResultNotifyRequest; import com.alipay.api.response.AlipayUserOpenCardResultNotifyResponse; public class AlipayUserOpenCardResultNotifyDemo { public static void main(String[] args) { // 1. 创建AlipayClient实例 AlipayClient alipayClient = new DefaultAlipayClient( "https://openapi.alipay.com/gateway.do", "你的AppID", "你的应用私钥", AlipayConstants.FORMAT_JSON, AlipayConstants.CHARSET_UTF8, "支付宝公钥", AlipayConstants.SIGN_TYPE_RSA2 ); // 2. 创建AlipayUserOpenCardResultNotifyRequest实例 AlipayUserOpenCardResultNotifyRequest request = new AlipayUserOpenCardResultNotifyRequest(); // 3. 设置请求参数 request.setBizContent("{" + "\"card_status\":\"activate\"," + // 会员卡状态 "\"template_id\":\"TM00000001\"," + // 会员卡模板ID "\"open_card_agreement_id\":\"20191212000000000000000000000001\"," + // 开卡协议号 "\"notify_time\":\"2019-12-12 12:00:00\"," + // 通知时间 "\"user_id\":\"2088100000000000\"," + // 用户ID "\"card_id\":\"1234567890\"" + // 会员卡ID "}"); // 4. 调用alipay.user.opencard.result.notify接口,获取响应 AlipayUserOpenCardResultNotifyResponse response = alipayClient.execute(request); // 5. 处理响应结果 if (response.isSuccess()) { System.out.println("调用alipay.user.opencard.result.notify成功"); } else { System.out.println("调用alipay.user.opencard.result.notify失败:" + response.getMsg()); } } } ``` 需要注意的是,上述代码中的参数需要替换成实际的值。其中,AppID、应用私钥、支付宝公钥等参数可以在支付宝开放平台上申请获取。biz_content中的参数具体含义可以参考支付宝开放平台文档。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值