Hi,
you should try this
[https://github.com/swisspol/GCDWebServer)
when you run GCDWebServer on your MacBook , you can access web page from your phone app ,
i'v just tested using swift ( URLRequest + URLSession )
var req = URLRequest(url: URL(string: "http://your_macos_ip_address:8080/")!)
if let error = error {
print("Failed: \(error)")
return
}
guard let data = data else {
print("data is nil")
return
}
print(" \(data.count) bytes and is: \n")
let responseText = String(data: data, encoding: .utf8) ?? "*unknow encoding*"
print("The response is: \(responseText)")
}
task.resume()
Post
Replies
Boosts
Views
Activity
static void advertising_init(void){ ... ble_advdata_manuf_data_t manuf_data; uint8_t awesomeData [8] = {0}; // your customize data here manuf_data.company_identifier = 0xaeac; // customize here manuf_data.data.p_data = awesomeData; manuf_data.data.size = sizeof(awesomeData); init.advdata.p_manuf_specific_data = &manuf_data;
now when you power on your peripheral device , you can scan the advertisement data and found your customized bytes
the advertisement package of a peripheral device can included some customer data (several bytes) that iPhone / iPads can discover and parse without connecting to it.
such as the firmware of ble chip nrf52840 , one customised the manufacturer info in the advertising data :
It seems that zstack still has some issues when recalculating multiple layers with lots of views inside it.
I consider that overly a floating view on zstack, this view was not calculated by zstack, I copied the code of floating view from here, and the following is the code modified from your version:
import SwiftUI
struct TMainWnd: View {
@State var strings: [String] = ["A", "B", "C", "D", "E"]
@State var ints: [Int] = Array(1...300)
@State var selectedInt: Int?
@State var isShow = false
var body: some View {
ZStack {
ScrollView {
VStack {
ForEach(strings, id: \.self) { string in
VStack {
HStack {
Text(string)
Spacer()
}
LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible())]) {
ForEach(ints, id: \.self) { int in
VStack {
Text(String(int))
Spacer()
}
.frame( maxWidth: .infinity )
.frame(height: 200)
.background(
RoundedRectangle(cornerRadius: 5)
.fill(int % 2 == 0 ? .orange : .green)
)
.onTapGesture {
self.selectedInt = int
}
}
}
}
}
}
.padding()
}
}.floatingView(above: TFloatingWnd(selectedInt: $selectedInt))
}
}
struct TFloatingWnd : View
{
@Binding var selectedInt : Int?
var body: some View {
VStack {
Spacer()
if let selectedInt {
Text( String(selectedInt ) )
}
Spacer()
if let selectedInt {
Button {
self.selectedInt = nil
} label: {
Image(systemName: "x.circle")
.resizable()
.scaledToFit()
.frame(width: 30)
}
}
}.frame( maxWidth: .infinity, maxHeight: .infinity)
}
}
extension View {
func floatingView<Content: View>(above: Content) -> ModifiedContent<Self, Above<Content>> {
self.modifier(Above(aboveContent: above))
}
}
struct Above<AboveContent: View>: ViewModifier {
let aboveContent: AboveContent
func body(content: Content) -> some View {
content.overlay(
GeometryReader { proxy in
Rectangle().fill(Color.clear).overlay(
self.aboveContent,
alignment: .center
)
},
alignment: .center
)
}
}