1 Star 0 Fork 0

刘煜/esp_smartcfg_linux

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ti_smartcfg.txt 2.10 KB
一键复制 编辑 原始数据 按行查看 历史
CaptainDouche 提交于 2019-05-18 05:18 +08:00 . Add files via upload
// not tested and not complete ...
#define USE_TI_SMARTCFG 0
#if (USE_TI_SMARTCFG == 1)
// http://depletionregion.blogspot.com/2013/10/cc3000-smart-config-transmitting-ssid.html
#define SMARTCFG_TAG_SSID 1399
#define SMARTCFG_TAG_PASS 1459
#define SMARTCFG_L 28
#define SMARTCFG_C 593
#define LONIB(X) ((X) & 0x0f)
#define HINIB(X) LONIB((X) >> 4)
int ti_smartcfg_add_separator(int* dst)
{
*dst++ = 3;
*dst++ = 23;
return 2;
}
int ti_smartcfg_encodestr(int* dst, const char* src, int tag)
{
int n = 0;
dst[n++] = tag;
dst[n++] = strlen(src) + SMARTCFG_L;
//n += ti_smartcfg_add_separator(dst + n);
char prv = 0x00;
int i = 0;
while (*src)
{
char nib, c = *src++;
nib = HINIB(c);
dst[n++] = (((prv ^ i) << 4) | nib) + SMARTCFG_C;
i++;
i &= 0xf;
prv = nib;
//n += ti_smartcfg_add_separator(dst + n);
nib = LONIB(c);
dst[n++] = (((prv ^ i) << 4) | nib) + SMARTCFG_C;
i++;
i &= 0xf;
prv = nib;
//n += ti_smartcfg_add_separator(dst + n);
}
//n += ti_smartcfg_add_separator(dst + n);
return n;
}
bool smartcfg_ftc20(const char* ssid, const char* pass)
{
#define SSID_MAX 64
#define PASS_MAX 32
#define MTU_SIZE 1500
#define LENS_MAX (4 + (3 * SSID_MAX) + 4 + (3 * PASS_MAX))
int lens[LENS_MAX];
int n = 0;
for (int j=0; j<10; j++)
{ n += ti_smartcfg_add_separator(lens + n); }
n += ti_smartcfg_encodestr(lens + n, ssid, SMARTCFG_TAG_SSID);
n += ti_smartcfg_encodestr(lens + n, pass, SMARTCFG_TAG_PASS);
for (int i=0; i<n; i++)
{
printf("[%02u] = %d \n", i, lens[i]);
}
int cnt = 0;
char dummy[MTU_SIZE];
memset(dummy, 0xaa, sizeof(dummy));
while (run)
{
for (int i=0; i<n; i++)
{
send_sized(lens[i]);
}
cnt++;
printf("Sends: %u \r", cnt);
sleep_ms(100);
// todo: check for mDNS incomming ack, using recvfrom on an nonblocking udp-bound socket
}
}
#endif
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tinytaro/esp_smartcfg_linux.git
git@gitee.com:tinytaro/esp_smartcfg_linux.git
tinytaro
esp_smartcfg_linux
esp_smartcfg_linux
master

搜索帮助