Skip to content

Commit

Permalink
Merge branch 'rel-1.0.1'
Browse files Browse the repository at this point in the history
rel v1.0.1
1、Display BMC version,build time,ip and mac addr on web ui
2、Set the static IP and mac address by placing the tpi.ini configuration file in the sd card
3、Modify the ssh configuration file so that root can login
  • Loading branch information
wenyi0421 committed Apr 1, 2023
2 parents cb52530 + 8e62d97 commit 643df40
Show file tree
Hide file tree
Showing 167 changed files with 440 additions and 34,030 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
buildroot/output/
build/*
!build/tpi
app/board/*
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"files.associations": {
"goahead.h": "c",
"param.h": "c",
"bmc.h": "c",
"stdio.h": "c"
}
}
7 changes: 5 additions & 2 deletions app/bmc/bmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "param.h"
#include "bmc.h"

#include "version.h"

#include "comm_device_serial.h"

#define RTL_RESET GPIO_PIN_PG(13)
Expand Down Expand Up @@ -394,7 +396,7 @@ void *key_thread(void *arg)
}
sleep(1);
}
return;
// return;
}

/**
Expand Down Expand Up @@ -678,7 +680,8 @@ void node_uart_init()

int main(int argc, char *argv[])
{
printf("Hello bmct start build time = %s-%s------>\n", __TIME__, __DATE__);
printf("Hello bmc start build time = %s-%s\n", __TIME__, __DATE__);
printf("bmc version:v%s\n", BMCVERSION);
int ret = -1;
int i;
pthread_t pid, piduart;
Expand Down
3 changes: 3 additions & 0 deletions app/bmc/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* This file is auto generated. do not modify */
#define BMCVERSION "1.0.1"
#define BUILDTIME "2023-04-01"
141 changes: 139 additions & 2 deletions app/bmc/webserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,27 @@


#include <sys/vfs.h> //statfs
#include <net/if.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <netdb.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <linux/reboot.h>


#include "inc/goahead.h"
#include "cjson/cJSON.h"
#include "param.h"
#include <stdbool.h>
#include "bmc.h"
#include <linux/reboot.h>
#include "version.h"

#include <stdbool.h>

#define SD_PATH "/mnt/sdcard"

Expand Down Expand Up @@ -270,6 +285,124 @@ static int get_nodeInfoType(Webs* wp)



int comm_getMacAddr(char* ethname, char *macaddr, size_t len)
{
int fd;
char buffer[20];
struct ifreq ifr;

if ((fd = socket (AF_INET, SOCK_DGRAM, 0)) >= 0)
{
strncpy(ifr.ifr_name, ethname, IFNAMSIZ);
ifr.ifr_name[IFNAMSIZ - 1] = '\0';
if (ioctl(fd, SIOCGIFHWADDR, &ifr) == 0)
{
snprintf(buffer, 20, "%02x:%02x:%02x:%02x:%02x:%02x",
(unsigned char)ifr.ifr_hwaddr.sa_data[0],
(unsigned char)ifr.ifr_hwaddr.sa_data[1],
(unsigned char)ifr.ifr_hwaddr.sa_data[2],
(unsigned char)ifr.ifr_hwaddr.sa_data[3],
(unsigned char)ifr.ifr_hwaddr.sa_data[4],
(unsigned char)ifr.ifr_hwaddr.sa_data[5]);
}
else
{
close(fd);
return(-1);
}
}
else
{
return(-1);
}

if (strlen(buffer) > len - 1)
{
close(fd);
return(-1);
}
strncpy(macaddr, buffer, len);

close(fd);
return(0);
}



int comm_getIpAddr(char* ethname, char *ipaddr, size_t len)
{
int fd;
char buffer[20];
struct ifreq ifr;
struct sockaddr_in *addr;

if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) >= 0)
{
strncpy(ifr.ifr_name, ethname, IFNAMSIZ);
ifr.ifr_name[IFNAMSIZ - 1] = '\0';
if (ioctl(fd, SIOCGIFADDR, &ifr) == 0)
{
addr = (struct sockaddr_in *) & (ifr.ifr_addr);
inet_ntop(AF_INET, &addr->sin_addr, buffer, 20);
}
else
{
close(fd);
return(-1);
}
}
else
{
perror("st_comm_net_card_getIpAddr error :");
return(-1);
}

if (strlen(buffer) > len - 1)
{
close(fd);
return(-1);
}
strncpy(ipaddr, buffer, len);
close(fd);
return(0);
}




static int get_otherInfo(Webs* wp)
{
/*--json start--*/
cJSON* pRoot = cJSON_CreateObject();
cJSON* pArray = cJSON_CreateArray();
cJSON_AddItemToObject(pRoot, "response", pArray);
cJSON* pItem = NULL;

/*--json body--*/
char mac[24];
char ip[24];
comm_getMacAddr("eth0",mac,sizeof(mac));
comm_getIpAddr("eth0",ip,sizeof(ip));

pItem = cJSON_CreateObject();
cJSON_AddStringToObject(pItem, "version", BMCVERSION);
cJSON_AddStringToObject(pItem, "buildtime", BUILDTIME);
cJSON_AddStringToObject(pItem, "ip", ip);
cJSON_AddStringToObject(pItem, "mac", mac);
cJSON_AddItemToArray(pArray, pItem);

/*--json end--*/
char* szJSON = cJSON_Print(pRoot);
// printf("json ret:%s\n", szJSON);

websWrite(wp, szJSON);
websFlush(wp, 0);
websDone(wp);

cJSON_Delete(pRoot);
return 0;
}

static int get_uartString(Webs* wp)
{
char buff[BUFF_MAX_SIZE]={0};
Expand Down Expand Up @@ -607,6 +740,10 @@ static void bmcdemo(Webs *wp)
{
get_uartString(wp);
}
else if(0==strcasecmp(pType,"other"))
{
get_otherInfo(wp);
}
// strcpy(json_result_buff,"{\"response\":[{\"result\":\"ok\"}]}");
// websWrite(wp, "%s", json_result_buff);
// websFlush(wp, 0);
Expand Down
Binary file removed app/board/rootfs_overlay/bin/curl
Binary file not shown.
141 changes: 0 additions & 141 deletions app/board/rootfs_overlay/etc/asound.conf

This file was deleted.

33 changes: 0 additions & 33 deletions app/board/rootfs_overlay/etc/bt_init.sh

This file was deleted.

Loading

0 comments on commit 643df40

Please sign in to comment.