Re: Programming in C with Bluetooth Sockets

2023-11-18



Re: Programming in C with Bluetooth Sockets

This is the function run by the bluetooth device that will recieve the data.

char* BT_Target()
{
       int s, client, bytes_read, count = 0;
       char * buf;
       struct sockaddr_rc loc_addr = { 0 }, rem_addr = { 0 };
       int opt = sizeof(rem_addr);
       unsigned int max_count;

       //attempt to allocate reception buffer
       buf = (char *)calloc(MAX_MSG, 1);

       if(buf == NULL)
       {
               perror("No memory!");
               return("No memory!");
       }

       //attempt to allocate socket
       s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);

       if(s < 0)
       {
               perror("socket failed to open:");
               return("socket failed to open");
       }

       loc_addr.rc_family = AF_BLUETOOTH;
       loc_addr.rc_bdaddr = *BDADDR_ANY;
       loc_addr.rc_channel = (uint8_t) RFCOMM_CHANNEL;

       //attempt to bind the socket for a maximum number of attempts
       for( count = 0; count < MAX_ATTEMPTS && bind(s, (struct sockaddr
*)&loc_addr, sizeof(loc_addr)) < 0; count++);

       //if we tried to open the socket but failed
       if( count == MAX_ATTEMPTS )
       {
               perror("unable to bind socket: ");
               close(s);
               free(buf);
               return "unable to bind socket";
       }

       //attempt to listen
       if(listen(s, 1) < 0)
       {
               perror("listen failed: ");
               close(s);
               free(buf);
               return "listen failed.";
       }

       //attempt to accept the socket
       rem_addr.rc_family = AF_BLUETOOTH;
       rem_addr.rc_bdaddr = *BDADDR_ANY;
       rem_addr.rc_channel = (uint8_t) RFCOMM_CHANNEL;

       client = accept(s, (struct sockaddr *)&rem_addr, &opt);

       //if we have created a connection
       //we need to recieve the transmission length into max_count
       if(client >= 0)
       {
               count = 0;
               fprintf(stderr,"Got a connection\n");
               read(client, &max_count, sizeof(unsigned int));
               printf( "Message size: %d\n", max_count );
               close( client );

       }
       //the accept has failed
       else
       {
               perror("accept failed: ");
               close(s);
               free(buf);
               return("accept failed");
       }

       //while we have not recieved the entire message, get the next part
       while( count < max_count &&
                ( client = accept(s, (struct sockaddr*)&rem_addr, &opt) ) >= 0 )
       {
               bytes_read = read(client, buf + count, sizeof(buf) - count);

               fprintf(stderr, "got %d bytes this time\n", bytes_read);
               count += bytes_read;
               fprintf(stderr, "recieved %d [%s] so far\n", count, buf);
               close( client );

               if(bytes_read < 0)
               {
                       perror("socket issue.");
                       fprintf(stderr, "We have socket problems.\n");
                       close(s);
                       free(buf);
                       close(client);
                       return("We have socket Problems.");
               }
       }

       close(s);
       close(client);

       return "Success";
}

