Skip to content

Instantly share code, notes, and snippets.

@ashraf267
ashraf267 / do_wifi.dart
Created April 12, 2024 15:24
do-wifi: this version worked fine
import 'package:flutter/material.dart';
import 'package:app_settings/app_settings.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@ashraf267
ashraf267 / fmt_date_str.dart
Created April 8, 2024 22:41
custom formatted date string
void main() {
String dt = formatDate();
print(dt);
}
// format my date
// return a custom date formatted string
String formatDate() {
// dt obj
@ashraf267
ashraf267 / pad01.dart
Created March 24, 2024 23:20
Project App - type of user (new or existing) screen. **pad: project-app-design
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@ashraf267
ashraf267 / Demo.c
Created September 11, 2023 13:49
Sample code to be shared with Faruk
short TestGet(int iTimeout)
{
int sRC = -1;
unsigned char ucRecvBuff[3500] = {0};
unsigned short usRecvBUffLen = sizeof(ucRecvBuff);
// char *myHeader = "{\"Host\": \"dev.ucard.store\r\n\", \"Authorization\": \"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9lbWFpbGFkZHJlc3MiOiJqYXp6eWJ1cmdlckBxYS50ZWFtIiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvZ2l2ZW5uYW1lIjoiamF6enkgYnVyZ2VyIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9ncm91cHNpZCI6IkFnZW50IiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjoiQWdlbnQiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6Imphenp5YnVyZ2VyQHFhLnRlYW0iLCJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL3dzLzIwMDgvMDYvaWRlbnRpdHkvY2xhaW1zL3VzZXJkYXRhIjoie1wiVXNlcklkXCI6MzYzLFwiRnVsbE5hbWVcIjpcImphenp5IGJ1cmdlclwiLFwiRGVmYXVsdFdhbGxldElkXCI6XCI1MTQ5XCIsXCJXYWxsZXRDd
@ashraf267
ashraf267 / Demo.c
Created September 6, 2023 10:17
This kind of works for calling api. not fully tested.
#include "Ui.h"
#include "Common.h"
#include "Communication.h"
#include "jsmn.h"
#include "LibApi.h"
#include "Print.h"
#include "MessageBox.h"
#include "net_if.h"
// for print
@ashraf267
ashraf267 / Demo.c
Created August 30, 2023 09:00
Shows "Api call failed" to the screen
short makeApiCall(char *url, unsigned char *requestData, unsigned short requestDataLength)
{
short sRC;
sRC = UIWireHttpSend(url, requestData, requestDataLength, NULL);
// sRC = UIWireHttpSend(url, requestData, requestDataLength, "Content-type: application/json; charset=UTF-8");
return sRC;
// if (sRC != TY_OK)
// {
// return sRC; // failed, I think
// }
@ashraf267
ashraf267 / Demo.c
Created August 28, 2023 23:01
This really looks promising
#include "Ui.h"
#include "Common.h"
#include "Communication.h"
#include "jsmn.h"
short makeApiCall(char *url, unsigned char *requestData, unsigned short requestDataLength)
{
short sRC;
// sRC = UIWireHttpSend(url, requestData, requestDataLength, NULL);
sRC = UIWireHttpSend(url, requestData, requestDataLength, "Content-Type: application/json\r\n");
@ashraf267
ashraf267 / Demo.c
Created August 28, 2023 12:16
v2 of Demo.c - it crashes
#include "Ui.h"
#include "Common.h"
#include "Communication.h"
#include "jsmn.h"
const char* GetWallet(unsigned char *pcOut)
{
short sRC;
char url[] = "https://devapi.ucard.store/identity/Agent/login/wallet/initate";
@ashraf267
ashraf267 / Demo.c
Created August 28, 2023 07:53
This code appears to be working with API. I want to tweak it and get back to it later.
#include "Ui.h"
#include "Common.h"
#include "Communication.h"
#include "jsmn.h"
// cust replace func
// char *replace(char const *const original, char const *const pattern, char const *const replacement)
// {
// size_t const replen = strlen(replacement);
// size_t const patlen = strlen(pattern);
@ashraf267
ashraf267 / ucard.c
Created August 16, 2023 10:10
This looks like it works, but needs some tweaks. At 11:10am 16/08/23
#include "Ui.h"
#include "Common.h"
#include "Communication.h"
#include "net_if.h"
#include "jsmn.h"
// string replace function
char *replace(
char const *const original,
char const *const pattern,