And this is the function that will send the data.
char* BT_Source(char* fname, int iter, char* tMAC)
{
       struct sockaddr_rc addr = { 0 };
       int s, status, count = 0, fd;
       char* dest = tMAC;
       struct stat *stats;
       unsigned int len = 0;
       char* buf;

       //attempt to allocate a socket
       s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
       if(s < 0)
       {
               perror("error creating socket: ");
               return "socket creation failed.";
       }

       // set the connection parameters (who to connect to)
       addr.rc_family = AF_BLUETOOTH;
       addr.rc_channel = (uint8_t) RFCOMM_CHANNEL;

       fprintf(stderr, "The dest addr is now %s\n", dest);
       str2ba(dest, &addr.rc_bdaddr);

       //attempt to connect the socket for our maximum number of times
       status = connect(s, (struct sockaddr *)&addr, sizeof(addr));
       for(count = 0; status != 0 && count < MAX_ATTEMPTS;)
       {
               perror("retrying connection: ");

               //if the socket is busy or the host is down, close and reopen
               if(!(errno == EBUSY || errno == EHOSTDOWN))
               {
                       close(s);
                       s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
                       if(s < 0)
                       {
                               perror("error creating socket: ");
                               return "socket creation failed.";
                       }
                       count++;
               }

               status = connect(s, (struct sockaddr *)&addr, sizeof(addr));
       }

       //if the socket was opened properly, send a message
       if(status == 0)
       {
               count = 0;

               //get the file size and send it to the client
               stat(fname, stats);
               len = stats->st_size;
               fprintf(stderr, "The length in bytes is %d\n", len);
               write(s, &len, sizeof(unsigned int));

               //open the file
               if((fd = open(fname, O_RDONLY)) == NULL)
               {
                       perror( "Cannot open file for reading" );
                       close( s );
                       return "failed";
               }

               //attempt to allocate reception buffer
               buf = (char *)calloc( MAX_MSG + 1, 1 );

               if( buf == NULL )
               {
                       perror( "out of memory" );
                       close( fd );
                       close( s );
                       return "failed";
               }

               //while we still have message to send
               while((in = read(fd, buf, MAX_MSG)) > 0)
               {
                       //close previous socket connection to force a flush
                       close( s );

                       //allocate a socket
                       s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
                       if(s < 0)
                       {
                               perror("error creating socket: ");
                               return "socket creation failed.";
                       }

                       //connect the socket
                       status = connect(s, (struct sockaddr *)&addr,
sizeof(addr));
                       for(count = 0; status != 0 && count < MAX_ATTEMPTS;)
                       {
                               perror("retrying connection: ");

                               if(!(errno == EBUSY || errno == EHOSTDOWN))
                               {
                                       close(s);
                                       s = socket(AF_BLUETOOTH,
SOCK_STREAM, BTPROTO_RFCOMM);
                                       if(s < 0)
                                       {
                                               perror("error creating
socket: ");
                                               return "socket creation failed.";
                                       }
                                       count++;
                                       sleep( 1 );
                               }

                               status = connect(s, (struct sockaddr
*)&addr, sizeof(addr));
                       }

                       if( status < 0 )
                       {
                               perror("message failed: ");
                               close(s);
                               close(fd);
                               fprintf(stderr, "failed connecting, I
tried %d times.\n", count);
                               return "uh oh, that message did not go through";
                       }

                       //write the next message segment
                       fprintf(stderr,"data read '%s'\n", buf);
                       count = write(s, buf, MAX_MSG);
                       fprintf(stderr,"contents of in: %d, %d bytes
were written\n", in, count);
               }
       }
       else if(status < 0)
       {
               perror("message failed: ");
               close(s);
               close(fd);
               fprintf(stderr, "failed connecting, I tried %d times.\n", count);
               return "uh oh, that message did not go through";
       }

       fprintf(stderr, "message sent\n");
       close(s);
       close(fd);

       return strdup("Success");
}

This is the latest iteration where the connection is stopped after
each 4 byte transmission and restarted before the next.

-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642

Re: Programming in C with Bluetooth Sockets

This is the function run by the bluetooth device that will recieve the data.

char* BT_Target()
{
       int s, client, bytes_read, count = 0;
       char * buf;
       struct sockaddr_rc loc_addr = { 0 }, rem_addr = { 0 };
       int opt = sizeof(rem_addr);
       unsigned int max_count;

       //attempt to allocate reception buffer
       buf = (char *)calloc(MAX_MSG, 1);

       if(buf == NULL)
       {
               perror("No memory!");
               return("No memory!");
       }

       //attempt to allocate socket
       s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);

       if(s < 0)
       {
               perror("socket failed to open:");
               return("socket failed to open");
       }

       loc_addr.rc_family = AF_BLUETOOTH;
       loc_addr.rc_bdaddr = *BDADDR_ANY;
       loc_addr.rc_channel = (uint8_t) RFCOMM_CHANNEL;

       //attempt to bind the socket for a maximum number of attempts
       for( count = 0; count < MAX_ATTEMPTS && bind(s, (struct sockaddr
*)&loc_addr, sizeof(loc_addr)) < 0; count++);

       //if we tried to open the socket but failed
       if( count == MAX_ATTEMPTS )
       {
               perror("unable to bind socket: ");
               close(s);
               free(buf);
               return "unable to bind socket";
       }

       //attempt to listen
       if(listen(s, 1) < 0)
       {
               perror("listen failed: ");
               close(s);
               free(buf);
               return "listen failed.";
       }

       //attempt to accept the socket
       rem_addr.rc_family = AF_BLUETOOTH;
       rem_addr.rc_bdaddr = *BDADDR_ANY;
       rem_addr.rc_channel = (uint8_t) RFCOMM_CHANNEL;

       client = accept(s, (struct sockaddr *)&rem_addr, &opt);

       //if we have created a connection
       //we need to recieve the transmission length into max_count
       if(client >= 0)
       {
               count = 0;
               fprintf(stderr,"Got a connection\n");
               read(client, &max_count, sizeof(unsigned int));
               printf( "Message size: %d\n", max_count );
               close( client );

       }
       //the accept has failed
       else
       {
               perror("accept failed: ");
               close(s);
               free(buf);
               return("accept failed");
       }

       //while we have not recieved the entire message, get the next part
       while( count < max_count &&
                ( client = accept(s, (struct sockaddr*)&rem_addr, &opt) ) >= 0 )
       {
               bytes_read = read(client, buf + count, sizeof(buf) - count);

               fprintf(stderr, "got %d bytes this time\n", bytes_read);
               count += bytes_read;
               fprintf(stderr, "recieved %d [%s] so far\n", count, buf);
               close( client );

               if(bytes_read < 0)
               {
                       perror("socket issue.");
                       fprintf(stderr, "We have socket problems.\n");
                       close(s);
                       free(buf);
                       close(client);
                       return("We have socket Problems.");
               }
       }

       close(s);
       close(client);

       return "Success";
}

And this is the function that will send the data.
char* BT_Source(char* fname, int iter, char* tMAC)
{
       struct sockaddr_rc addr = { 0 };
       int s, status, count = 0, fd;
       char* dest = tMAC;
       struct stat *stats;
       unsigned int len = 0;
       char* buf;

       //attempt to allocate a socket
       s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
       if(s < 0)
       {
               perror("error creating socket: ");
               return "socket creation failed.";
       }

       // set the connection parameters (who to connect to)
       addr.rc_family = AF_BLUETOOTH;
       addr.rc_channel = (uint8_t) RFCOMM_CHANNEL;

       fprintf(stderr, "The dest addr is now %s\n", dest);
       str2ba(dest, &addr.rc_bdaddr);

       //attempt to connect the socket for our maximum number of times
       status = connect(s, (struct sockaddr *)&addr, sizeof(addr));
       for(count = 0; status != 0 && count < MAX_ATTEMPTS;)
       {
               perror("retrying connection: ");

               //if the socket is busy or the host is down, close and reopen
               if(!(errno == EBUSY || errno == EHOSTDOWN))
               {
                       close(s);
                       s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
                       if(s < 0)
                       {
                               perror("error creating socket: ");
                               return "socket creation failed.";
                       }
                       count++;
               }

               status = connect(s, (struct sockaddr *)&addr, sizeof(addr));
       }

       //if the socket was opened properly, send a message
       if(status == 0)
       {
               count = 0;

               //get the file size and send it to the client
               stat(fname, stats);
               len = stats->st_size;
               fprintf(stderr, "The length in bytes is %d\n", len);
               write(s, &len, sizeof(unsigned int));

               //open the file
               if((fd = open(fname, O_RDONLY)) == NULL)
               {
                       perror( "Cannot open file for reading" );
                       close( s );
                       return "failed";
               }

               //attempt to allocate reception buffer
               buf = (char *)calloc( MAX_MSG + 1, 1 );

               if( buf == NULL )
               {
                       perror( "out of memory" );
                       close( fd );
                       close( s );
                       return "failed";
               }

               //while we still have message to send
               while((in = read(fd, buf, MAX_MSG)) > 0)
               {
                       //close previous socket connection to force a flush
                       close( s );

                       //allocate a socket
                       s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
                       if(s < 0)
                       {
                               perror("error creating socket: ");
                               return "socket creation failed.";
                       }

                       //connect the socket
                       status = connect(s, (struct sockaddr *)&addr,
sizeof(addr));
                       for(count = 0; status != 0 && count < MAX_ATTEMPTS;)
                       {
                               perror("retrying connection: ");

                               if(!(errno == EBUSY || errno == EHOSTDOWN))
                               {
                                       close(s);
                                       s = socket(AF_BLUETOOTH,
SOCK_STREAM, BTPROTO_RFCOMM);
                                       if(s < 0)
                                       {
                                               perror("error creating
socket: ");
                                               return "socket creation failed.";
                                       }
                                       count++;
                                       sleep( 1 );
                               }

                               status = connect(s, (struct sockaddr
*)&addr, sizeof(addr));
                       }

                       if( status < 0 )
                       {
                               perror("message failed: ");
                               close(s);
                               close(fd);
                               fprintf(stderr, "failed connecting, I
tried %d times.\n", count);
                               return "uh oh, that message did not go through";
                       }

                       //write the next message segment
                       fprintf(stderr,"data read '%s'\n", buf);
                       count = write(s, buf, MAX_MSG);
                       fprintf(stderr,"contents of in: %d, %d bytes
were written\n", in, count);
               }
       }
       else if(status < 0)
       {
               perror("message failed: ");
               close(s);
               close(fd);
               fprintf(stderr, "failed connecting, I tried %d times.\n", count);
               return "uh oh, that message did not go through";
       }

       fprintf(stderr, "message sent\n");
       close(s);
       close(fd);

       return strdup("Success");
}

This is the latest iteration where the connection is stopped after
each 4 byte transmission and restarted before the next.

-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Re: Programming in C with Bluetooth Sockets 的相关文章

  • 蓝牙资讯

    苹果公司宣称 USB C 能够带来更多灵活性 现在用户可以使用手机的 USB C 接口 为 AirPods Pro 耳机盒充电 虽然苹果没有详细介绍这款耳机 但在今天的新闻稿中依然透露了一些不一样的地方 例如新款 AirPods Pro 2
  • Android蓝牙开发浅析

    由于近期正在开发一个通过蓝牙进行数据传递的模块 在参考了有关资料 并详细阅读了Android的官方文档后 总结了Android中蓝牙模块的使用 更新 之前承诺的蓝牙通讯模块的源码已经放出 详情请点击一下链接 http blog csdn n
  • Matter (CHIP) 从入门到入土 (一)

    文章目录 前言 架构 规范 网络拓扑结构 Single network Star network topology matter 设备发现 using BLE using WIFI Using Existing IP bearing Net
  • 微信小程序之蓝牙 BLE 踩坑记录

    前言 前段时间接手了一个微信小程序的开发 主要使用了小程序在今年 3 月开放的蓝牙 API 此过程踩坑无数 特此记录一下跳坑过程 顺便开了另一个相关的小项目 欢迎 start 和 fork BLE MiniProgram API简介 微信小
  • 蓝牙之十一 AVRCP协议

    Profile简介 AVRCP子协议的作用是支持CT控制TG 具体来说如果手机和一个蓝牙音箱设备连接上了 那么音箱可以控制手机播放 暂停 切歌以及获得手机上播放歌曲的信息 如专辑 歌名 歌手 时长等信息 iphone对信息获取支持较为完善
  • Android 蓝牙串口通信Demo

    目录 一 前言 二 效果图 三 源码 带注释 1 布局代码 2 Java代码 3 权限声明 四 注意 五 项目源码下载 一 前言 在学校和机电的同学组队准备做一个智能小车去参加比赛 需要我开发一个小车的控制app 所以我开始学习蓝牙串口通信
  • BLE芯片PHY6222的ANCS代码解读

    BLE芯片PHY6222的ANCS代码解读 ANCS是什么 实现原理 PHY6222软件实现框架 要获取的详细信息 开通知源 通知源的解析 数据源的解析 ANCS是什么 ANCS 苹果通知中心 Apple Notification Cent
  • Android 蓝牙开发(六)hfp连接

    转载请注明出处 http blog csdn net vnanyesheshou article details 71106622 本文已授权微信公众号 fanfan程序媛 独家发布 扫一扫文章底部的二维码或在微信搜索 fanfan程序媛
  • Bes 充电盒协议总结

    1 开盖 上升沿信号开机 a 充电脚设成3 0 v 然后延迟160ms b 充电脚设成5v 然后延时100 ms c充电脚设成3 0 v 2 合盖 a 开5v 然后延时3s b 关5v 然后延时45ms c 发送复位pattern 0101
  • Bluetooth 蓝牙介绍(三):低功耗蓝牙BLE空口协议Ⅱ

    文章目录 前言 4 5 CONNECTION STATE 4 5 1 Connection events 4 5 2 Supervision timeout 4 5 3 Connection event transmit window 4
  • BES2300X,BES2500X——UI(按键,提示音,指示灯)

    前言 BES2300X BES2500X系列博文请点击这里 本文是BES2300X BES2500X系列博文UI部分 一个耳机 音箱 UI是联系使用者与开发者最直接的一个窗口 当然 对于吾等码农而言 UI设计并不是我们最关心的 我们主要做的
  • BLE MESH组网(五)配置BLE MESH

    BLE MESH 五 配置BLE MESH 前言 概述 配置协议 供应程序 信标 邀请 交换公钥 前言 2017 年 5 月 全球最臭名昭著的勒索软件 WannaCry 在全球范围内积极攻击计算机 劫持用户数据索要赎金 这次攻击影响了 15
  • 基于snooplog分析蓝牙连接过程,进一步学习蓝牙协议栈

    一 什么是BT snoop log 首先问题 1 为什么远端发来的消息没有收到 2 为什么搜索不到设备 3 为什么连不上 4 总之 研发过程中会遇到很多奇奇怪怪的问题 我们无法通过现象去分析原因 也不可能再过一遍代码吧 这时候需要再某些代码
  • BT问题调试 -- HFP(AT指令)

    HFP基本知识 HFP的两个角色 AG和HF HFP AG角色发起连接请求 HFP HF角色发起连接请求 针对HFP的注意事项 必须先有SLC的建立过程 该过程可以由HF AG的任何一方发起 AT COPS用来查询运营商网络名称 AG的回应
  • 蓝牙之十八- bluetooth pair

    蓝牙之十八 bluetooth pair 在蓝牙核心规范2 1之后 蓝牙配对除了传统的PIN Code Pairing方式外 新增了Secure Simple Pairing配对方式 根据核心规范4 2 简单配对主要有两种目的 蓝牙配对过程
  • Android蓝牙开发教程(三)——蓝牙设备相互通讯

    在上一篇中已经介绍如何连接我们搜索到的蓝牙设备 如果你还没阅读过 建议先看看上一篇文章Android蓝牙开发教程 二 连接蓝牙设备 在上一篇文章中 无论是自动连接还是被动连接 连接成功后 都是将获取到的BluetoothSocket交由连接
  • 使用Arduino开发ESP32(22):蓝牙作为客户端使用

    文章目录 目的 基础准备 搜索蓝牙设备 搜索设备 信息查询 连接与交互 总结 目的 ESP32的蓝牙除了作为服务器 从设备 使用还可以作为客户端 主机 使用 这篇文章将对相关内容做个简单说明 基础准备 这篇文章中测试需要先准备一个蓝牙服务器
  • iPhone手机连接蓝牙鼠标和蓝牙键盘

    iPhone手机升级了IOS13之后 无意中发现了一个有趣的功能 iPhone手机可以连接蓝牙鼠标 具体方式如下 首先 要买一个支持蓝牙功能的鼠标 我用的罗技M590 建议再买一个蓝牙键盘 打开手机蓝牙 和蓝牙鼠标建立连接 这一步鼠标的说明
  • Filco圣手二代键盘蓝牙连接方法

    键盘前面的电源按钮按进去 即打开电源开关 同时按下Ctrl Alt Fn 看到蓝灯和红灯同时亮起 之后剩蓝灯闪烁 按下小键盘中数字键1 4中的一个 一共可以连4台设备 如果你选的数字之前连接过其他设备 可以在第2步做完之后先按两秒清除按钮
  • 【Android系统蓝牙开发】蓝牙基础知识-蓝牙核心系统架构

    什么是蓝牙 在开启基于蓝牙Spec v5 2的学习前 我们先了解下什么是蓝牙 蓝牙在我们日常生活中又存在哪些实际应用呢 蓝牙无线技术是一种短距离无线通信系统 其核心特性主要是以下三点 robustness 鲁棒性 抗干扰能力强 Low po

随机推荐

  • 作为一枚python小白如何提升项目实战——Python茅台抢购脚本详细教程

    今天给大家推荐的GitHub开源项目就是一款京东抢茅台的脚本 当然推荐的脚本也是仅用于测试和学习研究 禁止用于商业用途 不能保证其合法性 准确性 完整性和有效性 请根据情况自行判断 主要功能 预约茅台 定时自动预约 秒杀预约后等待抢购 定时
  • Python IO编程详解

    一 文件系统操作 1 os os path和pathlib的对比 Python中处理文件路径和文件系统操作的传统方式 是通过os和os path模块中的函数来完成的 这些函数完全能够胜任需求 但往往会使得代码过于冗长 自Python 3 5
  • java随机生成6位数

    生成6位随机数 仅只有6位 int Math random 9 1 100000 Math Random 函数能够返回带正号的double值 该值大于等于0 0且小于1 0 即取值范围是 0 0 1 0 的左闭右开区间
  • 理解 __declspec(dllexport)和__declspec(dllimport)

    这段时间要把tinyxml从静态库弄成动态库 要用到 declspec dllexport 和 declspec dllimport 来导出dll和lib文件 终于弄明白了export和import的作用 下面从使用的角度来说明一下他们的功
  • 2020北京邮电大学计算机学院复试经验分享

    初试组内第4 复试组内第1 综合第2 已成功上岸 最近大家问我复试的比较多 趁还热乎 在这里给大家分享一下吧 仅供参考 然后初试经验贴在这里 不要因为初试成绩不好就放弃复试或者不认真对待 复试是干嘛的就是用来翻盘的 都坚持了一年了 也不差这
  • C# 获取计算机信息

    文章目录 一 本机信息 1 本机名 2 获得本机MAC地址 3 获得计算机名 4 显示器分辨率 5 主显示器分辨率 6 系统路径 二 操作系统信息 1 操作系统类型 2 获得操作系统位数 3 获得操作系统版本 三 处理器信息 1 处理器个数
  • Sublime Text3设置文本的自动换行

    1 点击Preferences Settings 然后出现以下页面 2 点击保存即可 如果想要修改其他属性 可以直接在Default里面找就可以
  • Java正则表达式验证电话号码

    在注册会员时 经常需要输入电话号码 电话号码是指手机号码或者固定电话 如果输入的内容不合法 则会向用户输出提示 本实例模拟实现电话号码的验证功能 接收用户在控制台输入的电话号码 然后进行判断 并将结果输出 在这里使用 Java正则表达式 一
  • linux改变文件所属用户和组

    1 改变文件所属用户 chown 用户名 文件名 2 改变文件所属组 chgrp 用户名 文件名
  • 狂神说-Mybatis笔记(总)

    环境 JDK1 8 MySQL 8 0 23 maven 3 6 1 IDEA2020 3 框架 需要配置文件 官方中文文档 https mybatis org mybatis 3 zh index html 一 简介 1 什么是Mybat
  • 通俗易懂权限管理模块设计-Java

    最近一直在做CMS系统 发现一些内容其实都是重复出现的 例如权限管理模块 权限管理模块就是为了管理用户是否有权利访问某个权限 如果不能则拒绝访问 其实Java中已经有很成熟的权限管理框架 例如 Shiro Spring Security等
  • 怎么让人物脚贴地 模型_Unity利用FinalIK实现角色脚掌贴着地面行走工具

    using System Collections Generic using UnityEditor using UnityEngine public class FootBones public GameObject Bone1 publ
  • 设计原则学习之里氏替换原则

    以下内容均来自抖音号 it楠老师教java 的设计模式课程 1 原理概述 子类对象 objectofsubtype derivedclass 能够替换程序 program 中父类对象 objectofbase parentclass 出现的
  • C语言程序的undefined,c语言中undefined reference to ""怎么解决

    2 gcc c test c gcc c main c 得到两个 o 文件 一个是 main o 一个是 test o 然后我们链接 o 得到可执行程序 3 gcc o main main o这时 你会发现 报错了 4 main o In
  • python安装pandas失败问题

    开始使用pip install pandas报错 后来将pip语句更换为 pip default time 100 install pandas 成功安装pandas
  • 朋友拿下字节27K的offer,实名羡慕了....

    最近有朋友去字节面试 面试前后进行了20天左右 包含4轮电话面试 1轮笔试 1轮主管视频面试 1轮hr视频面试 据他所说 80 的人都会栽在第一轮面试 要不是他面试前做足准备 估计都坚持不完后面几轮面试 其实 第一轮的电话面试除了一些常规的
  • IBM也下场LLM了,自对齐、高效率的单峰驼Dromedary来了

    近期IBM Research发布了dromedary 并指出这个模型通过一种称为自对齐 SELF ALIGN 的新方法 结合了原则驱动 principle driven 的推理和LLM的生成能力 用于AI代理的自我对齐 使人类的监督最少化
  • 链式调用demo

    所谓链式调用就是调用完一个函数后还能再继续调用其它函数 这样大大减少了代码量 尤其是项目比较大的时候 逻辑集中清晰明了 且易于查看和修改 react hooks处理hooks原理用到了链式调用 fiber memorizedStaste h
  • 费马小定理题

    费马小定理 假如p是质数 且gcd a p 1 那么 A题HDU 4704 首先是挡板法 隔板法 然后用即可 高中数学范围不多叙述 然后得到答案是 这题读入数据大 就算快速幂也肯定TLE 所以用费马小定理 把数据规模降到int 范围内 时间
  • Re: Programming in C with Bluetooth Sockets

    Re Programming in C with Bluetooth Sockets This is the function run by the bluetooth device that will recieve the data c